bug fix .. top row stuff
This commit is contained in:
parent
c7b4341621
commit
45ac94bfc4
|
@ -437,7 +437,7 @@ class Parser (Process):
|
|||
#
|
||||
|
||||
# Let's parse this for default values
|
||||
return value # jsonmerge.merge(value,self.apply(content,_code))
|
||||
return jsonmerge.merge(value,self.apply(content,_code))
|
||||
|
||||
def read(self,filename) :
|
||||
"""
|
||||
|
@ -452,15 +452,42 @@ class Parser (Process):
|
|||
claims = []
|
||||
try:
|
||||
file = open(filename.strip(),errors='ignore')
|
||||
INITIAL_ROWS = list(islice(file,4)) #.readlines(4)
|
||||
INITIAL_ROWS = list(islice(file,100)) #.readlines(4)
|
||||
_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()
|
||||
|
||||
|
||||
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 = 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)
|
||||
|
@ -473,9 +500,10 @@ class Parser (Process):
|
|||
_toprows = []
|
||||
_default = None
|
||||
for row in file :
|
||||
|
||||
row = row.replace('\r','')
|
||||
if not segment and not row.startswith(section):
|
||||
_toprows += [row]
|
||||
# if not segment and not row.startswith(section):
|
||||
# _toprows += [row]
|
||||
|
||||
if row.startswith(section) and not segment:
|
||||
|
||||
|
@ -484,13 +512,7 @@ class Parser (Process):
|
|||
continue
|
||||
|
||||
elif segment and not row.startswith(section):
|
||||
if not _default :
|
||||
#
|
||||
# NOTE:
|
||||
# Some information in the toprows can be available and applied to claims that do not have this
|
||||
# This holds true for dates, N1, NM1 segments
|
||||
_default = (self.apply(_toprows,_code))
|
||||
DEFAULT_VALUE = dict(DEFAULT_VALUE,**_default)
|
||||
|
||||
segment.append(row)
|
||||
|
||||
|
||||
|
@ -512,7 +534,7 @@ class Parser (Process):
|
|||
else:
|
||||
schema = {}
|
||||
merger = jsonmerge.Merger(schema)
|
||||
claims.append( merger.merge(DEFAULT_VALUE,_claim))
|
||||
claims.append( merger.merge(DEFAULT_VALUE.copy(),_claim))
|
||||
segment = [row]
|
||||
index += 1
|
||||
|
||||
|
@ -520,8 +542,9 @@ class Parser (Process):
|
|||
pass
|
||||
#
|
||||
# Handling the last claim found
|
||||
|
||||
if segment[0].startswith(section) :
|
||||
default_claim = dict({"name":index},**DEFAULT_VALUE)
|
||||
# default_claim = dict({"name":index},**DEFAULT_VALUE)
|
||||
|
||||
claim = self.apply(segment,_code)
|
||||
if claim :
|
||||
|
@ -535,7 +558,7 @@ class Parser (Process):
|
|||
merger = jsonmerge.Merger(schema)
|
||||
# top_row_claim = self.apply(_toprows,_code)
|
||||
|
||||
claim = merger.merge(claim,self.apply(_toprows,_code))
|
||||
# claim = merger.merge(claim,self.apply(_toprows,_code))
|
||||
# claims.append(dict(DEFAULT_VALUE,**claim))
|
||||
claims.append(merger.merge(DEFAULT_VALUE,claim))
|
||||
if type(file) != list :
|
||||
|
|
2
setup.py
2
setup.py
|
@ -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.10",
|
||||
"name":"healthcareio","version":"1.6.2.12",
|
||||
"author":"Vanderbilt University Medical Center",
|
||||
"author_email":"steve.l.nyemba@vumc.org",
|
||||
"include_package_data":True,
|
||||
|
|
Loading…
Reference in New Issue