bug fix: preverity fixes new construct 'rewrite'

master
Steve L. Nyemba 4 years ago
parent 348f82aa16
commit 0a2803000a

@ -64,7 +64,9 @@ class Formatters :
pass pass
else: 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 : else :
@ -169,8 +171,12 @@ class Formatters :
_value = {"type":value.split(xchar)[0].strip(),"code":value.split(xchar)[1].strip()} _value = {"type":value.split(xchar)[0].strip(),"code":value.split(xchar)[1].strip()}
if len(value.split(xchar)) >2 : 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 break
else: else:
_value = str(value) _value = str(value)
return _value return _value
@ -240,10 +246,13 @@ class Parser (Process):
pointer = getattr(handler,config['apply']) pointer = getattr(handler,config['apply'])
object_value = pointer(row) object_value = pointer(row)
return object_value return object_value
#
# Pull the goto configuration that skips rows
#
omap = config['map'] if not version or version not in config else config[version] omap = config['map'] if not version or version not in config else config[version]
anchors = config['anchors'] if 'anchors' in config else [] anchors = config['anchors'] if 'anchors' in config else []
rewrite = config['rewrite'] if 'rewrite' in config else {}
if type(row[0]) == str: if type(row[0]) == str:
object_value = {} object_value = {}
for key in omap : for key in omap :
@ -265,10 +274,12 @@ class Parser (Process):
pointer = getattr(handler,config['cast'][key]) pointer = getattr(handler,config['cast'][key])
value = pointer(value) value = pointer(value)
else: else:
print ("Missing Pointer ",config['cast'][key]) print ("Missing Pointer ",key,config['cast'])
# print (key,value)
if type(value) == dict : if type(value) == dict :
for objkey in value : for objkey in value :
@ -277,21 +288,36 @@ class Parser (Process):
continue continue
if 'syn' in config and value[objkey] in config['syn'] : if 'syn' in config and value[objkey] in config['syn'] :
value[objkey] = config['syn'][ value[objkey]] value[objkey] = config['syn'][ value[objkey]]
value = {key:value} if key not in value else value 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: else:
if 'syn' in config and value in config['syn'] : if 'syn' in config and value in config['syn'] :
value = config['syn'][value] value = config['syn'][value]
if type(value) == dict :
if type(value) == dict :
object_value = dict(object_value, **value) object_value = dict(object_value, **value)
else: else:
object_value[key] = value object_value[key] = value
else: else:
# #
# we are dealing with a complex object # we are dealing with a complex object
@ -301,6 +327,7 @@ class Parser (Process):
value = self.get.value(row_item,config,version) value = self.get.value(row_item,config,version)
object_value.append(value) object_value.append(value)
# #
# We need to add the index of the object it matters in determining the claim types # 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('~','')) row = util.split(row.replace('\n','').replace('~',''))
_info = util.get.config(self.config[_code][0],row) _info = util.get.config(self.config[_code][0],row)
if self._custom_config and _code in self._custom_config: if self._custom_config and _code in self._custom_config:
_cinfo = util.get.config(self._custom_config[_code],row) _cinfo = util.get.config(self._custom_config[_code],row)
else: else:
_cinfo = {} _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 : if _info :
try: try:
_info = jsonmerge.merge(_info,_cinfo)
_info = jsonmerge.merge(_info,_cinfo)
tmp = self.get.value(row,_info) tmp = self.get.value(row,_info)
if not tmp : if not tmp :
continue continue
if 'label' in _info : if 'label' in _info :
@ -351,32 +376,20 @@ class Parser (Process):
else: else:
if label not in value: if label not in value:
value[label] = [tmp] 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: else:
value[label].append(tmp) value[label].append(tmp)
tmp['_index'] = len(value[label]) -1 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 : elif 'field' in _info :
name = _info['field'] name = _info['field']
# value[name] = tmp # value[name] = tmp
value = jsonmerge.merge(value,{name:tmp}) value = jsonmerge.merge(value,{name:tmp})
else: else:
value = dict(value,**tmp) value = dict(value,**tmp)
pass pass
@ -409,6 +422,7 @@ class Parser (Process):
value['provider_id'] = SENDER_ID value['provider_id'] = SENDER_ID
# #
# Let's parse this for default values # Let's parse this for default values
return value return value
def read(self,filename) : def read(self,filename) :
@ -431,11 +445,7 @@ class Parser (Process):
INITIAL_ROWS = file[:4] INITIAL_ROWS = file[:4]
if len(INITIAL_ROWS) < 3 : if len(INITIAL_ROWS) < 3 :
return None,[{"name":filename,"completed":False}],None 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() _code = INITIAL_ROWS[2].split('*')[1].strip()
# section = 'CLP' if _code == '835' else 'HL'
section = self.config[_code][0]['SECTION'].strip() section = self.config[_code][0]['SECTION'].strip()
# #
# adjusting the # adjusting the
@ -466,13 +476,8 @@ class Parser (Process):
# #
# process the segment somewhere (create a thread maybe?) # process the segment somewhere (create a thread maybe?)
# #
# default_claim = dict({"index":index},**DEFAULT_VALUE)
# print (_toprows)
_claim = self.apply(segment,_code) _claim = self.apply(segment,_code)
# if _claim['claim_id'] == 'P1080351470' :
# print (_claim)
# _claim = dict(DEFAULT_VALUE,**_claim)
if _claim : if _claim :
_claim['index'] = index #len(claims) _claim['index'] = index #len(claims)
claims.append(dict(DEFAULT_VALUE,**_claim)) 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)

@ -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.5.4", "name":"healthcareio","version":"1.5.6",
"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…
Cancel
Save