__init__.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. """
  2. (c) 2019 EDI Parser Toolkit,
  3. Health Information Privacy Lab, Vanderbilt University Medical Center
  4. Steve L. Nyemba <steve.l.nyemba@vanderbilt.edu>
  5. Khanhly Nguyen <khanhly.t.nguyen@gmail.com>
  6. This code is intended to process and parse healthcare x12 837 (claims) and x12 835 (remittances) into human readable JSON format.
  7. The claims/outpout can be forwarded to a NoSQL Data store like couchdb and mongodb
  8. Usage :
  9. Commandline :
  10. python xreader.py --parse claims|remits --config <path>
  11. Embedded :
  12. """
  13. import healthcareio
  14. import os
  15. import requests
  16. import platform
  17. import sqlite3 as lite
  18. from transport import factory
  19. import json
  20. #import healthcareio.params as params
  21. PATH = os.sep.join([os.environ['HOME'],'.healthcareio'])
  22. OUTPUT_FOLDER = os.sep.join([os.environ['HOME'],'healthcare-io'])
  23. def register (**args) :
  24. """
  25. This function will reset/register a user i.e they will download the configuration
  26. :email user's email address
  27. :url url of the provider to register
  28. """
  29. URL = "https://healthcareio.the-phi.com" if 'url' not in args else args['url']
  30. args['out_folder'] = os.sep.join([args['path'],args['out_folder']])
  31. email = args['email']
  32. url = args['url'] if 'url' in args else URL
  33. folders = [PATH,OUTPUT_FOLDER]
  34. for path in folders :
  35. if not os.path.exists(path) :
  36. os.mkdir(path)
  37. #
  38. #
  39. headers = {"email":email,"client":platform.node()}
  40. http = requests.session()
  41. r = http.post(url,headers=headers)
  42. #
  43. # store = {"type":"disk.DiskWriter","args":{"path":OUTPUT_FOLDER}}
  44. # if 'store' in args :
  45. # store = args['store']
  46. filename = (os.sep.join([PATH,'config.json']))
  47. info = r.json() #{"parser":r.json(),"store":store}
  48. info = dict({"owner":email},**info)
  49. info['store']['args']['path'] =os.sep.join([OUTPUT_FOLDER,'healthcare-io.db3']) #-- sql
  50. info['out-folder'] = OUTPUT_FOLDER
  51. file = open( filename,'w')
  52. file.write( json.dumps(info))
  53. file.close()