215 lines
7.6 KiB
Python
215 lines
7.6 KiB
Python
import constants
|
|
import streamlit as st
|
|
from streamlit_extras.add_vertical_space import add_vertical_space
|
|
from streamlit_pdf_viewer import pdf_viewer
|
|
import pandas as pd
|
|
from typing import List
|
|
import os
|
|
import re
|
|
|
|
st.set_page_config(layout="wide")
|
|
# Sidebar contents
|
|
with st.sidebar:
|
|
st.title("Doczy.AI ™")
|
|
st.markdown(
|
|
"""
|
|
## About
|
|
This app extracts data from contracts
|
|
|
|
"""
|
|
)
|
|
|
|
# AARETE LOGO
|
|
x, y, z = st.columns([15, 2, 15])
|
|
with y:
|
|
st.image("aaretelogo.png")
|
|
|
|
hide_img_fs = """
|
|
<style>
|
|
button[title="View fullscreen"]{
|
|
visibility: hidden;}
|
|
</style>
|
|
"""
|
|
st.markdown(hide_img_fs, unsafe_allow_html=True)
|
|
|
|
_, c1 = st.columns([5, 1])
|
|
st.session_state["user_info"] = {
|
|
"mail": constants.current_user["mail"],
|
|
"displayName": constants.current_user["name"],
|
|
}
|
|
try:
|
|
c1.write(f"User: **{st.session_state.user_info['displayName']}**")
|
|
user_mail = st.session_state.user_info["mail"]
|
|
except KeyError as e:
|
|
st.write("Session Expired.")
|
|
st.stop()
|
|
|
|
# try:
|
|
# query = 'select * from "PROMPT_CONFIG"'
|
|
# cur.execute(query)
|
|
# fields = pd.DataFrame.from_records(iter(cur), columns=[x[0] for x in cur.description])
|
|
|
|
# fields.rename(columns={'FIELD_DESC': 'Field Name'}, inplace = True)
|
|
# fields.rename(columns={'PROMPT': 'Interrogation Question?'}, inplace = True)
|
|
# fields.rename(columns={'GROUP_ID': 'PRIORITY'}, inplace = True)
|
|
# fields.rename(columns={'FIELD_NAME': 'SF_DB_COL_NAME'}, inplace = True)
|
|
# fields.rename(columns={'FM_MODEL_ID': 'llm_selected'}, inplace = True)
|
|
# except Exception as e:
|
|
# st.write("Unable to fetch data from Snowflake: ",e)
|
|
# # fields = pd.read_csv('contract_fields.csv', encoding='unicode_escape', skipinitialspace=True)
|
|
# # fields = fields[~fields['SF_COL_NAME'].str.endswith('_PG', na=None)]
|
|
|
|
client_row = st.columns([0.2, 0.7, 0.1])
|
|
with client_row[0]:
|
|
st.write("**Client Name**")
|
|
with client_row[1]:
|
|
client = st.selectbox(
|
|
"Client Name", (constants.client_list), label_visibility="collapsed", index=None
|
|
)
|
|
|
|
if client:
|
|
try:
|
|
folder_path = os.path.join(os.getcwd(), f"temp/{client}")
|
|
files = os.listdir(folder_path)
|
|
for f in files:
|
|
print(f.lower().endswith(".pdf"))
|
|
file_list = [f for f in files if f.lower().endswith(".pdf")]
|
|
except Exception as e:
|
|
print(f"An error occurred: {e}")
|
|
file_list = []
|
|
|
|
contract_list = sorted(file_list)
|
|
file_row = st.columns([0.2, 0.7, 0.1])
|
|
with file_row[0]:
|
|
st.write("**Contract Name**")
|
|
with file_row[1]:
|
|
file_name = st.selectbox(
|
|
"Select a file",
|
|
["All"] + contract_list,
|
|
label_visibility="collapsed",
|
|
index=None,
|
|
)
|
|
|
|
field_row = st.columns([0.2, 0.7, 0.1])
|
|
with field_row[0]:
|
|
st.write("**Field Group**")
|
|
with field_row[1]:
|
|
field_group = st.selectbox(
|
|
"Field Group",
|
|
("Unique Key", "Pricing Before Carveouts", "Contract Related"),
|
|
label_visibility="collapsed",
|
|
index=None,
|
|
)
|
|
|
|
button_cols = st.columns([1, 1, 8])
|
|
with button_cols[0]:
|
|
if st.button("Show PDF"):
|
|
if file_name == None or file_name == "All":
|
|
st.error("Choose one specific file.")
|
|
else:
|
|
with st.sidebar:
|
|
st.markdown(
|
|
"""
|
|
<style>
|
|
section[data-testid="stSidebar"] {
|
|
width: 550px !important; # Set the width to your desired value
|
|
}
|
|
</style>
|
|
""",
|
|
unsafe_allow_html=True,
|
|
)
|
|
pdf_viewer(os.path.join(folder_path, file_name), width=1500)
|
|
with button_cols[1]:
|
|
df2 = pd.read_csv("temp2.csv")
|
|
if st.button("Show Results"):
|
|
try:
|
|
csv_name = re.sub(
|
|
r"\.pdf",
|
|
".csv",
|
|
os.path.join(folder_path, file_name),
|
|
flags=re.IGNORECASE,
|
|
)
|
|
df2 = pd.read_csv(csv_name)
|
|
except:
|
|
df2 = pd.DataFrame(
|
|
columns=[
|
|
"Filename",
|
|
"Agreement_Name (Contract Title)",
|
|
"PAYER NAME",
|
|
"Health Plan State",
|
|
"Affiliate (Y/N)",
|
|
"Credentialing Application Indicator",
|
|
"Term Clause",
|
|
"Evergreen, Fixed or Hard Term",
|
|
"Termination Date",
|
|
"Termination Upon Notice - Days",
|
|
"Termination With Cause - Days",
|
|
"Amend Contract Upon notice Flag (Y/N)",
|
|
"Timeframe to Object - Days",
|
|
"Assignments Clause (Y/N)",
|
|
"Contract Effective Date",
|
|
"IRS #",
|
|
"IRS_Name",
|
|
"NPI (10-digits)",
|
|
"NPI_NAME",
|
|
"PROV_GROUP_TIN_SIGNATORY",
|
|
"PROV_TIN_OTHER",
|
|
"PROV_NPI_OTHER",
|
|
"Notice to Provider Name",
|
|
"Notice to Provider Address",
|
|
"Sequestration Language",
|
|
"Sequestration Reductions, included [Medicare only] (Y/N)",
|
|
"PROV_TIN_OTHER.1",
|
|
"PROV_NPI_OTHER.1",
|
|
"Parent Agreement Code",
|
|
"Pages",
|
|
"page_num",
|
|
"Attachment/Exhibit",
|
|
"Line of Business",
|
|
"Provider Type",
|
|
"Provider Type - Level 2",
|
|
"Service Type",
|
|
"Plan Type",
|
|
"Lesser of Logic Language, included (Y/N)",
|
|
"Lesser of Rate",
|
|
"Reimb. Methodology",
|
|
"Reimb. Methodology_short",
|
|
"If rate is % of Payer or MCR [STANDARD]",
|
|
"If rate is % of Payer or MCR [STANDARD]_Short",
|
|
"If rate is Flat Fee [STANDARD]",
|
|
"Default Term",
|
|
"Default Rate",
|
|
'Inclusion of essential RBRVS "Fee Source" Language (Y/N)',
|
|
"CDM Neutralization Language, included (Y/N)",
|
|
"Chargemaster Protection Language",
|
|
"Exclusions",
|
|
"Not to Exceed",
|
|
"Escalator or COLA (Y/N)",
|
|
"Escalator I, Eff. Date",
|
|
"IP/OP",
|
|
"IP - DSH/IME/UC, included (Y/N)",
|
|
"IP - Stoploss Catastrophic Threshold",
|
|
]
|
|
)
|
|
|
|
df2["Imputed Value"] = ""
|
|
df2.to_csv("temp2.csv", index=False)
|
|
|
|
edited_df = st.data_editor(df2)
|
|
|
|
@st.cache_data
|
|
def convert_df(df):
|
|
return df.to_csv(index=False).encode("utf-8")
|
|
|
|
csv = convert_df(edited_df)
|
|
|
|
buttons = st.columns(3)
|
|
with buttons[0]:
|
|
# st.button("Save All Imputations")
|
|
st.download_button(
|
|
"Download Table", csv, "file.csv", "text/csv", key="download-csv"
|
|
)
|
|
with buttons[1]:
|
|
# st.download_button("Download Table", csv, "file.csv", "text/csv", key='download-csv')
|
|
st.write("")
|