/**
 * ISO 15189:2022 Medical Laboratory Quality and Competence Compliance Pack
 *
 * ISO 15189:2022 (4th edition) is the international standard for quality and
 * competence in medical laboratories. It replaces ISO 17025-derived approaches
 * for the medical laboratory context and provides specific requirements for
 * quality management systems (QMS) combined with technical competence
 * requirements unique to clinical laboratory practice.
 *
 * Published by ISO/TC 212 (Clinical laboratory testing and in vitro diagnostic
 * test systems). The 2022 edition (4th edition) is aligned with:
 *   - ISO 17025:2017 (General requirements for the competence of testing and
 *     calibration laboratories) — structural parent
 *   - ISO 22870:2022 (Point-of-care testing — Requirements for quality and
 *     competence) — extends ISO 15189 to POCT settings
 *   - ISO 9001:2015 (QMS principles — Annex SL harmonised structure)
 *
 * Recognized by national accreditation bodies:
 *   - CAP (College of American Pathologists) — USA (CAP accreditation aligns
 *     with ISO 15189 and runs alongside CLIA for high-complexity labs)
 *   - ANAB (ANSI National Accreditation Board) — USA (direct ISO 15189 accreditor)
 *   - A2LA (American Association for Laboratory Accreditation) — USA
 *   - COLA (Commission on Office Laboratory Accreditation) — USA
 *   - UKAS (United Kingdom Accreditation Service) — UK
 *   - DAkkS (Deutsche Akkreditierungsstelle) — Germany
 *   - DANAK (Danish Accreditation and Metrology Fund) — Denmark
 *   - COFRAC (Comité français d'accréditation) — France
 *   - NATA (National Association of Testing Authorities) — Australia
 *   - ILAC (International Laboratory Accreditation Cooperation) — MRA framework
 *
 * US regulatory context:
 *   CMS/CLIA (Clinical Laboratory Improvement Amendments, 42 CFR Part 493)
 *   governs clinical laboratory testing in the US. CAP + ISO 15189 accreditation
 *   satisfies CLIA requirements for high-complexity labs under the CMS deemed-
 *   status programme. CAP inspection + ISO 15189 are effectively run together
 *   for high-complexity clinical labs.
 *
 * Standard scope (ISO 15189:2022 main clauses):
 *   §4 General requirements — impartiality (§4.1) + confidentiality (§4.2)
 *   §5 Structural requirements — legal entity + lab director + governance
 *   §6 Resource requirements:
 *     §6.2 Personnel (competence + training + authorisation)
 *     §6.3 Facilities and environmental conditions
 *     §6.4 Equipment (selection, verification, calibration, metrological traceability)
 *     §6.5 Reagents and consumables (receipt + storage + acceptance testing)
 *     §6.6 Service agreements (request + referral + reporting agreements)
 *   §7 Process requirements:
 *     §7.2 Pre-examination (request + patient preparation + sample collection + reception)
 *     §7.3 Examination (validation + verification + IQC + EQA + uncertainty of measurement)
 *     §7.4 Post-examination (review + authorisation + reporting + release + correction)
 *     §7.5 Nonconforming work
 *     §7.6 Data control and information management
 *     §7.7 Complaints
 *     §7.8 Continuity of service
 *   §8 Management system requirements (Option A: full ISO 9001 QMS alignment;
 *       Option B: ISO 15189-internal QMS — either satisfies accreditation)
 *
 * Annexes:
 *   Annex A — Risk management for medical laboratories (ISO 14971 + ISO 22367)
 *   Annex B — Patient safety, ethics, and confidentiality
 *   Annex C — Examiner competence requirements (interpretive + analytical)
 *
 * Key technical competence concepts:
 *   Internal Quality Control (IQC) — continuous monitoring of examination
 *     performance using control materials; Westgard rules or equivalent;
 *     immediate IQC out-of-control action required before patient results
 *     reported (§7.3.7).
 *   External Quality Assessment (EQA) / Proficiency Testing (PT) — mandatory
 *     participation in schemes where available; per §7.3.4; performance
 *     compared against peers and targets.
 *   Validation vs Verification:
 *     Validation (§7.3.2) — confirms an in-house developed or modified
 *       examination procedure fulfils its intended purpose.
 *     Verification (§7.3.3) — confirms a commercially-supplied examination
 *       procedure performs as specified by the manufacturer in the lab's
 *       own environment.
 *   Uncertainty of Measurement (§7.3.6) — labs must evaluate and document
 *     measurement uncertainty for all quantitative examination results.
 *   Metrological traceability (§6.4.9) — calibration traceable to SI units
 *     or certified reference materials through an unbroken chain.
 *
 * Patient-record retention:
 *   20-year baseline (7300 days) — derived from medical record retention
 *   requirements across key jurisdictions: US HIPAA/CLIA (minimum 10 years
 *   post-reporting; CAP recommends 20 years for special tests; CMS CLIA
 *   high-complexity lab records minimum 2 years by regulation; state-law
 *   varies 5–10 years); EU GDPR + national laws (healthcare records 15-30
 *   years post last contact per NHS Wales; 10 years minimum Germany § 630f
 *   BGB; 30 years France clinical records); Australian Health Records Act
 *   (7 years post last service for adults). Conservative 20-year (7300 days)
 *   baseline chosen for cross-jurisdictional medical laboratory compatibility.
 *
 * Incident / event reporting:
 *   72-hour baseline (3 days) — derived from CAP/CLIA event reporting
 *   expectations + ISO 15189 §7.7 complaints/nonconforming work timelines +
 *   GDPR Art. 33 (72h data breach notification for any labs handling EU PHI).
 *   CAP Q-Probes and Q-Tracks programmes track sentinel-event timelines.
 *   CMS/CLIA deficiency reporting under 42 CFR §493.1101 does not impose
 *   a fixed hours-based notification window (investigation-driven), but
 *   immediate clinical action on patient-impacting IQC failures is required.
 *   72h is the common cross-programme baseline for formal notification.
 *
 * @connexum/ai-governance
 */
/**
 * Category classifiers for ISO 15189:2022 medical-laboratory categories.
 *
 * Each classifier is a regex-based content sniff that fires for text that
 * plausibly references the regulated artefact. Classifiers are advisory:
 * the moduleConfig + behavioural validators are the load-bearing gates.
 *
 * F-NEW-PACK-ISO-15189-CLASSIFIERS-2026-05-12: authored to close the
 * categoryClassifiers gap so behavioral-validators-integration coverage
 * passes for iso-15189.
 */
