// ============================================================ // WELL VISIT / PREVENTIVE CARE TAB // ============================================================ (function () { 'use strict'; // ─── Human-readable labels ───────────────────────────────────────────────── var SCREEN_LABELS = { maternalDepression: 'Maternal/Caregiver Depression Screen (Edinburgh/PHQ)', developmentalScreening: 'Developmental Screening (ASQ / PEDS)', autismScreening: 'Autism Screening (M-CHAT-R)', developmentalSurveillance:'Developmental Surveillance', behavioralScreening: 'Social-Emotional/Behavioral Screening (ASQ:SE)', tobaccoAlcoholDrugs: 'Tobacco / Alcohol / Drug Use Screening (CRAFFT/AUDIT)', depressionSuicideRisk: 'Depression & Suicide Risk Screening (PHQ-A)', }; var PROC_LABELS = { newbornBlood: 'Newborn Blood Spot Screening (NBS)', newbornBilirubin: 'Newborn Bilirubin (TcB or TSB)', criticalCHD: 'Critical CHD Screening (Pulse Ox)', immunization: 'Immunizations Review & Update', anemia: 'Anemia Screening (Hgb/Hct)', lead: 'Lead Exposure Risk / Blood Lead Level', tuberculosis: 'Tuberculosis / Latent TB Risk Assessment', dyslipidemia: 'Dyslipidemia Screening (lipid panel)', sti: 'STI Screening (gonorrhea / chlamydia / syphilis)', hiv: 'HIV Screening', hepB: 'Hepatitis B Screening (HBsAg)', hepC: 'Hepatitis C Screening (anti-HCV)', suddenCardiacArrest:'Sudden Cardiac Arrest Risk Assessment', cervicalDysplasia: 'Cervical Dysplasia Screening (Pap smear)', }; var MEASURE_LABELS = { lengthHeight: 'Length / Height', weight: 'Weight', headCircumference: 'Head Circumference', weightForLength: 'Weight-for-Length', bmi: 'BMI', bloodPressure: 'Blood Pressure', }; var ORAL_LABELS = { assessment: 'Oral Health Risk Assessment', fluorideVarnish: 'Fluoride Varnish Application', fluorideSupplementation:'Fluoride Supplementation (if water <0.6 ppm)', }; var SENSORY_LABELS = { vision: 'Vision Screening', hearing: 'Hearing Screening', }; var VACCINE_FULL_NAMES = { HepB: 'Hepatitis B (HepB)', RV: 'Rotavirus (RV)', DTaP: 'DTaP (Diphtheria, Tetanus, Pertussis)', Hib: 'Hib (Haemophilus influenzae type b)', PCV: 'Pneumococcal (PCV)', IPV: 'Polio (IPV)', Flu_IIV: 'Influenza (IIV)', MMR: 'MMR (Measles, Mumps, Rubella)', VAR: 'Varicella (VAR)', HepA: 'Hepatitis A (HepA)', Tdap: 'Tdap (Tetanus, Diphtheria, Pertussis booster)', HPV: 'HPV (Human Papillomavirus)', MenACWY: 'Meningococcal ACWY (MenACWY)', MenB: 'Meningococcal B (MenB)', RSV_mAb: 'RSV Monoclonal Antibody (Nirsevimab/Beyfortus)', COVID: 'COVID-19', Dengue: 'Dengue (DEN4CYD / Dengvaxia)', Mpox: 'Mpox (JYNNEOS)', }; // ─── Init ────────────────────────────────────────────────────────────────── function init() { populateVisitSelect(); renderCatchUp(); renderFullSchedule(); document.getElementById('wv-visit-select').addEventListener('change', onVisitChange); document.querySelectorAll('.wv-subtab-btn').forEach(function (btn) { btn.addEventListener('click', function () { switchSubtab(btn.dataset.subtab); }); }); // Show first real visit by default var sel = document.getElementById('wv-visit-select'); if (sel && sel.value) onVisitChange(); } function populateVisitSelect() { var sel = document.getElementById('wv-visit-select'); if (!sel || typeof VISIT_AGES === 'undefined') return; var grouped = {}; VISIT_AGES.forEach(function (v) { if (!grouped[v.era]) grouped[v.era] = []; grouped[v.era].push(v); }); var eraNames = { prenatal: 'Prenatal', infancy: 'Infancy (0–12 mo)', earlyChildhood: 'Early Childhood (1–5 y)', middleChildhood: 'Middle Childhood (6–11 y)', adolescence: 'Adolescence (11–21 y)', }; Object.keys(grouped).forEach(function (era) { var og = document.createElement('optgroup'); og.label = eraNames[era] || era; grouped[era].forEach(function (v) { var opt = document.createElement('option'); opt.value = v.id; opt.textContent = v.label; og.appendChild(opt); }); sel.appendChild(og); }); // select newborn by default sel.value = 'newborn'; } function onVisitChange() { var visitId = document.getElementById('wv-visit-select').value; if (!visitId) return; renderVisitPanel(visitId); } function switchSubtab(name) { document.querySelectorAll('.wv-subtab-btn').forEach(function (b) { b.classList.toggle('active', b.dataset.subtab === name); }); document.querySelectorAll('.wv-subpanel').forEach(function (p) { p.classList.toggle('hidden', p.id !== 'wv-panel-' + name); }); } // ─── BY VISIT panel ─────────────────────────────────────────────────────── function renderVisitPanel(visitId) { var data = (typeof PERIODICITY !== 'undefined') ? PERIODICITY[visitId] : null; var codes = (typeof WELL_VISIT_CODES !== 'undefined') ? WELL_VISIT_CODES[visitId] : null; var panel = document.getElementById('wv-visit-detail'); if (!panel) return; if (!data) { panel.innerHTML = '
No data for this visit.
'; return; } var html = ''; // ── Billing codes ── if (codes) { html += 'No specific recommendations found for this visit.
'; } function buildStatusItems(obj, labels, exclude) { exclude = exclude || []; return Object.keys(obj).filter(function (k) { return obj[k] && obj[k] !== '' && exclude.indexOf(k) === -1; }).map(function (k) { return { key: k, status: obj[k], label: labels[k] || k }; }); } function renderScreenItems(items) { var html = '| Dose | Min Age | Min Interval from Prev | Notes |
|---|---|---|---|
| Dose ' + esc(String(s.dose)) + ' | '; html += '' + esc(s.minimumAge || '—') + ' | '; html += '' + esc(s.minimumIntervalToPrev || '—') + ' | '; html += '' + esc(s.notes || '') + ' | '; html += '
| Vaccine | '; visitLabels.forEach(function (v) { html += '' + esc(v.label) + ' | '; }); html += '|
|---|---|---|
| ' + esc(fullName) + ' | '; visitLabels.forEach(function (visit) { var vaxData = PERIODICITY[visit.id] && PERIODICITY[visit.id].vaccines; var match = vaxData && vaxData.find(function (v) { return v.vaccine === vaxKey; }); if (match) { var dose = match.dose ? String(match.dose) : '•'; var label = (typeof match.dose === 'number') ? '#' + dose : dose; html += '' + esc(label) + ' | '; } else { html += ''; } }); html += ' |
Dose number shown. Hover cells for notes. "#N" = routine dose N. "annual" / "seasonal" = per CDC guidance. "catch-up" = as needed.
'; panel.innerHTML = html; } function esc(str) { if (!str) return ''; return String(str) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"'); } // ─── Wire up ─────────────────────────────────────────────────────────────── document.addEventListener('DOMContentLoaded', function () { // Run when tab becomes visible (lazy init) var initialized = false; document.addEventListener('tabChanged', function (e) { if (e.detail && e.detail.tab === 'wellvisit' && !initialized) { initialized = true; init(); } }); }); })();