27 — Condition Template Packs Module
Version: 1.13
Status: Unlock + Stripe + Care Start apply + day-one bootstrap Delivered (VPS 2026-06-04); Care Module boards Phase A partial; archetype / care-pattern UI withdrawn 2026-06-26; C1d clinical sign-off and live paid pack checkout still open
Last Updated: 2026-08-06 10:05:00
Master requirements: 02-REQUIREMENTS.md §3.10, §7.36 (REQ-TMPL, REQ-CARE-START). Canonical catalogue: 35-CARE-PROFILE-CATALOGUE.md v2.7. Tier matrix: 23-SUBSCRIPTION-TIER-ENTITLEMENTS-MATRIX.md §2b. Migrations: 11-DATABASE-SAFETY §2j. Commerce UX: 25-SUBSCRIPTION-VS-CARE-PROFILES.md §6.
Module slug: condition_templates
Tier: All tiers — 2 free starter profiles; Family may purchase additional; Complete includes all twelve profiles.
Purpose
Section titled “Purpose”Care Profiles (condition template packs) are a tenant-level product:
- Unlock —
tenant_pack_purchasesvia free starters, tier inclusion, or Stripe one-time purchase. - Care Start apply —
apply_care_start_pack()seeds reason types, observation types, and shift tasks per patient (REQ-TMPL-02 — Delivered on dev + VPS). PRN reason codes live inreason_types.patient_id(V014) — not shared across people in care. Day-one bootstrap (2026-06-04): four medication time slots, sample pain medicine on paid packs, profile-themed shopping lists —care_start_bootstrap.py+SHOPPING_LISTS_BY_PACK_SLUGinseed_catalog.py. - Correction — wrong archetype or profile is non-destructive per patient (REQ-CARE-START-04 — Palliative §7.5).
Seven care archetypes (care situations) classify coordination patterns; twelve Care Profiles carry the seed content. They are paired, not interchangeable: selecting The Breath-by-Breath does not load board UI until breathing_difficulties (or another pack) is applied to that person via Care Start (dev QA panel or API; family UI TBD). Care Pathways (fourth product layer — Planning Ahead) extend archetypes with a staged planning journey; see 33-CARE-PATHWAYS-MODULE.md and Palliative §10. Do not duplicate pack slugs outside Palliative Care Archetypes.md §3.2. UI copy register: seed labels from §3.3–3.5 only (§4.4 R2) — not §2 narratives or §5 empathy brief.
Implementation status
Section titled “Implementation status”| Layer | State | Notes |
|---|---|---|
| Migrations V077–V079 | Done | Schema + draft seeds (superseded by V006–V009 on dev) |
| Reconciliation V006–V010 | Done | Dev + VPS 2026-06-04 (image deploy-20260604-1810) |
| Pack content seed | Done | V008 + V010 — reason types, observations, self-care, shift tasks |
| API — list, archetypes, preview, purchase | Done | routers/condition_packs.py |
| API — Care Start apply | Done | POST /api/patients/{id}/care-start; PATCH …/care-pattern; GET …/care-start/recommended — routers/care_start.py |
| Service / repo | Done | Purchase + tier grants + care_start_service.py + care_start_bootstrap.py + repositories/care_start.py |
| Day-one bootstrap | Done (dev) | Med slots + sample script (paid) + shopping lists on apply; slots on new patient — 05-DEVELOPER-GUIDE §7.1i |
| Stripe purchase | Done | Checkout + webhook |
| UI — Subscriptions marketplace | Done | /subscriptions — Add a Care Profile only; condition_templates excluded from module-access grid (2026-06-26) |
| UI — Add Person | Done (demographics only) | PatientCareStartWizard — name/DOB/gender/address/notes; no archetype or apply step (2026-06-26) |
| UI — archetype / care-pattern | Withdrawn (2026-06-26) | CarePatternPanel + ArchetypeOnboarding deleted; standalone /care-archetypes redirect → /subscriptions |
| Checkout Palliative Care Start bundle | Done (dev) | REQ-CARE-START-01 — API line item + marketing modal (2026-06-04); live gated by switchover |
| Care-pattern correction API | Done (dev) | PATCH …/care-pattern — REQ-CARE-START-04; no family UI (C5c UX withdrawn 2026-06-26) |
| Dev QA — Peter tenant | Done (dev) | seed_dev_peter_care_qa + CareProfileQaPanel (user id 1) — see 05-DEVELOPER-GUIDE §7.1j |
| Register R2 audit | Done (automated) | C7 — scripts/audit_register_r2_care_start.py |
Care Module boards (/care/*) | Partial (Phase A) | Separate from pack unlock — 30; cancer_at_home + breathing_difficulties only; preview user 1 |
API surface
Section titled “API surface”| Method | Path | Purpose | Status |
|---|---|---|---|
| GET | /api/condition-packs | All packs with tenant has_access flags | Done |
| GET | /api/condition-packs/archetypes | Seven archetypes | Done |
| GET | /api/condition-packs/{id}/preview | Pack content preview | Done (content on dev after V008) |
| POST | /api/condition-packs/{id}/purchase | Stripe Checkout for paid pack | Done |
| PATCH | /api/patients/{patient_id}/care-pattern | Non-destructive archetype/profile correction (C5c) | Done |
| POST | /api/patients/{patient_id}/care-start | Apply profile to patient | Done |
| GET | /api/patients/{patient_id}/care-start/recommended | Suggested pack for archetype | Done |
Gate: require_module("condition_templates") via _ctpacks in main.py.
V077–V079 reconciliation (do not lose this)
Section titled “V077–V079 reconciliation (do not lose this)”Migrations V077, V078, V079 created the right tables but seeded draft catalogue data that predates the finalized product model. Do not edit those migration files on applied databases.
Reconciliation shipped as active post-v1 files V006–V010 (2026-06-04 on dev and VPS). Content maps to Palliative §7.0.5 planned V106–V111.
| Layer | Shipped | Authoritative spec | Active migration |
|---|---|---|---|
| Archetypes | V077 — 7 rows | Palliative §2 | V006 — copy update |
| Care Profiles | V078 — legacy slugs | Palliative §3.2 | V007 — twelve canonical slugs + purchase remap |
| Pack content | Empty template tables | Palliative §3.3–3.6 | V008 — reason types, observations, shift tasks |
| Patient apply columns | — | REQ-TMPL-02 | V009 — patient columns + shift task templates |
Full mapping tables, legacy slug → canonical slug: Palliative Care Archetypes.md §7.0. Ops: 11-DATABASE-SAFETY §2j.
REQ traceability: REQ-CARE-START-02 (V007, V008), REQ-CARE-START-03 (V006), REQ-TMPL-02 (V009 + service). Delivery sequence: 04-ROADMAP.md §Master Phase 1.
Key files
Section titled “Key files”| Path | Role |
|---|---|
backend/routers/condition_packs.py | Pack catalogue HTTP |
backend/routers/care_start.py | Care Start apply + recommended preview |
backend/services/condition_packs_service.py | Access flags, preview, purchase, tier grants |
backend/services/care_start_service.py | apply_care_start_pack() |
backend/repositories/condition_packs.py | Pack catalogue SQL |
backend/repositories/care_start.py | Apply + patient Care Start SQL |
backend/care_start/seed_catalog.py | V008 seed source data |
backend/scripts/generate_care_start_seed_sql.py | Regenerate V008 SQL |
frontend/src/components/condition-packs/PatientCareStartWizard.tsx | Add Person form — demographics only (C5b UI simplified 2026-06-26) |
frontend/src/pages/admin/Patients.tsx | Add Person entry |
frontend/src/pages/admin/Subscriptions.tsx | Care Profiles purchase grid; module access (excludes condition_templates) |
frontend/src/components/condition-packs/CareProfileQaPanel.tsx | Dev one-tap pack apply (user id 1) |
backend/scripts/seed_dev_peter_care_qa.py | Dev: peter tenant modules + pack grants + QA patients |
scripts/seed-dev-peter-care-qa.ps1 | PowerShell wrapper for Peter QA seed |
frontend/src/components/condition-packs/ConditionPackCard.tsx | Buyable pack card — description + up to two feature_bullets (Cancer: V012) |
frontend/src/components/condition-packs/ConditionPackPreviewDialog.tsx | Preview modal — marketing layout for cancer_at_home; seed lists collapsible |
Related
Section titled “Related”- 24-SUBSCRIPTION-BILLING-AND-TIER-LIMITS.md §5.4 — pack purchase flow
- Palliative Care Archetypes.md — single source of truth for archetypes, profiles, content, commerce