"use strict";
/**
 * AU TGA Software as a Medical Device (SaMD)
 *
 * Primary legislation: Therapeutic Goods Act 1989 (Cth); Therapeutic Goods
 * (Medical Devices) Regulations 2002.
 *
 * Key instruments:
 *   - TGA Regulatory Guidance: Software as a Medical Device (updated 2023)
 *   - TGA AI/ML-enabled Medical Devices Guidance (2023, updated 2024)
 *   - IMDRF SaMD Key Definitions (N10, 2013); Risk Categorisation (N12, 2014)
 *   - Good Machine Learning Practice (GMLP) Principles (TGA adopted 2021/2023)
 *   - TGA Unique Device Identification (UDI) system
 *
 * Covered: Software meeting "medical device" definition: diagnosis, prevention,
 * monitoring, prediction, prognosis, treatment, alleviation of disease/injury.
 * AI/ML CDS in IMDRF SaMD Categories II-IV. Adaptive AI/ML algorithms require
 * enhanced pre-market review + post-market change management.
 *
 * IMDRF Risk Classification (TGA-adopted):
 *   I: Non-serious / Treat+diagnose
 *   II: Non-serious / Drive clinical management
 *   III: Serious / Inform clinical management
 *   IV: Critical / Treat+diagnose directly
 *
 * [CITATION TO VERIFY]:
 *   - Some IMDRF Category I software may be excluded under current TGA excluded
 *     software determination — verify current scope.
 *   - Pure data-consolidation CDS without analysis — verify scope alignment with
 *     updated 2023 TGA guidance.
 *
 * Key AI obligations:
 *   - TGA Registration: SaMD on ARTG before AU supply. s.41MA offence to supply
 *     unregistered. FDA clearance does NOT substitute for ARTG.
 *   - GMLP 10 Principles: Multi-disciplinary teams, clinical-AI collaboration,
 *     real-world deployment design, data management transparency, reference
 *     datasets, tailored model testing, human-AI teaming, contextualised
 *     performance testing, inform users of limitations, deployed model monitoring.
 *   - PCCP: Predetermined Change Control Plan for adaptive models; significant
 *     changes require pre-market notification or new conformity assessment.
 *   - Post-Market Surveillance: Real-world performance monitoring with drift
 *     detection; adverse events reported.
 *   - Adverse events: 10 calendar days for incidents likely causing death/serious
 *     deterioration; 30 days for incidents that could have caused death/serious
 *     injury.
 *
 * Cross-pack interactions:
 *   - au-tga-saimd + fda-samd: Sequential separate requirements; TGA-FDA mutual
 *     recognition for assessment bodies (not approvals). ISO 13485 satisfies both
 *     QMS requirements. FDA PCCP and TGA PCCP differ in detail — both reviewed
 *     separately. More demanding risk classification governs overall governance.
 *   - au-tga-saimd + hipaa: AU SaMD on platforms processing US patient data:
 *     HIPAA BAA covers US-side; Privacy Act APPs cover AU-side. Both required.
 *   - au-tga-saimd + au-privacy-act: Patient clinical data in SaMD = health info
 *     under Privacy Act (sensitive info — APP 3.3 explicit consent). TGA Essential
 *     Principles + APP 11 security both apply. Stricter TGA 10-year retention
 *     governs overlapping records.
 *   - au-tga-saimd + au-mandatory-ai-guardrails: Healthcare = proposed high-risk
 *     setting. TGA SaMD with GMLP, PCCP, clinical evidence, post-market monitoring
 *     satisfies most proposed guardrails for healthcare.
 *
 * Authority: Therapeutic Goods Administration (TGA) — Department of Health and
 *   Aged Care
 * Sovereignty: Australian Federal
 *
 * @connexum/ai-governance
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AU_TGA_SAIMD_PACK = exports.AU_TGA_SAIMD_CATEGORY_CLASSIFIERS = void 0;
exports.AU_TGA_SAIMD_CATEGORY_CLASSIFIERS = {
    TGA_SAMD_CLINICAL_DATA: {
        references: ['TGA AI/ML Guidance 2023/2024 — patient clinical data processed by ARTG-applicable SaMD'],
        classifier: (input) => {
            if (/\b(?:tga\s+(?:samd|saimd|medical\s+device)\s+(?:patient|clinical)\s+(?:data|record)|clinical\s+(?:data|record).*(?:tga|artg|samd|medical\s+device\s+ai))/i.test(input))
                return true;
            return false;
        },
    },
    TGA_SAMD_ADAPTIVE_MODEL: {
        references: ['TGA PCCP 2023 — adaptive/continuously learning AI/ML model requiring PCCP'],
        classifier: (input) => {
            if (/\b(?:adaptive\s+(?:ai|ml|model|algorithm)|continuously\s+learning\s+(?:model|algorithm)|pccp.*(?:tga|samd|medical\s+device)|predetermined\s+change\s+control\s+plan)/i.test(input))
                return true;
            return false;
        },
    },
    TGA_SAMD_ARTG_STATUS: {
        references: ['Therapeutic Goods Act 1989 s.41MA — ARTG registration before supply; unregistered = offence'],
        classifier: (input) => {
            if (/\bTGA\b.*\b(?:SaMD|ARTG)\b/i.test(input))
                return true;
            if (/\b(?:SaMD|ARTG)\b.*\bTGA\b/i.test(input))
                return true;
            if (/\bARTG\b.*\bunregistered\b/i.test(input))
                return true;
            if (/\bunregistered\b.*\b(?:ARTG|SaMD|medical\s+device)\b/i.test(input))
                return true;
            if (/\btherapeutic\s+goods\b/i.test(input))
                return true;
            if (/\b(?:artg\s+(?:registration|status|number|not\s+registered)|australian\s+register\s+of\s+therapeutic\s+goods)\b/i.test(input))
                return true;
            return false;
        },
    },
    TGA_SAMD_ADVERSE_EVENT: {
        references: ['Therapeutic Goods (Medical Devices) Regulations 2002 r.5.7 — adverse event notification 10/30 days'],
        classifier: (input) => {
            if (/\b(?:samd\s+adverse\s+event|adverse\s+event.*(?:samd|saimd|tga|medical\s+device\s+ai)|ai.*(?:medical\s+device\s+)?harm.*tga|patient\s+harm.*samd)/i.test(input))
                return true;
            return false;
        },
    },
    TGA_SAMD_PCCP_CHANGE: {
        references: ['TGA PCCP 2023 — algorithm change requiring PCCP assessment'],
        classifier: (input) => {
            if (/\b(?:pccp\s+(?:change|assessment|notification|review)|algorithm\s+change.*(?:pccp|tga|samd)|significant\s+change.*(?:medical\s+device\s+ai|adaptive\s+model))/i.test(input))
                return true;
            return false;
        },
    },
    TGA_SAMD_PERFORMANCE_DRIFT: {
        references: ['GMLP Principle 10 — deployed model monitoring; drift detection'],
        classifier: (input) => {
            if (/\b(?:(?:model|performance)\s+drift.*(?:tga|samd|clinical)|samd.*(?:performance\s+drift|degradation|out\s+of\s+bounds)|real[_\-\s]?world\s+performance.*(?:samd|tga).*(?:drift|decline))/i.test(input))
                return true;
            return false;
        },
    },
};
exports.AU_TGA_SAIMD_PACK = {
    categoryClassifiers: exports.AU_TGA_SAIMD_CATEGORY_CLASSIFIERS,
    /**
     * P3.5: TGA_SAMD_CLINICAL_DATA and TGA_SAMD_ADVERSE_EVENT are subject-keyed
     * by patient identifier — each clinical data access and adverse event must
     * carry a patient ID for 10-year technical documentation and TGA adverse event
     * reporting traceability. Adaptive model, ARTG status, PCCP, and performance
     * drift categories are system-level (non-subject-keyed).
     *
     * [CITATION TO VERIFY]: Some Category I exclusions; pure data-consolidation
     * CDS scope — see TGA guidance updated 2023.
     */
    subjectKeyedCategories: [
        'TGA_SAMD_CLINICAL_DATA',
        'TGA_SAMD_ADVERSE_EVENT',
    ],
    id: 'au-tga-saimd',
    name: 'AU TGA Software as a Medical Device (SaMD)',
    version: '1.0.0',
    description: 'TGA compliance for AI systems qualifying as Software as a Medical Device (SaMD) in Australia. Enforces ARTG registration before clinical use (s.41MA), GMLP 10 principles, PCCP for adaptive models, adverse event notification (10-day for death/serious deterioration, 30-day for could-have-caused), post-market performance monitoring with drift detection, and 10-year technical documentation retention. [CITATION TO VERIFY: Category I exclusions; 2023 guidance scope updates.]',
    authority: 'Therapeutic Goods Administration (TGA) — Department of Health and Aged Care',
    industries: [
        'medical-devices', 'digital-health', 'clinical-decision-support',
        'diagnostic-ai', 'radiology-ai', 'pathology-ai', 'remote-monitoring',
        'digital-therapeutics', 'mental-health-ai',
    ],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'ARTG registration gate (s.41MA); PCCP change approval; adverse event suspension; clinical data off-label use gate',
            reference: 'Therapeutic Goods Act 1989 s.41MA; TGA PCCP 2023',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: '10-year technical documentation and clinical evidence retention; adverse event records 10 years; post-market surveillance records',
            reference: 'Therapeutic Goods (Medical Devices) Regulations 2002 — lifetime + 10y retention',
        },
        {
            name: 'encryption-layer',
            required: true,
            reason: 'TGA Essential Principles + Privacy Act APP 11: patient clinical data in SaMD = sensitive health information requiring AES-256',
            reference: 'Therapeutic Goods Act 1989 Schedule 1 Essential Principles; Privacy Act APP 11',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Classify SaMD clinical data, adaptive model status, ARTG registration, adverse events, PCCP changes, performance drift',
            reference: 'TGA AI/ML Guidance 2023/2024; GMLP Principles',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'ARTG registration confirmation before clinical use; PCCP change approval; adverse event TGA notification workflow',
            reference: 'Therapeutic Goods Act 1989 s.41MA; r.5.7; TGA PCCP 2023',
        },
        {
            name: 'anomaly-detector',
            required: true,
            reason: 'GMLP Principle 10: post-market performance monitoring with drift detection; real-world performance metrics',
            reference: 'TGA AI/ML Guidance 2023/2024; GMLP P10',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Adverse event stream with 10-day/30-day TGA notification timers; PCCP change events; performance drift events',
            reference: 'Therapeutic Goods (Medical Devices) Regulations 2002 r.5.7',
        },
    ],
    moduleConfig: {
        'data-classifier': {
            enabledCategories: [
                'TGA_SAMD_CLINICAL_DATA',
                'TGA_SAMD_ADAPTIVE_MODEL',
                'TGA_SAMD_ARTG_STATUS',
                'TGA_SAMD_ADVERSE_EVENT',
                'TGA_SAMD_PCCP_CHANGE',
                'TGA_SAMD_PERFORMANCE_DRIFT',
            ],
            artgRegistrationConfirmed: true,
            adverseEventSuspensionEnabled: true,
            pccpChangeApprovalRequired: true,
            performanceMonitoringActive: true,
            driftDetectionEnabled: true,
            clinicalEvidenceOnFile: true,
            gmlpComplianceDocumented: true,
            samdLabellingCompliant: true,
            technicalDocRetentionYears: 10,
        },
        'governance-runtime': {
            artgRegistrationConfirmed: true,
            adverseEventSuspensionEnabled: true,
            pccpChangeApprovalRequired: true,
            performanceMonitoringActive: true,
            driftDetectionEnabled: true,
            clinicalEvidenceOnFile: true,
            gmlpComplianceDocumented: true,
            samdLabellingCompliant: true,
            technicalDocRetentionYears: 10,
        },
        'approval-queue': {
            artgRegistrationApprovalRequired: true,
            pccpChangeApprovalRequired: true,
            adverseEventNotificationRequired: true,
        },
        'anomaly-detector': {
            performanceDriftDetectionEnabled: true,
            realWorldMetricsRequired: true,
        },
    },
    providerPolicy: {
        blockedProviders: [],
        requiredCapabilities: [
            'ARTG-REGISTRATION-CONFIRMED',
            'GMLP-COMPLIANCE-DOCUMENTED',
            'ADVERSE-EVENT-NOTIFICATION-CAPABLE',
            'ISO-13485-ALIGNED',
        ],
        blockReasons: {},
    },
    dataPolicy: {
        scanCategories: [
            'TGA_SAMD_CLINICAL_DATA',
            'TGA_SAMD_ADAPTIVE_MODEL',
            'TGA_SAMD_ARTG_STATUS',
            'TGA_SAMD_ADVERSE_EVENT',
            'TGA_SAMD_PCCP_CHANGE',
            'TGA_SAMD_PERFORMANCE_DRIFT',
        ],
        categoryActions: {
            TGA_SAMD_CLINICAL_DATA: 'REQUIRE_APPROVAL',
            TGA_SAMD_ADAPTIVE_MODEL: 'REQUIRE_APPROVAL',
            TGA_SAMD_ARTG_STATUS: 'BLOCK',
            TGA_SAMD_ADVERSE_EVENT: 'BLOCK',
            TGA_SAMD_PCCP_CHANGE: 'REQUIRE_APPROVAL',
            TGA_SAMD_PERFORMANCE_DRIFT: 'WARN',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256',
        minimumClassification: 'CONFIDENTIAL',
    },
    retentionPolicy: {
        sovereignty: ['AU'],
        auditLogRetentionDays: 3650, // 10 years (technical documentation + clinical evidence)
        sessionRetentionDays: 1825, // 5 years (post-market surveillance)
        incidentRetentionDays: 3650, // 10 years (adverse event records)
        reference: 'Therapeutic Goods (Medical Devices) Regulations 2002: technical documentation lifetime + 10y; adverse events 10y from report; post-market 5y',
    },
    incidentPolicy: {
        notificationDeadlineHours: 240, // 10 calendar days for death/serious deterioration
        reference: 'Therapeutic Goods (Medical Devices) Regulations 2002 r.5.7 — 10 calendar days for death/serious deterioration; 30 days for could-have-caused',
        requiredRecipients: ['tga', 'sponsor', 'clinical-governance'],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'au-tga-samd-artg-registration',
            description: 'ARTG registration confirmed before SaMD used in clinical context; unregistered SaMD blocked',
            reference: 'Therapeutic Goods Act 1989 s.41MA',
            check: 'au_tga_samd_artg_registration_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'au-tga-samd-adverse-event-block',
            description: 'SaMD suspended and TGA notified within 10 days on adverse event with patient harm potential',
            reference: 'Therapeutic Goods (Medical Devices) Regulations 2002 r.5.7',
            check: 'au_tga_samd_adverse_event_block_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'au-tga-samd-pccp-change-approval',
            description: 'Algorithm changes assessed against PCCP before deployment; significant changes trigger pre-market notification',
            reference: 'TGA PCCP Guidance 2023',
            check: 'au_tga_samd_pccp_change_approval_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'au-tga-samd-performance-monitoring',
            description: 'Real-world performance monitoring active with drift detection per GMLP Principle 10',
            reference: 'TGA AI/ML Guidance 2023/2024; GMLP P10',
            check: 'au_tga_samd_performance_monitoring_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'au-tga-samd-clinical-evidence',
            description: 'Clinical evidence on file for all ARTG indications per TGA Essential Principles',
            reference: 'Therapeutic Goods Act 1989 Schedule 1 Essential Principles',
            check: 'au_tga_samd_clinical_evidence_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'au-tga-samd-gmlp-compliance',
            description: 'GMLP 10 principles compliance documented for AI/ML SaMD',
            reference: 'TGA GMLP Guidance 2021/2023',
            check: 'au_tga_samd_gmlp_compliance_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'au-tga-samd-labelling',
            description: 'SaMD labelling includes AI/ML nature, limitations, performance specs, and ARTG number',
            reference: 'TGA AI/ML Medical Devices Guidance 2023/2024',
            check: 'au_tga_samd_labelling_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'au-tga-samd-retention-10yr',
            description: 'Technical documentation and clinical evidence retained for lifetime plus 10 years',
            reference: 'Therapeutic Goods (Medical Devices) Regulations 2002',
            check: 'au_tga_samd_retention_10yr_active',
            failSeverity: 'MEDIUM',
        },
    ],
};
//# sourceMappingURL=au-tga-saimd.js.map