| import gradio as gr | |
| def display_form( | |
| first_name, last_name, middle_initial, dob, age, sex, address, city, state, zip_code, | |
| doctor_first_name, doctor_last_name, doctor_middle_initial, hospital_name, doctor_address, | |
| doctor_city, doctor_state, doctor_zip, | |
| admission_date, referral_source, admission_method, discharge_date, discharge_reason, date_of_death, | |
| diagnosis, procedures, medications, preparer_name, preparer_job_title | |
| ): | |
| form = f""" | |
| **Patient Discharge Form** | |
| **Patient Details:** | |
| - Name: {first_name} {middle_initial} {last_name} | |
| - Date of Birth: {dob}, Age: {age}, Sex: {sex} | |
| - Address: {address}, {city}, {state}, {zip_code} | |
| **Primary Healthcare Professional Details:** | |
| - Name: {doctor_first_name} {doctor_middle_initial} {doctor_last_name} | |
| - Hospital/Clinic: {hospital_name} | |
| - 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 (if applicable): {date_of_death} | |
| **Diagnosis & Procedures:** | |
| - Diagnosis: {diagnosis} | |
| - Procedures: {procedures} | |
| **Medication Details:** | |
| - Medications on Discharge: {medications} | |
| **Prepared By:** | |
| - Name: {preparer_name}, Job Title: {preparer_job_title} | |
| """ | |
| return form | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Patient Discharge Form") | |
| with gr.Row(): | |
| first_name = gr.Textbox(label="First Name") | |
| last_name = gr.Textbox(label="Last Name") | |
| middle_initial = gr.Textbox(label="Middle Initial") | |
| with gr.Row(): | |
| dob = gr.Textbox(label="Date of Birth") | |
| age = gr.Textbox(label="Age") | |
| sex = gr.Textbox(label="Sex") | |
| address = gr.Textbox(label="Address") | |
| with gr.Row(): | |
| city = gr.Textbox(label="City") | |
| state = gr.Textbox(label="State") | |
| zip_code = gr.Textbox(label="Zip Code") | |
| gr.Markdown("## Primary Healthcare Professional Details") | |
| with gr.Row(): | |
| doctor_first_name = gr.Textbox(label="Doctor's First Name") | |
| doctor_last_name = gr.Textbox(label="Doctor's Last Name") | |
| doctor_middle_initial = gr.Textbox(label="Middle Initial") | |
| hospital_name = gr.Textbox(label="Hospital/Clinic Name") | |
| doctor_address = gr.Textbox(label="Address") | |
| with gr.Row(): | |
| doctor_city = gr.Textbox(label="City") | |
| doctor_state = gr.Textbox(label="State") | |
| doctor_zip = gr.Textbox(label="Zip Code") | |
| gr.Markdown("## Admission and Discharge Details") | |
| with gr.Row(): | |
| admission_date = gr.Textbox(label="Date of Admission") | |
| referral_source = gr.Textbox(label="Source of Referral") | |
| admission_method = gr.Textbox(label="Method of Admission") | |
| with gr.Row(): | |
| discharge_date = gr.Textbox(label="Date of Discharge") | |
| discharge_reason = gr.Radio(["Treated", "Transferred", "Discharge Against Advice", "Patient Died"], label="Discharge Reason") | |
| date_of_death = gr.Textbox(label="Date of Death (if applicable)") | |
| gr.Markdown("## Diagnosis & Procedures") | |
| diagnosis = gr.Textbox(label="Diagnosis") | |
| procedures = gr.Textbox(label="Operation & Procedures") | |
| gr.Markdown("## Medication Details") | |
| medications = gr.Textbox(label="Medication on Discharge") | |
| gr.Markdown("## Prepared By") | |
| with gr.Row(): | |
| preparer_name = gr.Textbox(label="Name") | |
| preparer_job_title = gr.Textbox(label="Job Title") | |
| submit = gr.Button("Generate Form") | |
| output = gr.Markdown() | |
| submit.click( | |
| display_form, | |
| inputs=[ | |
| first_name, last_name, middle_initial, dob, age, sex, address, city, state, zip_code, | |
| doctor_first_name, doctor_last_name, doctor_middle_initial, hospital_name, doctor_address, | |
| doctor_city, doctor_state, doctor_zip, | |
| admission_date, referral_source, admission_method, discharge_date, discharge_reason, date_of_death, | |
| diagnosis, procedures, medications, preparer_name, preparer_job_title | |
| ], | |
| outputs=output | |
| ) | |
| demo.launch() | |