const ISO_15189_CATEGORY_CLASSIFIERS = {
    /**
     * IQC_OUT_OF_CONTROL_EVENT — ISO 15189:2022 §7.3.7. Internal quality
     * control out-of-control state. CRITICAL: no patient results released
     * until IQC passes + lab-director sign-off.
     */
    IQC_OUT_OF_CONTROL_EVENT: {
        references: [
            'ISO 15189:2022 §7.3.7 — internal quality control (IQC)',
        ],
        classifier: (input) => {
            if (/\b(?:IQC|internal\s+quality\s+control)\s+(?:out[-\s]?of[-\s]?control|failure|breach|alert)\b/i.test(input))
                return true;
            if (/\b(?:Westgard|Levey[-\s]?Jennings)\s+(?:rule|violation|alert)\b/i.test(input))
                return true;
            if (/\bcontrol\s+chart\s+(?:violation|alert|rule\s+(?:1[-_]?3s|2[-_]?2s|R[-_]?4s|4[-_]?1s|10x))\b/i.test(input))
                return true;
            return false;
        },
    },
    /**
     * PATIENT_EXAMINATION_DATA — ISO 15189:2022 §7.4. Patient laboratory
     * examination results subject to clinical-pathologist review before
     * AI-assisted release.
     */
    PATIENT_EXAMINATION_DATA: {
        references: [
            'ISO 15189:2022 §7.4 — examination processes',
            'ISO 15189:2022 §7.7 — release of results',
        ],
        classifier: (input) => {
            if (/\b(?:patient\s+(?:examination|laboratory|test)\s+(?:result|data|report)|laboratory\s+report\s+for\s+patient)\b/i.test(input))
                return true;
            if (/\b(?:clinical\s+pathology\s+(?:result|report)|histopathology\s+report|cytology\s+(?:result|report))\b/i.test(input))
                return true;
            if (/\b(?:interpretive\s+(?:comment|report)\s+(?:on|for)\s+patient|test\s+result\s+release\s+(?:to|for)\s+(?:clinician|ordering\s+provider))\b/i.test(input))
                return true;
            return false;
        },
    },
    /**
     * EQA_PERFORMANCE_RECORD — ISO 15189:2022 §7.3.7.2. External quality
     * assessment / proficiency testing performance records. Failures
     * require qms-lead + lab-director review.
     */
    EQA_PERFORMANCE_RECORD: {
        references: [
            'ISO 15189:2022 §7.3.7.2 — interlaboratory comparisons (EQA/PT)',
        ],
        classifier: (input) => {
            if (/\b(?:EQA|external\s+quality\s+assessment|proficiency\s+testing|PT\s+(?:result|performance|record))\b/i.test(input))
                return true;
            if (/\b(?:interlaboratory\s+comparison|CAP\s+(?:proficiency|PT)|NEQAS|UKNEQAS|RIQAS)\s+(?:result|record|performance)\b/i.test(input))
                return true;
            return false;
        },
    },
    /**
     * EXAMINATION_VALIDATION_RECORD — ISO 15189:2022 §7.3.2. Method
     * validation / verification records. Changes require clinical-
     * pathologist + lab-director sign-off.
     */
    EXAMINATION_VALIDATION_RECORD: {
        references: [
            'ISO 15189:2022 §7.3.2 — verification and validation of examination methods',
        ],
        classifier: (input) => {
            if (/\b(?:method\s+(?:validation|verification)\s+(?:record|report|protocol)|examination\s+(?:validation|verification)\s+(?:record|report))\b/i.test(input))
                return true;
            if (/\b(?:assay\s+(?:validation|verification|qualification)|analytical\s+performance\s+(?:specification|validation))\b/i.test(input))
                return true;
            if (/\b(?:linearity|precision|accuracy|reportable\s+range|reference\s+interval)\s+(?:study|verification|validation)\b/i.test(input))
                return true;
            return false;
        },
    },
    /**
     * PERSONNEL_COMPETENCE_RECORD — ISO 15189:2022 §6.2. Personnel
     * competence assessment records. Lab-director authorisation required.
     */
    PERSONNEL_COMPETENCE_RECORD: {
        references: [
            'ISO 15189:2022 §6.2 — personnel competence and authorisation',
        ],
        classifier: (input) => {
            if (/\b(?:personnel\s+competence\s+(?:assessment|record|evaluation|authorisation)|examiner\s+competence\s+(?:record|assessment))\b/i.test(input))
                return true;
            if (/\b(?:laboratory\s+(?:staff|personnel)\s+(?:competence|qualification|authorisation)|technologist\s+competence)\b/i.test(input))
                return true;
            if (/\b(?:CLIA\s+(?:high|moderate)[-\s]?complexity\s+(?:testing\s+)?personnel|CAP\s+personnel\s+(?:competence|qualification))\b/i.test(input))
                return true;
            return false;
        },
    },
};
/**
 * ISO 15189:2022 Medical Laboratory Quality and Competence Compliance Pack.
 *
 * Pack ID: 'iso-15189'
 * Jurisdiction: International — recognized by CAP (US), UKAS (UK), DAkkS (DE),
 *   COLA, ANAB, A2LA, DANAK, COFRAC, NATA, and all ILAC MRA signatories.
 *   CMS/CLIA-aligned via CAP deemed-status program for high-complexity labs.
 *
 * Guard-layer wiring:
 *   - G1-G4 (audit, logging, classification, session): always active
 *   - G5 (supply-chain): always active — PRC provider blocks; reagent/consumable
 *       vendor qualification; data sovereignty for clinical PHI
 *   - G6 (approval-queue): always active — examination result authorisation;
 *       IQC out-of-control release gate; EQA corrective action approval;
 *       non-conforming work approval before patient results released
 *   - G7 (attestation): always active — lab director attestation for IQC
 *       out-of-control release; clinical pathologist attestation for
 *       interpretive reports; examiner competence attestation (Annex C)
 *   - G8 (anomaly-detector): always active — IQC out-of-control immediate
 *       CRITICAL block (no patient results released until IQC passes);
 *       EQA failure signal detection; examination drift detection
 *   - G9 (transparency): always active — AI-generated interpretive content
 *       must be disclosed + reviewed by clinical pathologist; AI-assisted
 *       IQC rule checking must disclose model provenance
 *
 * Human-in-loop tier:
 *   - T1: Routine QMS records, pre-examination tracking, standard result
 *         reporting (qms-lead review)
 *   - T2: EQA performance failures, examination validation changes, personnel
 *         competence assessments (lab-director + clinical-pathologist sign-off)
 *   - T3: IQC out-of-control (immediate — lab-director + qms-lead + patient-
 *         safety-officer); sentinel events; accreditation non-conformities
 */
