/* Shared analysis data — the canned "coding assessment" used by the live demo,
   matching the reference screens (T2DM + HTN + hyperlipidemia, CPT 99213, Moderate MDM). */

const SAMPLE_NOTE = `OFFICE/OUTPATIENT VISIT — ESTABLISHED PATIENT

CC: Follow-up of type 2 diabetes and hypertension.

HPI: 58 y/o established patient returns for 3-month follow-up. Reports
home glucose readings running 180–230 mg/dL despite adherence to metformin
1000 mg BID. Denies polyuria, blurred vision, chest pain. Home BP log
averaging 138/86. Tolerating lisinopril without cough.

ASSESSMENT & PLAN:
1. Type 2 diabetes mellitus, poorly controlled — A1c 8.4% (reviewed).
   Increase metformin and add titration plan; reviewed home glucose log.
2. Essential hypertension, stable on lisinopril 10 mg daily. Continue.
3. Hyperlipidemia — continue statin, recheck lipid panel at next visit.

Reviewed prior labs and home monitoring data. Prescription drug management
this encounter. RTC 3 months.`;

const ANALYSIS = {
  status: "success",
  encounter_classification: "office_outpatient",
  patient_status_classified: "established",
  confidence: "high",
  unsupported_encounter_type: null,
  missing_information: null,
  message_to_user: null,
  suggested_missing_information: [
    "Add timeframe of metformin titration for clearer audit trail.",
    "Document follow-up interval and patient education delivered.",
  ],
  recommended_cpt: {
    code: "99213",
    rationale: "Established Patient Office or Other Outpatient Visit, Moderate MDM.",
    summary: "The MDM level for this established patient encounter is moderate, driven by a moderate level for problems and risk, and a low level for data.",
  },
  alternative_cpt: "99214 — Considered if problems or risk could be argued as high.",
  mdm_coding_rationale: {
    this_case_summary: "The final MDM level is moderate, based on two elements (Problems and Risk) meeting the moderate criteria, while Data met the low criteria.",
    why_lower_insufficient: "A lower MDM level (low or straightforward) is insufficient because the management of the patient's chronic illness with exacerbation requires prescription drug management.",
    problems: {
      level: "moderate",
      summary: "One chronic illness with exacerbation (poorly controlled Type 2 diabetes) and one stable chronic illness (hypertension).",
      evidence: [
        { quote: "Type 2 diabetes mellitus, poorly controlled.", reason: "Chronic illness with exacerbation/progression." },
        { quote: "Essential hypertension, stable on lisinopril.", reason: "Stable chronic illness." },
      ],
    },
    data: {
      level: "low",
      summary: "Review of prior external notes and independent review of home glucose monitoring data.",
      evidence: [
        { quote: "Reviewed prior labs and home monitoring data.", reason: "Review of prior external note(s) / unique test." },
      ],
    },
    risk: {
      level: "moderate",
      summary: "Prescription drug management documented this encounter.",
      evidence: [
        { quote: "Prescription drug management this encounter.", reason: "Prescription drug management = moderate risk." },
      ],
    },
    final: "moderate",
  },
  icd_suggestions: [
    { code:"E11.65", desc:"Type 2 diabetes mellitus with hyperglycemia", confidence:"high" },
    { code:"I10",    desc:"Essential (primary) hypertension", confidence:"high" },
    { code:"E78.5",  desc:"Hyperlipidemia, unspecified", confidence:"moderate" },
  ],
  guidance_summary: "The note supports a moderate MDM with two qualifying elements (Problems, Risk). CPT 99213 is the appropriate billable code for this established outpatient encounter.",
  strengths: [
    "Clear documentation of chronic conditions and exacerbation status.",
    "Prescription drug management explicitly recorded.",
    "Reviewed home monitoring data noted in the encounter.",
  ],
};

// processing steps for the live animation
const PIPELINE = [
  { k:"parse",    label:"Parsing clinical note",        icon:"doc"      },
  { k:"extract",  label:"Extracting problems & data",   icon:"spark"    },
  { k:"mdm",      label:"Scoring MDM elements",         icon:"activity" },
  { k:"cpt",      label:"Mapping CPT recommendation",   icon:"layers"   },
  { k:"icd",      label:"Generating ICD candidates",    icon:"workflow" },
  { k:"audit",    label:"Compiling evidence audit",     icon:"shield"   },
];

Object.assign(window, { SAMPLE_NOTE, ANALYSIS, PIPELINE });
