Spaces:
Runtime error
Runtime error
File size: 20,808 Bytes
feaf85d a2685eb feaf85d 0f3ec76 feaf85d f8fb8b6 feaf85d a2685eb f8fb8b6 a2685eb feaf85d f8fb8b6 feaf85d f8fb8b6 feaf85d f8fb8b6 feaf85d f8fb8b6 a2685eb feaf85d 0536385 feaf85d 0536385 feaf85d 0536385 feaf85d 5c117ac feaf85d 5c117ac feaf85d aab0b0a feaf85d aab0b0a feaf85d aab0b0a feaf85d aab0b0a feaf85d a183ea7 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 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
import streamlit as st
# Set the page configuration to use the full width of the screen
st.set_page_config(layout="wide")
# 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.set_page_config(layout="wide") # Use the full width of the screen
st.title("π€ Referral Letters")
# Create columns for layout
col1, col2 = st.columns([3, 1]) # Adjust the ratio of column widths as needed
# Search-style text box
with col2:
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"
with col2:
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
with col2:
username = st.text_input("π€ Username")
# Run the Streamlit UI function
# generate_referral_letters_ui()
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_medical_clearance_letters_ui():
st.title("πββοΈ Medical Clearance Letters")
# Search-style text box
search_query = st.text_input("Search Medical Clearance 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 = "Allow Mrs. Anderson to safely participate in a marathon\n" \
"Clear Mr. White to begin strength training"
middle_default = "The patient has been tested and has no chronic medical conditions or injuries\n" \
"The patientβs prior conditions are monitored, and it is advised to begin any physical activity or routine"
last_default = "Encourage gradual progression and cautious approach to intense activity\n" \
"List exercises that should be avoided, for instance, weightlifting for an individual with a heart condition"
first_text = st.text_area("First: State clearance conditions", value=first_default, max_chars=None, height=None)
middle_text = st.text_area("Middle: Explain clearance Details", value=middle_default, max_chars=None, height=None)
last_text = st.text_area("Last: Provide guidance on physical activity", 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_disability_support_letters_ui():
st.title("βΏ Disability Support Letters")
# Search-style text box
search_query = st.text_input("Search Disability Support 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 purpose of this letter is to validate Mr. Williamsβ disability so that he can receive disability benefits\n" \
"The purpose of this letter is to document Ms. Radcliffβs disability to request special accommodations at work"
middle_default = "Detail the patientβs physical or cognitive condition and how it affects their daily life\n" \
"Explain the cause of the patientβs condition and duration of symptoms"
last_default = "Outline the assistive equipment or technology necessary for the patient\n" \
"Describe the special consideration or modifications required"
first_text = st.text_area("First: State the purpose of the letter", value=first_default, max_chars=None, height=None)
middle_text = st.text_area("Middle: Explain the patientβs condition", value=middle_default, max_chars=None, height=None)
last_text = st.text_area("Last: List any necessary accommodations", 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()
|