let currentPatientId = null; // The chart most recently loaded. Add-forms read the MRN from here so the // generated identifiers can merge Patient ID + MRN without another fetch. let currentChart = null; let patientsCache = []; let patientSearchTerm = ''; function showSpinner(show) { document.getElementById('spinnerOverlay').style.display = show ? 'flex' : 'none'; } function showToast(message, variant = 'success') { const container = document.getElementById('toastContainer'); const el = document.createElement('div'); el.className = `toast align-items-center text-bg-${variant} border-0 show mb-2`; el.innerHTML = `