diff --git a/healthcareio/.parser.py.swp b/healthcareio/.parser.py.swp deleted file mode 100644 index 7bc23e7..0000000 Binary files a/healthcareio/.parser.py.swp and /dev/null differ diff --git a/healthcareio/__init__.py b/healthcareio/__init__.py index 9120b32..da839ce 100644 --- a/healthcareio/__init__.py +++ b/healthcareio/__init__.py @@ -14,4 +14,6 @@ Usage : Embedded : """ -import healthcareio +#import healthcareio +#import healthcareio.params as params +from healthcareio import params diff --git a/healthcareio/healthcareio.py b/healthcareio/healthcare-io.py similarity index 95% rename from healthcareio/healthcareio.py rename to healthcareio/healthcare-io.py index dc0830d..c941150 100644 --- a/healthcareio/healthcareio.py +++ b/healthcareio/healthcare-io.py @@ -29,10 +29,10 @@ Usage : conf = json.loads(open('config/837.json').read()) edi.parser.get_content(filename,conf) """ -from params import SYS_ARGS +from healthcareio.params import SYS_ARGS from transport import factory import requests -from parser import get_content +from healthcareio.parser import get_content import os import json import sys @@ -114,7 +114,8 @@ def init(): info = json.loads(file.read()) if not os.path.exists(info['out-folder']) : os.mkdir(info['out-folder']) - if not os.path.exists(info['store']['args']['path']) : + + if info['store']['type'] == 'disk.SQLiteWriter' and not os.path.exists(info['store']['args']['path']) : conn = lite.connect(info['store']['args']['path'],isolation_level=None) for key in info['schema'] : _sql = info['schema'][key]['create'] @@ -222,8 +223,11 @@ if __name__ == '__main__' : elif info['store']['type'] == 'disk.SQLiteWriter' : # info['store']['args']['path'] += (os.sep + 'healthcare-io.db3') pass - - info['store']['args']['table'] = SYS_ARGS['parse'].strip().lower() + if info['store']['type'] == 'disk.SQLiteWriter' : + info['store']['args']['table'] = SYS_ARGS['parse'].strip().lower() + else: + + info['store']['args']['doc'] = SYS_ARGS['parse'].strip().lower() writer = factory.instance(**info['store']) logger = factory.instance(type='disk.DiskWriter',args={'path':os.sep.join([info['out-folder'],SYS_ARGS['parse']+'.log'])}) #logger = factory.instance(type='mongo.MongoWriter',args={'db':'healthcareio','doc':SYS_ARGS['parse']+'_logs'}) @@ -240,6 +244,7 @@ if __name__ == '__main__' : # try: content,logs = parse(filename = filename,type=SYS_ARGS['parse']) + print ([filename, len(content)]) if content : writer.write(content) if logs : @@ -247,7 +252,7 @@ if __name__ == '__main__' : else: logger.write({"name":filename,"completed":True,"rows":len(content)}) except Exception as e: - logger.write({"filename":filename,"completed":False,"rows":-1}) + logger.write({"filename":filename,"completed":False,"rows":-1,"msg":e.args[0]}) # print ([filename,len(content)]) # # @TODO: forward this data to the writer and log engine diff --git a/healthcareio/parser.py b/healthcareio/parser.py index 0ee08f9..dfb2004 100644 --- a/healthcareio/parser.py +++ b/healthcareio/parser.py @@ -71,7 +71,7 @@ def get_config(config,row): def hash(value): salt = os.environ['HEALTHCAREIO_SALT'] if 'HEALTHCAREIO_SALT' in os.environ else '' _value = str(value)+ salt - if sys.info.version[0] > 2 : + if sys.version_info[0] > 2 : return hashlib.md5(_value.encode('utf-8')).hexdigest() else: return hashlib.md5(_value).hexdigest() diff --git a/setup.py b/setup.py index 04b0e80..f93959d 100644 --- a/setup.py +++ b/setup.py @@ -8,16 +8,16 @@ import sys def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() args = { - "name":"healthcareio","version":"1.2.2", + "name":"healthcareio","version":"1.2.3", "author":"Vanderbilt University Medical Center", "author_email":"steve.l.nyemba@vumc.org", "license":"MIT", - "packages":find_packages("."), + "packages":find_packages(), "keywords":["healthcare","edi","x12","analytics","835","837","data","transport","protocol"] } 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/healthcareio.py'] +args['scripts']= ['healthcareio/healthcare-io.py'] if sys.version_info[0] == 2 : args['use_2to3'] = False