Spaces:
Sleeping
Sleeping
import pandas as pd | |
import streamlit as st | |
from utils_casemaker import CaseMaker, format_casemaker_data | |
st.title("Juni Health Patient Casemaker") | |
casemaker = CaseMaker("terms.json") | |
uploaded_file = st.file_uploader("Choose a file") | |
if uploaded_file is not None: | |
# Can be used wherever a "file-like" object is accepted: | |
df = pd.read_csv(uploaded_file) | |
reports = format_casemaker_data( | |
df=df, | |
patient_id_column="patient_id", | |
date_column="report_id", | |
text_column="text", | |
) | |
patient_options = { | |
f"Patient {patient_id} ({len(reports[patient_id])} reports)": patient_id | |
for patient_id in reports.keys() | |
} | |
selected_patient_string = st.radio( | |
"Select a Patient ID", | |
list(patient_options.keys()), | |
key = "patient_select_button" | |
) | |
if st.button("Generate Case", key = "task_begin_button"): | |
selected_patient_id = patient_options[selected_patient_string] | |
summary_by_organ = casemaker.parse_records(reports[selected_patient_id]) | |
summary_by_organ = casemaker.format_reports(summary_by_organ) | |
# Display the report | |
col1, col2 = st.columns(2) | |
with col1: | |
st.subheader("Original") | |
for report in reports[selected_patient_id]: | |
st.write(f"**Report {report.date}**") | |
st.write(report.text) | |
with col2: | |
st.subheader("With Casemaker") | |
for chosen_organ in summary_by_organ.keys(): | |
if summary_by_organ[chosen_organ]: | |
st.header(chosen_organ.capitalize()) | |
st.write(summary_by_organ[chosen_organ]) |