"""CDC Infection Control Guidelines for Dental Settings — 40+ checks.

Based on CDC MMWR 2003 Guidelines for Infection Control in Dental Health-Care
Settings and 2016 Summary of Infection Prevention Practices in Dental Settings.
"""

from __future__ import annotations

CDC_INFECTION_CONTROLS: dict = {
    # ── Hand Hygiene ──
    "HH-1": {
        "name": "Hand Hygiene Protocols",
        "regulation_reference": "CDC MMWR 2003; WHO 5 Moments for Hand Hygiene",
        "checks": [
            {
                "id": "HH-1.1",
                "check": "Hand hygiene performed before and after each patient contact",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Implement WHO 5 Moments adapted for dental: (1) before patient contact, (2) before aseptic procedure, (3) after body fluid exposure, (4) after patient contact, (5) after touching patient surroundings.",
                "practice_types": ["all"],
            },
            {
                "id": "HH-1.2",
                "check": "Alcohol-based hand rub (ABHR) dispensers accessible in each operatory",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Install ABHR dispensers (60-95% alcohol) at point of care in each operatory. Must be accessible without touching contaminated surfaces.",
                "practice_types": ["all"],
            },
            {
                "id": "HH-1.3",
                "check": "Surgical hand antisepsis performed before surgical procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use antimicrobial soap and water OR alcohol-based surgical hand rub before surgical procedures (extractions, implants, periodontal surgery).",
                "practice_types": ["all"],
            },
            {
                "id": "HH-1.4",
                "check": "No artificial nails or extenders worn by clinical staff",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Prohibit artificial nails, nail extenders, and chipped nail polish for clinical staff. Natural nails kept short (< 1/4 inch).",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Surface Disinfection ──
    "SURF-1": {
        "name": "Surface Disinfection",
        "regulation_reference": "CDC MMWR 2003 — Environmental Infection Control",
        "checks": [
            {
                "id": "SURF-1.1",
                "check": "Clinical contact surfaces cleaned and disinfected between patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Clean and disinfect all clinical contact surfaces (light handles, chair switches, countertops, drawer handles) between patients using EPA-registered hospital disinfectant.",
                "practice_types": ["all"],
            },
            {
                "id": "SURF-1.2",
                "check": "Surface barriers used on difficult-to-clean surfaces",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Apply barrier protection (plastic wrap, plastic-backed paper) to surfaces difficult to clean: light handles, x-ray heads, chair controls, computer keyboards/mice.",
                "practice_types": ["all"],
            },
            {
                "id": "SURF-1.3",
                "check": "EPA-registered hospital disinfectant used with proper contact time",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use EPA-registered intermediate-level disinfectant (tuberculocidal claim). Follow manufacturer instructions for dilution and contact time. Document product and protocol.",
                "practice_types": ["all"],
            },
            {
                "id": "SURF-1.4",
                "check": "Housekeeping surfaces (floors, walls, sinks) cleaned on schedule",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Clean housekeeping surfaces with detergent and water on a regular basis and when visibly soiled. Use EPA-registered disinfectant for blood spills.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Instrument Processing ──
    "INST-1": {
        "name": "Instrument Processing — Cleaning",
        "regulation_reference": "CDC MMWR 2003 — Sterilization/Disinfection of Patient-Care Items",
        "checks": [
            {
                "id": "INST-1.1",
                "check": "Contaminated instruments transported safely to processing area",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Transport contaminated instruments in covered, puncture-resistant containers. Dedicated pathway from operatory to sterilization area.",
                "practice_types": ["all"],
            },
            {
                "id": "INST-1.2",
                "check": "Instruments cleaned before sterilization (ultrasonic or automated washer)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Clean all instruments before sterilization. Preferred: ultrasonic cleaner or instrument washer-disinfector. Manual scrubbing only if mechanical cleaning unavailable. Use heavy-duty gloves.",
                "practice_types": ["all"],
            },
            {
                "id": "INST-1.3",
                "check": "Instruments inspected for visible debris after cleaning",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Visually inspect cleaned instruments under magnification if needed. Re-clean any instrument with visible debris before packaging.",
                "practice_types": ["all"],
            },
        ],
    },
    "INST-2": {
        "name": "Instrument Processing — Packaging and Storage",
        "regulation_reference": "CDC MMWR 2003 — Sterilization/Disinfection",
        "checks": [
            {
                "id": "INST-2.1",
                "check": "Instruments packaged before sterilization using appropriate wrapping",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Package instruments in wraps, pouches, or rigid containers compatible with the sterilization method. Packages allow steam/chemical penetration.",
                "practice_types": ["all"],
            },
            {
                "id": "INST-2.2",
                "check": "Sterilized packages stored in clean, dry, covered area",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Store sterilized packages in closed, clean, dry cabinets or drawers. Event-related shelf life — re-sterilize if package compromised (wet, torn, dropped).",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Dental Unit Waterlines ──
    "DUWL-1": {
        "name": "Dental Unit Waterline Management",
        "regulation_reference": "CDC MMWR 2003 — Dental Unit Waterlines",
        "checks": [
            {
                "id": "DUWL-1.1",
                "check": "Dental unit waterline (DUWL) testing performed at least quarterly",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Test DUWL output water at least quarterly. Target: <500 CFU/mL (EPA drinking water standard). Document results and corrective actions.",
                "practice_types": ["all"],
            },
            {
                "id": "DUWL-1.2",
                "check": "DUWL treatment protocol in place (chemical or filtration)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use waterline treatment products (tablets, cartridges, or continuous systems) per manufacturer instructions. Options: chemical treatment, in-line filtration, independent water reservoirs.",
                "practice_types": ["all"],
            },
            {
                "id": "DUWL-1.3",
                "check": "Waterlines flushed for 20-30 seconds between patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Flush dental waterlines for 20-30 seconds between patients to reduce microbial count. Flush 2+ minutes at start of day.",
                "practice_types": ["all"],
            },
            {
                "id": "DUWL-1.4",
                "check": "Sterile saline or sterile water used for surgical procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Use sterile saline or sterile water as coolant/irrigant for surgical procedures (implant placement, extractions with bone removal). Do NOT use DUWL output for surgery.",
                "practice_types": ["oral_surgery", "perio", "all"],
            },
        ],
    },
    # ── Single-Use Devices ──
    "SUD-1": {
        "name": "Single-Use Device Protocols",
        "regulation_reference": "CDC MMWR 2003 — Single-Use Devices",
        "checks": [
            {
                "id": "SUD-1.1",
                "check": "Single-use devices disposed after one use (saliva ejectors, prophy angles, etc.)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Never reuse single-use devices: saliva ejectors, HVE tips, prophy angles, prophy cups, air/water syringe tips, matrix bands, wedges, endo files (single-use type).",
                "practice_types": ["all"],
            },
            {
                "id": "SUD-1.2",
                "check": "No backflow from patient through saliva ejector communicated to patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Instruct patients not to close lips tightly around saliva ejector to prevent backflow. Consider high-volume evacuation for procedures.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Dental Handpiece Sterilization ──
    "HP-1": {
        "name": "Dental Handpiece Sterilization",
        "regulation_reference": "CDC MMWR 2003 — Handpiece Sterilization",
        "checks": [
            {
                "id": "HP-1.1",
                "check": "All dental handpieces heat-sterilized between patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Heat-sterilize ALL dental handpieces (high-speed, low-speed, prophy angles, nose cones) between patients. Chemical sterilization is NOT acceptable for handpieces.",
                "practice_types": ["all"],
            },
            {
                "id": "HP-1.2",
                "check": "Handpieces lubricated and cleaned before sterilization per manufacturer",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Clean and lubricate handpieces per manufacturer instructions before sterilization. Run handpiece to expel excess lubricant. Use only recommended lubricants.",
                "practice_types": ["all"],
            },
            {
                "id": "HP-1.3",
                "check": "Handpieces run to discharge water/air for 20-30 seconds after attachment",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "After attaching handpiece to dental unit, run for 20-30 seconds to flush water and air lines before use on patient.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Impression and Prosthetic Disinfection ──
    "IMP-1": {
        "name": "Impression and Prosthetic Infection Control",
        "regulation_reference": "CDC MMWR 2003 — Dental Laboratories",
        "checks": [
            {
                "id": "IMP-1.1",
                "check": "Impressions rinsed and disinfected before sending to lab",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Rinse impressions under running water to remove blood/saliva. Disinfect per material compatibility: alginate (spray), PVS/polyether (immersion). Follow ADA/manufacturer guidance.",
                "practice_types": ["all"],
            },
            {
                "id": "IMP-1.2",
                "check": "Prosthetics/appliances from lab disinfected before insertion",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Disinfect all prosthetics, orthodontic appliances, and other items received from laboratory before patient try-in or insertion.",
                "practice_types": ["all"],
            },
            {
                "id": "IMP-1.3",
                "check": "Communication protocol with dental lab regarding infection control",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Establish infection control protocol with laboratory. Communicate disinfection status of items sent. Use sealed, labeled transport containers.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Extracted Teeth Handling ──
    "TEETH-1": {
        "name": "Extracted Teeth Handling",
        "regulation_reference": "CDC MMWR 2003 — Extracted Teeth",
        "checks": [
            {
                "id": "TEETH-1.1",
                "check": "Extracted teeth containing amalgam NOT placed in regulated medical waste",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Do not place extracted teeth with amalgam in regulated medical waste destined for incineration (mercury release). Collect separately for amalgam recycling.",
                "practice_types": ["all"],
            },
            {
                "id": "TEETH-1.2",
                "check": "Extracted teeth for educational use heat-sterilized or chemically disinfected",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Autoclave extracted teeth before use as educational specimens. If amalgam present, immerse in 10% formalin for 2 weeks (do not autoclave amalgam).",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Barrier Techniques ──
    "BARRIER-1": {
        "name": "Barrier Protection Techniques",
        "regulation_reference": "CDC MMWR 2003 — Contact Precautions",
        "checks": [
            {
                "id": "BARRIER-1.1",
                "check": "Patient protective eyewear provided during treatment",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Provide patients with protective eyewear during procedures to protect from debris, splatter, and chemical exposure.",
                "practice_types": ["all"],
            },
            {
                "id": "BARRIER-1.2",
                "check": "Rubber dam used when appropriate to minimize aerosol exposure",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Use rubber dam isolation during restorative, endodontic, and other procedures where feasible to minimize patient and operator exposure to aerosols.",
                "practice_types": ["all"],
            },
            {
                "id": "BARRIER-1.3",
                "check": "Pre-procedural antimicrobial mouth rinse offered to patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "low",
                "remediation": "Offer pre-procedural rinse (0.12% chlorhexidine or essential oil mouthwash) to reduce microbial load in aerosols. Particularly useful before aerosol-generating procedures.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Aerosol Management ──
    "AERO-1": {
        "name": "Aerosol-Generating Procedure Management",
        "regulation_reference": "CDC 2003/2020 Guidance — Aerosol Management",
        "checks": [
            {
                "id": "AERO-1.1",
                "check": "High-volume evacuation (HVE) used during aerosol-generating procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use high-volume evacuator during all aerosol-generating procedures (ultrasonic scaling, high-speed handpiece, air polishing). HVE reduces aerosols by up to 90%.",
                "practice_types": ["all"],
            },
            {
                "id": "AERO-1.2",
                "check": "Adequate ventilation in treatment rooms (air exchanges per hour)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Ensure adequate ventilation in operatories. ASHRAE recommends minimum 6 air exchanges per hour for dental treatment rooms. Consider HEPA filtration units.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Respiratory Hygiene / Cough Etiquette ──
    "RESP-1": {
        "name": "Respiratory Hygiene and Cough Etiquette",
        "regulation_reference": "CDC MMWR 2003 / 2007 Guideline for Isolation Precautions",
        "checks": [
            {
                "id": "RESP-1.1",
                "check": "Visual alerts posted at entrance about respiratory hygiene",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Post signs at entrance instructing patients with respiratory symptoms to: cover mouth when coughing, use tissues, perform hand hygiene, wear mask if available.",
                "practice_types": ["all"],
            },
            {
                "id": "RESP-1.2",
                "check": "Tissues and no-touch waste receptacles available in waiting areas",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Provide tissues and no-touch trash receptacles in patient waiting areas and at check-in. Provide masks for patients with respiratory symptoms.",
                "practice_types": ["all"],
            },
            {
                "id": "RESP-1.3",
                "check": "Spatial separation of symptomatic patients when feasible",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "low",
                "remediation": "Separate patients with respiratory symptoms by 3+ feet from others in waiting areas. Consider scheduling at end of day or separate entrance.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Safe Injection Practices ──
    "INJECT-1": {
        "name": "Safe Injection Practices",
        "regulation_reference": "CDC MMWR 2003 — Safe Injection Practices",
        "checks": [
            {
                "id": "INJECT-1.1",
                "check": "Single-dose vials used for one patient only (no multi-patient use)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Use single-dose vials for one patient only. Do not use single-dose vials for multiple patients or combine leftover contents. Discard after single use.",
                "practice_types": ["all"],
            },
            {
                "id": "INJECT-1.2",
                "check": "Multi-dose vials stored and accessed per manufacturer instructions",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Date multi-dose vials when first opened. Store per manufacturer requirements. Access with new sterile syringe and needle each time. Discard per manufacturer expiration after opening.",
                "practice_types": ["all"],
            },
            {
                "id": "INJECT-1.3",
                "check": "Anesthetic cartridges not used for multiple patients",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Use dental anesthetic cartridges for one patient only. Never administer contents of a cartridge to multiple patients even with needle change.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Lab Infection Control ──
    "LAB-1": {
        "name": "Dental Laboratory Infection Control",
        "regulation_reference": "CDC MMWR 2003 — Dental Laboratory",
        "checks": [
            {
                "id": "LAB-1.1",
                "check": "In-office lab area has dedicated disinfection protocol",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Maintain separate clean and contaminated zones in lab area. Disinfect work surfaces, lathes, and equipment. Use PPE when handling contaminated items.",
                "practice_types": ["all"],
            },
            {
                "id": "LAB-1.2",
                "check": "Pumice and ragwheels used on contaminated prosthetics are disposable or sterilized",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Use disposable pumice and individual ragwheels, or sterilize/disinfect between patients. Never share pumice between patients.",
                "practice_types": ["all"],
            },
        ],
    },
}
