From c7f1bd4901b151b60d304fdf8543f566e662da1a Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 23 Mar 2026 18:12:07 +0100 Subject: [PATCH] Fix: chart review New clears all fields/notes, date context for AI, Bedrock vendor model-only models - resetChartReview() clears all pasted notes, visit cards, labs, demographics, and output on New - clearTab('chart') in encounters.js now calls resetChartReview() for complete reset - chartReview route injects today's date so AI understands time-relative terms - Bedrock models updated to vendor model-only with verified 2025 IDs (Sonnet 4, 3.7 Sonnet, 3.5 Sonnet v2, 3.5 Haiku) - Removed Llama/Mistral/Titan from Bedrock; fixed incorrect vendor-model-4.6 Bedrock IDs - Bump version to 2.8.0 --- package.json | 2 +- public/js/chartReview.js | 41 +++++++++++++++++++++++++++++++++++++++ public/js/encounters.js | 4 ++++ src/routes/chartReview.js | 3 ++- src/utils/models.js | 27 +++++++++----------------- 5 files changed, 57 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index ef2d5c2..abc6b6d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pediatric-ai-scribe", - "version": "2.1.0", + "version": "2.8.0", "description": "AI-powered pediatric clinical documentation platform", "main": "server.js", "scripts": { diff --git a/public/js/chartReview.js b/public/js/chartReview.js index 56dfee6..21b0f8d 100644 --- a/public/js/chartReview.js +++ b/public/js/chartReview.js @@ -10,6 +10,47 @@ var visitIndex = 1; + function resetChartReview() { + // Clear demographics and fields + ['cr-age', 'cr-pmh', 'cr-instructions', 'chart-label'].forEach(function(id) { + var el = document.getElementById(id); + if (el) el.value = ''; + }); + var gender = document.getElementById('cr-gender'); + if (gender) gender.value = ''; + var type = document.getElementById('cr-type'); + if (type) type.value = 'outpatient'; + + // Reset visit index and restore single empty visit card + visitIndex = 1; + visitsContainer.innerHTML = '
' + + '

Visit / Note #1

