Skip to content

Care Module plugins — kill switch and core integration

Version: 1.38
Last Updated: 2026-08-03 18:23:23
Status: Adopted — Phase A + Cancer Board V2 shipped (top context panel drives Today’s care plan; Daily status radar with per-tap persist + merged retrospective reads; homepage dashboard-panel; bottom day/mode pickers removed from hub); 8-spoke radar geometry preserved
UI spec: 29-CARE-MODULE-UI-ARCHITECTURE.md · Support flow: 31-CANCER-AT-HOME-SUPPORT-FLOW-UX.md


1. Your instinct is right (with one clarification)

Section titled “1. Your instinct is right (with one clarification)”

Yes: Cancer at Home and Breathing & Oxygen should ship as plugins on top of the core app, with an instant off switch so you can launch on the base product alone.

Clarification: They are not optional npm packages. They are feature-flagged product plugins inside the same repo — same deploy, same database, isolated folders and routes. That matches how you already treat commerce (BILLING_TIER_PLANS_ONLY) and product readiness (module_delivery.json).

LayerWhat it gatesKill switch
Subscription (ModuleGate, tiers.json)Entitlement — can tenant use observations, calendar, etc.?Tier plan only
Care Profile purchase (tenant_pack_purchases)Unlock slug — can they apply cancer/breathing?BILLING_TIER_PLANS_ONLY (no pack checkout)
Care Module boards (new)Interactive hub UI — /care/...CARE_MODULE_BOARDS_ENABLED
Preview audience (new)Who may use boards when enabledCARE_MODULE_PREVIEW_USER_IDS (default 1)

The third and fourth layers are independent. You can have pack seeds + base app with boards completely off, or boards on only for user id 1 while you validate UX.


2.1 You cannot avoid some core touchpoints

Section titled “2.1 You cannot avoid some core touchpoints”

Pure plugins with zero core changes are not realistic. You need small integration points only:

