From b9ad861db9ceeaad67bc6ad5206d8a6f232c5d0a Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 18 Jan 2021 10:24:45 -0600 Subject: [PATCH] bug fix: configuration file reader --- healthcareio/export/export.py | 19 +++++++++++++++++-- setup.py | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/healthcareio/export/export.py b/healthcareio/export/export.py index d521247..fbac35b 100644 --- a/healthcareio/export/export.py +++ b/healthcareio/export/export.py @@ -36,17 +36,20 @@ import requests import time PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','config.json']) -CONFIG = json.loads((open(PATH)).read()) + STORE_URI = 'http://healthcareio.the-phi.com/store/healthcareio' # # let us see if we have any custom configurations ... + PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','custom']) +CONFIG = {} CUSTOM_CONFIG = {} if os.path.exists(PATH) and os.listdir(PATH) : + CONFIG = json.loads((open(PATH)).read()) PATH = os.sep.join([PATH,os.listdir(PATH)[0]]) CUSTOM_CONFIG = json.loads((open(PATH)).read()) -_args = dict(CONFIG['store'],**{'type':'mongo.MongoReader'}) +# _args = dict(CONFIG['store'],**{'type':'mongo.MongoReader'}) def get_field_names (_map,label): fields = list(_map.keys()) @@ -182,6 +185,18 @@ class Factory: :param type EDI type to be processed i.e 835 or 837 :param write_store target data-store (redshift, mariadb,mongodb ...) """ + global PATH + global CONFIG + global CUSTOM_CONFIG + PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','config.json']) + if os.path.exists(PATH): + CONFIG = json.loads((open(PATH)).read()) + CUSTOM_PATH = os.sep.join([os.environ.get('HOME'),'.healthcareio','custom']) + if os.path.exists(CUSTOM_PATH) and os.listdir(CUSTOM_PATH) : + + CUSTOM_PATH = os.sep.join([CUSTOM_PATH,os.listdir(CUSTOM_PATH)[0]]) + CUSTOM_CONFIG = json.loads((open(CUSTOM_PATH)).read()) + _features = Factory.license(email=CONFIG['owner']) store = copy.deepcopy(CONFIG['store']) store['type']='mongo.MongoReader' diff --git a/setup.py b/setup.py index 92e2057..9029d8b 100644 --- a/setup.py +++ b/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.4.8", + "name":"healthcareio","version":"1.5.0", "author":"Vanderbilt University Medical Center", "author_email":"steve.l.nyemba@vumc.org", "include_package_data":True,