Spaces:
Runtime error
Runtime error
import streamlit as st | |
# Define the letter types and their corresponding definitions and fields | |
letter_types = { | |
"Referral Letters": { | |
"Definition": "Letters asking for more help or treatment", | |
"Fields": ["Patient info", "Referral details"] | |
}, | |
"Medical Certificate Letters": { | |
"Definition": "Letters about a patient's health problem or limits", | |
"Fields": ["Patient info", "Health problem details"] | |
}, | |
"Prescription Letters": { | |
"Definition": "Letters allowing medicine", | |
"Fields": ["Patient info", "Medicine details"] | |
}, | |
"Diagnosis Letters": { | |
"Definition": "Letters explaining a patient's health problem", | |
"Fields": ["Patient info", "Health problem details"] | |
}, | |
"Treatment Plan Letters": { | |
"Definition": "Letters with a plan for getting better", | |
"Fields": ["Patient info", "Treatment details"] | |
}, | |
"Surgery Recommendation Letters": { | |
"Definition": "Letters saying a patient needs surgery", | |
"Fields": ["Patient info", "Surgery details"] | |
}, | |
"Medical Clearance Letters": { | |
"Definition": "Letters saying a patient can do activities", | |
"Fields": ["Patient info", "Activity details"] | |
}, | |
"Follow-up Appointment Letters": { | |
"Definition": "Letters reminding about appointments", | |
"Fields": ["Patient info", "Appointment details"] | |
}, | |
"Disability Support Letters": { | |
"Definition": "Letters about a patient's disability", | |
"Fields": ["Patient info", "Disability details"] | |
}, | |
"Health Education Letters": { | |
"Definition": "Letters teaching about health", | |
"Fields": ["Patient info", "Education topic"] | |
} | |
} | |
# Streamlit UI | |
st.title("AI Letter Generation") | |
# User selects the letter type | |
selected_letter_type = st.selectbox("Select Letter Type", list(letter_types.keys())) | |
# Display the definition and fields for the selected letter type | |
st.write("Definition:", letter_types[selected_letter_type]["Definition"]) | |
st.write("Fields Usually Needed:") | |
for field in letter_types[selected_letter_type]["Fields"]: | |
st.button(field) | |
def generate_referral_letters_ui(): | |
st.title("π€ Referral Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Referral Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "Urgent need for further diagnostic testing for Mrs. Smith, who has persistent stomach issues\n" \ | |
"Request for an audiological assessment for Mr. Johnson, aged 60" | |
middle_default = "The patient has symptoms that suggest a more comprehensive review is required\n" \ | |
"The patientβs issue requires specialized care beyond the scope of the referring physician" | |
last_default = "Patient demographics, Referral details\n" \ | |
"Diagnostic test reports, Medication details" | |
first_text = st.text_area("First: State the request for consultation/treatment", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Explain the reason for referral", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Provide patient info needed for the referred service", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_medical_certificate_letters_ui(): | |
st.title("π Medical Certificate Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Medical Certificate Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "To certify Mr. Brownβs condition and advise on work restrictions\n" \ | |
"To certify Ms. Leeβs health status for her impending travel." | |
middle_default = "Mr. Brown has suffered from a heart attack and is under medication\n" \ | |
"Ms. Lee has a chronic back pain condition that requires special accommodations during her travel" | |
last_default = "No driving should be allowed for 6 months\n" \ | |
"Ms. Lee must have an aisle seat and use cushions for lumbar support" | |
first_text = st.text_area("First: State the reason for certification", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Explain the patientβs medical condition", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Outline any necessary work/travel adjustments", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_prescription_letters_ui(): | |
st.title("π Prescription Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Prescription Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "Request for prescription for Mr. Clarke\n" \ | |
"Prescription authorization for Mrs. Davis" | |
middle_default = "Mr. Clarke requires medication for hypertension - Lisinopril 10mg BD with food\n" \ | |
"Mrs. Davis is required to take two 500mg penicillin V tablets every 6 hours" | |
last_default = "Medication details, allergies and any known side effects" | |
first_text = st.text_area("First: Introduce prescription request", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: List dosage and frequency of medication", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Provide medication details", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
import streamlit as st | |
def generate_prescription_letters_ui(): | |
st.title("π Prescription Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Prescription Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "Request for prescription for Mr. Clarke\n" \ | |
"Prescription authorization for Mrs. Davis" | |
middle_default = "Mr. Clarke requires medication for hypertension - Lisinopril 10mg BD with food\n" \ | |
"Mrs. Davis is required to take two 500mg penicillin V tablets every 6 hours" | |
last_default = "Medication details, allergies and any known side effects" | |
first_text = st.text_area("First: Introduce prescription request", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: List dosage and frequency of medication", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Provide medication details", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_treatment_plan_letters_ui(): | |
st.title("π©Ή Treatment Plan Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Treatment Plan Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "Outline treatment and testing plan for Mr.Smith\n" \ | |
"Suggest handling chronic asthma for Mrs.White" | |
middle_default = "Mr. Smithβs treatment will involve IV medication and chest x-ray\n" \ | |
"Mrs. Whiteβs asthma management plan requires frequent use of recommended inhaler and daily monitoring" | |
last_default = "Recommend follow-up visits for monitoring and periodic testing\n" \ | |
"Provide contact information in case of any emergencies" | |
first_text = st.text_area("First: Introduce treatment plan", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Explain treatment plan specifics", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Detail any follow-up needed", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_surgery_recommendation_letters_ui(): | |
st.title("π₯ Surgery Recommendation Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Surgery Recommendation Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "Recommend endoscopy procedure for Mr.Baker\n" \ | |
"Recommend an angiography for Mrs.Taylor" | |
middle_default = "Mr. Baker needs endoscopy for the diagnosis of GI tract abnormalities\n" \ | |
"Mrs. Taylor needs angiography to locate any arterial blockages" | |
last_default = "Suggest to take extra measures regarding allergies or post-procedural appointments\n" \ | |
"Provide details on necessary pre and post-hospitalization guidance" | |
first_text = st.text_area("First: Introduce surgical procedure", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Explain surgical procedure specifics", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Detail any adjustment needed before/after surgery", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_follow_up_appointment_letters_ui(): | |
st.title("π Follow-up Appointment Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Follow-up Appointment Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "This is a reminder for Mrs. Rodriguezβs appointment on Friday, 17th September, at 11:00 am\n" \ | |
"This letter is to confirm Mr. Johnsonβs appointment on Monday, 20th September, at 1:00 pm" | |
middle_default = "Review the date, time, and location of appointment\n" \ | |
"Detail any necessary preparations for the appointment" | |
last_default = "Provide contact information and phone numbers in case of schedule change or emergency\n" \ | |
"Encourage to reach out if an appointment must be canceled, or if there are any questions or concerns" | |
first_text = st.text_area("First: Remind of the appointment", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Confirm appointment details", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Provide contact details", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
# Run the Streamlit UI function | |
generate_follow_up_appointment_letters_ui() | |
def generate_health_education_letters_ui(): | |
st.title("π Health Education Letters") | |
# Search-style text box | |
search_query = st.text_input("Search Health Education Letters") | |
# Buttons with emojis and boldface text | |
st.button("π **First**") | |
st.button("π **Middle**") | |
st.button("π **Last**") | |
# Text areas with default values based on letter examples | |
first_default = "This letter is to provide Ms. Prince with information on healthy eating habits\n" \ | |
"This letter offers suggestions for stress management to Mr. Martin" | |
middle_default = "Outline the benefits of specific health practices for overall health\n" \ | |
"Detail steps that can be taken to manage specific health conditions properly" | |
last_default = "Provide handouts, online resources, or any relevant materials to supplement the information\n" \ | |
"Encourage patients to schedule follow-up appointments to discuss any questions or concerns." | |
first_text = st.text_area("First: Introduce the health education topic", value=first_default, max_chars=None, height=None) | |
middle_text = st.text_area("Middle: Explain the recommended practices", value=middle_default, max_chars=None, height=None) | |
last_text = st.text_area("Last: Provide Resources", value=last_default, max_chars=None, height=None) | |
# Username field with an emoji | |
username = st.text_input("π€ Username") | |
def generate_letter_grid_ui(): | |
st.title("π₯ Letter Type Selection") | |
# Define the data for the table | |
letter_types = [ | |
("1οΈβ£ Referral Letters", "π€ Letters asking for more help or treatment", "π Patient info, Referral details", generate_referral_letters_ui), | |
("2οΈβ£ Medical Certificate Letters", "πΌ Letters about a patient's health problem or limits", "π Patient info, Health problem details", generate_medical_certificate_letters_ui), | |
("3οΈβ£ Prescription Letters", "π Letters allowing medicine", "π Patient info, Medicine details", generate_prescription_letters_ui), | |
("4οΈβ£ Diagnosis Letters", "π Letters explaining a patient's health problem", "π Patient info, Health problem details", generate_diagnosis_letters_ui), | |
("5οΈβ£ Treatment Plan Letters", "π Letters with a plan for getting better", "π Patient info, Treatment details", generate_treatment_plan_letters_ui), | |
("6οΈβ£ Surgery Recommendation Letters", "π₯ Letters saying a patient needs surgery", "π Patient info, Surgery details", generate_surgery_recommendation_letters_ui), | |
("7οΈβ£ Medical Clearance Letters", "π Letters saying a patient can do activities", "π Patient info, Activity details", generate_medical_clearance_letters_ui), | |
("8οΈβ£ Follow-up Appointment Letters", "π Letters reminding about appointments", "π Patient info, Appointment details", generate_follow_up_appointment_letters_ui), | |
("9οΈβ£ Disability Support Letters", "βΏ Letters about a patient's disability", "π Patient info, Disability details", generate_disability_support_letters_ui), | |
("π Health Education Letters", "π Letters teaching about health", "π Patient info, Education topic", generate_health_education_letters_ui) | |
] | |
# Create the table with buttons | |
for letter_type, definition, fields, letter_function in letter_types: | |
col1, col2, col3, col4 = st.columns(4) | |
with col1: | |
if st.button(letter_type): | |
letter_function() | |
with col2: | |
st.write(definition) | |
with col3: | |
st.write(fields) | |
# Run the Streamlit UI function | |
generate_letter_grid_ui() | |
# Run the Streamlit UI function | |
#generate_referral_letters_ui() | |
# Run the Streamlit UI function | |
#generate_medical_certificate_letters_ui() | |
# Run the Streamlit UI function | |
#generate_prescription_letters_ui() | |
# Run the Streamlit UI function | |
#generate_prescription_letters_ui() | |
# Run the Streamlit UI function | |
#generate_treatment_plan_letters_ui() | |
# Run the Streamlit UI function | |
#generate_surgery_recommendation_letters_ui() | |
# Run the Streamlit UI function | |
#generate_health_education_letters_ui() | |
# Run the Streamlit UI function | |
#generate_letter_grid_ui() | |
# Define the functions for generating the letter UIs (examples) | |
#def generate_referral_letters_ui(): | |
# UI code for referral letters | |
# pass | |
#def generate_medical_certificate_letters_ui(): | |
# UI code for medical certificate letters | |
# pass | |