File size: 1,340 Bytes
2d00e5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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)

        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])