')
- continue
-
- # ── Bullet ─────────────────────────────────────────────────
- if stripped and stripped[0] in ("-", "*", "•"):
- close_lists()
- if not in_ul and not in_pep:
- output.append('
'
- f'⚠ Physician Review Required — '
- f'{svc_list} may need adjustment based on your health history. '
- f'Our medical team will evaluate during your consultation.'
- f'
'
- )
-
- # Service pills (MOA shown via shared tooltip on hover)
- badges = ""
- for p in stack["services"]:
- moa = SERVICE_MOA.get(p, "")
- esc_moa = moa.replace('"', '"').replace("'", "'") if moa else ""
- badges += f'
{p}
'
-
- # Build tier pricing grid (config values are monthly — convert to weekly)
- sorted_tiers = sorted(stack["tiers"].items(), key=lambda x: x[1]["sort_order"])
- tier_cells = ""
- for tier_name, tier_data in sorted_tiers:
- tier_desc = ""
- if stack["type"] == "training":
- tier_info = TRAINING_TIERS.get(tier_name, {})
- desc_text = tier_info.get("training_desc", "")
- if desc_text:
- tier_desc = f'
{desc_text}
'
- us_text = tier_info.get("ultrasound", "")
- if us_text:
- tier_desc += f'
',
- unsafe_allow_html=True,
- )
-
- # ── Downloads ─────────────────────────────────────────────────────────────
- st.markdown('', unsafe_allow_html=True)
- st.markdown("#### Download Your Results")
- st.caption("Save your Ignition Sequence recommendation or export data for clinic use.")
-
- c1, c2, c3 = st.columns(3)
- with c1:
- pdf_buf = generate_wellness_pdf(
- st.session_state["wellness_pathway"],
- {"name": pname, "email": pemail, "phone": pphone,
- "age": page, "sex": psex,
- "date": datetime.now().strftime("%B %d, %Y")},
- st.session_state["recommended_stacks"],
- st.session_state.get("contraindication_flags", []),
- )
- st.download_button(
- "PDF Report", data=pdf_buf, file_name="ignite_ignition_sequence.pdf",
- mime="application/pdf", use_container_width=True,
- )
- with c2:
- csv_buf = generate_csv_export(st.session_state.get("intake_data", {}), st.session_state["recommended_stacks"])
- safe_name = (pname or "patient").replace(" ", "_")
- st.download_button(
- "CSV Export", data=csv_buf, file_name=f"ignite_{safe_name}.csv",
- mime="text/csv", use_container_width=True,
- )
- with c3:
- json_buf = generate_json_export(st.session_state.get("intake_data", {}), st.session_state["recommended_stacks"])
- st.download_button(
- "JSON Export", data=json_buf, file_name=f"ignite_{safe_name}.json",
- mime="application/json", use_container_width=True,
- )
-
- st.info(
- "**Clinic staff:** CSV and JSON exports include full intake data, contraindication flags, "
- "and per-week / per-month / total pricing — ready for your EMR or CRM.",
- icon="ℹ️",
- )
-
- # ── Start over button ─────────────────────────────────────────────────────
- st.markdown('', unsafe_allow_html=True)
- if st.button("← Start New Assessment", use_container_width=True):
- for key in ["wellness_pathway", "recommended_stacks", "all_eligible_stacks", "intake_data",
- "patient_name", "patient_email", "patient_phone", "patient_age", "patient_sex",
- "contraindication_flags", "email_status"]:
- st.session_state[key] = None if key == "wellness_pathway" else (
- [] if key in ["recommended_stacks", "all_eligible_stacks", "contraindication_flags", "email_status"] else ""
- )
- st.session_state["scroll_to_top"] = True
- st.rerun()
-
- render_footer()
-
- # ── Scroll to top (fires ONCE on first results render, then stops) ──────
- if not st.session_state.get("results_scroll_done", False):
- st.session_state["results_scroll_done"] = True
- components.html(
- """
-
- """,
- height=0,
- )
-
- st.stop()
-
-
-# =============================================================================
-# INTAKE FORM PAGE
-# =============================================================================
-
-st.markdown('', unsafe_allow_html=True)
-
-if st.session_state.pop("scroll_to_top", False):
- components.html(
- """
-
- """,
- height=0,
- )
-
-st.markdown(
- '
'
- f''
- '
Ignition Sequence™
'
- '
Find Your Program
'
- '
Physician-Supervised • Personalized to Your Biology
'
- '
',
- unsafe_allow_html=True,
-)
-st.markdown(
- "Answer a few questions about your goals and where you are right now. "
- "We'll match you to the Ignition Sequence program that fits best. "
- "Our team reviews every result and will reach out within 24\u201348 hours to schedule your consultation.",
-)
-
-# ── Intake form ───────────────────────────────────────────────────────────────
-with st.form("wellness_intake_form"):
-
- st.markdown('
Your Information
', unsafe_allow_html=True)
- c1, c2 = st.columns(2)
- with c1:
- first_name = st.text_input("First Name *")
- last_name = st.text_input("Last Name *")
- email = st.text_input("Email Address *")
- with c2:
- phone = st.text_input("Cell Phone *")
- age = st.number_input("Age *", min_value=18, max_value=100, value=35)
- sex = st.radio("Biological Sex *", ["Male", "Female"], index=None)
-
- st.markdown('
1 — Current Symptoms
', unsafe_allow_html=True)
- st.caption("Check anything you're currently experiencing.")
-
- # Split symptoms dynamically into two columns
- symptom_keys = list(CURRENT_SYMPTOMS.keys())
- mid = (len(symptom_keys) + 1) // 2
- symptom_checks = {}
-
- c1, c2 = st.columns(2)
- with c1:
- for symptom in symptom_keys[:mid]:
- symptom_checks[symptom] = st.checkbox(symptom, key=f"symptom_{symptom}")
- with c2:
- for symptom in symptom_keys[mid:]:
- symptom_checks[symptom] = st.checkbox(symptom, key=f"symptom_{symptom}")
-
- st.markdown('
2 — Primary Goals
', unsafe_allow_html=True)
- st.caption("Select everything that applies to you.")
-
- # Split goals dynamically into two columns
- goal_keys = list(PRIMARY_GOALS.keys())
- mid = (len(goal_keys) + 1) // 2
- goal_checks = {}
-
- c1, c2 = st.columns(2)
- with c1:
- for goal in goal_keys[:mid]:
- goal_checks[goal] = st.checkbox(goal, key=f"goal_{goal}")
- with c2:
- for goal in goal_keys[mid:]:
- goal_checks[goal] = st.checkbox(goal, key=f"goal_{goal}")
-
- st.markdown('
3 — Physical Activity
', unsafe_allow_html=True)
- activity_level = st.radio(
- "What best describes your current activity level? *",
- ACTIVITY_LEVELS,
- index=None,
- )
-
- st.markdown('
4 — Energy & Recovery
', unsafe_allow_html=True)
- energy_recovery = st.radio(
- "How would you describe your current energy and physical recovery? *",
- list(ENERGY_RECOVERY_OPTIONS.keys()),
- index=None,
- )
-
- st.markdown('
5 — Medical History
', unsafe_allow_html=True)
- medical_care = st.radio(
- "Are you currently receiving care for hormone imbalances, cancer, or other chronic conditions not listed above? *",
- ["No", "Yes — please describe below"], index=None,
- )
- medical_details = st.text_area(
- "If yes, please provide details:",
- placeholder="Current conditions, medications, or recent treatments...",
- )
-
- st.markdown('
6 — Safety Screening
', unsafe_allow_html=True)
- st.caption(
- "Check any of the following that apply. This allows our physician team to identify services "
- "requiring modification or review. Checking an item does not exclude you from therapy."
- )
- flag_options = [f for f in ALL_CONTRAINDICATION_FLAGS if f != "None of the above"]
- mid = (len(flag_options) + 1) // 2
- contra_checks = {}
- cf1, cf2 = st.columns(2)
- with cf1:
- for flag in flag_options[:mid]:
- contra_checks[flag] = st.checkbox(flag, key=f"cf_{flag}")
- with cf2:
- for flag in flag_options[mid:]:
- contra_checks[flag] = st.checkbox(flag, key=f"cf_{flag}")
- none_of_above = st.checkbox("None of the above", key="cf_none")
-
- st.markdown('
Anything Else?
', unsafe_allow_html=True)
- additional_info = st.text_area(
- "Previous experience with training programs, specific concerns, or timeline goals:",
- placeholder="Optional — any context that may help our physician team.",
- )
-
- # ── Consent & Disclaimers ──────────────────────────────────────────────────
- st.markdown('
Consent & Privacy
', unsafe_allow_html=True)
-
- st.markdown(
- '
'
- 'Important: This platform is '
- 'not HIPAA-compliant. Any personal or health information you '
- 'enter may be transmitted and stored on servers that do not meet HIPAA security '
- 'standards. Please do not share sensitive medical records, Social Security numbers, '
- 'or information you would not be comfortable disclosing on a non-secure platform.
',
- unsafe_allow_html=True,
- )
-
- consent_privacy = st.checkbox(
- "I understand this platform is NOT HIPAA-compliant and that any information "
- "I provide may not be protected under HIPAA privacy regulations.",
- key="consent_privacy",
- )
- consent_contact = st.checkbox(
- "I consent to being contacted by Ignite Performance & Health via the email "
- "address and phone number I have provided above regarding my assessment "
- "and available programs.",
- key="consent_contact",
- )
-
- submitted = st.form_submit_button("Generate My Ignition Sequence", use_container_width=True)
-
-# ── Form processing ──────────────────────��────────────────────────────────────
-if submitted:
- primary_goals = [g for g, checked in goal_checks.items() if checked]
- current_issues = [i for i, checked in symptom_checks.items() if checked]
-
- if none_of_above:
- selected_flags = ["None of the above"]
- else:
- selected_flags = [flag for flag, checked in contra_checks.items() if checked]
- if not selected_flags:
- selected_flags = ["None of the above"]
-
- errors = []
- if not first_name: errors.append("First Name")
- if not last_name: errors.append("Last Name")
- if not email: errors.append("Email Address")
- if not phone: errors.append("Cell Phone")
- if sex is None: errors.append("Biological Sex")
- if not primary_goals: errors.append("Primary Goals (select at least one)")
- if energy_recovery is None: errors.append("Energy & Recovery level")
- if activity_level is None: errors.append("Physical Activity level")
- if medical_care is None: errors.append("Medical History")
- if not consent_privacy: errors.append("Privacy acknowledgment (required)")
- if not consent_contact: errors.append("Consent to contact (required)")
-
- # ── Male-specific restrictions ────────────────────────────────────────────
- male_conflicts = []
- if sex == "Male":
- male_restricted_goals = [g for g in primary_goals if g in MALE_RESTRICTED_GOALS]
- male_restricted_syms = [s for s in current_issues if s in MALE_RESTRICTED_SYMPTOMS]
- male_restricted_flags = [f for f in selected_flags if f in MALE_RESTRICTED_FLAGS]
-
- if male_restricted_goals:
- male_conflicts.append(f"Primary Goals: {', '.join(male_restricted_goals)}")
- if male_restricted_syms:
- male_conflicts.append(f"Symptoms: {', '.join(male_restricted_syms)}")
- if male_restricted_flags:
- male_conflicts.append(f"Flags: {', '.join(male_restricted_flags)}")
-
- if errors:
- st.error(f"Please complete the following required fields: **{', '.join(errors)}**")
- st.stop()
-
- # ── "None of the above" conflict check ────────────────────────────────────
- other_flags_checked = [flag for flag, checked in contra_checks.items() if checked]
- if none_of_above and other_flags_checked:
- st.error(
- "⚠ You selected **\"None of the above\"** in Safety Screening but also checked: "
- f"**{', '.join(other_flags_checked)}**. Please select one or the other."
- )
- st.stop()
-
- if male_conflicts:
- st.error(
- f"⚠ The following selections are not applicable for male patients: "
- f"**{', '.join(male_conflicts)}**. Please uncheck them and resubmit."
- )
- st.stop()
-
- # Scroll parent to top AND force-position spinner when it appears
- components.html(
- """""",
- height=0,
- )
- with st.spinner("Developing your Ignition Sequence..."):
- goals_data = {"primary_goals": primary_goals, "energy_recovery": energy_recovery,
- "current_issues": current_issues, "activity_level": activity_level}
- target_scores = map_goals_to_targets(goals_data)
- rec_stacks, _, all_eligible = recommend_programs(target_scores, len(primary_goals), patient_sex=sex, patient_flags=selected_flags)
- med = medical_details if medical_care == "Yes — please describe below" else "No current conditions reported"
-
- intake_data = {
- "name": f"{first_name} {last_name}", "first_name": first_name, "last_name": last_name,
- "email": email, "phone": phone, "age": age, "sex": sex,
- "primary_goals": primary_goals, "energy_recovery": energy_recovery,
- "current_issues": current_issues, "activity_level": activity_level,
- "medical_considerations": med, "medical_details": medical_details or "",
- "contraindication_flags": selected_flags,
- "additional_info": additional_info or "None provided",
- }
-
- pathway = generate_wellness_pathway(intake_data, rec_stacks, selected_flags)
-
- st.session_state["wellness_pathway"] = pathway
- st.session_state["results_scroll_done"] = False # allow one scroll-to-top on results load
- st.session_state["recommended_stacks"] = rec_stacks
- st.session_state["all_eligible_stacks"] = all_eligible
- st.session_state["intake_data"] = intake_data
- st.session_state["patient_name"] = f"{first_name} {last_name}"
- st.session_state["patient_email"] = email
- st.session_state["patient_phone"] = phone
- st.session_state["patient_age"] = age
- st.session_state["patient_sex"] = sex
- st.session_state["contraindication_flags"] = selected_flags
-
- # ── Auto-send emails ──────────────────────────────────────────────
- patient_info = {
- "name": f"{first_name} {last_name}", "email": email, "phone": phone,
- "age": age, "sex": sex, "date": datetime.now().strftime("%B %d, %Y"),
- }
- pdf_buf = generate_wellness_pdf(pathway, patient_info, rec_stacks, selected_flags)
- pdf_bytes = pdf_buf.getvalue()
- csv_buf = generate_csv_export(intake_data, rec_stacks)
- csv_bytes = csv_buf.getvalue()
- json_buf = generate_json_export(intake_data, rec_stacks)
- json_bytes = json_buf.getvalue()
-
- client_result = send_client_email(email, pdf_bytes)
- clinic_result = send_clinic_email(intake_data, pdf_bytes, csv_bytes, json_bytes)
-
- email_status = []
- if client_result is True and clinic_result is True:
- email_status = [("success", "Your results have been sent to your email.")]
- else:
- if client_result is not True:
- email_status.append(("warning", f"Patient email not sent: {client_result}"))
- if clinic_result is not True:
- email_status.append(("warning", f"Clinic email not sent: {clinic_result}"))
- st.session_state["email_status"] = email_status
-
- st.rerun()
-
-render_footer()