File size: 3,133 Bytes
5372c12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import gradio as gr

def display_discharge_form(
    patient_first, patient_last, patient_middle, dob, age, sex, address, city, state, zip_code,
    doctor_first, doctor_last, doctor_middle, hospital, doctor_address, doctor_city, doctor_state, doctor_zip,
    admission_date, referral_source, admission_method, discharge_date, discharge_reason, death_date,
    diagnosis, procedures, medications, preparer_name, job_title, signature
):
    
    form = f"""
    **Patient Details:**
    - **Name:** {patient_first} {patient_middle} {patient_last}
    - **Date of Birth:** {dob}, **Age:** {age}, **Sex:** {sex}
    - **Address:** {address}, {city}, {state} {zip_code}

    **Primary Healthcare Professional Details:**
    - **Name:** {doctor_first} {doctor_middle} {doctor_last}
    - **Hospital/Clinic:** {hospital}
    - **Address:** {doctor_address}, {doctor_city}, {doctor_state} {doctor_zip}
    
    **Admission and Discharge Details:**
    - **Date of Admission:** {admission_date}
    - **Source of Referral:** {referral_source}
    - **Method of Admission:** {admission_method}
    - **Date of Discharge:** {discharge_date}
    - **Discharge Reason:** {discharge_reason}
    - **Date of Death:** {death_date if discharge_reason == 'Patient Died' else 'N/A'}

    **Diagnosis & Procedures:**
    - **Diagnosis:** {diagnosis}
    - **Operations & Procedures:** {procedures}

    **Medication Details:**
    - **Medication on Discharge:** {medications}

    **Prepared By:**
    - **Name:** {preparer_name}, **Job Title:** {job_title}
    - **Signature:** {signature}
    """
    return form

discharge_interface = gr.Interface(
    fn=display_discharge_form,
    inputs=[
        gr.Textbox(label="Patient First Name"), gr.Textbox(label="Patient Last Name"), gr.Textbox(label="Patient Middle Initial"),
        gr.Textbox(label="Date of Birth"), gr.Textbox(label="Age"), gr.Textbox(label="Sex"),
        gr.Textbox(label="Address"), gr.Textbox(label="City"), gr.Textbox(label="State"), gr.Textbox(label="Zip Code"),
        gr.Textbox(label="Doctor First Name"), gr.Textbox(label="Doctor Last Name"), gr.Textbox(label="Doctor Middle Initial"),
        gr.Textbox(label="Hospital/Clinic Name"), gr.Textbox(label="Doctor Address"),
        gr.Textbox(label="Doctor City"), gr.Textbox(label="Doctor State"), gr.Textbox(label="Doctor Zip Code"),
        gr.Textbox(label="Date of Admission"), gr.Textbox(label="Source of Referral"), gr.Textbox(label="Method of Admission"),
        gr.Textbox(label="Date of Discharge"), gr.Radio(["Treated", "Transferred", "Discharge Against Advice", "Patient Died"], label="Discharge Reason"),
        gr.Textbox(label="Date of Death (if applicable)"),
        gr.Textbox(label="Diagnosis"), gr.Textbox(label="Operations & Procedures"),
        gr.Textbox(label="Medication on Discharge"),
        gr.Textbox(label="Prepared By (Name)"), gr.Textbox(label="Job Title"), gr.Textbox(label="Signature"),
    ],
    outputs=gr.Markdown(),
    title="Patient Discharge Form",
    description="Fill in the required fields to generate a complete patient discharge summary."
)

discharge_interface.launch()