diff --git a/edi/__main__.py b/edi/__main__.py index 20919d7..7d71068 100644 --- a/edi/__main__.py +++ b/edi/__main__.py @@ -64,13 +64,15 @@ if __name__ == '__main__' : args['dbname'] = SYS_ARGS['db'] elif SYS_ARGS ['store'] == 'mongo': - args = {'host':SYS_ARGS['host']if 'host' in SYS_ARGS else 'localhost:27217'} + args = {'host':SYS_ARGS['host']if 'host' in SYS_ARGS else 'localhost:27017'} if SYS_ARGS['store'] in ['mongo','couch']: args['dbname'] = SYS_ARGS['db'] if 'db' in SYS_ARGS else 'claims_outcomes' args['doc'] = CONTEXT TYPE = TYPE[SYS_ARGS['store']] writer = factory.instance(type=TYPE,args=args) + if SYS_ARGS['store'] == 'disk': + writer.init(path = 'output-claims.json') logger = factory.instance(type=TYPE,args= dict(args,**{"doc":"logs"})) files = os.listdir(SYS_ARGS['folder']) CONFIG = json.loads(open(SYS_ARGS['config']).read()) @@ -90,10 +92,12 @@ if __name__ == '__main__' : logs = [{"filename":filename,"msg":e.message}] content = None if content : - writer.write(row= content) + + writer.write(content) if logs: - logger.write(row=logs) + logger.write(logs) + pass else: diff --git a/edi/parser.py b/edi/parser.py index caa176d..6f39f92 100644 --- a/edi/parser.py +++ b/edi/parser.py @@ -150,8 +150,10 @@ def get_content(filename,config,section=None) : logs = [] # VERSION = x12_file[2].split('*')[3].replace('~','') - VERSION = x12_file[1].split('*')[-1].replace('~','') - + TOP_ROW = x12_file[1].split('*') + VERSION = x12_file[1].split('*')[-1].replace('~','') + SUBMITTED_DATE = format_date(TOP_ROW[4]) + SENDER_ID = TOP_ROW[2] row = split(x12_file[3]) _info = get_config(config,row) @@ -182,7 +184,13 @@ def get_content(filename,config,section=None) : break if 'label' not in _info : - tmp['version'] = VERSION + tmp['version'] = VERSION + tmp['submitted'] = SUBMITTED_DATE + if TOP_ROW[1] == 'HP' : + tmp['payer_id'] = SENDER_ID + else: + tmp['provider_id'] = SENDER_ID + claim = dict(claim, **tmp)