diff --git a/healthcareio/__main__.py b/healthcareio/__main__.py index abe5d9a..0cac63b 100644 --- a/healthcareio/__main__.py +++ b/healthcareio/__main__.py @@ -33,12 +33,16 @@ import time from healthcareio import x12 from healthcareio.x12.parser import X12Parser import requests +import pandas as pd +import numpy as np + # import healthcareio # import healthcareio.x12.util # from healthcareio.x12.parser import X12Parser app = typer.Typer() CONFIG_FOLDER = os.sep.join([os.environ['HOME'],'.healthcareio']) +HOST = "https://healthcareio.the-phi.com" if 'PARSER_HOST_URL' not in os.environ else os.environ['PARSER_HOST_URL'] @app.command(name='init') def config(email:str,provider:str='sqlite') : """\b @@ -49,6 +53,7 @@ def config(email:str,provider:str='sqlite') : :provider data store provider (visit https://hiplab.mc.vanderbilt.edu/git/hiplab/data-transport.git) """ _db = "healthcareio" + global CONFIG_FOLDER # _PATH = os.sep.join([os.environ['HOME'],'.healthcareio']) if not os.path.exists(CONFIG_FOLDER) : @@ -75,8 +80,9 @@ def config(email:str,provider:str='sqlite') : # This would also allow us to allow the users to be informed of new versions # try: - host = "https://healthcareio.the-phi.com" if 'PARSER_HOST_URL' not in os.environ else os.environ['PARSER_HOST'] - url = f"{host}/api/users/signup" + global HOST + # HOST = "https://healthcareio.the-phi.com" if 'PARSER_HOST_URL' not in os.environ else os.environ['PARSER_HOST'] + url = f"{HOST}/api/users/signup" _body = {"email":email,"version":meta.__version__} _headers = {"content-type":"application/json"} resp = requests.post(url,headers=_headers,data=json.dumps(_body)) @@ -94,7 +100,7 @@ def config(email:str,provider:str='sqlite') : The generatted configuration file found at {CONFIG_FOLDER} The database provider is {provider} - visit {host} to learn more about the features, + visit {HOST} to learn more about the features, """ @@ -140,6 +146,29 @@ def parse (claim_folder:str,plugin_folder:str = None,config_path:str = None): print ("...................... FINISHED .........................") # # +@app.command() +def check(): + """ + This function checks for the version running against the current version + """ + _info = [meta.__version__,None] + url = f'{HOST}/api/store/version' + try: + resp= requests.post(url) + _info[1] = resp.text if resp.status_code == 200 else "NA" + except Exception as e: + _info[1] = "NA" + pass + if _info[1] == "NA" : + _msg = "Unavailable server (unreachable)" + else: + _msg = "" + + print () + _info =pd.DataFrame(_info,columns=["versions"],index=["Yours","Current"]) + print (_info) + + print (_msg) @app.command(name="export") def publish (file_type:str,path:str):