@ -19,6 +19,7 @@
"""
import os
import sys
import json
def split ( row , sep = ' * ' , prefix = ' HI ' ) :
"""
This function is designed to split an x12 row and
@ -30,10 +31,13 @@ def split(row,sep='*',prefix='HI'):
if ' > ' in row_value :
if row_value . startswith ( ' HC ' ) or row_value . startswith ( ' AD ' ) :
value + = row_value . split ( ' > ' ) [ : 2 ]
value + = row_value . split ( ' > ' ) [ : 2 ]
else :
value + = row_value . split ( ' > ' )
value + = row_value . split ( ' > ' ) if row . startswith ( ' CLM ' ) is False else [ row_value ]
else :
value . append ( row_value )
return [ xchar . replace ( ' \r ' , ' ' ) for xchar in value ] #row.replace('~','').split(sep)
else :
@ -88,13 +92,20 @@ def format_proc(value):
def format_diag ( value ) :
return [ { " code " : item [ 2 ] , " type " : item [ 1 ] } for item in value if len ( item ) > 1 ]
def format_pos ( value ) :
xchar = ' > ' if ' > ' in value else ' : '
x = value . split ( xchar )
x = { " code " : x [ 0 ] , " indicator " : x [ 1 ] , " frequency " : x [ 2 ] } if len ( x ) == 3 else { " code " : x [ 0 ] , " indicator " : None , " frequency " : None }
return x
def get_map ( row , config , version ) :
label = config [ ' label ' ] if ' label ' in config else None
omap = config [ ' map ' ] if version not in config else config [ version ]
anchors = config [ ' anchors ' ] if ' anchors ' in config else [ ]
if type ( row [ 0 ] ) == str :
if type ( row [ 0 ] ) == str :
object_value = { }
for key in omap :
index = omap [ key ]
@ -108,13 +119,21 @@ def get_map(row,config,version):
value = row [ index ]
if ' cast ' in config and key in config [ ' cast ' ] and value . strip ( ) != ' ' :
value = eval ( config [ ' cast ' ] [ key ] ) ( value )
pass
if ' syn ' in config and value in config [ ' syn ' ] :
value = config [ ' syn ' ] [ value ]
if type ( value ) == dict :
object_value = dict ( object_value , * * value )
for objkey in value :
if ' syn ' in config and value [ objkey ] in config [ ' syn ' ] :
value [ objkey ] = config [ ' syn ' ] [ value [ objkey ] ]
value = { key : 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 :