Spaces:
Runtime error
Runtime error
File size: 17,658 Bytes
feaf85d 0536385 feaf85d 0536385 feaf85d 0536385 feaf85d 00937a8 feaf85d 8573c04 feaf85d |
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
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")
def generate_diagnosis_letters_ui():
st.title("π¬ Diagnosis Letters")
# Search-style text box
search_query = st.text_input("Search Diagnosis 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 = "The results of Mr. Thompsonβs chest x-ray reveal Pneumonia\n" \
"The blood test results indicate that Mrs. Jones has Type 2 diabetes"
middle_default = "Mr. Thompson has a bacterial infection that requires antibiotic treatment\n" \
"Mrs. Jones has a lifelong condition that requires medication, dietary adjustments, and lifestyle changes."
last_default = "Recommend follow-up visits for monitoring and periodic testing\n" \
"Refer patients to the relevant healthcare specialist"
first_text = st.text_area("First: State the diagnosis", value=first_default, max_chars=None, height=None)
middle_text = st.text_area("Middle: Explain the diagnosis details", value=middle_default, max_chars=None, height=None)
last_text = st.text_area("Last: Provide any necessary follow-up recommendations", 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")
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
|