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
|
# 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) :
|
def read(self,filename) :
|
||||||
"""
|
"""
|
||||||
|
@ -452,15 +452,42 @@ class Parser (Process):
|
||||||
claims = []
|
claims = []
|
||||||
try:
|
try:
|
||||||
file = open(filename.strip(),errors='ignore')
|
file = open(filename.strip(),errors='ignore')
|
||||||
INITIAL_ROWS = list(islice(file,4)) #.readlines(4)
|
INITIAL_ROWS = list(islice(file,100)) #.readlines(4)
|
||||||
_code = "unknown"
|
_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 :
|
if len(INITIAL_ROWS) == 1 :
|
||||||
file = INITIAL_ROWS[0].split('~')
|
INITIAL_ROWS = INITIAL_ROWS[0].split('~')
|
||||||
INITIAL_ROWS = file[:4]
|
else:
|
||||||
if len(INITIAL_ROWS) < 3 :
|
file.seek(0)
|
||||||
return None,[{"name":filename,"completed":False}],None
|
|
||||||
_code = INITIAL_ROWS[2].split('*')[1].strip()
|
|
||||||
section = self.config[_code][0]['SECTION'].strip()
|
_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
|
# adjusting the
|
||||||
DEFAULT_VALUE = self.get.default_value(INITIAL_ROWS,_code)
|
DEFAULT_VALUE = self.get.default_value(INITIAL_ROWS,_code)
|
||||||
|
@ -473,9 +500,10 @@ class Parser (Process):
|
||||||
_toprows = []
|
_toprows = []
|
||||||
_default = None
|
_default = None
|
||||||
for row in file :
|
for row in file :
|
||||||
|
|
||||||
row = row.replace('\r','')
|
row = row.replace('\r','')
|
||||||
if not segment and not row.startswith(section):
|
# if not segment and not row.startswith(section):
|
||||||
_toprows += [row]
|
# _toprows += [row]
|
||||||
|
|
||||||
if row.startswith(section) and not segment:
|
if row.startswith(section) and not segment:
|
||||||
|
|
||||||
|
@ -484,13 +512,7 @@ class Parser (Process):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif segment and not row.startswith(section):
|
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)
|
segment.append(row)
|
||||||
|
|
||||||
|
|
||||||
|
@ -512,7 +534,7 @@ class Parser (Process):
|
||||||
else:
|
else:
|
||||||
schema = {}
|
schema = {}
|
||||||
merger = jsonmerge.Merger(schema)
|
merger = jsonmerge.Merger(schema)
|
||||||
claims.append( merger.merge(DEFAULT_VALUE,_claim))
|
claims.append( merger.merge(DEFAULT_VALUE.copy(),_claim))
|
||||||
segment = [row]
|
segment = [row]
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
|
@ -520,8 +542,9 @@ class Parser (Process):
|
||||||
pass
|
pass
|
||||||
#
|
#
|
||||||
# Handling the last claim found
|
# Handling the last claim found
|
||||||
|
|
||||||
if segment[0].startswith(section) :
|
if segment[0].startswith(section) :
|
||||||
default_claim = dict({"name":index},**DEFAULT_VALUE)
|
# default_claim = dict({"name":index},**DEFAULT_VALUE)
|
||||||
|
|
||||||
claim = self.apply(segment,_code)
|
claim = self.apply(segment,_code)
|
||||||
if claim :
|
if claim :
|
||||||
|
@ -535,7 +558,7 @@ class Parser (Process):
|
||||||
merger = jsonmerge.Merger(schema)
|
merger = jsonmerge.Merger(schema)
|
||||||
# top_row_claim = self.apply(_toprows,_code)
|
# 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(dict(DEFAULT_VALUE,**claim))
|
||||||
claims.append(merger.merge(DEFAULT_VALUE,claim))
|
claims.append(merger.merge(DEFAULT_VALUE,claim))
|
||||||
if type(file) != list :
|
if type(file) != list :
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ import sys
|
||||||
def read(fname):
|
def read(fname):
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
args = {
|
args = {
|
||||||
"name":"healthcareio","version":"1.6.2.10",
|
"name":"healthcareio","version":"1.6.2.12",
|
||||||
"author":"Vanderbilt University Medical Center",
|
"author":"Vanderbilt University Medical Center",
|
||||||
"author_email":"steve.l.nyemba@vumc.org",
|
"author_email":"steve.l.nyemba@vumc.org",
|
||||||
"include_package_data":True,
|
"include_package_data":True,
|
||||||
|
|
Loading…
Reference in New Issue