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