bug fix ... toprow stuff

master
Steve L. Nyemba 4 years ago
parent d2021bb430
commit 0aa6eb3d5d

@ -416,25 +416,21 @@ class Parser (Process):
util = Formatters()
TOP_ROW = content[1].split('*')
SUBMITTED_DATE = util.parse.date(TOP_ROW[4])
CATEGORY= content[2].split('*')[1].strip()
VERSION = content[1].split('*')[-1].replace('~','').replace('\n','')
SUBMITTED_DATE = util.parse.date(TOP_ROW[4])
SENDER_ID = TOP_ROW[2]
row = util.split(content[3])
_info = util.get_config(self.config[_code][0],row)
value = self.get.value(row,_info,VERSION) if _info else {}
value['category'] = {"setid": CATEGORY,"version":'X'+VERSION.split('X')[1],"id":VERSION.split('X')[0].strip()}
value['category'] = {"setid": _code,"version":'X'+VERSION.split('X')[1],"id":VERSION.split('X')[0].strip()}
value["submitted"] = SUBMITTED_DATE
# value['version'] = VERSION
# if _code== '835' :
# value['receiver_id'] = SENDER_ID
# else:
# value['provider_id'] = SENDER_ID
# pass
value['sender_id'] = SENDER_ID
#
# Let's parse this for default values
return jsonmerge.merge(value,self.apply(content,_code))
@ -452,46 +448,22 @@ class Parser (Process):
claims = []
try:
file = open(filename.strip(),errors='ignore')
INITIAL_ROWS = list(islice(file,100)) # Read the first 100 lines (no particular reason)
_code = "unknown"
# if len(INITIAL_ROWS) == 1 :
# file = INITIAL_ROWS[0].split('~')
# INITIAL_ROWS = file[:4]
# if len(INITIAL_ROWS) < 3 :
# return None,[{"name":filename,"completed":False}],None
# _code = INITIAL_ROWS[2].split('*')[1].strip()
# section = self.config[_code][0]['SECTION'].strip()
# INITIAL_ROWS = file.read().readlines()
file = file.read().split('CLP')
_code = '835'
section = 'CLP'
if len(file) == 1 :
file = file[0].split('CLM')
_code = '837'
section = 'HL'
INITIAL_ROWS = file[0].split(section)[0].split('\n')
if len(INITIAL_ROWS) == 1 :
INITIAL_ROWS = INITIAL_ROWS[0].split('~')
else:
file.seek(0)
_code = INITIAL_ROWS[2].split('*')[1].strip() #-- x12 standard would have the code positiond here
section = self.config[_code][0]['SECTION'].strip() #-- This is either CLM or CLP
# INITIAL_ROWS =
# _code = INITIAL_ROWS[2].split('*')[1].strip()
for row in INITIAL_ROWS :
if section in row :
index = INITIAL_ROWS.index(row)
#-- The order here will matter because the initial rows will contain the entire file
# Assign this to the file object and move forward by making sure initial_rows are actually initial rows
#
file = INITIAL_ROWS[index:]
INITIAL_ROWS = INITIAL_ROWS[:index]
break
# print ([_code,section])
# print (self.get.default_value(INITIAL_ROWS,_code))
#
# adjusting the
DEFAULT_VALUE = self.get.default_value(INITIAL_ROWS,_code)
INITIIAL_ROWS = INITIAL_ROWS[0].split('~')
DEFAULT_VALUE = self.get.default_value(INITIAL_ROWS,_code)
DEFAULT_VALUE['name'] = filename.strip()
print (json.dumps(DEFAULT_VALUE))
file = section.join(file).split('\n')
if len(file) == 1:
file = file[0].split('~')
#
# In the initial rows, there's redundant information (so much for x12 standard)
# index 1 identifies file type i.e CLM for claim and CLP for remittance
@ -534,8 +506,11 @@ class Parser (Process):
else:
schema = {}
merger = jsonmerge.Merger(schema)
claims.append( merger.merge(DEFAULT_VALUE.copy(),_claim))
_claim = merger.merge(DEFAULT_VALUE.copy(),_claim)
claims.append( _claim)
segment = [row]
index += 1
@ -543,7 +518,7 @@ class Parser (Process):
#
# Handling the last claim found
if segment[0].startswith(section) :
if segment and segment[0].startswith(section) :
# default_claim = dict({"name":index},**DEFAULT_VALUE)
claim = self.apply(segment,_code)

@ -8,7 +8,7 @@ import sys
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
args = {
"name":"healthcareio","version":"1.6.2.12",
"name":"healthcareio","version":"1.6.2.14",
"author":"Vanderbilt University Medical Center",
"author_email":"steve.l.nyemba@vumc.org",
"include_package_data":True,

Loading…
Cancel
Save