Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import pandas as pd | |
| import re | |
| def evaluate_pa(drug, diagnosis, notes): | |
| text = (drug + " " + diagnosis + " " + notes).lower() | |
| # Simple rule-based checks | |
| approved_keywords = ["medically necessary", "failed therapy", "step therapy completed"] | |
| denial_keywords = ["cosmetic", "experimental", "not indicated"] | |
| needinfo_keywords = ["missing", "need labs", "need documentation"] | |
| # Decision logic | |
| if any(k in text for k in approved_keywords): | |
| decision = "Approved" | |
| reason = "Meets medical necessity criteria." | |
| elif any(k in text for k in denial_keywords): | |
| decision = "Denied" | |
| reason = "Does not meet required clinical criteria." | |
| elif any(k in text for k in needinfo_keywords): | |
| decision = "Needs More Information" | |
| reason = "Additional documentation is required." | |
| else: | |
| decision = "Needs Manual Review" | |
| reason = "Criteria unclear based on provided information." | |
| df = pd.DataFrame({ | |
| "Drug": [drug], | |
| "Diagnosis": [diagnosis], | |
| "Decision": [decision], | |
| "Reason": [reason] | |
| }) | |
| return df, f"### Decision: **{decision}**\nReason: {reason}" | |
| # --- Interface --- | |
| with gr.Blocks(title="Prior Authorization Decision Helper") as demo: | |
| gr.Markdown("## 📝 Prior Authorization Helper") | |
| gr.Markdown("Enter drug, diagnosis, and clinical notes to generate a mock PA decision.") | |
| with gr.Row(): | |
| drug = gr.Textbox(label="Drug Name", placeholder="Example: Ozempic") | |
| diagnosis = gr.Textbox(label="Diagnosis", placeholder="Example: Type 2 Diabetes") | |
| notes = gr.Textbox( | |
| label="Clinical Notes", | |
| placeholder="Example: Patient completed step therapy and met medically necessary criteria.", | |
| lines=6 | |
| ) | |
| submit = gr.Button("Evaluate PA Request") | |
| output_table = gr.Dataframe(label="PA Evaluation Summary") | |
| output_text = gr.Markdown(label="Decision Result") | |
| submit.click(evaluate_pa, [drug, diagnosis, notes], [output_table, output_text]) | |
| demo.launch(share=True) |