|
|
|
@ -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
|