modifyDataset.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #a script to modify a patient from list. Current implementation deletes
  2. #all data for patients identified by study regulatory number from study
  3. #basic python
  4. import os
  5. import subprocess
  6. import re
  7. import datetime
  8. import sys
  9. import json
  10. def main(parameterFile):
  11. fhome=os.path.expanduser('~')
  12. with open(os.path.join(fhome,".labkey","setup.json")) as f:
  13. setup=json.load(f)
  14. sys.path.insert(0,setup["paths"]["nixWrapper"])
  15. import nixWrapper
  16. nixWrapper.loadLibrary("labkeyInterface")
  17. import labkeyInterface
  18. import labkeyDatabaseBrowser
  19. import labkeyFileBrowser
  20. net=labkeyInterface.labkeyInterface()
  21. net.init(os.path.join(fhome,'.labkey','network.json'))
  22. db=labkeyDatabaseBrowser.labkeyDB(net)
  23. #by default uses .labkey/Remote.json configuration
  24. with open(parameterFile) as f:
  25. pars=json.load(f)
  26. project=pars['project']
  27. schema=pars['schema']
  28. query=pars['query']
  29. #study section ################
  30. #select patients enroled under regulatory number
  31. ds=db.selectRows(project,schema,query,[])
  32. for r in ds['rows']:
  33. r['View']='[VIEW]'
  34. db.modifyRows('update',project,schema,query,[r])
  35. print("Done")
  36. if __name__ == '__main__':
  37. main(sys.argv[1])