From a863f5e2b9f6a8787a7763c40967bf79568d750e Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 1 Dec 2023 12:16:10 -0600 Subject: [PATCH] bug fixes with export (Nulls) --- healthcareio/x12/plugins/default/claims.py | 6 +++--- healthcareio/x12/plugins/default/remits.py | 2 +- healthcareio/x12/publish.py | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/healthcareio/x12/plugins/default/claims.py b/healthcareio/x12/plugins/default/claims.py index 7df16fd..c0ee5c2 100644 --- a/healthcareio/x12/plugins/default/claims.py +++ b/healthcareio/x12/plugins/default/claims.py @@ -100,8 +100,8 @@ def DTP (**_args): # _columns = ['to','from','type'] # return self.parse(_columns,[3],**_args) _data = _args['data'] - _data['to'] = '-'.join([_data['to'][:4],_data['to'][4:6],_data['to'][6:]]) - _data['from'] = '-'.join([_data['from'][:4],_data['from'][4:6],_data['from'][6:]]) + _data['end_date'] = '-'.join([_data['end_date'][:4],_data['end_date'][4:6],_data['end_date'][6:]]) + _data['start_date'] = '-'.join([_data['start_date'][:4],_data['start_date'][4:6],_data['start_date'][6:]]) return _data pass @parser(element='PER',anchor={'IC':'submitter'},map={2:'contact',4:'phone_number',8:'email'}) @@ -124,7 +124,7 @@ def CLM (**_args): Expected Element CLM """ _data = _args['data'] - _data['claim_amount'] = np.float64(_data['claim_amount']) + _data['claim_amount'] = np.float64(_data['claim_amount']) if _data['claim_amount'] not in ['',None] else '' return _data # _columns = ['claim_id','claim_amount','facility_code','facility_qualifier','frequency_code'] # return self.parse(_columns,[1,2,5,5,5],**_args) diff --git a/healthcareio/x12/plugins/default/remits.py b/healthcareio/x12/plugins/default/remits.py index b037778..0c6cbc7 100644 --- a/healthcareio/x12/plugins/default/remits.py +++ b/healthcareio/x12/plugins/default/remits.py @@ -30,7 +30,7 @@ def BPR (**_args): def CLP (**_args): _data = _args['data'] for _id in ['charge_amount','payment_amount','patient_amount']: - _data[_id] = np.float64(_data[_id]) + _data[_id] = np.float64(_data[_id]) if _data[_id].strip() not in ['',None] else None return _data pass @parser (element='PER',x12='835',field="billing_provider",map={2:'name',4:'phone_number'}) diff --git a/healthcareio/x12/publish.py b/healthcareio/x12/publish.py index 6438925..b9a9c15 100644 --- a/healthcareio/x12/publish.py +++ b/healthcareio/x12/publish.py @@ -109,7 +109,7 @@ def init(**_args): _data = format(rows= _df.iloc[_ii].to_dict(orient='records'),x12=_file_type,primary_key=_pkey) - _thread = Process(target=post,args=({'store':_store['target'],'data':_data,'default':_default},)) + _thread = Process(target=post,args=({'store':_store['target'],'data':_data,'default':_default,'x12':_file_type},)) jobs.append(_thread) if jobs : jobs[0].start() @@ -133,18 +133,19 @@ def post(_args): _data = _args['data'] _store = _args['store'] _default = _args['default'] - + _prefix = 'clm_' if _args['x12'] == '837' else 'rem_' for _name in _data : - _store['table'] = _name + _tablename = _prefix+_name + _store['table'] = _tablename if _name not in ['remits','claims'] else _name _store['context']='write' writer = transport.factory.instance(**_store) - if len(_data[_name]) == 0 and _name in _default: + if len(_data[_name]) == 0 and _name in _default and not writer.has(table=_tablename): _rows = [_default[_name]] else: _rows = _data[_name] - writer.write(_rows) + writer.write(pd.DataFrame(_rows).fillna('')) if hasattr(writer,'close') : writer.close()