|
|
@ -29,10 +29,10 @@ Usage :
|
|
|
|
conf = json.loads(open('config/837.json').read())
|
|
|
|
conf = json.loads(open('config/837.json').read())
|
|
|
|
edi.parser.get_content(filename,conf)
|
|
|
|
edi.parser.get_content(filename,conf)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
from params import SYS_ARGS
|
|
|
|
from healthcareio.params import SYS_ARGS
|
|
|
|
from transport import factory
|
|
|
|
from transport import factory
|
|
|
|
import requests
|
|
|
|
import requests
|
|
|
|
from parser import get_content
|
|
|
|
from healthcareio.parser import get_content
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
@ -114,7 +114,8 @@ def init():
|
|
|
|
info = json.loads(file.read())
|
|
|
|
info = json.loads(file.read())
|
|
|
|
if not os.path.exists(info['out-folder']) :
|
|
|
|
if not os.path.exists(info['out-folder']) :
|
|
|
|
os.mkdir(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)
|
|
|
|
conn = lite.connect(info['store']['args']['path'],isolation_level=None)
|
|
|
|
for key in info['schema'] :
|
|
|
|
for key in info['schema'] :
|
|
|
|
_sql = info['schema'][key]['create']
|
|
|
|
_sql = info['schema'][key]['create']
|
|
|
@ -222,8 +223,11 @@ if __name__ == '__main__' :
|
|
|
|
elif info['store']['type'] == 'disk.SQLiteWriter' :
|
|
|
|
elif info['store']['type'] == 'disk.SQLiteWriter' :
|
|
|
|
# info['store']['args']['path'] += (os.sep + 'healthcare-io.db3')
|
|
|
|
# info['store']['args']['path'] += (os.sep + 'healthcare-io.db3')
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
if info['store']['type'] == 'disk.SQLiteWriter' :
|
|
|
|
info['store']['args']['table'] = SYS_ARGS['parse'].strip().lower()
|
|
|
|
info['store']['args']['table'] = SYS_ARGS['parse'].strip().lower()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info['store']['args']['doc'] = SYS_ARGS['parse'].strip().lower()
|
|
|
|
writer = factory.instance(**info['store'])
|
|
|
|
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='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'})
|
|
|
|
#logger = factory.instance(type='mongo.MongoWriter',args={'db':'healthcareio','doc':SYS_ARGS['parse']+'_logs'})
|
|
|
@ -240,6 +244,7 @@ if __name__ == '__main__' :
|
|
|
|
#
|
|
|
|
#
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
content,logs = parse(filename = filename,type=SYS_ARGS['parse'])
|
|
|
|
content,logs = parse(filename = filename,type=SYS_ARGS['parse'])
|
|
|
|
|
|
|
|
print ([filename, len(content)])
|
|
|
|
if content :
|
|
|
|
if content :
|
|
|
|
writer.write(content)
|
|
|
|
writer.write(content)
|
|
|
|
if logs :
|
|
|
|
if logs :
|
|
|
@ -247,7 +252,7 @@ if __name__ == '__main__' :
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
logger.write({"name":filename,"completed":True,"rows":len(content)})
|
|
|
|
logger.write({"name":filename,"completed":True,"rows":len(content)})
|
|
|
|
except Exception as e:
|
|
|
|
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)])
|
|
|
|
# print ([filename,len(content)])
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# @TODO: forward this data to the writer and log engine
|
|
|
|
# @TODO: forward this data to the writer and log engine
|