// chart-data.jsx — Doe, John A. The same patient as v1, deepened.
// Single source of truth for every pane in the Epic zone.
// Exports on window: PATIENT, LAB_DATES, LABS, MEDS, PROBLEMS, ALLERGIES,
//                    CONSULTS, IO_DATA, VITALS, PRIOR_NOTES, FORMULARY

const PATIENT = {
  name: 'Doe, John A',
  initials: 'JD',
  sex: 'Male',
  age: 67,
  dob: '3/14/1959',
  mrn: '4729-3841',
  csn: '8813-220-4471',
  phone: '617-555-0182',
  location: '7N-412B',
  bed: 'MGH White 7 · Bed B',
  code: 'Full Code',
  advDirectives: 'Not on File',
  pharmacy: 'MGH Outpatient',
  aco: 'No',
  admitDay: 4,
  service: 'Nephrology Inpatient',
  attending: 'Weaver, Margaret R, MD',
  resident: 'Okonkwo, Daniel, MD',
  summary: 'AKI on CKD; HTN; T2DM',
  isolation: 'Contact — MRSA hx',
  weight: '82.4 kg',
  bmi: '26.8 kg/m²',
  bp: '148/88',
  hr: '74',
};

const LAB_DATES = ['04/25', '04/26', '04/27', '04/28', '04/29 AM', '04/29 PM', '04/30'];

// vals align to LAB_DATES. '—' = not resulted.
const LABS = [
  { panel: 'BMP',   name: 'Creatinine',   ref: '0.6–1.2 mg/dL',  vals: ['1.4 ↑','1.6 ↑','1.8 ↑','2.1 ↑','2.6 ↑','2.4 ↑','2.1 ↑'] },
  { panel: 'BMP',   name: 'BUN',          ref: '7–25 mg/dL',     vals: ['26 ↑','29 ↑','32 ↑','36 ↑','44 ↑','40 ↑','38 ↑'] },
  { panel: 'BMP',   name: 'Potassium',    ref: '3.5–5.1 mEq/L',  vals: ['4.1','4.3','4.4','4.7','5.4 ↑','5.8 ↑','4.2'] },
  { panel: 'BMP',   name: 'Sodium',       ref: '136–145 mEq/L',  vals: ['141','140','140','139','138','137','138'] },
  { panel: 'BMP',   name: 'Chloride',     ref: '98–107 mEq/L',   vals: ['104','103','104','102','101','100','102'] },
  { panel: 'BMP',   name: 'CO2',          ref: '22–29 mEq/L',    vals: ['24','23','22','21 ↓','19 ↓','20 ↓','22'] },
  { panel: 'BMP',   name: 'Glucose',      ref: '70–99 mg/dL',    vals: ['142 ↑','168 ↑','154 ↑','188 ↑','201 ↑','176 ↑','149 ↑'] },
  { panel: 'BMP',   name: 'Calcium',      ref: '8.5–10.2 mg/dL', vals: ['9.1','9.0','8.8','8.6','8.4 ↓','8.5','8.7'] },
  { panel: 'BMP',   name: 'Phosphorus',   ref: '2.5–4.5 mg/dL',  vals: ['3.8','4.1','4.4','4.8 ↑','5.6 ↑','5.2 ↑','4.6 ↑'] },
  { panel: 'BMP',   name: 'Magnesium',    ref: '1.7–2.2 mg/dL',  vals: ['2.0','1.9','1.8','1.7','1.6 ↓','1.8','1.9'] },
  { panel: 'RENAL', name: 'eGFR',         ref: '≥60 mL/min',     vals: ['52 ↓','46 ↓','41 ↓','38 ↓','29 ↓','31 ↓','34 ↓'] },
  { panel: 'RENAL', name: 'BUN/Cr ratio', ref: '10–20',          vals: ['18.6','18.1','17.8','17.1','16.9','16.7','18.1'] },
  { panel: 'RENAL', name: 'FENa',         ref: '<1% pre-renal',  vals: ['—','—','0.7','—','0.6','—','0.8'] },
  { panel: 'RENAL', name: 'Urine Na',     ref: '—',              vals: ['—','—','18','—','14','—','21'] },
  { panel: 'CBC',   name: 'WBC',          ref: '4.0–11.0 K/uL',  vals: ['12.4 ↑','13.8 ↑','14.6 ↑','13.1 ↑','11.8 ↑','11.2 ↑','9.8'] },
  { panel: 'CBC',   name: 'Hemoglobin',   ref: '13.5–17.5 g/dL', vals: ['11.8 ↓','11.4 ↓','11.1 ↓','10.6 ↓','10.2 ↓','10.4 ↓','10.6 ↓'] },
  { panel: 'CBC',   name: 'Hematocrit',   ref: '41–53 %',        vals: ['35.2 ↓','34.1 ↓','33.4 ↓','31.8 ↓','30.6 ↓','31.2 ↓','31.9 ↓'] },
  { panel: 'CBC',   name: 'Platelets',    ref: '150–400 K/uL',   vals: ['212','198','186','174','168','171','182'] },
  { panel: 'HEP',   name: 'Albumin',      ref: '3.5–5.0 g/dL',   vals: ['3.4 ↓','3.3 ↓','3.2 ↓','3.0 ↓','2.8 ↓','2.9 ↓','3.0 ↓'] },
  { panel: 'HEP',   name: 'Total bili',   ref: '0.2–1.2 mg/dL',  vals: ['0.8','0.9','0.9','1.0','1.1','1.0','0.9'] },
  { panel: 'DRUG',  name: 'Vanc trough',  ref: '15–20 mcg/mL',   vals: ['—','—','—','12.1 ↓','—','—','18.4'] },
  { panel: 'DRUG',  name: 'Vanc peak',    ref: '25–40 mcg/mL',   vals: ['—','—','—','31.2','—','—','—'] },
];

