bug fix with list of diagnosis codes

docker
Steve L. Nyemba 5 years ago
parent 719ca4c466
commit f27e5773fd

@ -44,6 +44,7 @@ def get_config(config,row):
This function will return the meaningfull parts of the configuration for a given item This function will return the meaningfull parts of the configuration for a given item
""" """
_row = list(row) if type(row[0]) == str else list(row[0]) _row = list(row) if type(row[0]) == str else list(row[0])
_info = config[_row[0]] if _row[0] in config else {} _info = config[_row[0]] if _row[0] in config else {}
key = None key = None
if '@ref' in _info: if '@ref' in _info:
@ -60,6 +61,7 @@ def get_config(config,row):
if _row[0] in config['SIMILAR'] : if _row[0] in config['SIMILAR'] :
key = config['SIMILAR'][_row[0]] key = config['SIMILAR'][_row[0]]
_info = config[key] _info = config[key]
return _info return _info
def format_date(value) : def format_date(value) :
year = value[:4] year = value[:4]
@ -73,7 +75,9 @@ def format_proc(value):
return {"procedure_type":value.split(':')[0].strip(),"procedure_code":value.split(':')[1].strip()} return {"procedure_type":value.split(':')[0].strip(),"procedure_code":value.split(':')[1].strip()}
else: else:
return value return value
def format_diag(value):
return [ {"code":item[2], "type":item[1]} for item in value if len(item) > 1]
def get_map(row,config,version): def get_map(row,config,version):
label = config['label'] if 'label' in config else None label = config['label'] if 'label' in config else None
@ -92,6 +96,7 @@ def get_map(row,config,version):
if index < len(row) : if index < len(row) :
value = row[index] value = row[index]
if 'cast' in config and key in config['cast'] and value.strip() != '' : if 'cast' in config and key in config['cast'] and value.strip() != '' :
value = eval(config['cast'][key])(value) value = eval(config['cast'][key])(value)
@ -106,8 +111,11 @@ def get_map(row,config,version):
# #
# we are dealing with a complex object # we are dealing with a complex object
object_value = [] object_value = []
for row_item in row : for row_item in row :
object_value.append( list(get_map(row_item,config,version))) value = get_map(row_item,config,version)
object_value.append(value)
# object_value.append( list(get_map(row_item,config,version)))
# object_value = {label:object_value} # object_value = {label:object_value}
return object_value return object_value
@ -129,6 +137,7 @@ def get_content(filename,config,section=None) :
:filename location of the file :filename location of the file
""" """
section = section if section else config['SECTION'] section = section if section else config['SECTION']
x12_file = open(filename).read().split('\n') x12_file = open(filename).read().split('\n')
if len(x12_file) == 1 : if len(x12_file) == 1 :
@ -145,7 +154,9 @@ def get_content(filename,config,section=None) :
row = split(x12_file[3]) row = split(x12_file[3])
_info = get_config(config,row) _info = get_config(config,row)
_default_value = get_map(row,_info,VERSION) if _info else None
_default_value = get_map(row,_info,VERSION) if _info else {}
N = len(locations) N = len(locations)
for index in range(0,N-1): for index in range(0,N-1):
@ -158,6 +169,9 @@ def get_content(filename,config,section=None) :
if _info : if _info :
try: try:
# tmp = get_map(row,_info,VERSION) # tmp = get_map(row,_info,VERSION)
# if 'parser' in _info :
# pointer = eval(_info['parser'])
# print (pointer(row))
tmp = get_map(row,_info,VERSION) tmp = get_map(row,_info,VERSION)
except Exception as e: except Exception as e:
if sys.verion_info[0] > 2 : if sys.verion_info[0] > 2 :

Loading…
Cancel
Save