test.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import sys
  2. import os
  3. import json
  4. def main(parameterFile):
  5. fhome=os.path.expanduser('~')
  6. fsetup=os.path.join(fhome,'.labkey','setup.json')
  7. with open(fsetup) as f:
  8. setup=json.load(f)
  9. sys.path.append(setup['paths']['labkeyInterface'])
  10. import labkeyInterface
  11. import labkeyDatabaseBrowser
  12. net=labkeyInterface.labkeyInterface()
  13. fconfig=os.path.join(fhome,'.labkey','network.json')
  14. net.init(fconfig)
  15. with open(parameterFile) as f:
  16. pars=json.load(f)
  17. id=net.getUserId()
  18. print('User id: {}'.format(id))
  19. db=labkeyDatabaseBrowser.labkeyDB(net)
  20. fv={'PatientId':'NIX-LJU-D2002-IRAE-A011',
  21. 'visitCode':'VISIT_0',
  22. 'ModifiedBy':str(id)}
  23. fv={'ModifiedBy':str(id)}
  24. filters=[{'variable':v,'value':fv[v],'oper':'eq'} for v in fv]
  25. ds=db.selectRows(pars['project'],pars['schemaName'],pars['queryName'],filters)
  26. for r in ds['rows']:
  27. print(r)
  28. print('here')
  29. return 0
  30. if __name__=="__main__":
  31. main(sys.argv[1])