const MEDS = [
  { name: 'Vancomycin',            sig: '1,250 mg IV q24h — infuse over 120 min', start: '04/26', route: 'IV',  status: 'Active',  cls: 'Antibiotic', flag: 'renal' },
  { name: 'Piperacillin-Tazobactam', sig: '3.375 g IV q8h — extended infusion 4h', start: '04/26', route: 'IV', status: 'Active',  cls: 'Antibiotic', flag: 'renal' },
  { name: 'Furosemide',            sig: '40 mg IV BID', start: '04/29', route: 'IV', status: 'Active', cls: 'Diuretic', flag: '' },
  { name: 'Lisinopril',            sig: '10 mg PO daily', start: '—', route: 'PO', status: 'HELD',  cls: 'ACE inhibitor', flag: 'held' },
  { name: 'Metoprolol succinate',  sig: '50 mg PO daily', start: '04/25', route: 'PO', status: 'Active', cls: 'Beta blocker', flag: '' },
  { name: 'Amlodipine',            sig: '5 mg PO daily', start: '04/25', route: 'PO', status: 'Active', cls: 'CCB', flag: '' },
  { name: 'Insulin glargine',      sig: '18 units subcut QHS', start: '04/25', route: 'SubQ', status: 'Active', cls: 'Insulin', flag: '' },
  { name: 'Insulin lispro',        sig: 'Sliding scale subcut AC/HS', start: '04/25', route: 'SubQ', status: 'Active', cls: 'Insulin', flag: '' },
  { name: 'Atorvastatin',          sig: '40 mg PO QHS', start: '04/25', route: 'PO', status: 'Active', cls: 'Statin', flag: '' },
  { name: 'Pantoprazole',          sig: '40 mg PO daily', start: '04/25', route: 'PO', status: 'Active', cls: 'PPI', flag: '' },
  { name: 'Heparin',               sig: '5,000 units subcut q8h — VTE ppx', start: '04/25', route: 'SubQ', status: 'Active', cls: 'Anticoagulant', flag: '' },
  { name: 'Sodium bicarbonate',    sig: '650 mg PO TID', start: '04/28', route: 'PO', status: 'Active', cls: 'Alkalinizing', flag: '' },
  { name: 'Calcium acetate',       sig: '667 mg PO TID with meals', start: '04/29', route: 'PO', status: 'Active', cls: 'Phos binder', flag: '' },
  { name: 'Acetaminophen',         sig: '650 mg PO q6h PRN pain', start: '04/25', route: 'PO', status: 'PRN', cls: 'Analgesic', flag: '' },
];

const PROBLEMS = [
  { n: 1,  name: 'Acute kidney injury on chronic kidney disease stage G3a', icd: 'N17.9', onset: '04/25/2026', by: 'Weaver, M' },
  { n: 2,  name: 'Chronic kidney disease, stage 3a (eGFR 45–59)', icd: 'N18.31', onset: '11/02/2023', by: 'Weaver, M' },
  { n: 3,  name: 'Essential hypertension', icd: 'I10', onset: '06/14/2011', by: 'Ruiz, A' },
  { n: 4,  name: 'Type 2 diabetes mellitus with diabetic nephropathy', icd: 'E11.21', onset: '03/20/2014', by: 'Ruiz, A' },
  { n: 5,  name: 'Healthcare-associated pneumonia', icd: 'J18.9', onset: '04/25/2026', by: 'Patel, S' },
  { n: 6,  name: 'Anemia of chronic kidney disease', icd: 'D63.1', onset: '08/09/2024', by: 'Weaver, M' },
  { n: 7,  name: 'Secondary hyperparathyroidism of renal origin', icd: 'N25.81', onset: '01/17/2025', by: 'Weaver, M' },
  { n: 8,  name: 'Hyperlipidemia, mixed', icd: 'E78.2', onset: '06/14/2011', by: 'Ruiz, A' },
  { n: 9,  name: 'Hyperkalemia', icd: 'E87.5', onset: '04/29/2026', by: 'Okonkwo, D' },
  { n: 10, name: 'Metabolic acidosis', icd: 'E87.2', onset: '04/28/2026', by: 'Okonkwo, D' },
  { n: 11, name: 'History of MRSA colonization', icd: 'Z22.322', onset: '02/11/2022', by: 'Patel, S' },
];

