Skip to content

let users create/edit their own note template for note generation` #34

@sammargolis

Description

@sammargolis

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

  1. Add template preferences.
  • noteTemplateId (default, soap, custom)
  • customNoteTemplate (markdown string)
  1. Add UI in Settings for template management.
  • Selector for Default, SOAP, Custom
  • Multiline editor shown when Custom is selected
  1. 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
  1. Validate/fallback behavior.
  • If custom template is empty/invalid, fall back to default template
  • Keep app stable and log a warning (no crash)
  1. 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

  1. 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.
  1. Backward compatibility
  • If user does nothing, behavior remains unchanged.
  • Existing default flows still work for current encounter types.
  1. Reliability
  • Invalid/empty custom template does not break note generation.
  • System falls back to default template deterministically.
  1. Persistence
  • Template selection and custom template text persist across reload/restart.
  1. Test coverage
  • Preference persistence tests for template fields.
  • Template resolution tests (default, soap, custom, invalid).
  • Integration test that note generation receives resolved markdown template.
  1. Definition of Done
  • UI selector + custom editor implemented.
  • Runtime uses resolved markdown templates.
  • Docs updated.
  • Tests pass.

Suggested Test Cases

  1. Default path:
  • No template preference set -> generated note uses default template.
  1. SOAP preset:
  • Select SOAP -> generated note follows SOAP heading structure.
  1. Custom template:
  • Save custom markdown with unique headings -> generated note output follows those headings.
  1. Invalid custom:
  • Set custom template to empty string -> fallback to default template.
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions