# ED Encounters The ED encounter workflow is a multi-stage clinical documentation flow for emergency visits. ## Shape - Frontend: `public/js/ed-encounters.js`. - Backend: `src/routes/edEncounters.js`. - Prompts: ED-specific entries in `src/utils/prompts.js`. - Helpers: billing suggestions and don't-miss review can run after generated ED output. ## Typical Flow 1. Capture initial ED context and generate an initial note/stage output. 2. Add interval updates as the encounter evolves. 3. Consolidate relevant stages into the final ED note. 4. Generate MDM/final documentation using the ED finalize prompt. 5. Optionally run billing and don't-miss helpers. 6. Save or reload the encounter through the shared encounter system. ## Design Constraints - Later stages should not silently overwrite earlier clinical text. - Regeneration should make it clear which stage is being updated. - MDM/finalization prompt changes should be conservative and coding-aware. - Don't-miss output is clinician-facing safety support, not a replacement for clinical judgment. ## User Templates Templates saved under ED-relevant categories can be included through `/api/memories/context` and passed as `physicianMemories`. Legacy `correction_*` rows are filtered out. ## Testing Checklist When changing ED behavior: 1. Run syntax checks for `public/js/ed-encounters.js` and `src/routes/edEncounters.js`. 2. Run `npm test`. 3. Manually test stage generation, finalization, save/load, and helper panels in an authenticated session when possible.