From cb150f1d90b0afb8fe5f5e19c7e9cf3fbc275269 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 20 Oct 2020 12:31:09 -0500 Subject: [PATCH] bug fix: section/loop definition --- healthcareio/parser.py | 4 ++-- healthcareio/x12/__init__.py | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/healthcareio/parser.py b/healthcareio/parser.py index fed8a5b..e63ea32 100644 --- a/healthcareio/parser.py +++ b/healthcareio/parser.py @@ -287,7 +287,7 @@ def get_content(filename,config,section=None) : # tmp = get_map(row,_info,VERSION) # if 'parser' in _info : # pointer = eval(_info['parser']) - # print (pointer(row)) + tmp = get_map(row,_info,VERSION) except Exception as e: @@ -323,7 +323,7 @@ def get_content(filename,config,section=None) : if label not in claim: claim[label] = [tmp] elif len(list(tmp.keys())) == 1 : - # print "\t",len(claim[label]),tmp + index = len(claim[label]) -1 claim[label][index] = dict(claim[label][index],**tmp) else: diff --git a/healthcareio/x12/__init__.py b/healthcareio/x12/__init__.py index 6eec54e..cd3a2fd 100644 --- a/healthcareio/x12/__init__.py +++ b/healthcareio/x12/__init__.py @@ -277,7 +277,7 @@ class Parser (Process): value = {} for row in content[:] : - row = util.split(row) + row = util.split(row.replace('\n','').replace('~','')) _info = util.get.config(self.config[_code][0],row) if _info : @@ -327,7 +327,8 @@ class Parser (Process): pass except Exception as e : - print ('__',e) + + print ('__',e.args) pass return value if value else {} @@ -373,8 +374,8 @@ class Parser (Process): INITIAL_ROWS = file[:4] if len(INITIAL_ROWS) < 3 : return None,[{"name":filename,"completed":False}],None - section = 'CLM' if INITIAL_ROWS[1].split('*')[1] == 'HC' else 'CLP' - _code = '837' if section == 'CLM' else '835' + section = 'HL' if INITIAL_ROWS[1].split('*')[1] == 'HC' else 'CLP' + _code = '837' if section == 'HL' else '835' DEFAULT_VALUE = self.get.default_value(INITIAL_ROWS,_code) DEFAULT_VALUE['name'] = filename.strip() # @@ -396,13 +397,13 @@ class Parser (Process): # # process the segment somewhere (create a thread maybe?) # - default_claim = dict({"index":index},**DEFAULT_VALUE) + # default_claim = dict({"index":index},**DEFAULT_VALUE) _claim = self.apply(segment,_code) # if _claim['claim_id'] == 'P1080351470' : # print (_claim) # _claim = dict(DEFAULT_VALUE,**_claim) if _claim : - _claim['index'] = len(claims) + _claim['index'] = index #len(claims) claims.append(dict(DEFAULT_VALUE,**_claim)) segment = [row] index += 1