From 94b66c2d2a13d079fa7489f872ebd8d09e4fb904 Mon Sep 17 00:00:00 2001 From: Mayank Aamseek Date: Wed, 27 Mar 2024 18:59:29 +0530 Subject: [PATCH] added interface 0 --- streamlit/contract_fields.csv | 10 +-- streamlit/interface_0.py | 155 ++++++++++++++++++++++++++++++++++ streamlit/interface_1.py | 6 +- streamlit/interface_3.py | 17 ++-- 4 files changed, 172 insertions(+), 16 deletions(-) create mode 100644 streamlit/interface_0.py diff --git a/streamlit/contract_fields.csv b/streamlit/contract_fields.csv index b8db63e..57e414d 100644 --- a/streamlit/contract_fields.csv +++ b/streamlit/contract_fields.csv @@ -59,7 +59,7 @@ NETWORK" NETWORK" "If the Tertiary Reimbursement methodology is based on Status Indicator codes, then list the applicable codes or code ranges",Applicable Status Indicator Codes - Tertiary,TERTIARY_REIMBURSEMENT_STATUS_INDICATOR_CODES,VARCHAR,B,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Reimbursement Methodology,Required Only If Available ,"PAYMENT ACCURACY NETWORK" -"If this agreement is not the base contract, then what is the effective date of the associated base contract? This date is earlier than today's date and is a long date format.",Associated Base Contract Effective Date,CONTRACT_BASE_EFFECTIVE_DT,DATE,C,ACTIVE,No,Preamble ,Contract ,Required Only If Agreement Is NOT the Base Contract , +"If this agreement is not the base contract, then what is the effective date of the associated base contract? This date is earlier than today's date and is a long date format. Only return this date. If there is no date, return nothing. Do not explain or elaborate, only return the date converted to YYYY-MM-DD format or nothing.",Associated Base Contract Effective Date,CONTRACT_BASE_EFFECTIVE_DT,DATE,C,ACTIVE,No,Preamble ,Contract ,Required Only If Agreement Is NOT the Base Contract , "If this agreement is not the base contract, then what is the title of the associated base contract? This field will be present if there is an amendment or if the amendment is numbered. It is text that likely contains some of the following keywords: agreement, participating provider, participating hospital, provider agreement, or hospital agreement. Only say the title. Do not provide any context or explanation for it. Do not introduce what it is either, simply state the title. ",Associated Base Contract Title,CONTRACT_BASE_TITLE,VARCHAR,C,ACTIVE,No,Preamble ,Contract ,Required Only If Agreement Is NOT the Base Contract , "What are the names of other providers associated with this agreement? The names can be found across multiple pages after the signature page. These names can be found in a roster and can be a list of provider names or TINs. Do not provide any context or explanation, simply state the names.",Associated Provider Full Names,PROV_DOING_BUSINESS_AS,VARCHAR,A,ACTIVE,Yes,"Preamble, contract signatory section, and/or Exhibit, Attachment, or Schedule to contract",Provider ,Required Only If Available ,"UNIQUE KEY PDM" @@ -363,7 +363,7 @@ INTELLIGENT EDITS " INTELLIGENT EDITS " "If the contract includes a carve out for Neonatal Services, describe how these codes are reimbursed",Neonatal Reimbursement Methodology,NEONATAL_CARVEOUT_REIMBURSEMENT_METHODOLOGY,VARCHAR,G,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " -"If the contract is based on network type, then list them for each impacted line of business for each specifically listed network.",Network,CONTRACT_NETWORK,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Required Only If Available ,UNIQUE KEY +"If the contract is based on network type, list each payer network relevant to each line of business as outlined in the contract.",Network,CONTRACT_NETWORK,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Required Only If Available ,UNIQUE KEY Does the contract include a carve out for never events (Yes/No)?,Never Event Carve Out (Y/N)?,NEVER_EVENT_CAREVEOUT_IND,VARCHAR,F,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " "If the contract includes a carve out for never events, list the applicable codes or code ranges ",Never Event Codes or Code Range,NEVER_EVENT_CAREVOUT_CODES,VARCHAR,F,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY @@ -410,7 +410,7 @@ NETWORK" What triggers computation of penalties and interest?,Penalties & Interest Trigger,PENALTIES_INTEREST_TRIGGER,VARCHAR,B,ACTIVE,No,"From Base Contract or from LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider","Discounts, Premiums, Sequestration, Penalties, Interest",Required Only If Available ,"PAYMENT ACCURACY NETWORK" "If the contract is for Marketplace line of business, then list all metal levels , such as platinum, bronze, silver, and gold.",Plan - Metal Level,CONTRACT_MARKETPLACE_METAL_LEVEL,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Required Only If Available ,UNIQUE KEY -"If the contract is based on service areas, then list each specifically listed area, county, ZIP, etc. for each impacted line of business.",Plan- Service Area,CONTRACT_SERVICE_AREA,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Required Only If Available ,UNIQUE KEY +"If the contract is based on service areas, then list each specifically listed geographic area for each line of business. This could be a state, county, ZIP code, etc. Return either a comma separated list of these service areas, or do not return anything if the contract is not based on geography. Do not elaborate or add context.",Plan- Service Area,CONTRACT_SERVICE_AREA,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Required Only If Available ,UNIQUE KEY Does the contract include a carve out for post-discharge procedures (Yes/No)?,Post-Discharge Procedures Carve Out (Y/N)?,POSTDISCHARGE_PROC_CAREVEOUT_IND,VARCHAR,F,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " "If the contract includes a carve out for post-discharge procedures, list the applicable codes or code ranges",Post-Discharge Services Codes or Code Range,POSTDISCHARGE_PROC_CAREVOUT_CODES,VARCHAR,F,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY @@ -530,7 +530,7 @@ INTELLIGENT EDITS " INTELLIGENT EDITS " "If the contract includes a carve out for Technical Component, describe how these codes are reimbursed",Technical Component Reimbursement Methodology ,TECHNICAL_COMPONENT_CARVEOUT_REIMBURSEMENT_METHODOLOGY,VARCHAR,G,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " -Identify the specific date upon which the compensation specific to each line of business terminates.,Termination Date of Pricing Terms,LOB_PRICING_TERMS_TERMINATION_DT,D,A,ACTIVE,No (but please use GDP date format throughout),"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Always Required ,"GREEN LIGHT - IF DATE IS LESS THAN TODAY'S DATE THEN STOP, DO NOT REVIEW CONTRACT CONFIGURATION UNLESS THERE IS AN EFFECTIVE AMENDMENT UNIQUE KEY" +"For each line of business, identify the specific date upon which the compensation terminates, in the following format ONLY: MM/DD/YYYY.",Termination Date of Pricing Terms,LOB_PRICING_TERMS_TERMINATION_DT,D,A,ACTIVE,No (but please use GDP date format throughout),"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Always Required ,"GREEN LIGHT - IF DATE IS LESS THAN TODAY'S DATE THEN STOP, DO NOT REVIEW CONTRACT CONFIGURATION UNLESS THERE IS AN EFFECTIVE AMENDMENT UNIQUE KEY" What is timeline for payer to audit claims per Medicaid agreement (INSERT NUMBER)?,Timeline Medicaid Payer Claim Audit ,R156,,,INACTIVE,No,Medicaid Agreement ,Key Dates,Required Only If Available ,PAYMENT ACCURACY What is timeline for payer to identify overpayments in paid claims per Medicaid agreement (INSERT NUMBER)?,Timeline Medicaid Payer Overpayment Identification,R164,,,INACTIVE,No,Medicaid Agreement ,Key Dates,Required Only If Available ,PAYMENT ACCURACY What is timeline for payer to give notice of policy changes to provider per Medicaid agreement (INSERT NUMBER)?,Timeline Medicaid Payer Policy Change Notice ,R146,,,INACTIVE,No,Medicaid Agreement ,Key Dates,Required Only If Available ,"PAYMENT ACCURACY @@ -610,7 +610,7 @@ INTELLIGENT EDITS " INTELLIGENT EDITS " "If the contract includes a carve out for Trauma, describe how these codes are reimbursed",Trauma Reimbursement Methodology,TRAUMA_CARVEOUT_REIMBURSEMENT_METHODOLOGY,VARCHAR,G,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " -"Is the contract related to a Professional, Institutional or Ancillary provider?",Type of Contract,CONTRACT_TYPE,VARCHAR,A,ACTIVE,Yes,AArete Derived from Title or Preamble ,LOB/Provider Type Specific,Always Required ,UNIQUE KEY +"Is the contract related to a Professional, Institutional or Ancillary provider? Only respond with ""Professional,"" ""Institutional,"", or ""Ancillary.""",Type of Contract,CONTRACT_TYPE,VARCHAR,A,ACTIVE,Yes,AArete Derived from Title or Preamble ,LOB/Provider Type Specific,Always Required ,UNIQUE KEY "If the contract is based on type of provider, identify each provider type for each line of business. Often the provider type will be found next to the word ""services.""",Type of Provider,PROV_TYPE,VARCHAR,A,ACTIVE,Yes,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",LOB/Provider Type Specific,Always Required ,UNIQUE KEY "If the contract includes a carve out for Unlisted codes, describe how these codes are reimbursed",Unlisted Code Reimbursement Methodology ,UNLISTED_CARVEOUT_REIMBURSEMENT_METHODOLOGY,VARCHAR,G,ACTIVE,No,"From LOB Specific Exhibit, Attachment, Schedule or Amendment, Addendum, Rider",Carve Outs,Required Only If Available ,"PAYMENT ACCURACY INTELLIGENT EDITS " diff --git a/streamlit/interface_0.py b/streamlit/interface_0.py new file mode 100644 index 0000000..d76b110 --- /dev/null +++ b/streamlit/interface_0.py @@ -0,0 +1,155 @@ +import streamlit as st +from streamlit_extras.add_vertical_space import add_vertical_space +import os +import streamlit as st +import pandas as pd +from io import StringIO +from datetime import datetime +import boto3 +import util +import requests + +doczy_pipeline = 'https://8ir4vi1ri4.execute-api.us-east-2.amazonaws.com/dev/' + +REDIRECT_URI = 'https://doczy.aarete.com:8500' +user_list = ['maamseek@aarete.com', 'smahdavian@aarete.com', 'ahinge@aarete.com', 'akadam@aarete.com', 'pkatariya@aarete.com' +, 'piragavarapu@aarete.com', 'umistry@aarete.com', 'ahutchison@aarete.com', 'bgrunst@aarete.com', 'ddimeglio@aarete.com' +, 'vnair@aarete.com'] +st.set_page_config(layout = "wide") +# # Sidebar contents +# with st.sidebar: +# st.title("Doczy.AI ™") +# st.markdown( +# """ +# ## About +# This app extracts data from contracts + +# """ +# ) +# add_vertical_space(15) +# # st.write("Doczy") + +try: + # util.setup_page(REDIRECT_URI) + _,c1= st.columns([5,1]) + c1.write(f"User: **{st.session_state.user_info['displayName']}**") + user_mail = st.session_state.user_info['mail'] +except: + user_mail = 'maamseek@aarete.com' + +if user_mail in user_list: + + s3_client = boto3.client('s3', + region_name="us-east-1", + ) + objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract' + , Prefix="batches/batch_1/", Delimiter='/') + + folder_list = [] + for prefix in objects['CommonPrefixes']: + folder_list.append(prefix['Prefix'][:-1].split('/')[-1]) + + # # to be deleted later + # folder_list = ['Delaware First Health, Inc.', 'Community Health Choice, Inc','CareSource Network Partners LLC', + # 'HealthNet of Cali', 'Oklahoma Complete Health, Inc', 'HealthFirst', 'Molina Healthcare of TX', 'AvMed', 'Arizona Care1st', + # 'WellCare New Jersey'] + + client_row = st.columns([0.1, 0.8]) + with client_row[0]: + st.write("**Client Name**") + with client_row[1]: + client = st.selectbox('Client Name',(folder_list), label_visibility = "collapsed") + + # # to be deleted later + # client = 'textract-receiver-processed-file' + + folder_objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract' + , Prefix="batches/batch_1/"+client+"/", Delimiter='/') + + folder_list_2 = [] + for prefix in folder_objects['CommonPrefixes']: + folder_list_2.append(prefix['Prefix'][:-1].split('/')[-1]) + + path_row = st.columns([0.1, 0.8]) + with path_row[0]: + st.write("**Path to folder**") + with path_row[1]: + Directory = st.selectbox('**Path to folder**', folder_list_2, label_visibility = "collapsed") + + add_vertical_space(1) + + df = pd.DataFrame(columns=['Contract Name','Unique Key','Pricing Before Carveouts' + , 'Contract Related', 'Provider', 'Timeline', 'Carveout Indicator', 'Carveout Methodology']) + file_list = [] + file_objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract' + , Prefix="batches/batch_1/"+client+"/"+Directory+"/", Delimiter='/') + + if st.button("Create Batch"): + for obj in file_objects.get('Contents',[]): + if not obj['Key'].endswith('/'): + file_list.append(obj['Key'].split('/')[-1]) + + df['Contract Name'] = file_list + + add_vertical_space(1) + + @st.cache_data + def convert_df(df): + return df.to_csv(index=False).encode('utf-8') + + csv = convert_df(df) + + df = df.reset_index() # make sure indexes pair with number of rows + + # contract_list = [] + # for index, row in df.iterrows(): + # group_list = [] + # if row['Unique Key']: + # group_list.append('Unique Key') + # if row['Pricing Before Carveouts']: + # group_list.append('Pricing Before Carveouts') + # if row['Contract Related']: + # group_list.append('Contract Related') + # if row['Provider']: + # group_list.append('Provider') + # if row['Timeline']: + # group_list.append('Timeline') + # if row['Carveout Indicator']: + # group_list.append('Carveout Indicator') + # if row['Carveout Methodology']: + # group_list.append('Carveout Methodology') + # entry_dict = { + # "contract_name": row['Contract Name'], + # "groups": group_list, + # "contract_source_path": "batches/batch_1/"+client+"/"+row['Contract Name'] + # } + # contract_list.append(entry_dict) + contract_list = list(df['Contract Name']) + + myobj = { + "s3_bucket": 'doczy-dev-infra-textract', + "batch_id": "1", + "client_name": client, + "username": user_mail, + "contract_list": contract_list + } + + buttons = st.columns([0.8, 0.2]) + with buttons[0]: + st.download_button("Download Table", csv, "file.csv", "text/csv", key='download-csv') + with buttons[1]: + if st.button("Upload to DB"): + response = requests.post(doczy_pipeline, json = myobj) + if response.status_code >= 200 and response.status_code < 300: + st.write("Success") + else: + st.write("Failed") + # st.write(response.text) + + + +else: + st.write("Access Denied") + + + diff --git a/streamlit/interface_1.py b/streamlit/interface_1.py index 25dfaf5..a8961e2 100644 --- a/streamlit/interface_1.py +++ b/streamlit/interface_1.py @@ -29,7 +29,7 @@ st.set_page_config(layout = "wide") # # st.write("Doczy") try: - util.setup_page(REDIRECT_URI) + # util.setup_page(REDIRECT_URI) _,c1= st.columns([5,1]) c1.write(f"User: **{st.session_state.user_info['displayName']}**") user_mail = st.session_state.user_info['mail'] @@ -95,7 +95,7 @@ if user_mail in user_list: add_vertical_space(1) - df = pd.DataFrame(columns=['Request ID','Contract Name','Unique Key','Pricing Before Carveouts' + df = pd.DataFrame(columns=['Contract Name','Unique Key','Pricing Before Carveouts' , 'Contract Related', 'Provider', 'Timeline', 'Carveout Indicator', 'Carveout Methodology']) file_list = [] file_objects = s3_client.list_objects_v2(Bucket='doczy-dev-infra-textract' @@ -107,7 +107,7 @@ if user_mail in user_list: file_list.append(obj['Key'].split('/')[-1]) df['Contract Name'] = file_list - df['Request ID'] = range(len(file_list)) + # df['Request ID'] = range(len(file_list)) # df['Contract ID'] = file_list df['Unique Key'] = a df['Pricing Before Carveouts'] = b diff --git a/streamlit/interface_3.py b/streamlit/interface_3.py index 2eb5775..120ec5b 100644 --- a/streamlit/interface_3.py +++ b/streamlit/interface_3.py @@ -44,7 +44,7 @@ with st.sidebar: # st.write("Doczy") try: - util.setup_page(REDIRECT_URI) + # util.setup_page(REDIRECT_URI) _,c1= st.columns([4,1]) c1.write(f"User: **{st.session_state.user_info['displayName']}**") user_mail = st.session_state.user_info['mail'] @@ -245,9 +245,9 @@ if user_mail in user_list: sequence_input = '' if st.button("Back to default"): prompt = sequence_input - st.button("Save Prompt") + # st.button("Save Prompt") with prompt_row[0]: - prompt = st.text_area("**Prompt**", sequence_input, height = 150, label_visibility = "collapsed") + prompt = st.text_area("**Prompt**", sequence_input, height = 100, label_visibility = "collapsed") # column_name = fields.loc[fields['Field Name'] == field, 'SF_DB_COL_NAME'].iloc[0] @@ -503,7 +503,7 @@ if user_mail in user_list: df = df[~df['Contract ID'].isnull()] if 'Original Page Number' not in df.columns: df['Original Page Number'] = ' ' - df = df[['Contract Name','Contract ID', 'Field Name', 'Actual Value Stored','New Extracted value','Confidence Level' + df = df[['Contract Name','Contract ID', 'SF_DB_COL_NAME', 'Actual Value Stored','New Extracted value','Confidence Level' ,'Snippet','Original Page Number', 'New Page Number', 'Revised Prompt', 'Result']] try: @@ -524,25 +524,26 @@ if user_mail in user_list: if st.button("Test Configuration"): df, history, attempt, raw_response_text = run_llm(attempt, bucket, contract_list, llm_selected, field, field_values, history) - df = df[['Contract Name','Contract ID', 'Actual Value Stored','New Extracted value','Confidence Level' + df_1 = df[['Contract Name','Contract ID', 'Actual Value Stored','New Extracted value','Confidence Level' ,'Snippet','Original Page Number', 'New Page Number', 'Revised Prompt', 'Result']] # df.to_csv('results.csv', index=False) # history.to_csv('history.csv', index=False) # s3_client.upload_file('results.csv', bucket, key) csv_buf = StringIO() - df.to_csv(csv_buf, header=True, index=False) + df_1.to_csv(csv_buf, header=True, index=False) csv_buf.seek(0) s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/results.csv') csv_buf = StringIO() history.to_csv(csv_buf, header=True, index=False) csv_buf.seek(0) s3_client.put_object(Bucket='doczy-dev-infra-raw-data-ingestion', Body=csv_buf.getvalue(), Key='training_interface/history.csv') + df = df[['Contract Name','Contract ID', 'SF_DB_COL_NAME', 'Actual Value Stored','New Extracted value','Confidence Level' + ,'Snippet', 'New Page Number', 'Revised Prompt', 'Result']] # df = pd.read_csv('results.csv') # df['Result'] = df['Result'].astype('str') # history = pd.read_csv('history.csv') - df = df[['Contract Name','Contract ID', 'Actual Value Stored','New Extracted value','Confidence Level' - ,'Snippet', 'New Page Number', 'Revised Prompt', 'Result']] + st.dataframe(df) st.dataframe(history)