|
@@ -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()
|
|
|
+
|