From 27455a377020916e2d8b28940ab287a943c5a1f1 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Fri, 9 Feb 2024 10:00:29 -0600 Subject: [PATCH] documentation/function schema/tables created --- healthcareio/__main__.py | 12 ++++++++++++ healthcareio/x12/publish.py | 17 +++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/healthcareio/__main__.py b/healthcareio/__main__.py index 5f74ba5..43f513c 100644 --- a/healthcareio/__main__.py +++ b/healthcareio/__main__.py @@ -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): """ diff --git a/healthcareio/x12/publish.py b/healthcareio/x12/publish.py index 5f0265e..a68afb1 100644 --- a/healthcareio/x12/publish.py +++ b/healthcareio/x12/publish.py @@ -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)