|
|
@ -17,21 +17,25 @@ def build (**_args):
|
|
|
|
_x12 = _args['x12']
|
|
|
|
_x12 = _args['x12']
|
|
|
|
_template = util.template(plugins=_plugins)[_x12]
|
|
|
|
_template = util.template(plugins=_plugins)[_x12]
|
|
|
|
_primaryKey = util.getPrimaryKey(plugins=_plugins,x12=_x12)
|
|
|
|
_primaryKey = util.getPrimaryKey(plugins=_plugins,x12=_x12)
|
|
|
|
_tables = []
|
|
|
|
_tables = {}
|
|
|
|
_main = {}
|
|
|
|
_main = {}
|
|
|
|
for _name in _template :
|
|
|
|
for _name in _template :
|
|
|
|
_item = _template[_name] #copy.deepcopy(_template[_name])
|
|
|
|
_item = _template[_name] #copy.deepcopy(_template[_name])
|
|
|
|
|
|
|
|
if _name not in _tables and type(_item) in [list,dict] :
|
|
|
|
|
|
|
|
_tables[_name] = _item
|
|
|
|
if _primaryKey not in _item and type(_item) == dict:
|
|
|
|
if _primaryKey not in _item and type(_item) == dict:
|
|
|
|
_item[_primaryKey] = ''
|
|
|
|
_item[_primaryKey] = ''
|
|
|
|
_tables.append({_name:_item})
|
|
|
|
# _tables.append({_name:_item})
|
|
|
|
|
|
|
|
_tables[_name] = _item
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
_main[_name] = ''
|
|
|
|
_main[_name] = ''
|
|
|
|
|
|
|
|
|
|
|
|
_name = getContext(_x12)
|
|
|
|
_name = getContext(_x12)
|
|
|
|
_tables += [{_name:_main}]
|
|
|
|
# _tables += [{_name:_main}]
|
|
|
|
|
|
|
|
_tables[_name] = _main
|
|
|
|
_template[_name] = _main
|
|
|
|
_template[_name] = _main
|
|
|
|
|
|
|
|
|
|
|
|
return _template #_tables
|
|
|
|
return _tables #_template #_tables
|
|
|
|
def getContext(_x12) :
|
|
|
|
def getContext(_x12) :
|
|
|
|
return 'claims' if _x12 == '837' else 'remits'
|
|
|
|
return 'claims' if _x12 == '837' else 'remits'
|
|
|
|
def format(**_args) :
|
|
|
|
def format(**_args) :
|
|
|
@ -60,14 +64,15 @@ def format(**_args) :
|
|
|
|
|
|
|
|
|
|
|
|
for _attrName in _claim :
|
|
|
|
for _attrName in _claim :
|
|
|
|
_item = _claim[_attrName]
|
|
|
|
_item = _claim[_attrName]
|
|
|
|
_item = update(_item,_primary_key,_pkvalue)
|
|
|
|
# _item = update(_item,_primary_key,_pkvalue)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# We have a casting problem, with relational data-store and JSON objects
|
|
|
|
# We have a casting problem, with relational data-store and JSON objects
|
|
|
|
#
|
|
|
|
#
|
|
|
|
if type(_item) == str and (_item.startswith("{") or _item.startswith("{")) :
|
|
|
|
if type(_item) == str and (_item.startswith("[") or _item.startswith("{")) :
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
|
|
_item = json.loads(_item)
|
|
|
|
_item = json.loads(_item)
|
|
|
|
|
|
|
|
_item = update(_item,_primary_key,_pkvalue)
|
|
|
|
|
|
|
|
|
|
|
|
except Exception as ee :
|
|
|
|
except Exception as ee :
|
|
|
|
# print (ee)
|
|
|
|
# print (ee)
|
|
|
|