import streamlit as st st.set_page_config(page_title="Male Intake Form") st.title("🏥 Male Intake Questionnaire") # ---------------- General Information ---------------- st.header("General Information") st.text_input("Name", key="text_input_name_1") st.number_input("Age", min_value=0, max_value=120) st.date_input("Date of Birth") st.text_input("Email", key="text_input_email_1") st.text_input("Address", key="text_input_address_1") st.text_input("City", key="text_input_city_1") st.text_input("State", key="text_input_state_1") st.text_input("Zip Code", key="text_input_zip_code_1") # ---------------- Contact Information ---------------- st.header("Contact Information") st.text_input("Phone (Home)", key="text_input_phone_(home)_1") st.text_input("Phone (Cell)", key="text_input_phone_(cell)_1") st.text_input("Phone (Work)", key="text_input_phone_(work)_1") # ---------------- Emergency Contact ---------------- st.header("Emergency Contact") st.text_input("Emergency Contact Name", key="text_input_emergency_contact_name_1") st.text_input("Relationship", key="text_input_relationship_1") st.text_input("Emergency Phone (Home)", key="text_input_emergency_phone_(home)_1") st.text_input("Emergency Phone (Cell)", key="text_input_emergency_phone_(cell)_1") st.text_input("Emergency Phone (Work)", key="text_input_emergency_phone_(work)_1") # ---------------- How Did You Hear ---------------- st.header("How Did You Hear About Our Practice?") st.multiselect("Select all that apply", [ "Clinic website", "IFM website", "Referral from doctor", "Referral from friend/family", "Social media", "Other"]) # ---------------- Current Health Concerns ---------------- st.header("Current Health Concerns") for i in range(1, 4): st.subheader(f"Concern #{i}") st.text_input("Describe Problem", key=f"problem_{i}") st.radio("Severity", ["Mild", "Moderate", "Severe"], key=f"severity_{i}") st.text_input("Prior Treatment/Approach", key=f"treatment_{i}") st.selectbox("Success", ["Excellent", "Good", "Fair"], key=f"success_{i}") # ---------------- Allergies ---------------- st.header("Allergies") for i in range(1, 6): st.text_input(f"Allergy #{i}: Medication/Supplement/Food", key=f"allergy_{i}") st.text_input(f"Reaction for Allergy #{i}", key=f"reaction_{i}") # ---------------- Sleep ---------------- st.header("Lifestyle Review: Sleep") st.number_input("How many hours of sleep do you get each night on average?", min_value=0.0, max_value=24.0) st.multiselect("Do you have any of the following sleep issues?", [ "Problems falling asleep", "Staying asleep", "Insomnia", "Snore", "Not feeling rested"]) if st.radio("Do you use sleeping aids?", ["Yes", "No"]) == "Yes": st.text_input("If yes, explain:", key="text_input_if_yes,_explain:_1") # ---------------- Exercise ---------------- st.header("Lifestyle Review: Exercise") exercise_types = ["Cardio/Aerobic", "Strength/Resistance", "Flexibility/Stretching", "Balance", "Sports/Leisure", "Other"] for ex in exercise_types: st.text_input(f"{ex} - # of Times Per Week") st.text_input(f"{ex} - Time/Duration (Minutes)") st.radio("Do you feel motivated to exercise?", ["Yes", "A little", "No"]) st.radio("Are there any problems that limit exercise?", ["Yes", "No"]) st.text_input("If yes, explain:", key="text_input_if_yes,_explain:_2") st.radio("Do you feel unusually fatigued or sore after exercise?", ["Yes", "No"]) st.text_input("If yes, explain:", key="text_input_if_yes,_explain:_3") # ---------------- Nutrition and Diet ---------------- st.header("Nutrition and Diet") st.multiselect("Special diets you follow:", [ "Vegetarian", "Vegan", "Allergy Elimination", "Low Fat", "Low Carb", "High Protein", "Blood Type", "Low sodium", "No Dairy", "No Wheat", "Gluten Free"]) st.text_input("Other diet:", key="text_input_other_diet:_1") st.radio("Do you have sensitivities to certain foods?", ["Yes", "No"]) st.text_area("If yes, list food and symptoms:", key="text_area_if_yes,_list_food_and_symptoms:_1") st.radio("Do you have an aversion to certain foods?", ["Yes", "No"]) st.text_area("If yes, explain:", key="text_area_if_yes,_explain:_1") st.multiselect("Do you react adversely to:", [ "MSG", "Artificial sweeteners", "Garlic/onion", "Cheese", "Citrus", "Chocolate", "Alcohol", "Red wine", "Sulfites", "Preservatives", "Food colorings"]) st.text_input("Other food substances:", key="text_input_other_food_substances:_1") st.radio("Crave or binge on certain foods?", ["Yes", "No"]) st.text_input("If yes, what foods?", key="text_input_if_yes,_what_foods?_1") st.radio("Do you eat 3 meals/day?", ["Yes", "No"]) st.number_input("If no, how many?", min_value=0, max_value=6) st.radio("Does skipping a meal affect you?", ["Yes", "No"]) st.radio("How many meals out per week?", ["0-1", "1-3", "3-5", "More than 5"]) st.multiselect("Lifestyle and eating habits:", [ "Fast eater", "Eat too much", "Late-night eating", "Dislike healthy foods", "Time constraints", "Travel frequently", "Poor snack choices", "Healthy food not available", "Emotional eater", "Eat under stress", "Eat too little under stress", "Don't care to cook", "Confused by nutrition advice"]) # ---------------- Diet Intake ---------------- st.subheader("Typical Daily Intake") st.text_area("Breakfast", key="text_area_breakfast_1") st.text_area("Lunch", key="text_area_lunch_1") st.text_area("Dinner", key="text_area_dinner_1") st.text_area("Snacks", key="text_area_snacks_1") st.text_area("Fluids", key="text_area_fluids_1") st.subheader("Weekly Servings") st.number_input("Fruits", min_value=0) st.number_input("Vegetables", min_value=0) st.number_input("Legumes", min_value=0) st.number_input("Red meat", min_value=0) st.number_input("Fish", min_value=0) st.number_input("Dairy", min_value=0) st.number_input("Nuts & Seeds", min_value=0) st.number_input("Fats & Oils", min_value=0) st.number_input("Soda", min_value=0) st.number_input("Sweets", min_value=0) # ---------------- Submit ---------------- if st.button("Submit Form"): st.success("Form submitted successfully!") # ---------------- Stress ---------------- st.header("Stress") st.radio("Do you feel you have an excessive amount of stress in your life?", ["Yes", "No"]) st.radio("Do you feel you can easily handle the stress in your life?", ["Yes", "No"]) st.slider("How much stress does work cause on a daily basis? (1-10)", 1, 10) st.slider("How much stress does family cause on a daily basis? (1-10)", 1, 10) st.slider("How much stress does social life cause on a daily basis? (1-10)", 1, 10) st.slider("How much stress do finances cause on a daily basis? (1-10)", 1, 10) st.slider("How much stress does your health cause on a daily basis? (1-10)", 1, 10) st.slider("How much stress do other things cause on a daily basis? (1-10)", 1, 10) if st.radio("Do you use relaxation techniques?", ["Yes", "No"]) == "Yes": st.text_input("If yes, how often?", key="text_input_if_yes,_how_often?_1") st.multiselect("Which techniques do you use?", ["Meditation", "Breathing", "Tai Chi", "Yoga", "Prayer", "Other"]) st.radio("Have you ever sought counseling?", ["Yes", "No"]) st.radio("Are you currently in therapy?", ["Yes", "No"]) st.text_area("If yes, describe:", key="text_area_if_yes,_describe:_1") st.radio("Have you ever been abused, a victim of crime, or experienced significant trauma?", ["Yes", "No"]) st.text_area("What are your hobbies or leisure activities?", key="text_area_what_are_your_hobbies_or_leisure_activities?_1") # ---------------- Relationships ---------------- st.header("Relationships") st.selectbox("Marital status:", ["Single", "Married", "Divorced", "Gay/Lesbian", "Long-Term Partner", "Widow/er"]) st.text_area("With whom do you live?", key="text_area_with_whom_do_you_live?_1") st.text_input("Current occupation:", key="text_input_current_occupation:_1") st.text_input("Previous occupations:", key="text_input_previous_occupations:_1") if st.radio("Do you have resources for emotional support?", ["Yes", "No"]) == "Yes": st.multiselect("Support system includes:", ["Spouse/Partner", "Family", "Friends", "Religious/Spiritual", "Pets", "Other"]) if st.radio("Do you have a religious or spiritual practice?", ["Yes", "No"]) == "Yes": st.text_input("If yes, what kind?", key="text_input_if_yes,_what_kind?_1") st.subheader("How Well Have Things Been Going for You?") categories = ["Overall", "At school", "In your job", "In your social life", "With close friends", "With sex", "With your attitude", "With your boyfriend/girlfriend", "With your children", "With your parents", "With your spouse"] for cat in categories: st.text_input(f"{cat} (Score or N/A)") # ---------------- History ---------------- st.header("Birth/Childhood History") st.radio("You were born:", ["Term", "Premature", "Don't know"]) st.radio("Were there any pregnancy or birth complications?", ["Yes", "No"]) st.text_input("If yes, explain:", key="text_input_if_yes,_explain:_4") st.radio("You were:", ["Breast-fed", "Bottle-fed", "Don't know"]) st.text_input("How long breast-fed?", key="text_input_how_long_breast-fed?_1") st.text_input("Type of formula:", key="text_input_type_of_formula:_1") st.text_input("Age solid food introduced:", key="text_input_age_solid_food_introduced:_1") st.text_input("Age wheat introduced:", key="text_input_age_wheat_introduced:_1") st.text_input("Age dairy introduced:", key="text_input_age_dairy_introduced:_1") st.radio("Any food sensitivities as child?", ["Yes", "No"]) st.text_area("If yes, what foods and what symptoms?", key="text_area_if_yes,_what_foods_and_what_symptoms?_1") st.radio("Did you eat a lot of sugar or candy as a child?", ["Yes", "No"]) # ---------------- Dental History ---------------- st.header("Dental History") st.multiselect("Check all that apply:", [ "Silver mercury fillings", "Gold fillings", "Root canals", "Implants", "Caps/Crowns", "Tooth pain", "Bleeding gums", "Gingivitis", "Problems with chewing"]) st.text_area("Other dental concerns:", key="text_area_other_dental_concerns:_1") st.radio("Have you had mercury fillings removed?", ["Yes", "No"]) st.text_input("If yes, when?", key="text_input_if_yes,_when?_1") st.text_input("How many fillings did you have as a kid?", key="text_input_how_many_fillings_did_you_have_as_a_kid?_1") st.radio("Do you brush regularly?", ["Yes", "No"]) st.radio("Do you floss regularly?", ["Yes", "No"]) # ---------------- Men's History ---------------- st.header("Men's History") st.multiselect("Check all that apply:", [ "Testicular mass", "Testicular pain", "Prostate enlargement", "Prostate infection", "Change in sex drive", "Impotence", "Premature ejaculation", "Difficulty obtaining an erection", "Difficulty maintaining an erection", "Loss of control of urine", "Urinary urgency/hesitancy/change in stream", "Vasectomy", "Nocturia"]) st.text_input("Nocturia (# of times per night):", key="text_input_nocturia_(#_of_times_per_night):_1") st.text_input("Sexually transmitted diseases (describe):", key="text_input_sexually_transmitted_diseases_(describe):_1") st.subheader("Screening/Procedures") st.text_input("Last PSA test:", key="text_input_last_psa_test:_1") st.selectbox("PSA Level:", ["0-2", "2-4", "4-10", "More than 10"]) st.text_area("Other tests/procedures (list type and dates):", key="text_area_other_tests_procedures_(list_type_and_dates):_1") # ---------------- Family History ---------------- st.header("Family History") family_members = ["Mother", "Father", "Brother", "Sister", "Child", "Maternal Grandmother", "Maternal Grandfather", "Paternal Grandmother", "Paternal Grandfather", "Other"] conditions = [ "Cancer", "Heart disease", "Hypertension", "Obesity", "Diabetes", "Stroke", "Autoimmune disease", "Arthritis", "Kidney disease", "Thyroid problems", "Seizures/epilepsy", "Psychiatric disorders", "Anxiety", "Depression", "Asthma", "Allergies", "Eczema", "ADHD", "Autism", "Irritable Bowel Syndrome", "Dementia", "Substance abuse", "Genetic disorders" ] for member in family_members: with st.expander(f"{member}"): st.text_input("Age (if still alive):", key=f"{member}_age") st.text_input("Age at death (if deceased):", key=f"{member}_death_age") st.multiselect("Conditions:", conditions, key=f"{member}_conditions") st.text_input("Other:", key=f"{member}_other") # ---------------- Medical History ---------------- st.header("Medical History: Illnesses/Conditions") def yes_past_row(label, key_prefix): col1, col2, col3 = st.columns([2, 1, 1]) col1.markdown(label) col2.checkbox("Yes", key=f"{key_prefix}_yes") col3.checkbox("Past", key=f"{key_prefix}_past") st.subheader("Gastrointestinal") for condition in ["Irritable bowel syndrome", "GERD (reflux)", "Crohn’s disease/ulcerative colitis", "Peptic ulcer disease", "Celiac disease", "Gallstones", "Other GI"]: yes_past_row(condition, f"GI_{condition.replace(' ', '_')}") st.subheader("Respiratory") for condition in ["Bronchitis", "Asthma", "Emphysema", "Pneumonia", "Sinusitis", "Sleep apnea", "Other respiratory"]: yes_past_row(condition, f"Resp_{condition.replace(' ', '_')}") st.subheader("Urinary/Genital") for condition in ["Kidney stones", "Gout", "Interstitial cystitis", "Frequent yeast infections", "Frequent urinary tract infections", "Sexual dysfunction", "Sexually transmitted diseases", "Other urinary"]: yes_past_row(condition, f"Urinary_{condition.replace(' ', '_')}") st.subheader("Endocrine/Metabolic") for condition in ["Diabetes", "Hypothyroidism", "Hyperthyroidism", "Infertility", "Metabolic syndrome", "Eating disorder", "Hypoglycemia", "Other endocrine"]: yes_past_row(condition, f"Endo_{condition.replace(' ', '_')}") st.subheader("Inflammatory/Immune") for condition in ["Rheumatoid arthritis", "Chronic fatigue syndrome", "Food allergies", "Environmental allergies", "Multiple chemical sensitivities", "Autoimmune disease", "Immune deficiency", "Mononucleosis", "Hepatitis", "Other immune"]: yes_past_row(condition, f"Immune_{condition.replace(' ', '_')}") st.subheader("Musculoskeletal") for condition in ["Fibromyalgia", "Osteoarthritis", "Chronic pain", "Other musculoskeletal"]: yes_past_row(condition, f"MSK_{condition.replace(' ', '_')}") st.subheader("Skin") for condition in ["Eczema", "Psoriasis", "Acne", "Skin cancer", "Other skin"]: yes_past_row(condition, f"Skin_{condition.replace(' ', '_')}") st.subheader("Cardiovascular") for condition in ["Angina", "Heart attack", "Heart failure", "Hypertension", "Stroke", "High blood fats", "Rheumatic fever", "Arrhythmia", "Murmur", "Mitral valve prolapse", "Other cardio"]: yes_past_row(condition, f"CV_{condition.replace(' ', '_')}") st.subheader("Neurologic/Emotional") for condition in ["Epilepsy/Seizures", "ADD/ADHD", "Headaches", "Migraines", "Depression", "Anxiety", "Autism", "Multiple sclerosis", "Parkinson’s disease", "Dementia", "Other neuro"]: yes_past_row(condition, f"Neuro_{condition.replace(' ', '_')}") st.subheader("Cancer") for condition in ["Lung", "Breast", "Colon", "Prostate", "Skin", "Other cancer"]: yes_past_row(condition, f"Cancer_{condition.replace(' ', '_')}") # ---------------- Diagnostic Studies ---------------- st.header("Diagnostic Studies") for i, study in enumerate(["Bone Density", "CT scan", "Colonoscopy", "Cardiac stress test", "EKG", "MRI", "Upper endoscopy", "Upper GI series", "Chest X-ray", "Other X-rays", "Barium enema", "Other"]): st.text_input(f"{study} - Date:", key=f"diag_{i}_{study}_date") st.text_input(f"{study} - Comments:", key=f"diag_{i}_{study}_comments") # ---------------- Injuries ---------------- st.header("Injuries") for i, injury in enumerate(["Broken bone(s)", "Back injury", "Neck injury", "Head injury", "Other"]): st.text_input(f"{injury} - Date:", key=f"injury_{i}_{injury}_date") st.text_input(f"{injury} - Comments:", key=f"injury_{i}_{injury}_comments") # ---------------- Surgeries ---------------- st.header("Surgeries") for i, surgery in enumerate(["Appendectomy", "Dental", "Gallbladder", "Hernia", "Tonsillectomy", "Joint Replacement", "Heart surgery", "Other"]): st.text_input(f"{surgery} - Date:", key=f"surgery_{i}_{surgery}_date") st.text_input(f"{surgery} - Comments:", key=f"surgery_{i}_{surgery}_comments") # ---------------- Hospitalizations ---------------- st.header("Hospitalizations") for i in range(1, 6): st.text_input(f"Date #{i}:", key=f"hospital_date_{i}") st.text_input(f"Reason #{i}:", key=f"hospital_reason_{i}") # ---------------- Symptom Review ---------------- st.header("Symptom Review") def symptom_severity(label, key_prefix): col1, col2, col3, col4 = st.columns([3, 1, 1, 1]) col1.markdown(label) col2.checkbox("Mild", key=f"{key_prefix}_mild") col3.checkbox("Moderate", key=f"{key_prefix}_moderate") col4.checkbox("Severe", key=f"{key_prefix}_severe") symptom_categories = { "General": [ "Cold hands and feet", "Cold intolerance", "Daytime sleepiness", "Difficulty falling asleep", "Early waking", "Fatigue", "Fever", "Flushing", "Heat intolerance", "Night waking", "Nightmares", "Can’t remember dreams", "Low body temperature" ], "Head, Eyes, and Ears": [ "Conjunctivitis", "Distorted sense of smell", "Distorted taste", "Ear fullness", "Ear ringing/buzzing", "Eye crusting", "Eye pain", "Eyelid margin redness", "Headache", "Hearing loss", "Hearing problems", "Migraine", "Sensitivity to loud noises", "Vision problems" ], "Musculoskeletal": [ "Back muscle spasm", "Calf cramps", "Chest tightness", "Foot cramps", "Joint deformity", "Joint pain", "Joint redness", "Joint stiffness", "Muscle pain", "Muscle spasms", "Muscle stiffness", "Muscle twitches", "Around eyes", "Arms or legs", "Muscle weakness", "Neck muscle spasm", "Tendonitis", "Tension headache", "TMJ problems" ], "Mood/Nerves": [ "Agoraphobia", "Anxiety", "Auditory hallucinations", "Blackouts", "Depression", "Difficulty: Concentrating", "With balance", "With thinking", "With judgment", "With speech", "With memory", "Dizziness (spinning)", "Fainting", "Fearfulness", "Irritability", "Light-headedness", "Numbness", "Other phobias", "Panic attacks", "Paranoia", "Seizures", "Suicidal thoughts", "Tremor/trembling", "Visual Hallucinations" ], "Cardiovascular": [ "Angina/chest pain", "Breathlessness", "Heart attack", "Heart murmur", "High blood pressure", "Irregular pulse", "Mitral valve prolapse", "Palpitations", "Phlebitis", "Swollen ankles/feet", "Varicose veins" ], "Urinary": [ "Bed wetting", "Hesitancy", "Infection", "Kidney disease", "Kidney stone", "Leaking/incontinence", "Pain/burning", "Prostate enlargement", "Prostate infection", "Urgency" ], "Digestion": [ "Anal spasms", "Bad teeth", "Bleeding gums", "Bloating of: Lower abdomen", "Whole abdomen", "Bloating after meals", "Blood in stools", "Burping", "Canker sores", "Cold sores", "Constipation", "Cracking at corner of lips", "Dentures w/poor chewing", "Diarrhea", "Difficulty swallowing", "Dry mouth", "Farting", "Fissures", "Foods “repeat” (reflux)", "Heartburn", "Hemorrhoids", "Intolerance to: Lactose", "All dairy products", "Gluten (wheat)", "Corn", "Eggs", "Fatty foods", "Yeast", "Liver disease/jaundice", "Lower abdominal pain", "Mucus in stools", "Nausea", "Periodontal disease", "Sore tongue", "Strong stool odor", "Undigested food in stools", "Upper abdominal pain", "Vomiting" ], "Eating": [ "Binge eating", "Bulimia", "Can’t gain weight", "Can’t lose weight", "Carbohydrate craving", "Carbohydrate intolerance", "Poor appetite", "Salt cravings", "Frequent dieting", "Sweet cravings", "Caffeine dependency" ], "Respiratory": [ "Bad breath", "Bad odor in nose", "Cough – dry", "Cough – productive", "Hayfever: Spring", "Summer", "Fall", "Change of season", "Hoarseness", "Nasal stuffiness", "Nose bleeds", "Post nasal drip", "Sinus fullness", "Sinus infection", "Snoring", "Sore throat", "Wheezing", "Winter stuffiness" ], "Nails": [ "Bitten", "Brittle", "Curve Up", "Frayed", "Fungus – fingers", "Fungus – toes", "Pitting", "Ragged cuticles", "Ridges", "Soft", "Thickening of: Fingernails", "Toenails", "White spots/lines" ], "Lymph Nodes": [ "Enlarged/neck", "Tender/neck", "Other enlarged/tender lymph nodes" ], "Skin, Dryness of": [ "Eyes", "Feet", "Any cracking?", "Any peeling?", "Hair", "And unmanageable?", "Hands", "Mouth/throat", "Scalp", "Any dandruff", "Skin in general" ], "Skin Problems": [ "Acne on back", "Acne on chest", "Acne on face", "Acne on shoulders", "Athlete’s foot", "Bumps on back of upper arms", "Cellulite", "Dark circles under eyes", "Ears get red", "Easy bruising", "Eczema", "Herpes – genital", "Hives", "Jock itch", "Lackluster skin", "Moles w color/size change", "Oily skin", "Pale skin", "Patchy dullness", "Psoriasis", "Rash", "Red face", "Sensitive to bites", "Sensitive to poison ivy/oak", "Shingles", "Skin cancer", "Skin darkening", "Strong body odor", "Thick calluses", "Vitiligo" ], "Itching Skin": [ "Anus", "Arms", "Ear canals", "Eyes", "Feet", "Hands", "Legs", "Nipples", "Nose", "Genitals", "Roof of mouth", "Scalp", "Skin in general", "Throat" ], "Male Reproductive": [ "Discharge from penis", "Ejaculation problem", "Genital pain", "Impotence", "Infections", "Lumps in testicles", "Poor libido (low sex drive)" ] } for category, symptoms in symptom_categories.items(): st.subheader(category) for symptom in symptoms: symptom_severity(symptom, f"{category}_{symptom.replace(' ', '_').replace('/', '_')}") # ---------------- Medications/Supplements ---------------- st.header("Medications and Supplements") st.subheader("Current Medications (prescription and OTC)") for i in range(1, 6): st.text_input(f"Medication #{i}", key=f"med_name_{i}") st.text_input(f"Dosage #{i}", key=f"med_dose_{i}") st.text_input(f"Start Date (mo/yr) #{i}", key=f"med_start_{i}") st.text_input(f"Reason for Use #{i}", key=f"med_reason_{i}") st.subheader("Nutritional Supplements") for i in range(1, 6): st.text_input(f"Supplement #{i} Name and Brand", key=f"supp_name_{i}") st.text_input(f"Dosage #{i}", key=f"supp_dose_{i}") st.text_input(f"Start Date (mo/yr) #{i}", key=f"supp_start_{i}") st.text_input(f"Reason for Use #{i}", key=f"supp_reason_{i}") st.radio("Have medications or supplements ever caused unusual side effects or problems?", ["Yes", "No"], key="med_side_effects") st.text_area("If yes, describe:", key="med_side_effects_desc") st.subheader("Medication History") st.radio("NSAIDs, Motrin, Aspirin usage?", ["Yes", "No"], key="nsaid_use") st.radio("Tylenol (acetaminophen) usage?", ["Yes", "No"], key="tylenol_use") st.radio("Acid-blocking drugs usage?", ["Yes", "No"], key="acidblock_use") st.subheader("Antibiotic Use") for stage in ["Infancy/childhood", "Teen", "Adulthood"]: st.radio(f"{stage}: How many times taken?", ["Less than 5", "5 or more"], key=f"abx_{stage}_freq") st.text_input(f"{stage}: Reason for use", key=f"abx_{stage}_reason") st.radio("Ever taken long term antibiotics?", ["Yes", "No"], key="long_abx") st.text_input("If yes, explain:", key="long_abx_explain") st.subheader("Steroid Use") for stage in ["Infancy/childhood", "Teen", "Adulthood"]: st.radio(f"{stage}: Oral steroid use?", ["Less than 5", "5 or more"], key=f"steroids_{stage}_freq") st.text_input(f"{stage}: Reason for use", key=f"steroids_{stage}_reason") # ---------------- Readiness Assessment and Health Goals ---------------- st.header("Readiness Assessment") def readiness_slider(prompt, key): st.slider(prompt, 1, 5, key=key) readiness_slider("Willingness to significantly modify your diet", "ready_diet") readiness_slider("Willingness to take several nutritional supplements daily", "ready_supps") readiness_slider("Willingness to keep a food diary", "ready_log") readiness_slider("Willingness to modify lifestyle (e.g., sleep, work)", "ready_lifestyle") readiness_slider("Willingness to practice relaxation techniques", "ready_relax") readiness_slider("Willingness to engage in regular exercise", "ready_exercise") readiness_slider("Confidence in your ability to follow through", "ready_confidence") st.text_area("If not confident, what aspects concern you?", key="ready_concerns") readiness_slider("Supportiveness of people in your household", "ready_support") readiness_slider("How much ongoing support from staff would help you?", "ready_contact") st.text_area("Additional comments:", key="ready_comments") st.header("Health Goals") st.text_area("What do you hope to achieve in your visit with us?", key="goal_visit") st.text_input("When was the last time you felt well?", key="goal_last_well") st.text_input("Did something trigger your change in health?", key="goal_trigger") st.text_input("What makes you feel better?", key="goal_better") st.text_input("What makes you feel worse?", key="goal_worse") st.text_area("How does your condition affect you?", key="goal_affect") st.text_area("What do you think is happening and why?", key="goal_thoughts") st.text_area("What do you feel needs to happen for you to get better?", key="goal_improve") # ---------------- PDF Generation Instead of AI Story ---------------- # ---------------- PDF Generation Instead of AI Story ---------------- import tempfile from reportlab.lib.pagesizes import letter from reportlab.pdfgen.canvas import Canvas from datetime import datetime st.header("🚀 Submit Your Form") # if st.button("✅ Submit Form and Generate PDF"): # # 1. Collect all fields from session state # form_summary = [] # for key, val in st.session_state.items(): # form_summary.append(f"{key.replace('_', ' ').capitalize()}: {val}") # # 2. Generate PDF file # pdf_filename = f"intake_summary_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf" # temp_pdf_path = f"{pdf_filename}" # c = Canvas(temp_pdf_path, pagesize=letter) # width, height = letter # x, y = 40, height - 40 # line_height = 14 # c.setFont("Helvetica", 10) # c.drawString(x, y, "Male Intake Questionnaire Summary") # y -= 30 # for line in form_summary: # if y <= 40: # c.showPage() # c.setFont("Helvetica", 10) # y = height - 40 # c.drawString(x, y, line[:110]) # y -= line_height # c.save() # st.success("✅ PDF generated successfully!") # st.download_button("📄 Download PDF", data=open(temp_pdf_path, "rb").read(), file_name=pdf_filename) if st.button("✅ Submit Form and Generate PDF"): # 1. Define the boundary: from General Info to Medications and Supplements section_keys_to_include = [] collecting = False for key in st.session_state: if key == "text_input_name_1": collecting = True if collecting: section_keys_to_include.append(key) if key == "supp_reason_5": collecting = False # 2. Create form summary with filtered keys form_summary = [] for key in section_keys_to_include: val = st.session_state.get(key) formatted_key = key.replace("_", " ").capitalize() form_summary.append(f"{formatted_key}: {val}") # 3. Generate PDF pdf_filename = f"intake_summary_{datetime.now().strftime('%Y%m%d_%H%M%S')}.pdf" temp_pdf_path = f"{pdf_filename}" c = Canvas(temp_pdf_path, pagesize=letter) width, height = letter x, y = 40, height - 40 line_height = 14 c.setFont("Helvetica", 10) c.drawString(x, y, "Male Intake Questionnaire Summary") y -= 30 for line in form_summary: if y <= 40: c.showPage() c.setFont("Helvetica", 10) y = height - 40 c.drawString(x, y, str(line)[:110]) y -= line_height c.save() st.success("✅ PDF generated successfully!") st.download_button("📄 Download PDF", data=open(temp_pdf_path, "rb").read(), file_name=pdf_filename)