' + + '
' + + '
' + + '' + + '' + + '' + + '
' + + '
' + + '
'; + visitsContainer.querySelector('.remove-visit-btn').addEventListener('click', function() { + visitsContainer.querySelector('.visit-card').remove(); + }); + + // Clear labs container - restore single empty entry + labsContainer.innerHTML = '
' + + '' + + '' + + '
'; + + // Clear output + reviewText.textContent = ''; + outputCard.classList.add('hidden'); + } + + // Expose for encounters.js clearTab + window.resetChartReview = resetChartReview; + addVisitBtn.addEventListener('click', function() { visitIndex++; var card = document.createElement('div'); diff --git a/public/js/encounters.js b/public/js/encounters.js index 8b39102..34660dd 100644 --- a/public/js/encounters.js +++ b/public/js/encounters.js @@ -429,6 +429,10 @@ // Reset saved ID (memory + sessionStorage) window['_savedEncId_' + type] = null; try { sessionStorage.removeItem('_savedEncId_' + type); } catch(e) {} + // Chart review has additional fields/cards to clear + if (type === 'chart' && typeof window.resetChartReview === 'function') { + window.resetChartReview(); + } showToast('Ready for new patient', 'info'); } diff --git a/src/routes/chartReview.js b/src/routes/chartReview.js index 6b5cdee..8c96e6c 100644 --- a/src/routes/chartReview.js +++ b/src/routes/chartReview.js @@ -18,8 +18,9 @@ router.post('/generate-chart-review', authMiddleware, async (req, res) => { additionalInstructions } = req.body; + const today = new Date().toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }); let prompt; - let clinicalData = `Patient: ${patientAge || 'Unknown'}, ${patientGender || 'Unknown'}`; + let clinicalData = `Today's date: ${today}\nPatient: ${patientAge || 'Unknown'}, ${patientGender || 'Unknown'}`; if (pmh) clinicalData += `\nPMH: ${pmh}`; if (type === 'ed' || (edVisits && edVisits.length > 0)) { diff --git a/src/utils/models.js b/src/utils/models.js index 6f94e26..9300925 100644 --- a/src/utils/models.js +++ b/src/utils/models.js @@ -27,24 +27,15 @@ var OPENROUTER_MODELS = [ ]; var BEDROCK_MODELS = [ - { id: 'anthropic/vendor-model-opus-4-6', name: 'vendor model Opus 4.6', cost: '~$0.075', tag: 'BEST NUANCE', category: 'premium', - bedrockId: 'anthropic.agent-config-opus-4-6-20251001-v1:0' }, - { id: 'anthropic/vendor-model-sonnet-4-6', name: 'vendor model Sonnet 4.6', cost: '~$0.015', tag: 'RECOMMENDED', category: 'premium', - bedrockId: 'anthropic.agent-config-sonnet-4-6-20251001-v1:0' }, - { id: 'anthropic/vendor-model-sonnet-4', name: 'vendor model Sonnet 4', cost: '~$0.015', tag: 'BEST', category: 'premium', + // vendor model models only — verified Bedrock IDs (2025) + { id: 'anthropic/vendor-model-sonnet-4', name: 'vendor model Sonnet 4', cost: '~$0.015', tag: 'RECOMMENDED', category: 'premium', bedrockId: 'anthropic.agent-config-sonnet-4-20250514-v1:0' }, - { id: 'anthropic/vendor-model-3.5-sonnet', name: 'vendor model 3.5 Sonnet', cost: '~$0.015', tag: 'MEDICAL', category: 'premium', + { id: 'anthropic/vendor-model-3-7-sonnet', name: 'vendor model 3.7 Sonnet', cost: '~$0.015', tag: 'SMART', category: 'premium', + bedrockId: 'anthropic.agent-config-3-7-sonnet-20250219-v1:0' }, + { id: 'anthropic/vendor-model-3.5-sonnet', name: 'vendor model 3.5 Sonnet v2', cost: '~$0.015', tag: 'MEDICAL', category: 'premium', bedrockId: 'anthropic.agent-config-3-5-sonnet-20241022-v2:0' }, - { id: 'anthropic/vendor-model-3-haiku', name: 'vendor model 3 Haiku', cost: '~$0.001', tag: 'CHEAPEST', category: 'fast', - bedrockId: 'anthropic.agent-config-3-haiku-20240307-v1:0' }, - { id: 'meta-llama/llama-3.1-70b', name: 'Llama 3.1 70B', cost: '~$0.003', tag: 'GOOD', category: 'smart', - bedrockId: 'meta.llama3-1-70b-instruct-v1:0' }, - { id: 'meta-llama/llama-3.1-8b', name: 'Llama 3.1 8B', cost: '~$0.001', tag: 'FAST', category: 'fast', - bedrockId: 'meta.llama3-1-8b-instruct-v1:0' }, - { id: 'mistral/mistral-large', name: 'Mistral Large', cost: '~$0.008', tag: 'GOOD', category: 'smart', - bedrockId: 'mistral.mistral-large-2407-v1:0' }, - { id: 'amazon/titan-text-premier', name: 'Amazon Titan Premier', cost: '~$0.002', tag: 'AWS', category: 'fast', - bedrockId: 'amazon.titan-text-premier-v1:0' } + { id: 'anthropic/vendor-model-3.5-haiku', name: 'vendor model 3.5 Haiku', cost: '~$0.003', tag: 'FAST', category: 'smart', + bedrockId: 'anthropic.agent-config-3-5-haiku-20241022-v1:0' } ]; var AZURE_MODELS = [ @@ -69,7 +60,7 @@ function getAvailableModels() { function getDefaultModel() { switch (activeProvider) { - case 'bedrock': return 'anthropic/vendor-model-sonnet-4-6'; + case 'bedrock': return 'anthropic/vendor-model-sonnet-4'; case 'azure': return process.env.AZURE_DEPLOYMENT_NAME || 'gpt-4o-mini'; case 'openrouter': default: return 'google/gemini-2.5-flash'; @@ -78,7 +69,7 @@ function getDefaultModel() { function getFallbackModel() { switch (activeProvider) { - case 'bedrock': return 'meta-llama/llama-3.1-8b'; + case 'bedrock': return 'anthropic/vendor-model-3.5-haiku'; case 'azure': return process.env.AZURE_DEPLOYMENT_NAME || 'gpt-4o-mini'; case 'openrouter': default: return 'deepseek/deepseek-chat-v3-0324';