bug fix with segment setup

docker
Steve L. Nyemba 4 years ago
parent e6d0725ba7
commit 22800d3bbc

@ -153,6 +153,8 @@ class Formatters :
return _value
else:
return value
def procedure(self,value):
for xchar in [':','<'] :
if xchar in value and len(value.split(xchar)) > 1 :
@ -263,14 +265,15 @@ class Parser (Process):
# object_value.append( list(get_map(row_item,config,version)))
# object_value = {label:object_value}
return object_value
def apply(self,content,_code,default_value) :
def apply(self,content,_code) :
"""
:file content i.e a segment with the envelope
:_code 837 or 835 (helps get the appropriate configuration)
"""
util = Formatters()
claim = default_value.copy()
# header = default_value.copy()
value = {}
for row in content[:] :
@ -281,7 +284,10 @@ class Parser (Process):
try:
tmp = self.get.value(row,_info)
# if 'P1080351470' in content[0] and 'PLB' in row:
# print (_info)
# print (row)
# print (tmp)
if not tmp :
continue
if 'label' in _info :
@ -300,15 +306,18 @@ class Parser (Process):
value[label][index] = dict(value[label][index],**tmp)
else:
value[label].append(tmp)
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
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']
value[name] = tmp
else:
@ -321,7 +330,7 @@ class Parser (Process):
print ('__',e)
pass
return dict(claim,**value) if value else {}
return value if value else {}
def get_default_value(self,content,_code):
util = Formatters()
@ -377,7 +386,7 @@ class Parser (Process):
segment = [row]
continue
elif segment:
elif segment and not row.startswith(section):
segment.append(row)
@ -386,9 +395,13 @@ class Parser (Process):
# process the segment somewhere (create a thread maybe?)
#
default_claim = dict({"index":index},**DEFAULT_VALUE)
claim = self.apply(segment,_code,default_claim)
claims.append(claim)
_claim = self.apply(segment,_code)
# if _claim['claim_id'] == 'P1080351470' :
# print (_claim)
# _claim = dict(DEFAULT_VALUE,**_claim)
if _claim :
_claim['index'] = len(claims)
claims.append(dict(DEFAULT_VALUE,**_claim))
segment = [row]
index += 1
@ -399,8 +412,10 @@ class Parser (Process):
if segment[0].startswith(section) :
default_claim = dict({"name":index},**DEFAULT_VALUE)
claim = self.apply(segment,_code,DEFAULT_VALUE)
claims.append(claim)
claim = self.apply(segment,_code)
if claim :
claim['index'] = len(claims)
claims.append(dict(DEFAULT_VALUE,**claim))
if type(file) != list :
file.close()

@ -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.3.4",
"name":"healthcareio","version":"1.3.5",
"author":"Vanderbilt University Medical Center",
"author_email":"steve.l.nyemba@vumc.org",
"license":"MIT",

Loading…
Cancel
Save