Explorar el Código

Adding idField to change default ParticipantId to an alternative labkey field, particularly usefule when updating lists rather than datasets

Andrej hace 10 meses
padre
commit
638406421a
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      importXLSX.py

+ 4 - 2
importXLSX.py

@@ -336,6 +336,7 @@ def importData(pars,filename,getId=getId,modify=modify,\
 #set this is as sequenceNum for entries, or initial seqNum if more than a single entry is in the dataset
    seqNumOffset=pars.get('seqNumOffset',0)
    additionalVars=pars.get('additionalVars',{})
+   idField=pars.get('idField','ParticipantId')
 
    fields=getFields(pars)
    lookupVars=getVariables(fields,fieldType='LOOKUP')
@@ -368,7 +369,7 @@ def importData(pars,filename,getId=getId,modify=modify,\
          continue
       id=getId(df,r)    
       entry={}
-      entry['ParticipantId']=id
+      entry[idField]=id
 
       for v in vars:
          qv=validate(df.at[r,v])
@@ -428,6 +429,7 @@ def loadSafely(pars,entries,dryRun=True):
    project=pars.get('project','DCIS/Study')
    schema=pars.get('schema','demographics')
    query=pars.get('query','demographics')
+   idField=pars.get('idField','ParticipantId')
 #add columns from labkey that will be checked to find a match
    matchColumns=pars.get('matchColumns',[])
 #whether to insert new entries
@@ -439,7 +441,7 @@ def loadSafely(pars,entries,dryRun=True):
    insertRows=[]
 
 
-   selVal=['ParticipantId','SequenceNum']
+   selVal=[idField,'SequenceNum']
    selVal.extend(matchColumns)
    print(f'Matching by {selVal}')