bug fix: preverity fixes new construct 'rewrite'

This commit is contained in:
Steve Nyemba 2021-01-19 00:21:33 -06:00
parent 348f82aa16
commit 0a2803000a
2 changed files with 47 additions and 54 deletions

View File

@ -64,7 +64,9 @@ class Formatters :
pass
else:
value += row_value.split('>') if row.startswith('CLM') is False else [row_value]
value += [row_value]
# value += row_value.split('>') if row.startswith('CLM') is False else [row_value]
else :
@ -169,8 +171,12 @@ class Formatters :
_value = {"type":value.split(xchar)[0].strip(),"code":value.split(xchar)[1].strip()}
if len(value.split(xchar)) >2 :
_value['modifier'] = value.split(xchar)[2]
index = 1;
for modifier in value.split(xchar)[2:] :
_value['modifier_'+str(index)] = modifier
index += 1
break
else:
_value = str(value)
return _value
@ -240,10 +246,13 @@ class Parser (Process):
pointer = getattr(handler,config['apply'])
object_value = pointer(row)
return object_value
#
# Pull the goto configuration that skips rows
#
omap = config['map'] if not version or version not in config else config[version]
anchors = config['anchors'] if 'anchors' in config else []
rewrite = config['rewrite'] if 'rewrite' in config else {}
if type(row[0]) == str:
object_value = {}
for key in omap :
@ -265,10 +274,12 @@ class Parser (Process):
pointer = getattr(handler,config['cast'][key])
value = pointer(value)
else:
print ("Missing Pointer ",config['cast'][key])
# print (key,value)
else:
print ("Missing Pointer ",key,config['cast'])
if type(value) == dict :
for objkey in value :
@ -278,20 +289,35 @@ class Parser (Process):
if 'syn' in config and value[objkey] in config['syn'] :
value[objkey] = config['syn'][ value[objkey]]
if key in rewrite :
_key = rewrite[key]
if _key in value :
value = value[_key]
else:
value = ""
value = {key:value} if key not in value else value
else:
if 'syn' in config and value in config['syn'] :
value = config['syn'][value]
if type(value) == dict :
object_value = dict(object_value, **value)
else:
object_value[key] = value
else:
#
# we are dealing with a complex object
@ -301,6 +327,7 @@ class Parser (Process):
value = self.get.value(row_item,config,version)
object_value.append(value)
#
# We need to add the index of the object it matters in determining the claim types
#
@ -322,24 +349,22 @@ class Parser (Process):
row = util.split(row.replace('\n','').replace('~',''))
_info = util.get.config(self.config[_code][0],row)
if self._custom_config and _code in self._custom_config:
_cinfo = util.get.config(self._custom_config[_code],row)
else:
_cinfo = {}
# _info = self.consolidate(row=row,type=_code,config=_info,util=util)
# print ([row[0],_info])
# print ()
# continue
# _cinfo = util.get.config(self._custom_config[_code],row)
if _info :
try:
_info = jsonmerge.merge(_info,_cinfo)
tmp = self.get.value(row,_info)
if not tmp :
continue
if 'label' in _info :
@ -351,23 +376,12 @@ class Parser (Process):
else:
if label not in value:
value[label] = [tmp]
# elif len(list(tmp.keys())) == 1 :
# # print "\t",len(claim[label]),tmp
# index = len(value[label]) -1
# value[label][index] = dict(value[label][index],**tmp)
else:
value[label].append(tmp)
tmp['_index'] = len(value[label]) -1
# if len(value[label]) > 0 :
# labels = []
# for item in value[label] :
# item['_index'] = len(labels)
# if item not in labels :
# labels.append(item)
# value[label] = labels
elif 'field' in _info :
name = _info['field']
@ -376,7 +390,6 @@ class Parser (Process):
else:
value = dict(value,**tmp)
pass
@ -409,6 +422,7 @@ class Parser (Process):
value['provider_id'] = SENDER_ID
#
# Let's parse this for default values
return value
def read(self,filename) :
@ -431,11 +445,7 @@ class Parser (Process):
INITIAL_ROWS = file[:4]
if len(INITIAL_ROWS) < 3 :
return None,[{"name":filename,"completed":False}],None
# section = 'HL' if INITIAL_ROWS[1].split('*')[1] == 'HC' else 'CLP'
# _code = '837' if section == 'HL' else '835'
# print ([_code,section])
_code = INITIAL_ROWS[2].split('*')[1].strip()
# section = 'CLP' if _code == '835' else 'HL'
section = self.config[_code][0]['SECTION'].strip()
#
# adjusting the
@ -466,13 +476,8 @@ class Parser (Process):
#
# process the segment somewhere (create a thread maybe?)
#
# default_claim = dict({"index":index},**DEFAULT_VALUE)
# print (_toprows)
_claim = self.apply(segment,_code)
# if _claim['claim_id'] == 'P1080351470' :
# print (_claim)
# _claim = dict(DEFAULT_VALUE,**_claim)
if _claim :
_claim['index'] = index #len(claims)
claims.append(dict(DEFAULT_VALUE,**_claim))
@ -536,15 +541,3 @@ class Parser (Process):
# p = Parser('/home/steve/.healthcareio/config.json')
# p.set.files(['../../data/small/claims/ssiUB1122042711220427127438.clm_191122T043504'])
# path = '../../data/small/claims/ssiUB1122042711220427127438.clm_191122T043504'
# path = '../../data/small/claims/problems-with-procs'
# path = '../../data/small/remits/1SG03927258.dat_181018T074559'
# _path = "../../data/small/remits/1TR21426701.dat_180703T074559"
# p.start()
# p.join()
# claims,logs = p.read(path)
# print (json.dumps(claims[3]))
# print (logs)

View File

@ -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.5.4",
"name":"healthcareio","version":"1.5.6",
"author":"Vanderbilt University Medical Center",
"author_email":"steve.l.nyemba@vumc.org",
"include_package_data":True,