"""State Dental Board Regulations — Top 10 states, 20+ checks per state.

Covers: CA, TX, FL, NY, PA, IL, OH, GA, NC, MI.
Tracks continuing education, license renewal, scope of practice, sedation permits,
mandatory reporting, prescribing, teledentistry, mobile dentistry, and advertising.
"""

from __future__ import annotations

# Each check includes a "states" key listing which states it applies to.
# If "states" is absent or empty, it applies to all states.

STATE_BOARD_CONTROLS: dict = {
    # ── Continuing Education ──
    "CE-1": {
        "name": "Continuing Education Requirements",
        "regulation_reference": "State dental practice acts (varies by state)",
        "checks": [
            {
                "id": "CE-1.1",
                "check": "Dentist CE hours completed per renewal cycle",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Complete required CE hours per renewal cycle. CA: 50hrs/2yr. TX: 24hrs/yr. FL: 30hrs/2yr. NY: 60hrs/3yr. PA: 30hrs/2yr. IL: 48hrs/3yr. OH: 40hrs/2yr. GA: 40hrs/2yr. NC: 45hrs/3yr. MI: 60hrs/3yr.",
                "practice_types": ["all"],
                "states": ["CA", "TX", "FL", "NY", "PA", "IL", "OH", "GA", "NC", "MI"],
            },
            {
                "id": "CE-1.2",
                "check": "Hygienist CE hours completed per renewal cycle",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Verify hygienist CE completion. CA: 25hrs/2yr. TX: 12hrs/yr. FL: 24hrs/2yr. NY: 24hrs/3yr. PA: 20hrs/2yr. IL: 36hrs/3yr. OH: 24hrs/2yr. GA: 25hrs/2yr. NC: 24hrs/2yr. MI: 36hrs/3yr.",
                "practice_types": ["all"],
                "states": ["CA", "TX", "FL", "NY", "PA", "IL", "OH", "GA", "NC", "MI"],
            },
            {
                "id": "CE-1.3",
                "check": "Mandatory CE topics completed (CPR, infection control, opioid prescribing, etc.)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Complete mandatory CE topics by state. Common requirements: CPR/BLS (most states), infection control/OSHA (FL, NY), opioid prescribing (OH, MI, PA), ethics (TX, NC), child abuse (CA, NY, FL).",
                "practice_types": ["all"],
                "states": ["CA", "TX", "FL", "NY", "PA", "IL", "OH", "GA", "NC", "MI"],
            },
            {
                "id": "CE-1.4",
                "check": "CPR/BLS certification current for all clinical staff",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain current CPR/BLS certification (AHA or Red Cross) for all dentists, hygienists, and assistants. Typically required every 2 years. Required by most state boards.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── License Renewal ──
    "LIC-1": {
        "name": "License Renewal",
        "regulation_reference": "State dental practice acts",
        "checks": [
            {
                "id": "LIC-1.1",
                "check": "All practitioner licenses current and renewed before expiration",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Track renewal deadlines for all licenses (DDS/DMD, RDH, DA). Set reminders 90 days before expiration. Practicing on expired license is illegal.",
                "practice_types": ["all"],
            },
            {
                "id": "LIC-1.2",
                "check": "Practice/facility permit current (if required by state)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Some states require separate facility/practice permits. Verify requirement for your state and maintain current permit.",
                "practice_types": ["all"],
            },
            {
                "id": "LIC-1.3",
                "check": "DEA registration current for practitioners who prescribe controlled substances",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain current DEA registration. Renew every 3 years. Required to prescribe any controlled substance (opioids, benzodiazepines, nitrous oxide in some states).",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Scope of Practice ──
    "SCOPE-1": {
        "name": "Scope of Practice — Hygienist and Assistant",
        "regulation_reference": "State dental practice acts",
        "checks": [
            {
                "id": "SCOPE-1.1",
                "check": "Dental hygienist duties limited to state-allowed scope",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Review state-specific hygienist scope. Varies significantly: some states allow local anesthesia (CA, TX, FL), some allow restorative (OR, WA). Document delegated duties.",
                "practice_types": ["all"],
            },
            {
                "id": "SCOPE-1.2",
                "check": "Dental assistant duties limited to state-allowed scope",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Review state-specific assistant scope. Expanded Function Dental Assistants (EFDA) have broader scope in PA, OH, FL. Verify certification for expanded duties.",
                "practice_types": ["all"],
            },
            {
                "id": "SCOPE-1.3",
                "check": "Supervision requirements met for delegated procedures",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Ensure supervision levels met per state law: direct (dentist present), indirect (dentist on premises), general (dentist authorized). Document supervision for delegated procedures.",
                "practice_types": ["all"],
            },
            {
                "id": "SCOPE-1.4",
                "check": "EFDA certification verified for expanded duties (states that require it)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Verify EFDA certification for assistants performing expanded duties (coronal polishing, sealants, temporary restorations). PA, OH, FL, TX have EFDA programs.",
                "practice_types": ["all"],
                "states": ["PA", "OH", "FL", "TX"],
            },
        ],
    },
    # ── Sedation / Anesthesia ──
    "SED-1": {
        "name": "Sedation and Anesthesia Permits",
        "regulation_reference": "State dental board sedation rules",
        "checks": [
            {
                "id": "SED-1.1",
                "check": "Sedation/anesthesia permit current (if administering sedation)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Obtain and maintain state sedation permit for level administered: minimal sedation (N2O/O2), moderate sedation (oral/IV), deep sedation, general anesthesia. Separate permits required by most states.",
                "practice_types": ["all"],
            },
            {
                "id": "SED-1.2",
                "check": "Sedation equipment and emergency drugs current and accessible",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain age/size-appropriate emergency equipment: positive pressure O2, suction, pulse oximeter, BP cuff, AED, emergency drug kit. Check expiration dates monthly.",
                "practice_types": ["all"],
            },
            {
                "id": "SED-1.3",
                "check": "Sedation training and ACLS/PALS certification current (for moderate+ sedation)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain ACLS certification for moderate/deep sedation. PALS required if treating pediatric patients under sedation. Complete required sedation CE hours per state.",
                "practice_types": ["all"],
            },
            {
                "id": "SED-1.4",
                "check": "Sedation facility inspection current (if required by state)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Schedule and pass state-required facility inspection for sedation. Many states require on-site evaluation before issuing or renewing sedation permit.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Mandatory Reporting ──
    "REPORT-1": {
        "name": "Mandatory Reporting Requirements",
        "regulation_reference": "State mandatory reporting statutes",
        "checks": [
            {
                "id": "REPORT-1.1",
                "check": "Child abuse/neglect mandatory reporting protocol documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Document reporting protocol. All dental professionals are mandated reporters in all 50 states. Know signs of abuse/neglect (oral injuries, untreated caries in children). Report to CPS immediately.",
                "practice_types": ["all"],
            },
            {
                "id": "REPORT-1.2",
                "check": "Domestic violence identification and referral protocol documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Document protocol for identifying and responding to domestic violence. Facial injuries are common. Know state-specific reporting requirements (mandatory in some states). Maintain resource list.",
                "practice_types": ["all"],
            },
            {
                "id": "REPORT-1.3",
                "check": "Elder abuse mandatory reporting protocol documented",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Document elder abuse reporting protocol. Dental professionals are mandated reporters for elder abuse in most states. Know signs: unexplained oral injuries, poor oral hygiene despite caretaker.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Prescribing Authority ──
    "RX-1": {
        "name": "Prescribing Authority Rules",
        "regulation_reference": "State dental practice act; DEA regulations",
        "checks": [
            {
                "id": "RX-1.1",
                "check": "Prescription records maintained per state and DEA requirements",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Maintain prescription records including: patient name, drug, dose, quantity, date, refills. Schedule II records kept 2+ years. Use state PDMP before prescribing opioids (required in most states).",
                "practice_types": ["all"],
            },
            {
                "id": "RX-1.2",
                "check": "PDMP (Prescription Drug Monitoring Program) checked before opioid prescribing",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "critical",
                "remediation": "Check state PDMP before prescribing opioids. Required by law in most states. Document PDMP check in patient record. Available at state pharmacy board website.",
                "practice_types": ["all"],
            },
            {
                "id": "RX-1.3",
                "check": "Opioid prescribing follows state-specific limits",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Follow state opioid prescribing limits. Many states cap initial prescriptions at 3-7 days for acute pain. Document clinical rationale. Consider non-opioid alternatives first.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Teledentistry ──
    "TELE-1": {
        "name": "Teledentistry Regulations",
        "regulation_reference": "State teledentistry statutes (emerging area)",
        "checks": [
            {
                "id": "TELE-1.1",
                "check": "Teledentistry services comply with state-specific regulations",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Review state-specific teledentistry rules. Varies: some states have specific teledentistry statutes (CA, TX, FL), others apply existing telehealth rules. Ensure licensure in patient's state.",
                "practice_types": ["all"],
            },
            {
                "id": "TELE-1.2",
                "check": "Informed consent obtained for teledentistry encounters",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Obtain informed consent specific to teledentistry: limitations of virtual exam, emergency protocols, privacy/security of platform, right to in-person visit.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Mobile Dentistry ──
    "MOBILE-1": {
        "name": "Mobile Dentistry Requirements",
        "regulation_reference": "State dental board mobile dentistry rules",
        "checks": [
            {
                "id": "MOBILE-1.1",
                "check": "Mobile/portable dental permit obtained (if providing off-site services)",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Obtain mobile/portable dental facility permit per state requirements. Covers school-based programs, nursing home visits, community events. Ensure equipment meets infection control standards.",
                "practice_types": ["all"],
            },
        ],
    },
    # ── Advertising ──
    "ADV-1": {
        "name": "Dental Advertising Rules",
        "regulation_reference": "State dental board advertising regulations",
        "checks": [
            {
                "id": "ADV-1.1",
                "check": "Advertising does not include false or misleading claims",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Review all advertising (website, social media, print, TV) for compliance. No false claims about specialties (cannot claim 'specialist' without board certification in most states), outcomes, or credentials.",
                "practice_types": ["all"],
            },
            {
                "id": "ADV-1.2",
                "check": "Specialty claims comply with state board rules",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "high",
                "remediation": "Only advertise as a specialist in ADA-recognized specialties if you have completed accredited program and/or hold board certification. Some states allow 'practice limited to' language.",
                "practice_types": ["all"],
            },
            {
                "id": "ADV-1.3",
                "check": "Fee advertising includes required disclaimers per state",
                "scanner": "practice",
                "auto_fix": False,
                "severity": "medium",
                "remediation": "Include required disclaimers in fee advertising. Some states require: 'additional fees may apply,' expiration dates on offers, and clear terms and conditions.",
                "practice_types": ["all"],
            },
        ],
    },
}