#Core touchWhy
1Route registration (lazy, behind flag)App.tsx — /care/* when VITE_CARE_MODULE_BOARDS=true
2Per-user feature flagGET /api/subscriptions/active → feature_flags.care_module_boards (loaded once in ModuleContext; useCareModuleFlags() derives gates — no duplicate request)
3Patient context (existing)Boards read activePatient.care_profile_slug

You do not need to refactor Dashboard, Observations, or ModuleGate for v1 beyond an optional dashboard chip.

2.2 Do not make Care Boards a tiers.json module yet

Section titled “2.2 Do not make Care Boards a tiers.json module yet”

Do not add care_module_cancer to subscription modules. That couples billing to experimental UI and makes kill switches harder.

SwitchWhereEffect when OFF
Build-timeVITE_CARE_MODULE_BOARDS=falseRoutes and JS chunks not in bundle — safest launch
RuntimeCARE_MODULE_BOARDS_ENABLED=false on APINav hidden; APIs 404; old clients cannot use boards

Launch recommendation: both OFF in production until you are happy. Turn on in staging with both true.

2.4 Go-live registry + owner preview toggle (current rollout)

Section titled “2.4 Go-live registry + owner preview toggle (current rollout)”

When both deploy flags are true, visibility is driven by backend/care_modules/go_live.json (one status per board slug) and users.care_module_dev_preview for users in CARE_MODULE_PREVIEW_USER_IDS.

Registry statusPublic board + commercePreview cohort (preview_user_ids)
liveEveryone with pack accessN/A
previewHiddenBoard + Subscriptions offer only when user is in cohort and dev preview toggle is ON

Default posture: slugs stay preview (not live). Toggle defaults OFF — user id 1 sees the customer view (no board nav, no paid profile cards) until they enable preview on Subscriptions.

Deploy gate: scripts/verify-care-module-preview-gate.ps1 probes slug_board_visible('cancer_at_home', …) — user 1 off → False, user 1 on → True, user 2 off → False.

Keep condition_templates as partial. Do not mark boards live until product sign-off.


off

on

live

yes

no

preview

no

yes

no

yes

CARE_MODULE_BOARDS_ENABLED + VITE_CARE_MODULE_BOARDS

No board APIs / nav

go_live.json status

tenant owns pack?

Board + apply

Buy on Subscriptions

user in preview_user_ids?

Hidden

care_module_dev_preview ON?

Board + offer UI; checkout closed until live


frontend/src/care-modules

backend/care_modules

flags.py

manifests/*.json

routers/board.py

services/cancer_hub_service.py

services/zone_engine.py

registry.ts

CareModuleRoutes.tsx

CareBoardShell.tsx

cancer/CareBoardPage.tsx

cancer/VisitPrepPage.tsx

CareBoardDashboardPanel.tsx

breathing/CareBoardPage.tsx

backend/
care_modules/
flags.py
manifest_loader.py
manifests/
cancer_at_home.json
breathing_difficulties.json
routers/
status.py
board.py
services/
zone_engine.py
board_service.py
cancer_hub_service.py
dashboard_panel_service.py
cancer_defaults.py
cancer_board_visual.py # enrich_tiles(), icon keys for hub visual layer
visit_prep_narrative.py
repositories/
care_module_events.py
care_module_settings.py
migrations/
V011__care_module_events.sql
V015__care_module_patient_settings.sql
frontend/src/
care-modules/
CareModuleRoutes.tsx # lazy routes + Suspense + ErrorBoundary per /care/*
registry.ts
hooks/useCareBoard.ts
shared/CareBoardShell.tsx, CareBoardGate.tsx
cancer/CareBoardPage.tsx
cancer/cancerBoardV2Model.ts # V2 section builders (status, plan, watch, activation, clinic)
cancer/cancerCareFlow.ts # buildCancerCareFlow, buildComfortBecauseLine, resolvePainLogFork
cancer/cancerBoardVisual.ts
cancer/cancerRadarConfig.ts # 8-spoke metadata (Daily cancer status)
cancer/radarTapGeometry.ts # tap hit-test (do not change in V2)
cancer/components/CancerTodayContextPanel.tsx # cc-card; composes CancerDayPicker + CancerModeToggle
cancer/components/CancerStatusSummary.tsx
cancer/components/CancerTodayPlan.tsx
cancer/components/CancerWatchClosely.tsx
cancer/components/CancerActivatedAcrossLynCareOS.tsx
cancer/components/CancerClinicHandover.tsx
cancer/components/CancerTileCard.tsx
cancer/components/CancerDayPicker.tsx
cancer/components/CancerModeToggle.tsx
cancer/components/CancerPrimarySitePicker.tsx # header Listbox pill (right of title row)
cancer/components/CancerComfortDateStrip.tsx # day picker for daily cancer status
cancer/components/CancerComfortRadar.tsx
cancer/components/CancerComfortRadarChart.tsx # ECharts 8-spoke radar
cancer/components/InlineComfortCheckIn.tsx # Daily status wrapper (cancer_symptom_bundle / comfort_round)
cancer/components/CareFlowRail.tsx # retained; not mounted on hub
cancer/components/BecauseLine.tsx # What this tells us (post-save implication)
cancer/components/NextStepFork.tsx # Do now / Later / Skip
cancer/components/CollapsibleSection.tsx # chevron groups (other tasks, today, treatment)
cancer/VisitPrepPage.tsx
breathing/CareBoardPage.tsx
components/dashboard/
CareBoardDashboardPanel.tsx
CareActionsForTodayBlock.tsx
CareProfileIconStrip.tsx
CancerTodayStrip.tsx
components/care-capture/
CareCaptureOverlay.tsx # portal; phone full-screen / tablet 85vw / desktop ~50% main column
CaptureSession.tsx # wizard | stacked layout from manifest
SegmentedBar.tsx # tap-segment bar (3–5 choices; Comfort check-in)
TrafficLight3.tsx
context/
ModuleContext.tsx # active modules + feature_flags (single /subscriptions/active)
CareModuleFlagsContext.tsx # useCareModuleFlags() hook only (no extra provider)

Core app imports only:

  • CareModuleRoutes inside if (CARE_BOARDS_BUILD_ENABLED)
  • useCareModuleFlags() (under ModuleProvider in App.tsx)

There is no CareModuleFlagsProvider. Flags come from the same ModuleContext fetch as module entitlements.

AuthProvider
└── ProtectedRoute
└── ModuleProvider ← GET /subscriptions/active (modules + feature_flags)
└── PatientProvider
└── AlertProvider
└── Layout → pages (Dashboard chip, /care/* gates)

CareBoardDashboardChip and CareBoardGate call useCareModuleFlags(); that hook reads careModuleBoards from useModules().

Each slug’s backend/care_modules/manifests/{slug}.json defines capture_sessions:

FieldPurpose
labelOverlay title
layoutOptional: wizard (default) or stacked (all steps on one phone screen)
steps[]key, widget, family_prompt, choices[] with clinical_value

Cancer Daily status (inline 8-spoke radar): sessions cancer_symptom_bundle and comfort_round — eight manifest steps (Energy, Pain, Eating, Breath, Mood, Sleep, Fever, Treatment) rendered on CareBoardPage via InlineComfortCheckIn (not overlay). CancerComfortDateStrip selects care_date. Tap ring dots on CancerComfortRadarChart to score each spoke 1–4; postStep on each tap (immediate care_module_events write with care_date + capture_instance_id). completeSession when all eight spokes saved in UI (automatic — no Save button). GET …/comfort-checkin (board): merged latest per spoke across all instances on that date so retrospective edits keep the full spider; optional capture_instance_id query for single-instance reads. Dashed overlay = Past N-day average from GET …/comfort-checkin/spoke-averages. GET …/comfort-checkin/week-series?anchor= returns Mon–Sun merged levels; comfortWeekInsightNarrative.ts turns that into CancerStatusSummary copy (1–7 days of data: single-day snapshots, multi-day trends, per-spoke deterioration questions, team/palliative/emergency hints — hub zone fallback only when the week has zero daily-status days). cancerRadarConfig.ts: fever_worry uses higherIsBetter: false (stored 4 = fever/chills, 1 = no signs). Overlay CaptureSession retained for fever / infusion / oral medicine / tablet pathways from tiles. visit_prep_narrative and hub due-counts include both session ids.

Cancer Board V2 (shipped 2026-06-10): CareBoardPage renders CancerTodayContextPanel (top — cc-card composing CancerDayPicker + CancerModeToggle treatment modes only; day/mode patch + scroll to plan) → CancerStatusSummary (Mon–Sun spoke insights + escalation copy from week-series — 2026-07-31) → CancerTodayPlan (buildTodayPlan / buildPlanSubtitle — day-type and mode steps only; daily status and breakthrough review removed from the numbered plan list 2026-07-31, still available via InlineComfortCheckIn and CancerWatchClosely / tiles) → date strip → InlineComfortCheckIn → Other cancer tasks today (#cancer-other-tasks) → CancerWatchClosely → CancerActivatedAcrossLynCareOS → CancerClinicHandover. /calendar: CalendarFocusDayPanel — writable action pills for the focus date (§4.3). Superseded the read-only CareActionsForTodayBlock, deleted 2026-07-31. gentle_mode: backend only — no hub toggle. Bottom collapsible day/mode sections removed from the hub page. Section data from cancerBoardV2Model.ts against existing hub JSON. CareFlowRail not mounted. Home: GET …/dashboard-panel + CareBoardDashboardPanel. Spec: 31.

Calendar + breakthrough (2026-06-05, MVP completion):

IntegrationBackendFrontend
Oncology appointment typesV016 column; patient_appointments.py create/PATCHAddShiftForm optional type chips
Hub day synccancer_hub_service.today_oncology_appointments, suggested_day_type_from_calendar, effective_day_typeCalendar suggestion step in CancerTodayPlan + CancerTodayContextPanel day icons (CancerDayPicker → today_day_type)
Breakthrough logresolve_breakthrough_log_route() → hub.breakthrough_log_routeCancerTileCard + LogDose.tsx query params
Site tipsPRIMARY_SITE_TIPS in cancer_defaults.py → hub.today.site_tipTip card on hub
Comfort overridecomfort_override_state() → hub.comfort_overrideApricot banner on hub
Visit prep discussedvisit_prep_discussed in settings JSONBVisitPrepPage checkboxes
Analytics/api/analytics/by-reason?reason_pattern=; /care-module-eventsHub tile sparklines from hub metrics

Manifest reload: manifest_loader.load_manifest() caches by (slug, file mtime_ns) — editing manifests/*.json invalidates on next board request without restarting the API.

4.3 Calendar actions in manifest JSON (2026-07-31)

Section titled “4.3 Calendar actions in manifest JSON (2026-07-31)”

A module contributes to the care calendar by declaring calendar_actions in backend/care_modules/manifests/{slug}.json. Each entry is a named bundle of structured tasks (prompt + response buttons) that the family can put on a date with one tap. Adding a module to the calendar is a manifest edit, not a code change.

FieldPurpose
idStable action id, persisted on each task as source_action_id. Renaming it orphans existing tasks.
labelPill text
iconKey in CARE_PROFILE_ICON_MAP (care-modules/shared/careProfileVisual.ts) — not a Lucide component name. Applied actions show this icon in the month grid day cell as well as on the focus-day pill.
suggested_by_appointment_types[]patient_appointments.appointment_type values that highlight the pill on that date
tasks[]Task definitions applied when the action is tapped (see below)

Each task object:

FieldPurpose
idStable task id → source_task_id on the row
titleStable label (idempotent apply index, exports)
promptQuestion shown on the focus-day panel
response_kindButton set id — see backend/care_modules/calendar_task_responses.py

Legacy manifest entries that list plain strings in tasks[] normalize to done_pending on apply.

{
"id": "infusion",
"label": "Infusion day",
"icon": "iv",
"suggested_by_appointment_types": ["iv_infusion", "labs"],
"tasks": [
{
"id": "blood_tests",
"title": "Confirm blood tests are done",
"prompt": "Have blood tests been done?",
"response_kind": "yes_no"
},
{
"id": "transport",
"title": "Arrange driver / transport",
"prompt": "Is driver or transport arranged?",
"response_kind": "arrangement"
}
]
}

Rules:

  • Suggested never auto-applies. A matching appointment highlights the pill; the family still taps to confirm. Inferring the day from the calendar is what the retired today_day_types mechanism did wrong.
  • Task text comes only from the manifest. calendar_actions_service.find_action() rejects an unknown action_id with 404, so a client cannot write arbitrary task text through the action endpoint.
  • Answers are explicit. The UI renders fixed buttons per response_kind; PATCH /api/care-tasks/{id} with { "response_code" } stores the choice and timestamp (V027). Checkbox strikethrough alone is not the product model for module tasks.
  • A module with no calendar_actions key simply has no pills — a valid state, not an error.
  • Applying is idempotent. uq_care_tasks_module_action (V026) plus ON CONFLICT DO NOTHING means re-tapping writes nothing; DELETE soft-deletes only that action’s tasks on that date.

Shipping today: cancer_at_home (infusion, tablet, clinic, rest, line care) and breathing_difficulties (oxygen check, respiratory clinic).

LayerFile
Response kindsbackend/care_modules/calendar_task_responses.py · frontend/src/lib/calendarModuleTaskResponses.ts
Manifest normalizebackend/care_modules/calendar_task_manifest.py
Repositorybackend/repositories/care_tasks.py — date-scoped SQL (V026 + V027 columns)
Servicebackend/care_modules/services/calendar_actions_service.py — manifest lookup, apply, undo, audit on apply/undo
Router (gated)backend/care_modules/routers/calendar_actions.py — behind require_care_module_access
Router (ungated)backend/routers/care_tasks.py, care_shifts.py — read/create dated tasks; PATCH structured response_code
Frontend (focus day)pages/calendar/CalendarFocusDayPanel.tsx, CalendarModuleDayTasks.tsx, ModuleTaskResponseButtons.tsx, useCalendarFocusDay.ts
Frontend (month grid)pages/calendar/useCalendarModuleActionsRange.ts, CalendarMonthGrid.tsx, CalendarDayCell.tsx, lib/calendarViewHelpers.ts (careModuleDayIconKeys, careModuleDayIconsForViewport), careModuleSlugIconKey() in careProfileVisual.ts — desktop lg+: up to five per-action icons; phone/tablet: one module icon
API (month at a glance)GET /api/patients/{id}/care-modules/calendar-actions/range?slug=&start=&end= → CalendarActionsRange.dates

Tests: backend/tests/test_calendar_actions.py, test_calendar_task_responses.py. Calendar file map and interaction rules: 15-CARE-CALENDAR-COMPOSITION.md.


5. Turn off instantly — operator runbook

Section titled “5. Turn off instantly — operator runbook”
# backend .env / VPS
CARE_MODULE_BOARDS_ENABLED=false
# frontend build (CI / docker)
VITE_CARE_MODULE_BOARDS=false

Redeploy. Families see: Dashboard, Log, Calendar, Observations — no /care/* routes.

CARE_MODULE_BOARDS_ENABLED=true
CARE_MODULE_PREVIEW_USER_IDS=1
VITE_CARE_MODULE_BOARDS=true

Apply the Care Profile pack (cancer_at_home or breathing_difficulties) to a test patient — not the care situation (archetype) alone. Then open /care/cancer-at-home or /care/breathing, or use the dashboard Open care board chip.

Peter tenant shortcut (dev):

Terminal window
.\scripts\seed-dev-peter-care-qa.ps1

Log in as Peter → tenant peter → switch active person to QA — Breathing board or QA — Cancer board → Home. Optional: People in care → Care profile QA (dev) one-tap apply (user id 1). See 05-DEVELOPER-GUIDE §7.1i–§7.1j.

Set CARE_MODULE_BOARDS_ENABLED=false and restart API. Ideal rollback: both flags false + redeploy frontend.


PhaseDeliverableFlagStatus
P0Flags + registry + shell + routesON in devDone
P1care_module_events + CaptureSession + board APION stagingDone
P2Breathing MVP tiles (O₂, flare)Staging sign-offNext
P3Cancer MVP hub (visual tiles, fever, visit prep, calendar sync, breakthrough log, dashboard strip)Staging sign-offDone (2026-06-05)
P4Production ON + widen PREVIEW_USER_IDSYour call—

VersionDateChange
1.02026-06-04Plugin + dual kill switch; core integration scope
1.12026-06-04Preview user gate; Mermaid diagrams; Phase A paths
1.32026-06-04Removed CareModuleFlagsProvider; useCareModuleFlags() hook on ModuleContext; §4.1 provider tree
1.42026-06-04Peter dev QA seed (seed_dev_peter_care_qa); archetype vs Care Profile apply path in §5
1.52026-06-04Cancer MVP: V015 care_module_patient_settings, hub/visit-prep/chips APIs, full CareBoardPage, VisitPrepPage, CancerTodayStrip; P3 marked done
1.62026-06-04CareCaptureOverlay (body portal, z-[1100]); ModuleContext super-admin care-board flag fix; capture vs route tiles documented
1.72026-06-05Overlay opaque bg-canvas fix (bg-background was transparent — hub bleed-through); key={sessionId} on capture mount
1.82026-06-05Responsive overlay: phone full-screen, tablet ~85vw card, desktop ~50% main-column width + backdrop
1.92026-06-05Visit prep narrative: visit_prep_narrative.py, GET …/visit-prep → story; VisitPrepPage story-first UI + clinician text toggle (CANC-H02 lite)
1.102026-06-05Visit prep abbreviated: story.lines bullet facts; lean VisitPrepPage (patient name + desk framing + questions)
1.112026-06-05Cancer hub treatment mode feedback: hub.board_effects, toggle banners, test_cancer_board_effects.py
1.122026-06-05Cancer board crash fix: null-safe CareBoardPage, settings treatment_modes normalize; explicit Suspense on care routes
1.132026-06-05Dashboard + hub labels: infusion visit packing (replaces “chair day” in family UI)
1.142026-06-05Visual cancer hub: cancer_board_visual.py, telemetry tiles, icon mode/day components, LEARNING layout
1.152026-06-05Comfort check-in: manifest comfort_round with "layout": "stacked" + segmented_bar (How are they? · Ready for clinic? · Breakthrough pain?); SegmentedBar.tsx; CaptureSession stacked mode; _primary_cta() gentle/palliative → Comfort check-in
1.162026-06-05Comfort mode QA: manifest_loader mtime cache (manifest edits without API restart); _visible_tiles() gentle path → symptom tile opens comfort_round; dev guide Comfort mode steps
1.172026-06-05Default Comfort check-in: cancer_symptom_bundle → layout: stacked (same 3 steps as comfort_round); _primary_cta() label Comfort check-in; SegmentedBar numbers+legend; overlay contentAlign start for stacked; visit prep counts both session ids
1.182026-06-05Header Where cancer is: CancerPrimarySitePicker beside hub title; Home on patient-name row (cc-btn-soft); bottom-card site select removed
1.192026-06-05Site picker UX: native <select> → Headless UI Listbox; slim rounded-full chip inline with title; compact floating panel on small phones
1.202026-06-05Site picker right-aligned on title row (justify-between); dropdown anchor bottom end
1.212026-06-05Mobile-minimal hub: zone chip; inline spider Comfort check-in; CollapsibleSection for tiles/today/treatment; hero CTA removed on check-in days
1.222026-06-08Care Flow Rail pilot: cancerCareFlow.ts, CareFlowRail, BecauseLine, NextStepFork; link 31
1.232026-06-05MVP completion: V016 appointment types; calendar→hub day sync; breakthrough /log deep link + sparkline; site tips; comfort override; visit prep discussed; analytics filters
1.272026-06-10Cancer Board V2 shipped: cancerBoardV2Model.ts + five section components; V2 section order on CareBoardPage; Daily cancer status terminology; comfort-checkin APIs and radar geometry unchanged
1.282026-06-10Actions for today UI label replaces “Today is…” on CancerDayPicker section; Comfort mode (gentle_mode) documented as simplify-board-for-today toggle
1.292026-06-10Context panel at top (CancerTodayContextPanel composes pickers in cc-card); plan driven by day/mode; Daily status rename; homepage dashboard-panel; bottom pickers removed from hub
1.302026-06-10Comfort mode toggle removed from hub UI; calendar CareActionsForTodayBlock read-only strip; CareProfileIconGrid removed
1.312026-07-31Daily status: per-tap persist; auto session_completed; comfort-checkin GET merges spokes across capture_instance_id on a care_date; dev guide QA + scroll notes
1.382026-07-31 23:02:18comfortWeekInsightNarrative — 1–7 day insights, escalation copy, fever_worry radar polarity documented
1.372026-07-31 22:56:05CancerStatusSummary weekly spoke narrative — comfort-checkin/week-series, comfortWeekInsightNarrative.ts
1.362026-07-31 22:47:33buildTodayPlan — daily status + breakthrough review dropped from Today’s care plan cards (sections unchanged)
1.352026-07-31 22:06:59§4.3 — structured calendar_actions tasks (prompt, response_kind), V027 persistence, focus-day response buttons
1.332026-07-31 21:54:00§4.3 — month grid icons for applied calendar_actions via range API + careModuleDayIconKeys
1.322026-07-31§4.3 calendar_actions manifest contract — modules contribute tappable action pills to the care calendar that write date-scoped care_tasks (V026). Suggested never auto-applies; titles only from manifest; apply is idempotent. CareActionsForTodayBlock deleted, replaced by CalendarFocusDayPanel