Skip to content

Add patient safety plan generator mockup - #1015

Merged
BigSimmo merged 4 commits into
mainfrom
claude/patient-safety-plan-mockup-wldmyc
Jul 21, 2026
Merged

Add patient safety plan generator mockup#1015
BigSimmo merged 4 commits into
mainfrom
claude/patient-safety-plan-mockup-wldmyc

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a design-exploration mockup for a clinician-facing Safety plan generator tool at /mockups/patient-safety-plan (dev-only route; 404 in production, robots-disallowed).
  • New patient-safety-plan-mockup.tsx: a two-pane builder + live patient-copy preview based on the Stanley–Brown Safety Planning Intervention (six prioritised steps), plus a reasons-for-living callout and a prominent emergency-escalation band.
  • Hides the shared bottom search composer for this route (it provides its own primary surfaces), matching the existing tool/favourites mockup treatment in mockups-layout-client.tsx.
  • Regenerates docs/site-map.md for the new route.
  • Built entirely on the Clinical White / Aegean design tokens and shared ui-primitives; light/dark, reduced-motion and forced-colors follow the shared system. Australian English + AU crisis resources per the Clinical KB voice. Sample content is seeded and clearly labelled as editable.

Verification

  • Typecheck (tsc --noEmit) — clean
  • Lint (changed files) — clean
  • npm run sitemap:check — passes (new route registered)
  • tests/production-mockup-boundary.test.ts + tests/env-mockups-gate.test.ts — 7/7 pass
  • UI verification not run: the dev server / npm run verify:ui / npm run verify:pr-local cannot compile in this environment due to a pre-existing Turbopack CSS-parse error in generated Tailwind output (::file-selector-button from DocumentManagerPanel.tsx, unrelated to this change). This mockup adds no file: utilities. A standalone rendered preview confirmed the layout.
  • Not applicable (no retrieval/answer/clinical-workflow surface touched): eval:retrieval:quality, eval:rag, eval:quality, check:production-readiness.

Risk and rollout

Complete this section for clinical, data, API, auth/privacy, workflow, dependency, build, or deployment changes.

  • Risk: minimal — a new development-only mockup route. No production surface, no shared-component changes, no clinical logic. The only change to existing code is one added pathname check in mockups-layout-client.tsx.
  • Rollback: revert the commit (removes the route, component, layout-client line, and site-map entry).
  • Provider or production effects: None.

Clinical Governance Preflight

This dev-only mockup renders static, clearly-labelled synthetic sample content and never queries live data or sources. Crisis contacts are editable placeholders a clinician confirms for their local service. No ingestion, answer generation, retrieval/ranking, source rendering, document access, privacy, production-env, or clinical-output behaviour is touched — all items below hold unchanged.

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

Notes

  • The plan follows the six-step Stanley–Brown structure with a supportive, non-alarming tone: warning signs → internal coping → distracting people/places → people to ask for help → professionals & crisis lines → means-safety, plus reasons for living and a calm "call 000 / Emergency Department / Lifeline 13 11 14" escalation band.
  • An evidence + advisory footer makes clear the plan is built collaboratively and is not a substitute for clinical risk assessment.

🤖 Generated with Claude Code

https://claude.ai/code/session_019g9m5emoPKCmDDPeGrchYd

Summary by CodeRabbit

  • New Features

    • Added an interactive patient safety plan mockup with six customizable steps.
    • Supports adding, editing, and removing plan items and emergency contacts.
    • Includes live patient preview, completion tracking, finalization status, and reasons-for-living entries.
    • Added options to copy the completed plan or print/save it as a PDF.
    • Added the patient safety plan mockup to the site map and dedicated route.
  • UI Improvements

    • Hid the global search composer while viewing the safety plan mockup.

Add a design-exploration mockup for a clinician-facing "Safety plan
generator" tool at /mockups/patient-safety-plan.

- New component `patient-safety-plan-mockup.tsx`: a two-pane builder +
  live patient-copy preview based on the Stanley-Brown Safety Planning
  Intervention (six prioritised steps), plus reasons for living and a
  prominent emergency-escalation band.
- New route and metadata under src/app/mockups/patient-safety-plan/.
- Hide the shared bottom search composer for this route (it provides its
  own primary surfaces), matching the tool/favourites mockup treatment.
- Regenerate docs/site-map.md for the new route.

Uses the Clinical White / Aegean design tokens and shared ui-primitives
throughout; Australian English and AU crisis resources per the Clinical
KB voice. Light/dark, reduced-motion and forced-colors follow the shared
system. Sample content is seeded and fully editable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019g9m5emoPKCmDDPeGrchYd
@supabase

supabase Bot commented Jul 20, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fb073de-db5d-440a-92f5-04cd28331f7e

📥 Commits

Reviewing files that changed from the base of the PR and between f6193d7 and 823277a.

📒 Files selected for processing (1)
  • src/components/patient-safety-plan-mockup.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/patient-safety-plan-mockup.tsx

📝 Walkthrough

Walkthrough

Adds a /mockups/patient-safety-plan route with an interactive six-step builder, patient-facing preview, copy/print actions, completion state, seeded example content, and route-specific suppression of the shared search composer.

Changes

Patient Safety Plan Mockup

