1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import os
- def getPatientId(row,xconfig):
- return row[getPatientField(xconfig)]
- def getPatientField(xconfig):
- return xconfig['ParticipantField']
- def getVisitField(xconfig):
- return 'visitName'
- def getVisitId(row,xconfig):
- return row[getVisitField(xconfig)]
- def getIdFilter(row,xconfig):
- return {'variable':getPatientField(xconfig),\
- 'value':getPatientId(row,xconfig),
- 'oper':'eq'}
- def getVisitFilter(row,xconfig):
- return {'variable':getVisitField(xconfig),\
- 'value':getVisitId(row,xconfig),
- 'oper':'eq'}
- def getCode(row,xconfig):
- return '{}_{}'.format(getPatientId(row,xconfig),getVisitId(row,xconfig))
- def getTargetSeqNum(row,xconfig):
- if getVisitId(row,xconfig)=='OBR':
- return 2
- return 1
- def getPathList(row,xconfig):
- return [xconfig['baseDir'],getPatientId(row,xconfig),getVisitId(row,xconfig)]
- def getOutputDir(row,xconfig):
- return '/'.join(getPathList(row,xconfig))
- def getLocalDir(row,xconfig):
- return os.path.join(xconfig['tempDir'],getCode(row,xconfig))
- def getNodeName(row,xconfig,mode,i=0):
- if mode=='CT':
- return getCode(row,xconfig)+'_CT'
- if mode=='NM':
- return '{}_Volume{}'.format(getCode(row,xconfig),i)
- return getCode(row,xconfig)+'_Dummy'
- def decode(code,xconfig):
- #invert code and return object equivalent to row with relevant
- #fields set that can be used in
- #getPatientId, getVisitId,getIdFilter,getVisitFilter
- #as an equivalent replacement for r
- values=code.split('_')
- fid=values[0]
- vid=values[1]
- return {getPatientField(xconfig):fid,getVisitField(xconfig):vid}
|