|
@@ -63,13 +63,37 @@ def main(parameterFile):
|
|
|
dsImage=db.selectRows(projectStudy,outputSchema,transferQuery,[])
|
|
|
|
|
|
for im in dsImage['rows']:
|
|
|
+
|
|
|
+
|
|
|
+ #for orthanc
|
|
|
inputIdFilter={'variable':inputParticipantField,\
|
|
|
'value':im[dbParticipantField],\
|
|
|
'oper':'eq'}
|
|
|
|
|
|
+ #for database
|
|
|
idFilter={'variable':dbParticipantField,\
|
|
|
'value':im[dbParticipantField],\
|
|
|
'oper':'eq'}
|
|
|
+
|
|
|
+
|
|
|
+ seqNum=im['imagingVisitId']
|
|
|
+ seqFilter={'variable':'SequenceNum','value':str(seqNum),'oper':'eq'}
|
|
|
+
|
|
|
+
|
|
|
+ #for speedup one should check if a match was already done in Database/queryName
|
|
|
+ #ds1 are the matching outputs in target dataset
|
|
|
+ ds1=db.selectRows(projectStudy,outputSchema,outputQuery,\
|
|
|
+ [idFilter,seqFilter])
|
|
|
+
|
|
|
+ if len(ds1['rows'])>1:
|
|
|
+ #never happens (idFilter and seqFilter)
|
|
|
+ print('ERROR: too many matches in {} for {}/{}'.\
|
|
|
+ format(outputQuery,im[dbParticipantField],seqNum))
|
|
|
+ continue
|
|
|
+ if len(ds1['rows'])>0:
|
|
|
+ #just the one match, fine
|
|
|
+ continue
|
|
|
+
|
|
|
#have to convert from datetime to %Y%m%d format
|
|
|
#dateFilter={'variable':'imageDate','value':im['imageDate'],'oper':'eq'}
|
|
|
|
|
@@ -105,19 +129,9 @@ def main(parameterFile):
|
|
|
|
|
|
#figure out which row in output study to update
|
|
|
filters=[]
|
|
|
- seqNum=im['imagingVisitId']
|
|
|
- seqFilter={'variable':'SequenceNum','value':str(seqNum),'oper':'eq'}
|
|
|
print('Participant {} Sequence number {}'.\
|
|
|
format(im[dbParticipantField],str(seqNum)))
|
|
|
- #ds1 are the matching outputs in target dataset
|
|
|
- ds1=db.selectRows(projectStudy,outputSchema,outputQuery,\
|
|
|
- [idFilter,seqFilter])
|
|
|
|
|
|
- if len(ds1['rows'])>1:
|
|
|
- print('ERROR: too many matches for {}/{}'.\
|
|
|
- format(im[dbParticipantField],seqNum))
|
|
|
- status="MULTIPLE MATCHES"
|
|
|
- continue
|
|
|
|
|
|
mode='update'
|
|
|
outRow={}
|
|
@@ -129,8 +143,10 @@ def main(parameterFile):
|
|
|
outRow['dicomStudy']=im1['dicomStudy']
|
|
|
|
|
|
else:
|
|
|
+ #never happens if we check for sd1 before matches are found
|
|
|
outRow=ds1['rows'][0]
|
|
|
|
|
|
+
|
|
|
outRow[outvar]=im1['orthancSeries']
|
|
|
outRow['studyDate']=im1['studyDate']
|
|
|
outRow['imagingVisitId']=im['imagingVisitId']
|