- Admin CMS: announcements, feature flags, email templates, AI prompts, SMTP, model management, reset-to-defaults - Save/resume encounter progress with 7-day auto-expiry and patient labels - Inline searchable load popover (replaces settings-modal redirect) - User memory/template system (physical exam, ROS, encounter format, etc.) - SSHADESS psychosocial screening form (8 domains, listen-in recording) - Well visit note generation with vitals, vaccines, screenings, SSHADESS - Interactive screenings/vaccines status buttons (Done/Refused/Already Given/N/A) - ROS 15-system checklist + PE 17-system checklist in well visit note tab - ICD-10 diagnoses tag picker (28 common pediatric codes + free text) - Simple sick visit tab: chief complaint, inferred ROS (4) + PE (7), diagnoses, generate note - Settings converted from modal to full-page tab - Fix: /api/models moved before authenticated routes (was returning 401 → empty model selector) - Fix: getUserMemoryContext always fetches from API regardless of cache state - Pause/resume recording on all recording tabs - Site-level SMTP config stored in DB; ElevenLabs TTS with browser fallback
73 lines
2.3 KiB
JavaScript
73 lines
2.3 KiB
JavaScript
// ============================================================
|
|
// SICK VISIT ROUTE — sick visit note generation
|
|
// ============================================================
|
|
|
|
var express = require('express');
|
|
var router = express.Router();
|
|
var { callAI } = require('../utils/ai');
|
|
var PROMPTS = require('../utils/prompts');
|
|
var { authMiddleware } = require('../middleware/auth');
|
|
var logger = require('../utils/logger');
|
|
|
|
// ── POST generate sick visit note ────────────────────────────────────────
|
|
router.post('/sick-visit/note', authMiddleware, async function(req, res) {
|
|
var start = Date.now();
|
|
try {
|
|
var {
|
|
patientAge, patientGender, chiefComplaint,
|
|
transcript, dictation,
|
|
ros, physicalExam, diagnoses,
|
|
physicianMemories,
|
|
model
|
|
} = req.body;
|
|
|
|
if (!chiefComplaint) {
|
|
return res.status(400).json({ error: 'Chief complaint is required' });
|
|
}
|
|
|
|
// Assemble context
|
|
var context = 'SICK VISIT\n';
|
|
context += 'Patient: ' + (patientAge || 'Unknown age') + ', ' + (patientGender || 'Unknown gender') + '\n';
|
|
context += 'Chief Complaint: ' + chiefComplaint + '\n\n';
|
|
|
|
if (transcript) {
|
|
context += 'ENCOUNTER TRANSCRIPT/DICTATION:\n' + transcript + '\n\n';
|
|
} else if (dictation) {
|
|
context += 'PHYSICIAN DICTATION:\n' + dictation + '\n\n';
|
|
}
|
|
|
|
if (ros) {
|
|
context += ros + '\n\n';
|
|
}
|
|
|
|
if (physicalExam) {
|
|
context += physicalExam + '\n\n';
|
|
}
|
|
|
|
if (diagnoses) {
|
|
context += diagnoses + '\n\n';
|
|
}
|
|
|
|
if (physicianMemories) {
|
|
context += physicianMemories + '\n\n';
|
|
}
|
|
|
|
var result = await callAI([
|
|
{ role: 'system', content: PROMPTS.sickVisitNote },
|
|
{ role: 'user', content: context }
|
|
], { model });
|
|
|
|
var dur = Date.now() - start;
|
|
logger.apiCall(req.user.id, '/api/sick-visit/note', {
|
|
model: result.model, tokensInput: result.usage?.input_tokens,
|
|
tokensOutput: result.usage?.output_tokens, duration: dur, statusCode: 200
|
|
});
|
|
|
|
res.json({ success: true, note: result.content, model: result.model });
|
|
} catch (e) {
|
|
logger.error('[SickVisit] Note generation failed', e.message);
|
|
res.status(500).json({ error: e.message });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|