Background
Custom templates are partially scaffolded but not user-configurable yet.
Current state in code:
- Visit type is mapped to
"default" or "soap" in page.tsx.
- That value is passed to server note generation in actions.ts.
- Prompt builder currently treats
template as raw markdown in v1.ts.
- Template registry exists in templates/index.ts, but it is not wired into runtime selection.
- Preferences currently store only
noteLength and processingMode in preferences.ts.
Objective
Allow users to select a template and create/edit one custom markdown template in the UI, then use that template in note generation without changing note-generation flow outside this path.
Scope
- Add template preferences.
noteTemplateId (default, soap, custom)
customNoteTemplate (markdown string)
- Add UI in Settings for template management.
- Selector for
Default, SOAP, Custom
- Multiline editor shown when
Custom is selected
- Wire note generation to resolved template markdown.
- Resolve preset IDs through template registry (
default/soap)
- Pass actual markdown template content into note-generation prompt
- Keep existing behavior when no custom template is set
- Validate/fallback behavior.
- If custom template is empty/invalid, fall back to default template
- Keep app stable and log a warning (no crash)
- Add brief docs.
- How to use preset vs custom template
- Markdown heading guidance (
#, ##, ###)
Out of Scope
- Full template library manager (multiple saved custom templates)
- Sharing templates across users/devices
- Local Python backend template editing parity
- Major note parser redesign
Detailed Success Criteria
- Functional
- User can choose
Default, SOAP, or Custom from Settings.
- User can edit/save custom template markdown.
- Note generation uses selected template for new encounters.
- Backward compatibility
- If user does nothing, behavior remains unchanged.
- Existing default flows still work for current encounter types.
- Reliability
- Invalid/empty custom template does not break note generation.
- System falls back to default template deterministically.
- Persistence
- Template selection and custom template text persist across reload/restart.
- Test coverage
- Preference persistence tests for template fields.
- Template resolution tests (
default, soap, custom, invalid).
- Integration test that note generation receives resolved markdown template.
- Definition of Done
- UI selector + custom editor implemented.
- Runtime uses resolved markdown templates.
- Docs updated.
- Tests pass.
Suggested Test Cases
- Default path:
- No template preference set -> generated note uses default template.
- SOAP preset:
- Select
SOAP -> generated note follows SOAP heading structure.
- Custom template:
- Save custom markdown with unique headings -> generated note output follows those headings.
- Invalid custom:
- Set custom template to empty string -> fallback to default template.
- Persistence:
- Reload app -> selected template and custom content remain.
Docs Snippet (example)
Template options:
- Default: History & Physical structure
- SOAP: Subjective/Objective/Assessment/Plan
- Custom: Your own markdown template
Custom template tips:
- Use `#` for note title
- Use `##` for primary sections
- Use `###` for subsections
Rationale
This is a contained, high-impact UX improvement that builds directly on existing template infrastructure and unblocks true “custom note templates” without large architectural changes.
Background
Custom templates are partially scaffolded but not user-configurable yet.
Current state in code:
"default"or"soap"in page.tsx.templateas raw markdown in v1.ts.noteLengthandprocessingModein preferences.ts.Objective
Allow users to select a template and create/edit one custom markdown template in the UI, then use that template in note generation without changing note-generation flow outside this path.
Scope
noteTemplateId(default,soap,custom)customNoteTemplate(markdown string)Default,SOAP,CustomCustomis selecteddefault/soap)#,##,###)Out of Scope
Detailed Success Criteria
Default,SOAP, orCustomfrom Settings.default,soap,custom, invalid).Suggested Test Cases
SOAP-> generated note follows SOAP heading structure.Docs Snippet (example)
Rationale
This is a contained, high-impact UX improvement that builds directly on existing template infrastructure and unblocks true “custom note templates” without large architectural changes.