afb6d5185d
Feature/lesser table caching refactor hybrid * chore: Remove unused duplicate main.py from shared pipeline * fix: Correct crosswalk paths in aarete_derived.py * chore: Remove unused documentation files from fieldExtraction * docs: Add documentation files to documentation folder * docs: Update README with uv setup, expanded project structure, and branching conventions * docs: Add uv installation steps with Ubuntu/WSL emphasis * Enable prompt caching for all remaining LLM calls - Add _INSTRUCTION() functions for: EXHIBIT_HEADER, EXHIBIT_LINKAGE, EXHIBIT_TITLE_MATCH, DATE_FIX, DERIVED_TERM_DATE, CHECK_PROVIDER_NAME_MATCH, SPECIAL_CASE_ASSIGNMENT - Update all invoke_claude() calls in saas and clover pipelines to use cache=True with corresponding _INSTRUCTION() functions - Add new instructions to get_cacheable_instructions() for cache warming - Update tests for new instruction functions Functions now using caching: - prompt_exhibit_level - prompt_exhibit_lesser (EXHIBIT_LEVEL_LESSER_OF) - prompt_fee_schedule_breakout - prompt_grouper_breakout - prompt_special_case_assignment - prompt_exhibit_linkage - prompt_exhibit_header - prompt_smart_chunked (ONE_TO_ONE templates) - prompt_date_fix - prompt_derived_term_date - prompt_exhibit_title_match - provider_name_match_check 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Reorder * feat: Add bcbs_promise client pipeline with OFFSET_TERM extraction - Add new bcbs_promise client with HSC-based OFFSET_TERM field extraction - Extract full paragraph text of offset/recoupment provisions from contracts - Derive OFFSET_INDICATOR (Y/N) from OFFSET_TERM presence - Fix reorder_columns to preserve extra columns not in COLUMN_ORDER - Update QC/QA output path to outputs/qc_qa/ * fix: Update dev deps and test assertions for QC/QA output path - Add pytest/pytest-mock to dev dependencies for mypy type checking - Update test assertions to expect outputs/qc_qa instead of qa_qc_output * style: Apply black formatting to prompt_templates.py * Merge main, move scripts * Archive some scripts * update py version * remove .py version file * Remove ASCII characters * Restore testbed code * restore tracking * Update testbed metrics * Enable prompt caching for CODE_LAST_CHECK, FILL_BILL_TYPE, DUAL_LOB_CHECK, and GROUPER_BREAKOUT - Add CODE_LAST_CHECK_INSTRUCTION() for service specificity classification - Add FILL_BILL_TYPE_INSTRUCTION() for bill type code determination - Add DUAL_LOB_CHECK_INSTRUCTION() for Medicare/Medicaid classification - Update code_funcs.py to use caching for CODE_LAST_CHECK, FILL_BILL_TYPE, GROUPER_BREAKOUT - Update postprocessing_funcs.py to use caching for DUAL_LOB_CHECK - Add new instructions to get_cacheable_instructions() for cache warming - Add unit tests for new instruction functions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Fix postprocessing_funcs to remove invalid columns * Merge branch 'main' into feature/lesser-table-caching-refactor-hybrid * Revert prompt caching changes from aed1b73c * update formatting * Update imports Approved-by: Sha Brown Approved-by: Praneel Panchigar
178 lines
5.6 KiB
Python
178 lines
5.6 KiB
Python
import os
|
|
import streamlit as st
|
|
from streamlit_extras.add_vertical_space import add_vertical_space
|
|
import pandas as pd
|
|
from datetime import datetime
|
|
import time
|
|
import constants
|
|
|
|
if "uploading" not in st.session_state:
|
|
st.session_state.uploading = False
|
|
if "upload_key" not in st.session_state:
|
|
st.session_state.upload_key = 0
|
|
if "file_list" not in st.session_state:
|
|
st.session_state.file_list = []
|
|
if "show_batchID" not in st.session_state:
|
|
st.session_state.show_batchID = False
|
|
if "numFiles" not in st.session_state:
|
|
st.session_state.numFiles = 0
|
|
|
|
st.set_page_config(layout="wide")
|
|
# # # Sidebar contents
|
|
with st.sidebar:
|
|
st.title("Doczy.AI ™")
|
|
st.markdown(
|
|
"""
|
|
## About
|
|
Doczy.ai™ is an advanced AI-powered platform designed to streamline the management of healthcare contracts and optimize claims processing. Using Optical Character Recognition (OCR), Natural Language Processing (NLP) and Generative AI, Doczy.ai™ transforms unstructured, complex contract documents into structured data, enabling accurate extraction of key terms such as contract terms, reimbursement rates and payment methodologies. By eliminating manual errors, reducing overpayments, and ensuring contract configurations are correct, Doczy.ai™ helps healthcare payers save time and money while improving overall operational efficiency.
|
|
|
|
"""
|
|
)
|
|
add_vertical_space(15)
|
|
# st.write("Doczy")
|
|
|
|
# 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": "piragavarapu@aarete.com",
|
|
"displayName": "Priya Iragavarapu",
|
|
}
|
|
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()
|
|
|
|
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", (constants.client_list), label_visibility="collapsed", index=None
|
|
)
|
|
|
|
file_row = st.columns([0.1, 0.8])
|
|
with file_row[0]:
|
|
st.write("**Upload Files**")
|
|
with file_row[1]:
|
|
file_list = st.file_uploader(
|
|
"Upload",
|
|
type=["docx", "tiff", "pdf"],
|
|
accept_multiple_files=True,
|
|
label_visibility="collapsed",
|
|
help="Only PDF, TIFF and DOCX file formats are supported.",
|
|
disabled=st.session_state.uploading,
|
|
key=st.session_state.upload_key,
|
|
)
|
|
|
|
add_vertical_space(2)
|
|
df = pd.DataFrame(columns=["Contract Name"])
|
|
df["Contract Name"] = file_list
|
|
file_names: list[str] = []
|
|
buttons = st.columns([0.4, 0.4, 0.2])
|
|
|
|
|
|
def set_uploading_state():
|
|
if not client == None and not len(file_list) == 0:
|
|
st.session_state.file_list = file_list
|
|
st.session_state.upload_key += 1
|
|
st.session_state.uploading = True
|
|
|
|
|
|
def save_uploaded_files(uploaded_files, save_path):
|
|
try:
|
|
if not os.path.exists(save_path):
|
|
os.makedirs(save_path)
|
|
for uploaded_file in uploaded_files:
|
|
with open(os.path.join(save_path, uploaded_file.name), "wb") as f:
|
|
f.write(uploaded_file.getbuffer())
|
|
return True
|
|
except Exception as e:
|
|
st.error(f"Error saving files: {e}")
|
|
return False
|
|
|
|
|
|
with buttons[1]:
|
|
if st.button("Create Batch", on_click=set_uploading_state):
|
|
file_list = st.session_state.file_list
|
|
if client == None:
|
|
st.error("No Client Name Selected.")
|
|
elif len(file_list) == 0:
|
|
st.error("No Files Selected.")
|
|
else:
|
|
with st.spinner("Running..."):
|
|
time.sleep(2)
|
|
st.session_state.numFiles = len(file_list)
|
|
st.session_state.uploading = False
|
|
st.session_state.show_batchID = True
|
|
st.rerun()
|
|
|
|
if st.session_state.show_batchID:
|
|
st.write(f"{st.session_state.numFiles} files uploaded successfully!")
|
|
# st.session_state.file_list = []
|
|
|
|
add_vertical_space(1)
|
|
|
|
df = pd.DataFrame(columns=["Contract Name", "Run Flag"])
|
|
|
|
df["Contract Name"] = [file.name for file in st.session_state.file_list]
|
|
# df['Contract Name'] = st.session_state.file_list
|
|
df["Run Flag"] = True
|
|
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
print(f"DEBUGGING: PWD= {dir_path}")
|
|
df.to_csv("temp1.csv", index=False)
|
|
|
|
add_vertical_space(1)
|
|
df2 = pd.read_csv("temp1.csv")
|
|
edited_df = st.data_editor(df2)
|
|
|
|
edited_df["REQUEST_USER"] = user_mail
|
|
edited_df["LATEST_FLAG BOOLEAN"] = True
|
|
edited_df["PIPELINE_KICKOFF_DATETIME"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
edited_df["REQUEST_DATETIME"] = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
@st.cache_data
|
|
def convert_df(df):
|
|
return df.to_csv(index=False).encode("utf-8")
|
|
|
|
|
|
csv = convert_df(edited_df)
|
|
|
|
additional_info = pd.DataFrame(
|
|
columns=["CLIENT_NAME", "REQUEST_USERNAME", "REQUEST_DATETIME"]
|
|
)
|
|
additional_info.loc[0] = [
|
|
client,
|
|
st.session_state.user_info["mail"],
|
|
datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
|
]
|
|
st.write(additional_info)
|
|
|
|
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("Run Doczy.AI Pipeline"):
|
|
with st.spinner("Running..."):
|
|
time.sleep(2)
|
|
st.write("Success!")
|
|
st.write("Current processing time for Contract Terms: 1 min")
|
|
st.write("Current processing time for Reimbursement: 10 mins")
|