export const ISO_15189_PACK = {
    categoryClassifiers: ISO_15189_CATEGORY_CLASSIFIERS,
    id: 'iso-15189',
    aliases: ['iso15189', 'medical-laboratory', 'clinical-laboratory'],
    name: 'ISO 15189:2022 Medical Laboratory Quality and Competence',
    version: '1.0.0',
    contentHash: 'ca5b17cac720d68d5649df979a32d24f6c725f5c529cf66a336de57b7eedbb4a',
    description: 'ISO 15189:2022 (4th edition) — international standard for quality and competence in ' +
        'medical laboratories. Recognized by CAP (US), UKAS (UK), DAkkS (DE), COLA, ANAB, A2LA, ' +
        'DANAK, COFRAC, NATA, and all ILAC MRA signatories. CMS/CLIA-aligned via CAP deemed-status ' +
        'programme for US high-complexity labs. Applies to clinical, pathology, microbiology, ' +
        'haematology, immunology, molecular diagnostic labs, reference laboratories, ' +
        'pharmacogenomics labs, and point-of-care testing programmes. Combines ISO 9001 QMS ' +
        'principles with technical competence requirements: examination validation (in-house ' +
        'developed procedures) + verification (commercially-supplied procedures), Internal Quality ' +
        'Control (IQC — §7.3.7), External Quality Assessment / Proficiency Testing (EQA — §7.3.4), ' +
        'measurement uncertainty (§7.3.6), metrological traceability (§6.4.9). Full examination ' +
        'process chain: pre-examination (request + sample collection + reception) → examination ' +
        '(validation + IQC + EQA) → post-examination (review + authorisation) → reporting → ' +
        'interpretation. CRITICAL behavioral validator for IQC-out-of-control immediate-escalation: ' +
        'no patient results released until IQC passes — absolute CRITICAL block. 20-year patient- ' +
        'record retention (7300 days). 72h CAP/CLIA event-reporting baseline. Risk management per ' +
        'Annex A (ISO 14971 + ISO 22367 alignment). Reviewer tier: ASCLS / ASCP / IFCC / ' +
        'accreditation-trained inspector. Pack pairings: HIPAA (US PHI), GDPR (EU patient data), ' +
        'CLIA / CAP (US regulatory + accreditation), ISO 22870 (POCT), ISO 17025 (general lab ' +
        'competence — structural parent). PRC providers blocked: ISO 15189 §4.2 confidentiality ' +
        'requirements for clinical laboratory PHI are incompatible with PRC data localisation law.',
    authority: 'International Organization for Standardization (ISO/TC 212 — Clinical laboratory testing); ' +
        'recognized by CAP, UKAS, DAkkS, COLA, ANAB, A2LA + national accreditation bodies; ' +
        'CMS/CLIA-aligned',
    industries: [
        'medical-laboratory',
        'clinical-diagnostics',
        'pathology',
        'molecular-diagnostics',
        'point-of-care-testing',
        'reference-laboratory',
        'pharmacogenomics',
    ],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'ISO 15189 §4.1 (Impartiality) + §4.2 (Confidentiality) enforcement mandatory for all ' +
                'AI operations in medical laboratory context — impartiality policy and confidentiality ' +
                'controls must be active for every AI-assisted examination, result interpretation, and ' +
                'QMS record. IQC out-of-control absolute CRITICAL block: §7.3.7 requires that patient ' +
                'results are not released when IQC is out-of-control — AI agents must enforce this gate ' +
                'with immediate escalation. EQA participation active: §7.3.4 requires enrolment in ' +
                'external proficiency testing schemes; AI-generated performance reports require lab- ' +
                'director + clinical-pathologist review. Examination validation: §7.3.2 (validation — ' +
                'in-house) and §7.3.3 (verification — commercial) required for every examination ' +
                'procedure before use; AI-generated examination procedures require clinical-pathologist ' +
                'attestation. Equipment calibration + metrological traceability (§6.4.9): AI-generated ' +
                'calibration records require accreditation-liaison review. Risk management per Annex A ' +
                '(ISO 14971 + ISO 22367): all AI-introduced risks to examination processes require ' +
                'formal risk assessment. Lab director oversight (§5.1): all significant AI governance ' +
                'decisions require lab-director accountability.',
            reference: 'ISO 15189:2022 §4.1 Impartiality; §4.2 Confidentiality; §5.1 Legal entity + Lab Director; ' +
                '§6.4 Equipment + calibration + traceability; §7.3.2-7.3.7 Examination process; ' +
                'Annex A Risk management; Annex C Examiner competence',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident records for medical laboratory critical artefacts: IQC records (§7.3.7 — ' +
                'IQC performance data must be retained and auditable for accreditation inspection; ' +
                'out-of-control events must be traceable with corrective action records); EQA/PT ' +
                'participation and performance records (§7.3.4 — enrolment certificates, performance ' +
                'reports, corrective action documentation required for CAP/UKAS inspection); examination ' +
                'validation and verification records (§7.3.2-7.3.3 — validation data package must ' +
                'demonstrate fitness-for-purpose; retained for full procedure lifetime + audit window); ' +
                'personnel competence records (§6.2 — training records, competence assessments, ' +
                'authorisation to perform examinations, CLIA-required director sign-off); equipment ' +
                'calibration and maintenance records (§6.4 — metrological traceability chain; ' +
                'calibration certificates; corrective maintenance records); complaint and non-conforming ' +
                'work records (§7.5 + §7.7 — root cause analysis + corrective action + verification). ' +
                '20-year retention baseline (7300 days) for cross-jurisdictional medical record ' +
                'compatibility (US CAP/CLIA, EU GDPR/NHS, AU Privacy Act).',
            reference: 'ISO 15189:2022 §6.2 Personnel records; §6.4 Equipment calibration; §7.3.4 EQA records; ' +
                '§7.3.7 IQC records; §7.5 Non-conforming work; §7.7 Complaints; §8 QMS records; ' +
                'CAP accreditation inspection requirements; CLIA 42 CFR §493.1105 (records retention)',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Medical laboratory PHI signal detection: patient-identifiable examination request ' +
                'and result data (ISO 15189 §4.2 + HIPAA PHI + GDPR special-category health data — ' +
                'lab test results are special-category data under GDPR Art. 9; Protected Health ' +
                'Information under HIPAA 45 CFR §164.514); IQC out-of-control signal classification ' +
                '(§7.3.7 — immediate CRITICAL escalation trigger, no patient result release until ' +
                'resolved); examination validation/verification record classification (§7.3.2-7.3.3 — ' +
                'human review gate before new procedures activated); EQA non-conformance signal ' +
                'classification (§7.3.4 — corrective action trigger); pre-examination non-conformity ' +
                'classification (§7.2 — unsuitable samples, inappropriate requests); risk event ' +
                'classification per Annex A (ISO 14971 risk threshold application for lab processes).',
            reference: 'ISO 15189:2022 §4.2 Confidentiality; §7.2 Pre-examination; §7.3.4 EQA; §7.3.7 IQC; ' +
                'HIPAA 45 CFR §164 (PHI classification); GDPR Art. 9 (special-category health data); ' +
                'Annex A Risk management classification',
        },
        {
            name: 'supply-chain',
            required: true,
            reason: 'ISO 15189 §6.5 (Reagents and consumables) + §6.6 (Service agreements) supply-chain ' +
                'requirements: reagent and consumable vendor qualification with receipt inspection and ' +
                'acceptance testing; reference material and calibrator traceability (§6.4.9 — ' +
                'metrological traceability chain documentation); external service agreements for ' +
                'referral testing (§6.6 — referral laboratory qualification + result integrity ' +
                'verification); third-party LLM/AI vendor qualification for clinical AI components ' +
                'used in examination process support. PRC-jurisdiction LLM provider blocking: ' +
                'ISO 15189 §4.2 confidentiality requirements for clinical laboratory PHI (patient- ' +
                'identifiable examination requests and results) are incompatible with PRC data ' +
                'localisation law (Cybersecurity Law Art. 37 + Data Security Law Art. 36 + PIPL Art. ' +
                '38-46) — routing patient examination data through PRC-jurisdiction services exposes ' +
                'clinical PHI to government access obligations irreconcilable with HIPAA, GDPR, and ' +
                'ISO 15189 §4.2 confidentiality controls. HIPAA Business Associate Agreement required ' +
                'for any external AI vendor processing PHI in US context.',
            reference: 'ISO 15189:2022 §6.4.9 Metrological traceability; §6.5 Reagents and consumables; ' +
                '§6.6 Service agreements; §4.2 Confidentiality; ' +
                'HIPAA 45 CFR §164.308(b) BAA requirements; PRC CSL Art. 37 / DSL Art. 36 / PIPL Art. 38-46',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'ISO 15189 requires formal approval gates for: IQC out-of-control event resolution ' +
                '(§7.3.7 — lab-director + qms-lead must approve patient result release after IQC ' +
                'out-of-control event is resolved and root cause documented); examination validation ' +
                'completion (§7.3.2 — clinical-pathologist + lab-director sign-off before new procedure ' +
                'activated for patient use); personnel competence authorisation (§6.2 — lab-director ' +
                'authorisation to perform examinations; Annex C interpretive competence sign-off); ' +
                'EQA corrective action closure (§7.3.4 — lab-director approval of corrective action ' +
                'plan before re-participation); complaint resolution (§7.7 — qms-lead + lab-director ' +
                'approval of corrective action + response); nonconforming work corrective action ' +
                '(§7.5 — qms-lead approval before result release or procedure re-activation); ' +
                'risk management decision (Annex A — lab-director acceptance of residual risk).',
            reference: 'ISO 15189:2022 §5.1 Lab Director responsibility; §6.2 Personnel authorisation; ' +
                '§7.3.2 Examination validation approval; §7.3.7 IQC out-of-control release approval; ' +
                '§7.5 Non-conforming work; §7.7 Complaints resolution; Annex A risk acceptance',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'ISO 15189 attestation requirements: lab-director attestation for IQC out-of-control ' +
                'corrective action sign-off (§7.3.7 — no patient results released without lab-director ' +
                'acknowledgement after out-of-control episode); clinical pathologist attestation for ' +
                'AI-generated interpretive reports (Annex C — clinical interpretation competence ' +
                'requirement); examination validation attestation (§7.3.2 — clinical-pathologist ' +
                'certification that validation data supports intended purpose); personnel competence ' +
                'attestation (§6.2 + Annex C — lab-director authorisation of each examiner for each ' +
                'examination type); QMS lead attestation for EQA corrective action effectiveness ' +
                '(§7.3.4 — qms-lead certification that corrective action resolves identified performance ' +
                'gap); accreditation liaison attestation for internal audit findings (§8 — internal ' +
                'audit sign-off and corrective action closure before CAP/UKAS inspection).',
            reference: 'ISO 15189:2022 §5.1 Lab Director responsibility; §6.2 Personnel competence attestation; ' +
                '§7.3.2 Validation attestation; §7.3.7 IQC corrective action attestation; ' +
                'Annex C Examiner competence sign-off; CAP accreditation attestation requirements',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'ISO 15189 mandates long-term record retention for all quality and technical records: ' +
                'examination validation and verification data (§7.3.2-7.3.3 — retained for full ' +
                'procedure lifetime + audit window; cross-jurisdictional 20-year baseline); IQC ' +
                'performance records including out-of-control episodes and corrective actions ' +
                '(§7.3.7 — required for trend analysis, accreditation inspection, and CLIA survey); ' +
                'EQA/PT participation and performance records (§7.3.4 — CAP requires 2-year minimum ' +
                'for most programmes; ISO 15189 audit requires full programme history for accreditation ' +
                'assessment); personnel training and competence assessment records (§6.2 — full ' +
                'employment history required; CLIA minimum 2 years; CAP recommends indefinite for ' +
                'credentials); equipment calibration, maintenance, and malfunction records (§6.4 — ' +
                'calibration certificates + traceability chains; instrument maintenance log); patient ' +
                'examination result records (20-year baseline per HIPAA + EU + AU medical record law).',
            reference: 'ISO 15189:2022 §6.2 Personnel records; §6.4 Equipment records; §7.3.2-7.3.3 Validation records; ' +
                '§7.3.4 EQA records; §7.3.7 IQC records; §8 QMS records; ' +
                'CLIA 42 CFR §493.1105; CAP accreditation checklists; HIPAA 45 CFR §164.530(j)',
        },
        {
            name: 'anomaly-detector',
            required: true,
            reason: 'Real-time detection of ISO 15189 critical process failures: IQC out-of-control ' +
                'detection (§7.3.7 — Westgard rule violation or equivalent; CRITICAL immediate ' +
                'escalation to lab-director + qms-lead + patient-safety-officer; no patient results ' +
                'released until IQC passes — absolute block with no compensating control path); ' +
                'EQA performance anomaly detection (§7.3.4 — unacceptable performance on proficiency ' +
                'testing triggers immediate corrective action and qms-lead escalation); examination ' +
                'drift detection (§7.3.6 — measurement uncertainty trending outside pre-defined ' +
                'limits triggers re-validation review); pre-examination non-conformity detection ' +
                '(§7.2 — unsuitable specimens, out-of-reference-range conditions); equipment ' +
                'calibration anomaly detection (§6.4 — calibration failure or metrological ' +
                'traceability chain break triggers equipment quarantine).',
            reference: 'ISO 15189:2022 §6.4 Equipment anomaly; §7.2 Pre-examination non-conformity; ' +
                '§7.3.4 EQA performance anomaly; §7.3.6 Measurement uncertainty drift; ' +
                '§7.3.7 IQC out-of-control immediate escalation; Annex A risk event detection',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'AI-generated medical laboratory output provenance disclosure to clinical pathologists, ' +
                'ASCLS / ASCP / IFCC members, lab directors, and accreditation-trained inspectors. ' +
                'Required for: AI-assisted interpretation of laboratory results (Annex C — interpretive ' +
                'competence requirement; AI-generated content must be labelled and reviewed by ' +
                'qualified clinical pathologist before release); AI-generated QMS documentation ' +
                '(§8 — AI involvement in quality records, audit reports, and corrective action ' +
                'documentation must be disclosed); AI-assisted IQC rule application (§7.3.7 — ' +
                'where AI assists in applying Westgard rules or statistical QC analysis, model ' +
                'provenance must be disclosed to lab director reviewing IQC data); CAP/UKAS ' +
                'accreditation inspection readiness: inspectors expect to see AI governance ' +
                'documentation for any AI-assisted examination or interpretive process.',
            reference: 'ISO 15189:2022 §4.1 Impartiality — AI conflict-of-interest disclosure; ' +
                'Annex C Examiner competence — AI interpretation provenance; ' +
                '§8 QMS document authenticity; CAP accreditation transparency expectations',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'ISO 15189 lifecycle event routing: IQC out-of-control event (§7.3.7 — CRITICAL ' +
                'immediate escalation: lab-director + qms-lead + clinical-pathologist + patient-safety- ' +
                'officer; result-release blocked); EQA unacceptable-performance event (§7.3.4 — ' +
                'corrective-action trigger: qms-lead + accreditation-liaison + lab-director routing); ' +
                'examination validation completion event (§7.3.2 — clinical-pathologist + lab-director ' +
                'sign-off routing before procedure activation); personnel competence assessment event ' +
                '(§6.2 + Annex C — lab-director authorisation routing); equipment calibration-failure ' +
                'event (§6.4 — instrument quarantine + accreditation-liaison + qms-lead routing); ' +
                'complaint received event (§7.7 — qms-lead + lab-director routing, 72h response ' +
                'target); pre-examination nonconformity event (§7.2 — clinical-pathologist + lab- ' +
                'director routing for high-impact specimen non-conformities); accreditation ' +
                'non-conformity event (§8 — lab-director + accreditation-liaison immediate routing).',
            reference: 'ISO 15189:2022 §6.2 Personnel events; §6.4 Equipment events; §7.2 Pre-examination events; ' +
                '§7.3.2 Validation completion events; §7.3.4 EQA events; §7.3.7 IQC out-of-control events; ' +
                '§7.7 Complaint events; §8 Accreditation non-conformity events',
        },
    ],
    moduleConfig: {
        'governance-runtime': {
            impartialityPolicyRequired: true,
            confidentialityControlsRequired: true,
            labDirectorOversightRequired: true,
            personnelCompetenceTrackingRequired: true,
            equipmentCalibrationTraceabilityRequired: true,
            examinationValidationRequired: true,
            internalQualityControlActive: true,
            externalProficiencyTestingActive: true,
            riskManagementAnnexAActive: true,
            iqcOutOfControlImmediateEscalationRequired: true,
            resultReportingControlsRequired: true,
            pointOfCareTestingControlsActive: true,
        },
        'approval-queue': {
            iqcOutOfControlResultReleaseApprovalRequired: true,
            examinationValidationCompletionApprovalRequired: true,
            personnelCompetenceAuthorisationRequired: true,
            eqaCorrectiveActionClosureApprovalRequired: true,
            complaintResolutionApprovalRequired: true,
            nonconformingWorkCorrectiveActionApprovalRequired: true,
            riskAcceptanceApprovalRequired: true,
            humanInLoopTierRoutine: 'T1',
            humanInLoopTierValidationChange: 'T2',
            humanInLoopTierIqcOutOfControl: 'T3',
        },
        'attestation-manager': {
            labDirectorIqcCorrectiveActionAttestationRequired: true,
            clinicalPathologistInterpretiveReportAttestationRequired: true,
            examinationValidationAttestationRequired: true,
            personnelCompetenceAttestationRequired: true,
            qmsLeadEqaCorrectiveActionAttestationRequired: true,
            accreditationLiaisonInternalAuditAttestationRequired: true,
        },
        'supply-chain': {
            reagentConsumableVendorQualificationRequired: true,
            referenceMateriаlTracabilityRequired: true,
            referralLaboratoryQualificationRequired: true,
            prcProviderBlockRequired: true,
            hipaaBusinessAssociateAgreementRequired: true,
        },
        'anomaly-detector': {
            iqcOutOfControlImmediateEscalationRequired: true,
            eqaPerformanceAnomalyDetectionRequired: true,
            examinationDriftDetectionRequired: true,
            preExaminationNonConformityDetectionRequired: true,
            equipmentCalibrationAnomalyDetectionRequired: true,
        },
        'transparency-injector': {
            aiGeneratedLaboratoryInterpretiveContentDisclosureRequired: true,
            aiGeneratedQmsDocumentationDisclosureRequired: true,
            aiAssistedIqcRuleApplicationDisclosureRequired: true,
            humanPathologistReviewBeforeResultReleaseRequired: true,
        },
        'event-bus': {
            iqcOutOfControlEventsActive: true,
            eqaUnacceptablePerformanceEventsActive: true,
            examinationValidationCompletionEventsActive: true,
            personnelCompetenceAssessmentEventsActive: true,
            equipmentCalibrationFailureEventsActive: true,
            complaintReceivedEventsActive: true,
            preExaminationNonConformityEventsActive: true,
            accreditationNonConformityEventsActive: true,
        },
    },
    providerPolicy: {
        blockedProviders: ['deepseek', 'baidu', 'alibaba'],
        requiredCapabilities: [
            'MEDICAL-LABORATORY-READY',
            'ISO-15189-COMPLIANT',
            'CLINICAL-PHI-GOVERNANCE',
        ],
        blockReasons: {
            deepseek: 'PRC-jurisdiction LLM providers cannot meet HIPAA + GDPR + ISO 15189 §4.2 ' +
                'confidentiality requirements for clinical laboratory PHI handling. Medical laboratory ' +
                'examination data (patient test requests, sample details, examination results, ' +
                'interpretive reports) constitutes Protected Health Information under HIPAA 45 CFR §164 ' +
                'and special-category health data under GDPR Art. 9. ISO 15189:2022 §4.2 requires that ' +
                'laboratories protect patient information obtained in the course of laboratory activities ' +
                'and take measures to ensure confidentiality. PRC data localisation law (Cybersecurity ' +
                'Law Art. 37, Data Security Law Art. 36, PIPL Art. 38-46) creates government access ' +
                'obligations to clinical PHI that are irreconcilable with HIPAA minimum-necessary ' +
                'standards, GDPR adequacy requirements, and ISO 15189 §4.2 confidentiality controls. ' +
                'CAP accreditation inspection would flag PRC-jurisdiction processing of patient ' +
                'examination data as a confidentiality non-conformity.',
            baidu: 'PRC-jurisdiction LLM; HIPAA + GDPR + ISO 15189 §4.2 confidentiality requirements ' +
                'for clinical laboratory PHI cannot be met. Patient examination requests, results, and ' +
                'interpretive reports are special-category health data (GDPR Art. 9) and PHI (HIPAA). ' +
                'ISO 15189 §4.2 confidentiality requirement prohibits processing patient examination ' +
                'data through systems subject to PRC government access obligations under CSL Art. 37 ' +
                'and DSL Art. 36. CLIA 42 CFR §493 requires patient data confidentiality; CAP ' +
                'accreditation checklists explicitly address information security for patient data. ' +
                'Processing clinical laboratory PHI through PRC-jurisdiction services exposes labs ' +
                'to HIPAA breach notification obligations and GDPR Art. 83(4) penalties, and would ' +
                'constitute a material non-conformity under CAP/UKAS accreditation inspections.',
            alibaba: 'PRC-jurisdiction LLM; clinical laboratory PHI (patient examination data, interpretive ' +
                'reports, genomic data in molecular diagnostic labs, pharmacogenomics data) cannot be ' +
                'processed through PRC-jurisdiction AI systems under HIPAA, GDPR, and ISO 15189 §4.2. ' +
                'Molecular diagnostic and pharmacogenomics labs additionally handle genomic data ' +
                'subject to GDPR Art. 9 (genetic data special category) and US Genetic Information ' +
                'Nondiscrimination Act (GINA). PRC PIPL Art. 38-46 cross-border data transfer ' +
                'restrictions and DSL Art. 36 government access obligations are incompatible with ' +
                'ISO 15189 §4.2 confidentiality requirements, HIPAA minimum-necessary and breach ' +
                'notification rules, and GDPR data localisation + adequacy requirements for health ' +
                'data. CAP LAP (Laboratory Accreditation Program) would classify PRC-jurisdiction ' +
                'PHI routing as a Phase II deficiency (immediate corrective action required).',
        },
    },
    dataPolicy: {
        scanCategories: [
            'PATIENT_EXAMINATION_DATA',
            'IQC_OUT_OF_CONTROL_EVENT',
            'EQA_PERFORMANCE_RECORD',
            'EXAMINATION_VALIDATION_RECORD',
            'PERSONNEL_COMPETENCE_RECORD',
        ],
        categoryActions: {
            // IQC out-of-control: BLOCK — no patient results released until IQC passes
            IQC_OUT_OF_CONTROL_EVENT: 'BLOCK',
            // Patient examination data: REVIEWED — clinical-pathologist review before AI-assisted release
            PATIENT_EXAMINATION_DATA: 'REVIEWED',
            // EQA performance records: REVIEWED — qms-lead + lab-director review
            EQA_PERFORMANCE_RECORD: 'REVIEWED',
            // Examination validation records: REVIEWED — clinical-pathologist + lab-director sign-off
            EXAMINATION_VALIDATION_RECORD: 'REVIEWED',
            // Personnel competence: REVIEWED — lab-director authorisation
            PERSONNEL_COMPETENCE_RECORD: 'REVIEWED',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256-GCM',
        minimumClassification: 'RESTRICTED',
    },
    retentionPolicy: {
        /**
         * 20-year patient-record retention baseline (7300 days).
         *
         * Derived from the conservative cross-jurisdictional maximum for medical
         * laboratory records across ISO 15189 major-market jurisdictions:
         *   US: CAP recommends 20 years for special/genetic tests;
         *       CLIA minimum 2 years (42 CFR §493.1105); state law varies 5-10 years.
         *   EU: NHS Wales 20 years post last contact; Germany §630f BGB 10 years;
         *       France clinical records 20 years; GDPR storage limitation balanced
         *       against medical record retention obligations (Art. 9(2)(h) + recital 65).
         *   AU: Health Records Acts typically 7 years for adults;
         *       state cancer and genetic registry records retained indefinitely.
         *
         * 20-year conservative baseline chosen for cross-jurisdictional compatibility
         * with ISO 15189 accreditation requirements that may span multiple national
         * accreditation body frameworks simultaneously (e.g. UKAS + CAP).
         */
        sovereignty: ['us', 'eu', 'gb', 'au'],
        auditLogRetentionDays: 7300, // 20 years — patient-record retention baseline
        sessionRetentionDays: 7300,
        incidentRetentionDays: 7300,
        reference: 'ISO 15189:2022 §8 QMS records retention; CAP LAP 20-year recommendation for special/genetic tests. ' +
            'CLIA 42 CFR §493.1105 — minimum 2 years from date of reporting. ' +
            'EU NHS Wales: 20 years post last contact; Germany §630f BGB: 10 years; France: 20 years clinical records. ' +
            'Conservative 20-year (7300 days) cross-jurisdictional baseline applied for ISO 15189 medical laboratories.',
    },
    incidentPolicy: {
        /**
         * 72-hour event-reporting baseline (3 days).
         *
         * Derived from the most stringent applicable regulatory window across
         * ISO 15189 major-market jurisdictions and accreditation programmes:
         *   CAP/CLIA: Sentinel event + patient-safety event reporting expectations
         *             within CAP Q-Probes/Q-Tracks programmes; immediate clinical
         *             action required on IQC out-of-control per §7.3.7.
         *   GDPR Art. 33: 72-hour data breach notification to supervisory authority
         *             (applies to EU labs or labs handling EU patient data).
         *   CMS/CLIA 42 CFR §493.1101: Deficiency investigation-driven; no fixed
         *             hour window but immediate corrective action required.
         *   ISO 15189 §7.7: Complaints — labs shall acknowledge and investigate
         *             without undue delay; 72h initial response is standard.
         *
         * 72h (3 days) is the common cross-programme formal-notification baseline.
         * IQC out-of-control events require IMMEDIATE internal action (not 72h) —
         * the 72h window governs external/formal notification, not internal response.
         */
        notificationDeadlineHours: 72, // 3 days — CAP/CLIA event-reporting baseline + GDPR Art. 33
        reference: 'ISO 15189:2022 §7.7 Complaints — investigate without undue delay; §7.3.7 IQC — immediate action on out-of-control. ' +
            'CAP Q-Probes/Q-Tracks: sentinel event reporting expectations. ' +
            'GDPR Art. 33: 72-hour supervisory authority notification (for labs handling EU patient data). ' +
            'CLIA 42 CFR §493.1101: immediate corrective action on deficiencies. ' +
            '72h (3 days) is the common cross-programme formal-notification baseline.',
        requiredRecipients: [
            'lab-director',
            'qms-lead',
            'clinical-pathologist',
            'patient-safety-officer',
            'accreditation-liaison',
            'cms-clia-coordinator',
        ],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'iso15189-impartiality',
            description: 'Impartiality policy established and enforced per ISO 15189:2022 §4.1: laboratory ' +
                'impartiality policy documented and communicated to all personnel; management commitment ' +
                'to impartiality evidenced (signed policy + periodic review); conflicts of interest ' +
                'identification and management process operational — commercial, financial, and personal ' +
                'pressures that could influence examination results are identified and mitigated; ' +
                'personnel declarations of interest documented; AI-assisted examination interpretation ' +
                'assessed for algorithmic bias that could compromise impartiality; sponsor/vendor ' +
                'influence on examination procedures identified and managed; impartiality safeguards ' +
                'for referral laboratory selection operational; management review includes impartiality ' +
                'risk assessment; impartiality policy reviewed at each management review cycle.',
            reference: 'ISO 15189:2022 §4.1 (Impartiality)',
            check: 'iso15189_impartiality',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-confidentiality',
            description: 'Confidentiality controls established and enforced per ISO 15189:2022 §4.2: patient ' +
                'information protection policy documented; legal basis for processing patient data ' +
                'identified and documented (HIPAA authorisation / GDPR Art. 9(2)(h) / applicable ' +
                'national law); data sharing agreements in place for all external parties receiving ' +
                'patient examination data; personnel trained on confidentiality obligations; ' +
                'information security controls operational (access controls, encryption, audit logging); ' +
                'AI system access to patient examination data governed by data classification policy; ' +
                'patient results communicated only to authorised requestors; electronic transmission ' +
                'of results encrypted in transit and at rest; breach detection and notification ' +
                'process operational (72h GDPR Art. 33 for EU patient data); data retention and ' +
                'disposal process compliant with applicable law; HIPAA BAA in place for all AI ' +
                'vendors processing US patient PHI.',
            reference: 'ISO 15189:2022 §4.2 (Confidentiality)',
            check: 'iso15189_confidentiality',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-lab-director-responsibility',
            description: 'Laboratory director responsibility and structural requirements established per ' +
                'ISO 15189:2022 §5.1: legal entity documented with authority to operate the ' +
                'laboratory; qualified laboratory director appointed meeting educational and ' +
                'experience requirements for scope of accreditation (CLIA high-complexity: MD/DO ' +
                'with board certification in laboratory medicine, or PhD with appropriate experience); ' +
                'lab director responsibilities documented including quality policy ownership, QMS ' +
                'implementation oversight, resource allocation authority, personnel supervision, ' +
                'accreditation liaison, and final accountability for examination quality and safety; ' +
                'delegation of authority documented when lab director is absent; organisational ' +
                'structure defined (§5.4) with reporting lines for all technical + quality functions; ' +
                'management review conducted at defined intervals with lab director participation; ' +
                'lab director accessible for quality and patient-safety decisions.',
            reference: 'ISO 15189:2022 §5.1 (Legal entity + Lab Director)',
            check: 'iso15189_lab_director_responsibility',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-personnel-competence',
            description: 'Personnel competence management established per ISO 15189:2022 §6.2 and Annex C: ' +
                'competence requirements defined for all examination and interpretive roles; ' +
                'initial competence assessed before independent work begins (six-element CLIA ' +
                'competency assessment for each new examiner and new procedure); ongoing competency ' +
                'assessment performed at minimum annually (§6.2.6); authorisation records maintained ' +
                'for each examiner for each examination type (lab-director authorisation); training ' +
                'records maintained (including continuing education); competency gap corrective action ' +
                'process operational; Annex C interpretive competence requirements addressed for ' +
                'clinical pathologists and interpretive specialists; AI-assisted examination tools ' +
                'require personnel training records on limitations, appropriate use, and human ' +
                'oversight requirements; locum/contract staff competency managed equivalently; ' +
                'student/trainee supervision requirements documented.',
            reference: 'ISO 15189:2022 §6.2 (Personnel)',
            check: 'iso15189_personnel_competence',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-equipment-calibration',
            description: 'Equipment management, calibration, and metrological traceability established per ' +
                'ISO 15189:2022 §6.4: equipment selection criteria documented; equipment verification ' +
                'performed before use and after repair; calibration programme operational for all ' +
                'measuring equipment with calibration intervals defined; metrological traceability ' +
                'chain documented (calibration traceable to SI units or certified reference materials ' +
                'per §6.4.9); calibration certificates retained with traceability documentation; ' +
                'equipment maintenance programme active (preventive maintenance schedule + records); ' +
                'equipment malfunction and corrective maintenance records maintained; instrument ' +
                'comparison programme operational where multiple instruments perform the same ' +
                'examination; reference materials and calibrators managed per manufacturer ' +
                'specifications; equipment performance monitoring integrated with IQC; AI-assisted ' +
                'equipment monitoring requires disclosure of anomaly-detection model provenance.',
            reference: 'ISO 15189:2022 §6.4 (Equipment + calibration + traceability)',
            check: 'iso15189_equipment_calibration',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-reagents-consumables',
            description: 'Reagent and consumable management established per ISO 15189:2022 §6.5: procurement ' +
                'specifications defined for all critical reagents, calibrators, and consumables; ' +
                'receipt inspection and acceptance testing procedures documented and followed; ' +
                'storage conditions monitored and recorded (temperature, humidity where applicable); ' +
                'expiry date management process operational (no expired reagents used); lot-to-lot ' +
                'verification performed when new lots received for critical reagents; traceability ' +
                'of reagent and calibrator lot numbers to patient examination results maintained ' +
                '(essential for result recall and root-cause analysis); reference material ' +
                'certification documentation retained; vendor qualification for critical suppliers ' +
                'operational; incoming inspection records maintained; abnormal performance triggers ' +
                'investigation and IQC review.',
            reference: 'ISO 15189:2022 §6.5 (Reagents + consumables)',
            check: 'iso15189_reagents_consumables',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-pre-examination',
            description: 'Pre-examination process management established per ISO 15189:2022 §7.2: request ' +
                'form requirements defined and communicated to requestors (§7.2.2); patient ' +
                'preparation instructions documented and available (§7.2.3); primary sample ' +
                'collection procedures documented per examination type (§7.2.4 — container, ' +
                'additives, volume, labelling); sample transport requirements documented and ' +
                'monitored; sample reception criteria defined — unsuitable samples identified, ' +
                'documented, and managed (§7.2.7); referral sample management documented; ' +
                'pre-examination process performance monitored (sample rejection rate, collection ' +
                'adequacy); turnaround time tracking from sample receipt; AI-assisted pre-examination ' +
                'screening (e.g. haemolysis / lipaemia / icterus detection) requires model ' +
                'validation documentation and clinical-pathologist review of decision logic.',
            reference: 'ISO 15189:2022 §7.2 (Pre-examination — request + sample collection + reception)',
            check: 'iso15189_pre_examination',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-examination-validation',
            description: 'Examination validation and verification established per ISO 15189:2022 §7.3.2-7.3.3: ' +
                'VALIDATION (§7.3.2 — in-house developed or modified procedures): validation plan ' +
                'documented; validation parameters established (analytical measurement range, ' +
                'analytical sensitivity/specificity, precision, trueness, interferences, reference ' +
                'intervals, measurement uncertainty); validation data collected against pre-defined ' +
                'acceptance criteria; validation report prepared and approved by clinical-pathologist ' +
                '+ lab-director before patient use; re-validation triggered by significant procedure ' +
                'modification. VERIFICATION (§7.3.3 — commercially-supplied procedures): manufacturer ' +
                'performance specifications verified in the lab\'s own environment; verification ' +
                'parameters at minimum: precision, trueness/bias, reference interval applicability; ' +
                'verification report prepared and approved before clinical use. AI-generated ' +
                'examination procedures require full validation per §7.3.2.',
            reference: 'ISO 15189:2022 §7.3 (Examination — validation + verification)',
            check: 'iso15189_examination_validation',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-internal-quality-control',
            description: 'Internal Quality Control (IQC) program established and operational per ISO 15189:2022 ' +
                '§7.3.7: IQC program documented covering all quantitative examinations; control ' +
                'materials selected appropriately (commutable preferred; matrix similar to patient ' +
                'samples; concentrations spanning clinically relevant decision points); IQC ' +
                'statistical rules defined (Westgard multi-rule or equivalent); IQC frequency ' +
                'defined per examination (minimum: each analytical run); IQC data plotted (Levey- ' +
                'Jennings or equivalent) and trends reviewed; IQC OUT-OF-CONTROL POLICY: when IQC ' +
                'signals out-of-control, patient results from the affected run are HELD — no release ' +
                'until root cause identified and corrective action taken and IQC passes — ABSOLUTE ' +
                'CRITICAL BLOCK; IQC corrective action documented with lab-director sign-off; ' +
                'IQC data reviewed at defined intervals for trending; AI-assisted IQC rule ' +
                'application requires model provenance disclosure.',
            reference: 'ISO 15189:2022 §7.3.7 (Internal Quality Control)',
            check: 'iso15189_internal_quality_control',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-external-proficiency-testing',
            description: 'External Quality Assessment (EQA) / Proficiency Testing (PT) program established ' +
                'per ISO 15189:2022 §7.3.4: enrolment in appropriate EQA/PT programmes for all ' +
                'examinations where schemes are available (CAP PT, RCPA QAP, UKNEQAS, INSTAND, ' +
                'EQAS, or equivalent ILAC-recognised scheme); EQA samples handled in same manner ' +
                'as patient samples (§7.3.4 — no special handling; reviewed by normal staff); ' +
                'performance criteria defined for each programme; unacceptable EQA performance ' +
                'triggers immediate investigation and corrective action before next survey cycle; ' +
                'corrective action documented and approved by qms-lead + lab-director; EQA ' +
                'participation certificates maintained; where no EQA scheme available, interlaboratory ' +
                'comparison or alternative assessment method documented; EQA results reviewed at ' +
                'management review; comparability programme operational where multiple methods ' +
                'used (§7.3.5).',
            reference: 'ISO 15189:2022 §7.3.4 (Comparability + external assessment)',
            check: 'iso15189_external_proficiency_testing',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'iso15189-result-reporting',
            description: 'Result reporting controls established per ISO 15189:2022 §7.4: examination results ' +
                'reviewed and authorised by qualified personnel before release (§7.4.1); critical ' +
                'value notification process operational — critical results communicated to ' +
                'responsible clinician immediately with documentation of notification (§7.4.1.2); ' +
                'report format includes required elements: patient identification, requestor ' +
                'identification, laboratory identification, examination identification, sample ' +
                'collection date/time, result with units and reference intervals, interpretive ' +
                'comments where required, report issue date/time, responsible authoriser; ' +
                'amended report process documented (§7.4.2 — traceability to original); result ' +
                'transmission integrity verified; AI-generated interpretive comments require ' +
                'clinical-pathologist review and clear disclosure of AI assistance before release; ' +
                'turnaround time monitoring and alerts operational.',
            reference: 'ISO 15189:2022 §7.4 (Reporting of results)',
            check: 'iso15189_result_reporting',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-clinical-interpretation',
            description: 'Post-examination process and clinical interpretation controls established per ' +
                'ISO 15189:2022 §7.5 + Annex C: post-examination review process documented; ' +
                'responsible authoriser competence verified (Annex C — interpretive competence for ' +
                'clinical pathologist and interpretive specialist roles); clinical interpretation ' +
                'comments appropriately grounded in clinical context + examination results + ' +
                'reference data; cases requiring clinical pathologist consultation identified and ' +
                'routed; AI-generated clinical interpretation must be reviewed by ASCLS/ASCP/IFCC- ' +
                'qualified clinical pathologist before release (Annex C competence requirement); ' +
                'consultation results documented; nonconforming work identified post-examination ' +
                'handled per §7.5; retained sample policy documented (§7.2.5 — sample storage ' +
                'for verification of results, complaints, and additional examinations); post- ' +
                'examination performance monitoring (complaint and amendment rates tracked).',
            reference: 'ISO 15189:2022 §7.5 (Post-examination + clinical interpretation)',
            check: 'iso15189_clinical_interpretation',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-risk-management-annex-a',
            description: 'Risk management for medical laboratories established per ISO 15189:2022 Annex A, ' +
                'aligned with ISO 14971 (medical device risk management) and ISO 22367 (medical ' +
                'laboratories — risk management in the laboratory): risk management plan documented ' +
                'covering the full examination process (pre-examination + examination + post- ' +
                'examination); hazard identification process operational for all examination types; ' +
                'risk estimation using probability × severity matrix; risk control measures ' +
                'implemented and verified (IQC, EQA, sample acceptance criteria, critical value ' +
                'notification, personnel competence); residual risk acceptability assessed by ' +
                'lab-director; risk monitoring continuous (IQC data + complaint data + EQA ' +
                'performance + near-miss reports); risk management process reviewed annually; ' +
                'AI-introduced risks to examination processes formally assessed (algorithmic ' +
                'bias, model drift, system failure modes) before AI tool activation.',
            reference: 'ISO 15189:2022 Annex A (Risk management for medical laboratories)',
            check: 'iso15189_risk_management_annex_a',
            failSeverity: 'HIGH',
        },
        {
            id: 'iso15189-complaints-handling',
            description: 'Complaints handling process established per ISO 15189:2022 §8.7: complaints policy ' +
                'documented and communicated; all complaints received, recorded, and acknowledged ' +
                'without undue delay (72h formal response baseline); complaints investigated to ' +
                'identify root cause; corrective action implemented and verified; complainant ' +
                'informed of outcome (where legally permissible); complaints data analysed for ' +
                'trends at management review; complaints related to AI-assisted examinations or ' +
                'interpretive outputs managed with additional clinical-pathologist + qms-lead ' +
                'review; complaints potentially indicating a patient safety event escalated to ' +
                'patient-safety-officer immediately; accreditation body notified of significant ' +
                'complaints per accreditation requirements; complaints records retained per ' +
                'retention policy.',
            reference: 'ISO 15189:2022 §8.7 (Complaints)',
            check: 'iso15189_complaints_handling',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'iso15189-behavioral-validator-iqc-out-of-control',
            description: 'Behavioral validator: detects IQC (Internal Quality Control) out-of-control ' +
                'conditions for any governed examination process. When IQC signals an out-of-control ' +
                'condition (Westgard rule violation or equivalent statistical QC signal), the release ' +
                'of patient examination results from the affected analytical run is an ABSOLUTE ' +
                'CRITICAL BLOCK with NO compensating control path. ' +
                'ISO 15189:2022 §7.3.7 requires that out-of-control IQC results be acted upon ' +
                'IMMEDIATELY and patient results from the affected run must NOT be reported until: ' +
                '(a) root cause of the IQC failure is identified; (b) corrective action is taken; ' +
                '(c) IQC is repeated and passes; (d) lab-director + qms-lead formally approve ' +
                'result release. The IQC-out-of-control event triggers immediate escalation to: ' +
                'lab-director, qms-lead, clinical-pathologist, patient-safety-officer, ' +
                'accreditation-liaison, and cms-clia-coordinator. No time-pressure override, no ' +
                'senior-examiner bypass — IQC out-of-control is an absolute block until formally ' +
                'resolved. Any AI agent operating in an examination workflow must enforce this gate. ' +
                'This is the highest-severity medical laboratory governance event — patient safety ' +
                'depends on IQC integrity as the primary technical competence signal.',
            reference: 'ISO 15189:2022 §7.3.7 (Internal Quality Control — out-of-control action); ' +
                'behavioral validator: iqc-out-of-control immediate-escalation',
            check: 'behavioralValidator_iso15189_iqc_out_of_control',
            failSeverity: 'CRITICAL',
        },
    ],
};
//# sourceMappingURL=iso-15189.js.map