Layer / File(s) Summary
Safety plan UI building blocks
src/components/patient-safety-plan-mockup.tsx
Defines the six-step configuration, seeded entries, reusable add/remove controls, clinician builder cards, and patient-facing preview steps.
Safety plan state and output
src/components/patient-safety-plan-mockup.tsx
Manages editable plan state, readiness, generated plain text, copy and print actions, builder inputs, finalisation status, and formatted preview output.
Route and mockup shell integration
src/app/mockups/patient-safety-plan/page.tsx, src/app/mockups/mockups-layout-client.tsx, docs/site-map.md
Adds the Next.js route and metadata, registers the route in the site map, and hides the shared search composer on the safety-plan pathname.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant PatientSafetyPlanRoute
  participant MockupsLayoutClient
  participant PatientSafetyPlanMockup

  Browser->>PatientSafetyPlanRoute: request safety plan mockup
  PatientSafetyPlanRoute->>MockupsLayoutClient: render route within mockup shell
  MockupsLayoutClient->>PatientSafetyPlanMockup: render without shared search composer
  PatientSafetyPlanMockup->>Browser: display builder and patient preview
  PatientSafetyPlanMockup->>Browser: copy or print generated plan
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a patient safety plan generator mockup.
Description check ✅ Passed The description follows the required template and includes summary, verification, risk, governance, and notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/patient-safety-plan-mockup-wldmyc

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo marked this pull request as ready for review July 20, 2026 23:52
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/components/patient-safety-plan-mockup.tsx (2)

196-260: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

AddRow inputs rely solely on placeholder text for their accessible name.

Neither the primary nor secondary <input> has an associated <label> or aria-label; screen-reader users get no persistent accessible name once the field has a value (placeholder text is not read as a label). Given this is a clinician tool for entering safety-critical information, consider adding aria-label={primaryPlaceholder} / aria-label={secondaryPlaceholder}.

♿ Proposed fix
       <input
         value={primary}
         onChange={(event) => setPrimary(event.target.value)}
+        aria-label={primaryPlaceholder}
         onKeyDown={(event) => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/patient-safety-plan-mockup.tsx` around lines 196 - 260, Add
persistent accessible names to both inputs in AddRow by setting aria-label from
primaryPlaceholder and secondaryPlaceholder respectively. Keep the existing
placeholder props and input behavior unchanged.

191-192: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Module-level mutable counter persists across mounts.

seq lives at module scope, so if this component unmounts/remounts (route revisit) the id sequence keeps incrementing rather than resetting; harmless for a mockup but worth noting if this pattern is reused elsewhere. crypto.randomUUID() or a per-instance useRef counter would avoid the shared mutable state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/patient-safety-plan-mockup.tsx` around lines 191 - 192, Update
the uid generation near uid so the counter is scoped per component instance
rather than shared at module scope, using a per-instance useRef counter or
crypto.randomUUID(). Remove the module-level mutable seq state while preserving
the existing prefixed ID format and uniqueness within each mounted instance.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/patient-safety-plan-mockup.tsx`:
- Around line 419-472: Reset finalised to false whenever any plan content
changes, not only in addEntry and removeEntry. Update the handlers for patient
name, planDate, and reasons-for-living additions/removals to clear finalised,
while preserving their existing state updates and the current finalisation
behavior.
- Around line 432-452: Update the planText useMemo to include the
reasons-for-living entries from reasons, matching the live preview’s formatting
and placement, and add the Suicide Call Back Service crisis line alongside the
existing emergency lines. Keep Copy and Print/PDF output aligned with the
preview while preserving the existing section rendering and blank-line
normalization.

---

Nitpick comments:
In `@src/components/patient-safety-plan-mockup.tsx`:
- Around line 196-260: Add persistent accessible names to both inputs in AddRow
by setting aria-label from primaryPlaceholder and secondaryPlaceholder
respectively. Keep the existing placeholder props and input behavior unchanged.
- Around line 191-192: Update the uid generation near uid so the counter is
scoped per component instance rather than shared at module scope, using a
per-instance useRef counter or crypto.randomUUID(). Remove the module-level
mutable seq state while preserving the existing prefixed ID format and
uniqueness within each mounted instance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 985d515b-fea3-46c7-8b5c-77ddaae32515

📥 Commits

Reviewing files that changed from the base of the PR and between 87815f4 and f6193d7.

📒 Files selected for processing (4)
  • docs/site-map.md
  • src/app/mockups/mockups-layout-client.tsx
  • src/app/mockups/patient-safety-plan/page.tsx
  • src/components/patient-safety-plan-mockup.tsx

Comment thread src/components/patient-safety-plan-mockup.tsx
Comment thread src/components/patient-safety-plan-mockup.tsx Outdated
claude and others added 2 commits July 21, 2026 00:01
…, label add inputs

- planText (Copy / Print–PDF) now includes the reasons-for-living section
  and the Suicide Call Back Service crisis line, so the copied/printed
  artefact matches the on-screen patient preview.
- Reset the "Plan finalised" state when the patient name, date, or a
  reason-for-living changes — previously only the six steps cleared it,
  so the banner could go stale after a content edit.
- Give the AddRow inputs persistent aria-labels (from their placeholders)
  so the accessible name survives once a value is entered.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019g9m5emoPKCmDDPeGrchYd
@BigSimmo
BigSimmo enabled auto-merge (squash) July 21, 2026 00:05
@BigSimmo
BigSimmo merged commit accf60c into main Jul 21, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the claude/patient-safety-plan-mockup-wldmyc branch July 21, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants