v2.0 upgrade #10
|
@ -174,6 +174,18 @@ def check():
|
|||
|
||||
print (_msg)
|
||||
|
||||
@app.command(name="export-schema")
|
||||
def export_schema (file_type:str):
|
||||
"""
|
||||
This function will display the schema in JSON format of a given file/type
|
||||
"""
|
||||
_plugins,_parents = x12.plugins.instance()
|
||||
if file_type not in ['835','837'] and file_type in ['claims','remits']:
|
||||
file_type = '835' if file_type == 'remits' else '837'
|
||||
_template = x12.publish.build(x12=file_type,plugins=_plugins)
|
||||
print ( json.dumps(_template))
|
||||
|
||||
|
||||
@app.command(name="export")
|
||||
def publish (file_type:str,path:str):
|
||||
"""
|
||||
|
|
|
@ -17,21 +17,25 @@ def build (**_args):
|
|||
_x12 = _args['x12']
|
||||
_template = util.template(plugins=_plugins)[_x12]
|
||||
_primaryKey = util.getPrimaryKey(plugins=_plugins,x12=_x12)
|
||||
_tables = []
|
||||
_tables = {}
|
||||
_main = {}
|
||||
for _name in _template :
|
||||
_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:
|
||||
_item[_primaryKey] = ''
|
||||
_tables.append({_name:_item})
|
||||
# _tables.append({_name:_item})
|
||||
_tables[_name] = _item
|
||||
else:
|
||||
_main[_name] = ''
|
||||
|
||||
_name = getContext(_x12)
|
||||
_tables += [{_name:_main}]
|
||||
# _tables += [{_name:_main}]
|
||||
_tables[_name] = _main
|
||||
_template[_name] = _main
|
||||
|
||||
return _template #_tables
|
||||
return _tables #_template #_tables
|
||||
def getContext(_x12) :
|
||||
return 'claims' if _x12 == '837' else 'remits'
|
||||
def format(**_args) :
|
||||
|
@ -60,14 +64,15 @@ def format(**_args) :
|
|||
|
||||
for _attrName in _claim :
|
||||
_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
|
||||
#
|
||||
if type(_item) == str and (_item.startswith("{") or _item.startswith("{")) :
|
||||
if type(_item) == str and (_item.startswith("[") or _item.startswith("{")) :
|
||||
try:
|
||||
|
||||
_item = json.loads(_item)
|
||||
_item = update(_item,_primary_key,_pkvalue)
|
||||
|
||||
except Exception as ee :
|
||||
# print (ee)
|
||||
|
|
Loading…
Reference in New Issue