const ALLERGIES = [
  { agent: 'Sulfamethoxazole-Trimethoprim', reaction: 'Rash, urticaria', severity: 'Moderate', noted: '05/2009' },
  { agent: 'Iodinated contrast media', reaction: 'Hives, flushing', severity: 'Moderate', noted: '09/2019' },
  { agent: 'Codeine', reaction: 'Nausea, vomiting', severity: 'Low (intolerance)', noted: '03/2015' },
  { agent: 'Adhesive tape', reaction: 'Contact dermatitis', severity: 'Low', noted: '07/2021' },
];

const CONSULTS = [
  { service: 'Infectious Disease', md: 'Patel, Sunita, MD', called: '04/26', status: 'Following', lastNote: '04/30 06:41' },
  { service: 'Pharmacy — Renal Dosing', md: 'Nguyen, Thu, PharmD', called: '04/26', status: 'Following', lastNote: '04/30 05:12' },
  { service: 'Endocrinology', md: 'Adeyemi, Kofi, MD', called: '04/27', status: 'Sign-off pending', lastNote: '04/29 14:20' },
];

const IO_DATA = [
  { date: '04/27', inPO: 720, inIV: 1450, out: 1180, net: 990,   weight: '84.1 kg' },
  { date: '04/28', inPO: 640, inIV: 1600, out: 1020, net: 1220,  weight: '84.9 kg' },
  { date: '04/29', inPO: 580, inIV: 1350, out: 2640, net: -710,  weight: '83.2 kg' },
  { date: '04/30', inPO: 610, inIV: 900,  out: 2180, net: -670,  weight: '82.4 kg' },
];

const VITALS = [
  { t: '04/30 04:00', bp: '152/90', hr: 78, rr: 18, temp: '37.1', spo2: '95%' },
  { t: '04/30 08:00', bp: '148/88', hr: 74, rr: 17, temp: '36.9', spo2: '96%' },
  { t: '04/29 20:00', bp: '158/94', hr: 82, rr: 19, temp: '37.4', spo2: '94%' },
  { t: '04/29 12:00', bp: '162/96', hr: 88, rr: 20, temp: '37.8', spo2: '93%' },
];

const PRIOR_NOTES = [
  { day: 4, date: '04/30 06:41', author: 'Patel, Sunita, MD',   svc: 'Infectious Disease', title: 'ID Progress Note', words: 612 },
  { day: 4, date: '04/30 05:12', author: 'Nguyen, Thu, PharmD', svc: 'Pharmacy',           title: 'Renal Dosing Consult', words: 388 },
  { day: 3, date: '04/29 07:18', author: 'Okonkwo, Daniel, MD', svc: 'Nephrology',         title: 'Progress Note', words: 1890 },
  { day: 2, date: '04/28 07:02', author: 'Okonkwo, Daniel, MD', svc: 'Nephrology',         title: 'Progress Note', words: 1140 },
  { day: 1, date: '04/27 06:55', author: 'Weaver, Margaret, MD', svc: 'Nephrology',        title: 'H&P / Admission Note', words: 312 },
];

// 18 near-identical formulations. This is not an exaggeration.
const FORMULARY = [
  'lisinopril 2.5 mg tablet',
  'lisinopril 5 mg tablet',
  'lisinopril 10 mg tablet',
  'lisinopril 20 mg tablet',
  'lisinopril 30 mg tablet',
  'lisinopril 40 mg tablet',
  'lisinopril 10 mg tablet [FORMULARY ALT]',
  'lisinopril 20 mg tablet [FORMULARY ALT]',
  'lisinopril-hydrochlorothiazide 10-12.5 mg tablet',
  'lisinopril-hydrochlorothiazide 20-12.5 mg tablet',
  'lisinopril-hydrochlorothiazide 20-25 mg tablet',
  'lisinopril 1 mg/mL oral suspension (compounded)',
  'lisinopril 10 mg tablet [HOME MED — do not use inpatient]',
  'lisinopril 20 mg tablet [HOME MED — do not use inpatient]',
  'LISINOPRIL 10 MG TAB (legacy record — inactive)',
  'lisinopril 5 mg tablet [NON-FORMULARY — requires approval]',
  'lisinopril 40 mg tablet [NON-FORMULARY — requires approval]',
  'Zestril 10 mg tablet (brand)',
];

Object.assign(window, {
  PATIENT, LAB_DATES, LABS, MEDS, PROBLEMS, ALLERGIES,
  CONSULTS, IO_DATA, VITALS, PRIOR_NOTES, FORMULARY,
});
