Browse Source

bug fix with claim type

Steve Nyemba 4 years ago
parent
commit
b7ec1df072
3 changed files with 52 additions and 5 deletions
  1. 46 2
      healthcareio/__init__.py
  2. 1 1
      healthcareio/__main__.py
  3. 5 2
      setup.py

+ 46 - 2
healthcareio/__init__.py

@@ -14,6 +14,50 @@ Usage :
     Embedded    :
 
 """
-#import healthcareio
+import healthcareio
+import os
+import requests
+import platform
+import sqlite3 as lite
+from transport import factory
+import json
 #import healthcareio.params as params
-from healthcareio import params
+PATH = os.sep.join([os.environ['HOME'],'.healthcareio'])
+OUTPUT_FOLDER = os.sep.join([os.environ['HOME'],'healthcare-io'])
+
+def register (**args) :
+    """
+    This function will reset/register a user i.e they will download the configuration
+    :email  user's email address
+    :url    url of the provider to register
+    """
+    URL = "https://healthcareio.the-phi.com" if 'url' not in args else args['url']
+
+    args['out_folder'] = os.sep.join([args['path'],args['out_folder']])
+    email = args['email']
+    url = args['url'] if 'url' in args else URL
+    folders = [PATH,OUTPUT_FOLDER]
+    for path in folders :
+        if not os.path.exists(path) :
+            os.mkdir(path)
+    
+    #
+    # 
+    headers = {"email":email,"client":platform.node()}
+    http = requests.session()    
+    r = http.post(url,headers=headers)
+    
+    #
+    # store = {"type":"disk.DiskWriter","args":{"path":OUTPUT_FOLDER}}
+    # if 'store' in args :
+    #     store = args['store']
+    filename =  (os.sep.join([PATH,'config.json']))
+    info = r.json() #{"parser":r.json(),"store":store}
+    info = dict({"owner":email},**info)
+    info['store']['args']['path'] =os.sep.join([OUTPUT_FOLDER,'healthcare-io.db3']) #-- sql
+    info['out-folder'] = OUTPUT_FOLDER
+
+    file = open( filename,'w')
+    file.write( json.dumps(info))
+    file.close()
+

+ 1 - 1
healthcareio/__main__.py

@@ -14,4 +14,4 @@ Usage :
     Embedded    :
 
 """
-import healthcareio
+# import healthcareio

+ 5 - 2
setup.py

@@ -8,7 +8,7 @@ import sys
 def read(fname):
     return open(os.path.join(os.path.dirname(__file__), fname)).read() 
 args = {
-    "name":"healthcareio","version":"1.2.3",
+    "name":"healthcareio","version":"1.2.4",
     "author":"Vanderbilt University Medical Center",
     "author_email":"steve.l.nyemba@vumc.org",
     "license":"MIT",
@@ -17,7 +17,10 @@ args = {
 }
 args["install_requires"] = ['seaborn','jinja2', 'weasyprint','data-transport@git+https://dev.the-phi.com/git/steve/data-transport.git','pymongo','numpy','cloudant','pika','boto','flask-session','smart_open']
 args['url'] = 'https://hiplab.mc.vanderbilt.edu'
-args['scripts']= ['healthcareio/healthcare-io.py']
+# args['scripts']= ['healthcareio/healthcare-io.py']
+args['entry_points'] = {
+    'console_scripts'  : ['healthcareio=healthcareio:register']
+}
 
 if sys.version_info[0] == 2 :
     args['use_2to3'] = False