"""OSHA Dental-Specific Standards — 50+ checks.

Covers Bloodborne Pathogen Exposure Control Plan (29 CFR 1910.1030),
Hazard Communication, PPE, needlestick/sharps prevention, employee training,
dental-specific chemical hazards, ergonomics, and fire safety.
"""

from __future__ import annotations

OSHA_DENTAL_CONTROLS: dict = {
    # ── Bloodborne Pathogens (29 CFR 1910.1030) ──
    "BBP-1": {
        "name": "Exposure Control Plan",
        "regulation_reference": "29 CFR 1910.1030(c)",
        "checks": [
            {
                "id": "BBP-1.1",
                "check": "Written Exposure Control Plan exists and is current (updated annually)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Create or update written Exposure Control Plan. Must be reviewed and updated annually and whenever new tasks or procedures affect occupational exposure.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-1.2",
                "check": "Exposure determination completed — all job classifications with occupational exposure listed",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "List all job classifications with occupational exposure (dentists, hygienists, assistants, lab techs). Include tasks and procedures where exposure occurs.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-1.3",
                "check": "Schedule and method of implementation documented for each provision",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Document how each provision of the standard will be implemented, including schedules for compliance.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-1.4",
                "check": "Annual review of Exposure Control Plan with employee input documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Conduct annual review involving frontline employees. Document date, participants, and any changes made.",
                "practice_types": ["all"],
            },
        ],
    },
    "BBP-2": {
        "name": "Universal Precautions and Engineering Controls",
        "regulation_reference": "29 CFR 1910.1030(d)(1)-(2)",
        "checks": [
            {
                "id": "BBP-2.1",
                "check": "Universal precautions observed — all blood and OPIM treated as infectious",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Ensure all employees treat all blood and Other Potentially Infectious Materials (OPIM) as infectious, regardless of perceived status of the source individual.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-2.2",
                "check": "Sharps disposal containers available, accessible, and maintained",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Place puncture-resistant, labeled sharps containers at each operatory. Replace when 3/4 full. Never overfill.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-2.3",
                "check": "Self-sheathing needles or needleless systems used where available",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Evaluate and adopt safety-engineered sharps devices (self-sheathing anesthetic needles, safety scalpels).",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-2.4",
                "check": "No recapping of needles by two-handed technique",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Use one-hand scoop technique or mechanical recapping device. Never recap using two hands.",
                "practice_types": ["all"],
            },
        ],
    },
    "BBP-3": {
        "name": "Hepatitis B Vaccination",
        "regulation_reference": "29 CFR 1910.1030(f)",
        "checks": [
            {
                "id": "BBP-3.1",
                "check": "Hepatitis B vaccination offered to all employees with occupational exposure within 10 days of hire",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Offer HBV vaccine series to all at-risk employees within 10 working days of initial assignment. Document offer and acceptance/declination.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-3.2",
                "check": "Signed declination forms on file for employees who refused vaccination",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Obtain signed declination statements from employees who refuse HBV vaccination. Use OSHA-prescribed language.",
                "practice_types": ["all"],
            },
        ],
    },
    "BBP-4": {
        "name": "Post-Exposure Evaluation and Follow-Up",
        "regulation_reference": "29 CFR 1910.1030(f)(3)",
        "checks": [
            {
                "id": "BBP-4.1",
                "check": "Post-exposure evaluation procedure documented and accessible",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Document post-exposure procedures: immediate wound care, reporting protocol, confidential medical evaluation, source individual testing (with consent), follow-up.",
                "practice_types": ["all"],
            },
            {
                "id": "BBP-4.2",
                "check": "Sharps injury log maintained (practices with 10+ employees)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Maintain sharps injury log recording: date, type/brand of device, work area, description of incident. Required for practices with 10+ employees.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Hazard Communication (29 CFR 1910.1200) ──
    "HAZCOM-1": {
        "name": "Hazard Communication Program",
        "regulation_reference": "29 CFR 1910.1200",
        "checks": [
            {
                "id": "HAZCOM-1.1",
                "check": "Written Hazard Communication Program exists",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Create written HazCom program describing labeling system, SDS management, and employee training procedures.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-1.2",
                "check": "Safety Data Sheets (SDS) available for all hazardous chemicals",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain SDS binder or electronic access for all chemicals: composites, etchants, bonding agents, disinfectants, glutaraldehyde, impression materials, amalgam, nitrous oxide.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-1.3",
                "check": "Chemical inventory list maintained and current",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Maintain a current list of all hazardous chemicals used in the practice. Cross-reference with SDS availability.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-1.4",
                "check": "All chemical containers properly labeled (GHS format)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Ensure all chemical containers bear GHS-compliant labels with product identifier, signal word, hazard statements, pictograms, and precautionary statements.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-1.5",
                "check": "Secondary containers labeled with chemical name and hazards",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Label all secondary containers (spray bottles, etc.) with chemical identity and applicable hazard warnings.",
                "practice_types": ["all"],
            },
        ],
    },
    "HAZCOM-2": {
        "name": "Dental-Specific Chemical Hazards",
        "regulation_reference": "29 CFR 1910.1200 / 29 CFR 1910.1000",
        "checks": [
            {
                "id": "HAZCOM-2.1",
                "check": "Nitrous oxide exposure monitoring program in place (if N2O used)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Monitor N2O levels — NIOSH recommends <25 ppm TWA. Use scavenging systems, ensure adequate ventilation, perform periodic monitoring.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-2.2",
                "check": "Amalgam waste handling procedures documented (mercury hygiene)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Implement amalgam waste management: chair-side traps, vacuum filters, amalgam separators, proper recycling. No contact amalgam in regular trash.",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-2.3",
                "check": "Glutaraldehyde exposure controls in place (if used for cold sterilization)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use glutaraldehyde only in ventilated areas with covered containers. PEL: 0.2 ppm ceiling. Consider switching to less hazardous alternatives (OPA, peracetic acid).",
                "practice_types": ["all"],
            },
            {
                "id": "HAZCOM-2.4",
                "check": "Mercury spill kit available and staff trained on spill procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Maintain a mercury spill kit with sulfur powder, disposal bag, and instructions. Train staff on cleanup procedures.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── PPE Requirements (29 CFR 1910.132-138) ──
    "PPE-1": {
        "name": "Personal Protective Equipment",
        "regulation_reference": "29 CFR 1910.132-138",
        "checks": [
            {
                "id": "PPE-1.1",
                "check": "PPE hazard assessment completed and documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Conduct workplace PPE hazard assessment. Document hazards identified and PPE selected for each task.",
                "practice_types": ["all"],
            },
            {
                "id": "PPE-1.2",
                "check": "Appropriate gloves available for all clinical procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Provide exam gloves (nitrile recommended for latex-sensitive), heavy-duty utility gloves for instrument processing, surgical gloves for surgical procedures.",
                "practice_types": ["all"],
            },
            {
                "id": "PPE-1.3",
                "check": "Face masks meet ASTM standards (Level 1/2/3 appropriate to procedure)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use ASTM Level 1 for exams, Level 2 for restorative, Level 3 for surgical/high-aerosol procedures. Change between patients and when visibly soiled.",
                "practice_types": ["all"],
            },
            {
                "id": "PPE-1.4",
                "check": "Protective eyewear with side shields available for all clinical staff",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Provide safety glasses or goggles with side shields. Face shields for procedures generating significant splash/spatter.",
                "practice_types": ["all"],
            },
            {
                "id": "PPE-1.5",
                "check": "Protective gowns/lab coats worn during patient treatment",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Provide long-sleeve, closed-front protective clothing. Changed daily or when visibly soiled. Laundered by practice, not taken home.",
                "practice_types": ["all"],
            },
            {
                "id": "PPE-1.6",
                "check": "Employee PPE training documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Train employees on when PPE is necessary, what PPE is required, proper donning/doffing, care and disposal. Document training.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Employee Training (29 CFR 1910.1030(g)(2)) ──
    "TRAIN-1": {
        "name": "Employee Training Records",
        "regulation_reference": "29 CFR 1910.1030(g)(2) / 29 CFR 1910.1200(h)",
        "checks": [
            {
                "id": "TRAIN-1.1",
                "check": "Annual Bloodborne Pathogen training completed for all at-risk employees",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Conduct annual BBP training covering: epidemiology, modes of transmission, exposure control plan, PPE use, post-exposure procedures, HBV vaccination, signs/labels.",
                "practice_types": ["all"],
            },
            {
                "id": "TRAIN-1.2",
                "check": "Hazard Communication training completed for all employees",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Train all employees on: location and availability of HazCom program and SDS, physical/health hazards of chemicals, protective measures, GHS label elements.",
                "practice_types": ["all"],
            },
            {
                "id": "TRAIN-1.3",
                "check": "Fire safety training completed annually",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Conduct annual fire safety training: fire extinguisher use (PASS method), evacuation routes, alarm procedures.",
                "practice_types": ["all"],
            },
            {
                "id": "TRAIN-1.4",
                "check": "Training records retained for 3+ years beyond employment",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Retain training records (dates, contents, trainer name, attendees) for at least 3 years past the date of employment.",
                "practice_types": ["all"],
            },
            {
                "id": "TRAIN-1.5",
                "check": "New employee orientation includes OSHA compliance training",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Train new employees before they begin tasks with exposure risk. Document initial training date and content covered.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Emergency Action Plan (29 CFR 1910.38) ──
    "EAP-1": {
        "name": "Emergency Action Plan",
        "regulation_reference": "29 CFR 1910.38",
        "checks": [
            {
                "id": "EAP-1.1",
                "check": "Written Emergency Action Plan exists",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Create written EAP covering: emergency reporting procedures, evacuation procedures and routes, critical operations, employee accounting, rescue and medical duties.",
                "practice_types": ["all"],
            },
            {
                "id": "EAP-1.2",
                "check": "Emergency exit routes posted and unobstructed",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Post evacuation route maps. Ensure all exit paths are clear. Exit signs illuminated. Emergency lighting functional.",
                "practice_types": ["all"],
            },
            {
                "id": "EAP-1.3",
                "check": "Fire extinguishers inspected annually and accessible",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Mount fire extinguishers within 75 feet of travel. Annual professional inspection. Monthly visual check (tag initialed).",
                "practice_types": ["all"],
            },
            {
                "id": "EAP-1.4",
                "check": "Medical emergency protocol documented (syncope, allergic reaction, cardiac arrest)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Document medical emergency protocols. Maintain emergency drug kit (epinephrine, nitroglycerin, oxygen, diphenhydramine, aspirin). Staff CPR/BLS certified.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Fire Safety — Compressed Gas ──
    "FIRE-1": {
        "name": "Fire Safety and Compressed Gas",
        "regulation_reference": "29 CFR 1910.101 / 29 CFR 1910.253",
        "checks": [
            {
                "id": "FIRE-1.1",
                "check": "Compressed gas cylinders (O2, N2O) properly secured and stored",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Chain or strap all gas cylinders to wall or cart. Store upright. Separate O2 from flammables by 20 feet or by firewall. Cap valves when not in use.",
                "practice_types": ["all"],
            },
            {
                "id": "FIRE-1.2",
                "check": "Oxygen safety protocols documented (no oil/grease near O2)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Post O2 safety rules. No smoking, open flames, or petroleum products near oxygen equipment. Use only O2-compatible regulators and fittings.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Ergonomics ──
    "ERGO-1": {
        "name": "Ergonomic Hazards",
        "regulation_reference": "OSHA General Duty Clause (Section 5(a)(1))",
        "checks": [
            {
                "id": "ERGO-1.1",
                "check": "Ergonomic assessment completed for clinical positions",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Assess ergonomic risks for dentists, hygienists, and assistants. Evaluate operator stool, patient chair positioning, instrument design, loupes use.",
                "practice_types": ["all"],
            },
            {
                "id": "ERGO-1.2",
                "check": "Magnification loupes available for clinical staff",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "low",
                "remediation": "Provide properly fitted magnification loupes to reduce neck/back strain from hunching. Custom-fitted recommended.",
                "practice_types": ["all"],
            },
            {
                "id": "ERGO-1.3",
                "check": "Operator stools adjustable and ergonomically appropriate",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "low",
                "remediation": "Provide adjustable operator stools with lumbar support, arm rests, and proper height range for the operating position.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Waste Management ──
    "WASTE-1": {
        "name": "Regulated Medical Waste Management",
        "regulation_reference": "29 CFR 1910.1030(d)(4)(iii); State regulations",
        "checks": [
            {
                "id": "WASTE-1.1",
                "check": "Regulated medical waste segregated from regular trash",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Separate regulated medical waste (blood-soaked items, pathological waste, sharps) from regular trash. Use red bags or containers with biohazard symbol.",
                "practice_types": ["all"],
            },
            {
                "id": "WASTE-1.2",
                "check": "Biohazard containers labeled with biohazard symbol and color-coded red",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Use red bags or containers marked with biohazard symbol for regulated medical waste. Containers must be closable, leak-proof, and puncture-resistant for sharps.",
                "practice_types": ["all"],
            },
            {
                "id": "WASTE-1.3",
                "check": "Licensed medical waste hauler contracted for pickup and disposal",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Contract with licensed regulated medical waste hauler. Maintain copies of hauler license and manifests. Verify proper treatment (autoclave/incineration).",
                "practice_types": ["all"],
            },
            {
                "id": "WASTE-1.4",
                "check": "Amalgam separator installed and maintained per EPA requirements",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Install ISO 11143-compliant amalgam separator. Maintain per manufacturer schedule. Recycle collected amalgam through certified recycler. Required by EPA Dental Rule (40 CFR 441).",
                "practice_types": ["all"],
            },
            {
                "id": "WASTE-1.5",
                "check": "Pharmaceutical waste disposal procedures documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Document disposal procedures for expired medications, anesthetic cartridges, and other pharmaceutical waste. Do not place in regular trash or down drain.",
                "practice_types": ["all"],
            },
            {
                "id": "WASTE-1.6",
                "check": "Lead foil from film packets recycled (not placed in regular trash)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Collect lead foil from film packets for recycling. Lead is a hazardous material — do not place in regular trash. Use certified recycler.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Recordkeeping (29 CFR 1904) ──
    "RECORD-1": {
        "name": "OSHA Recordkeeping",
        "regulation_reference": "29 CFR 1904",
        "checks": [
            {
                "id": "RECORD-1.1",
                "check": "OSHA 300 Log maintained (if 10+ employees)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Maintain OSHA Form 300 (Log of Work-Related Injuries and Illnesses) for practices with 10+ employees. Post Form 300A summary Feb 1 - Apr 30.",
                "practice_types": ["all"],
            },
            {
                "id": "RECORD-1.2",
                "check": "Employee medical records maintained per 29 CFR 1910.1020",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Maintain employee medical records (exposure records, vaccination records) for duration of employment plus 30 years.",
                "practice_types": ["all"],
            },
            {
                "id": "RECORD-1.3",
                "check": "OSHA poster (Job Safety and Health) displayed in workplace",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Display OSHA's 'Job Safety and Health: It's the Law' poster in a conspicuous location where employees can see it.",
                "practice_types": ["all"],
            },
        ],
    },
}
