





















const db = require('../models');
const Users = db.users;






const DocumentTypes = db.document_types;

const Standards = db.standards;

const Clauses = db.clauses;

const DocumentTemplates = db.document_templates;

const Documents = db.documents;

const DocumentVersions = db.document_versions;

const ChangeRequests = db.change_requests;

const ApprovalWorkflows = db.approval_workflows;

const ApprovalSteps = db.approval_steps;

const ApprovalTasks = db.approval_tasks;

const EsignatureEvents = db.esignature_events;

const TrainingCourses = db.training_courses;

const TrainingAssignments = db.training_assignments;

const Products = db.products;

const Suppliers = db.suppliers;

const Batches = db.batches;

const CertificatesOfAnalysis = db.certificates_of_analysis;

const DeviceMasterRecords = db.device_master_records;

const RiskAssessments = db.risk_assessments;

const RiskItems = db.risk_items;

const Capas = db.capas;

const Nonconformances = db.nonconformances;

const Complaints = db.complaints;

const Audits = db.audits;

const AuditFindings = db.audit_findings;

const ManagementReviews = db.management_reviews;

const RegulatorySubmissions = db.regulatory_submissions;

const AuditLogs = db.audit_logs;







const DocumentTypesData = [
    
    {
    
        
        
            
                "name": "Standard Operating Procedure",
            
        
    
        
        
            
                "code": "SOP",
            
        
    
        
        
            
                "description": "Controlled procedure describing how activities are performed.",
            
        
    
        
        
            
                "category": "form",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Batch Manufacturing Record",
            
        
    
        
        
            
                "code": "BMR",
            
        
    
        
        
            
                "description": "Record capturing manufacturing and in-process details for a batch.",
            
        
    
        
        
            
                "category": "report",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Certificate of Analysis",
            
        
    
        
        
            
                "code": "COA",
            
        
    
        
        
            
                "description": "Certificate reporting test results and disposition for released lots.",
            
        
    
        
        
            
                "category": "report",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Device Master Record",
            
        
    
        
        
            
                "code": "DMR",
            
        
    
        
        
            
                "description": "Compilation of records for manufacturing a device.",
            
        
    
        
        
            
                "category": "report",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Risk Management File",
            
        
    
        
        
            
                "code": "RMF",
            
        
    
        
        
            
                "description": "Risk management plan, analyses, controls, and evaluation records.",
            
        
    
        
        
            
                "category": "form",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const StandardsData = [
    
    {
    
        
        
            
                "name": "ISO 13485:2016 Medical devices Quality management systems",
            
        
    
        
        
            
                "short_name": "ISO 13485",
            
        
    
        
        
            
                "version": "2016",
            
        
    
        
        
            
                "publisher": "ISO",
            
        
    
        
        
            
                "scope_notes": "Quality management systems requirements for medical devices.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "ISO 14971 Medical devices Application of risk management",
            
        
    
        
        
            
                "short_name": "ISO 14971",
            
        
    
        
        
            
                "version": "2019",
            
        
    
        
        
            
                "publisher": "ISO",
            
        
    
        
        
            
                "scope_notes": "Risk management process for medical devices across life cycle.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "EU Medical Device Regulation",
            
        
    
        
        
            
                "short_name": "EU MDR",
            
        
    
        
        
            
                "version": "2017/745",
            
        
    
        
        
            
                "publisher": "European Union",
            
        
    
        
        
            
                "scope_notes": "Regulatory requirements for placing medical devices on the EU market.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "21 CFR Part 820 Quality System Regulation",
            
        
    
        
        
            
                "short_name": "21 CFR 820",
            
        
    
        
        
            
                "version": "Current",
            
        
    
        
        
            
                "publisher": "US FDA",
            
        
    
        
        
            
                "scope_notes": "US quality system regulation for medical devices.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "21 CFR Part 11 Electronic Records and Signatures",
            
        
    
        
        
            
                "short_name": "21 CFR 11",
            
        
    
        
        
            
                "version": "Current",
            
        
    
        
        
            
                "publisher": "US FDA",
            
        
    
        
        
            
                "scope_notes": "Requirements for electronic records and electronic signatures.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const ClausesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "clause_code": "4.2.4",
            
        
    
        
        
            
                "title": "Control of records",
            
        
    
        
        
            
                "text_excerpt": "Records shall be established and maintained to provide evidence of conformity.",
            
        
    
        
        
            
                "guidance_notes": "Define retention, identification, storage, protection, retrieval, and disposal.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "clause_code": "4.2.3",
            
        
    
        
        
            
                "title": "Control of documents",
            
        
    
        
        
            
                "text_excerpt": "Documents shall be controlled to ensure current approved versions are available.",
            
        
    
        
        
            
                "guidance_notes": "Include review, approval, change control, and distribution controls.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "clause_code": "5",
            
        
    
        
        
            
                "title": "Risk analysis",
            
        
    
        
        
            
                "text_excerpt": "The manufacturer shall perform risk analysis for the intended use and foreseeable misuse.",
            
        
    
        
        
            
                "guidance_notes": "Capture hazards, sequences of events, and initial risk estimates.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "clause_code": "820.40",
            
        
    
        
        
            
                "title": "Document controls",
            
        
    
        
        
            
                "text_excerpt": "Each manufacturer shall establish and maintain procedures to control all documents.",
            
        
    
        
        
            
                "guidance_notes": "Ensure change review and approval, and prevent unintended use of obsolete documents.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "clause_code": "11.200",
            
        
    
        
        
            
                "title": "Electronic signature components and controls",
            
        
    
        
        
            
                "text_excerpt": "Electronic signatures shall be unique to one individual and not reused or reassigned.",
            
        
    
        
        
            
                "guidance_notes": "Define identity verification and signature manifestation requirements.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const DocumentTemplatesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "SOP Template General",
            
        
    
        
        
            
                "template_code": "TPL-SOP-001",
            
        
    
        
        
            
                "template_family": "doc",
            
        
    
        
        
            
                "purpose": "Standard SOP structure with controlled header, purpose, scope, responsibilities, and records.",
            
        
    
        
        
            
                "template_body": "SOP Template Body Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "format": "docx",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "BMR Template Standard",
            
        
    
        
        
            
                "template_code": "TPL-BMR-001",
            
        
    
        
        
            
                "template_family": "bmr",
            
        
    
        
        
            
                "purpose": "Batch record layout for traceability and in-process checks.",
            
        
    
        
        
            
                "template_body": "BMR Template Body Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "format": "pdf",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "COA Template Supplier Incoming",
            
        
    
        
        
            
                "template_code": "TPL-COA-001",
            
        
    
        
        
            
                "template_family": "other",
            
        
    
        
        
            
                "purpose": "Certificate of analysis structure for supplier lots and acceptance criteria.",
            
        
    
        
        
            
                "template_body": "COA Template Body Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "format": "html",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "DMR Index Template",
            
        
    
        
        
            
                "template_code": "TPL-DMR-001",
            
        
    
        
        
            
                "template_family": "bmr",
            
        
    
        
        
            
                "purpose": "DMR index and compilation checklist with links to controlled documents.",
            
        
    
        
        
            
                "template_body": "DMR Template Body Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "format": "xlsx",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "template_name": "Risk Management File Template",
            
        
    
        
        
            
                "template_code": "TPL-RMF-001",
            
        
    
        
        
            
                "template_family": "bmr",
            
        
    
        
        
            
                "purpose": "Risk management plan and analysis sections aligned to ISO 14971.",
            
        
    
        
        
            
                "template_body": "RMF Template Body Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "format": "mixed",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
];



const DocumentsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "SOP Document Control",
            
        
    
        
        
            
                "document_number": "SOP-0001",
            
        
    
        
        
            
                "current_revision": "B",
            
        
    
        
        
            
                "lifecycle_status": "draft",
            
        
    
        
        
            
                "control_level": "controlled",
            
        
    
        
        
            
                "confidentiality": "restricted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "effective_date": new Date('2026-01-15T00:00:00Z'),
            
        
    
        
        
            
                "next_review_date": new Date('2027-01-15T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Defines document creation, review, approval, distribution, and obsolescence controls.",
            
        
    
        
        
            
                "content": "Document Control SOP Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "training_required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "SOP Training Management",
            
        
    
        
        
            
                "document_number": "SOP-0002",
            
        
    
        
        
            
                "current_revision": "A",
            
        
    
        
        
            
                "lifecycle_status": "draft",
            
        
    
        
        
            
                "control_level": "controlled",
            
        
    
        
        
            
                "confidentiality": "public_internal",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "effective_date": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "next_review_date": new Date('2027-04-01T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Defines training assignment, completion, and effectiveness evidence for controlled procedures.",
            
        
    
        
        
            
                "content": "Training SOP Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "training_required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "Risk Management Plan Pulse Oximeter",
            
        
    
        
        
            
                "document_number": "RMF-0100",
            
        
    
        
        
            
                "current_revision": "A",
            
        
    
        
        
            
                "lifecycle_status": "in_review",
            
        
    
        
        
            
                "control_level": "uncontrolled",
            
        
    
        
        
            
                "confidentiality": "restricted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "effective_date": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "next_review_date": new Date('2027-06-01T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Defines methodology, roles, and acceptance criteria for risk management activities.",
            
        
    
        
        
            
                "content": "Risk Plan Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "training_required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "DMR Index Pulse Oximeter Model PO-100",
            
        
    
        
        
            
                "document_number": "DMR-100",
            
        
    
        
        
            
                "current_revision": "C",
            
        
    
        
        
            
                "lifecycle_status": "in_review",
            
        
    
        
        
            
                "control_level": "uncontrolled",
            
        
    
        
        
            
                "confidentiality": "restricted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "effective_date": new Date('2025-11-10T00:00:00Z'),
            
        
    
        
        
            
                "next_review_date": new Date('2026-11-10T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Index of drawings, specifications, and procedures comprising the device master record.",
            
        
    
        
        
            
                "content": "DMR Index Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "training_required": false,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "title": "BMR Pulse Oximeter Assembly",
            
        
    
        
        
            
                "document_number": "BMR-PO-100",
            
        
    
        
        
            
                "current_revision": "B",
            
        
    
        
        
            
                "lifecycle_status": "obsolete",
            
        
    
        
        
            
                "control_level": "controlled",
            
        
    
        
        
            
                "confidentiality": "restricted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "effective_date": new Date('2025-12-05T00:00:00Z'),
            
        
    
        
        
            
                "next_review_date": new Date('2026-12-05T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Batch record for assembly, inspection steps, and acceptance signatures.",
            
        
    
        
        
            
                "content": "BMR Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
        
        
            
                "training_required": true,
            
        
    
    },
    
];



const DocumentVersionsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "version_status": "obsolete",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "submitted_at": new Date('2025-10-01T10:00:00Z'),
            
        
    
        
        
            
                "approved_at": new Date('2025-10-15T15:30:00Z'),
            
        
    
        
        
            
                "effective_at": new Date('2025-11-01T00:00:00Z'),
            
        
    
        
        
            
                "change_summary": "Initial release for controlled documents.",
            
        
    
        
        
            
                "version_content": "SOP-0001 Rev A Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "hash_checksum": "9f86d081884c7d659a2feaa0c55ad015",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision": "B",
            
        
    
        
        
            
                "version_status": "superseded",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "submitted_at": new Date('2025-12-20T09:00:00Z'),
            
        
    
        
        
            
                "approved_at": new Date('2026-01-10T13:15:00Z'),
            
        
    
        
        
            
                "effective_at": new Date('2026-01-15T00:00:00Z'),
            
        
    
        
        
            
                "change_summary": "Clarified distribution controls and electronic approval expectations.",
            
        
    
        
        
            
                "version_content": "SOP-0001 Rev B Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "hash_checksum": "2c26b46b68ffc68ff99b453c1d304134",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision": "A",
            
        
    
        
        
            
                "version_status": "obsolete",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "submitted_at": new Date('2026-03-05T14:10:00Z'),
            
        
    
        
        
            
                "approved_at": new Date('2026-03-25T16:00:00Z'),
            
        
    
        
        
            
                "effective_at": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                "change_summary": "New SOP defining training assignment and evidence collection.",
            
        
    
        
        
            
                "version_content": "SOP-0002 Rev A Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "hash_checksum": "4a44dc15364204a80fe80e9039455cc1",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision": "B",
            
        
    
        
        
            
                "version_status": "obsolete",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "submitted_at": new Date('2025-08-10T08:45:00Z'),
            
        
    
        
        
            
                "approved_at": new Date('2025-09-01T11:20:00Z'),
            
        
    
        
        
            
                "effective_at": new Date('2025-09-15T00:00:00Z'),
            
        
    
        
        
            
                "change_summary": "Updated drawing list and inspection references.",
            
        
    
        
        
            
                "version_content": "DMR-100 Rev B Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "hash_checksum": "ef2d127de37b942baad06145e54b0c61",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "revision": "C",
            
        
    
        
        
            
                "version_status": "superseded",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "submitted_at": new Date('2025-10-20T10:30:00Z'),
            
        
    
        
        
            
                "approved_at": new Date('2025-11-05T12:40:00Z'),
            
        
    
        
        
            
                "effective_at": new Date('2025-11-10T00:00:00Z'),
            
        
    
        
        
            
                "change_summary": "Added supplier specification and tightened acceptance criteria.",
            
        
    
        
        
            
                "version_content": "DMR-100 Rev C Content Placeholder",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "hash_checksum": "e3b0c44298fc1c149afbf4c8996fb924",
            
        
    
    },
    
];



const ChangeRequestsData = [
    
    {
    
        
        
            
                "change_number": "CHG-2026-0001",
            
        
    
        
        
            
                "change_type": "document_change",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason_for_change": "Align document control with electronic approval and audit expectations.",
            
        
    
        
        
            
                "impact_assessment": "Low operational impact; improves clarity and control.",
            
        
    
        
        
            
                "requires_validation": false,
            
        
    
        
        
            
                "requires_regulatory_notification": true,
            
        
    
        
        
            
                "requested_at": new Date('2025-12-10T09:30:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-01-05T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "change_number": "CHG-2026-0002",
            
        
    
        
        
            
                "change_type": "software_change",
            
        
    
        
        
            
                "status": "submitted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason_for_change": "Add in-process inspection checkpoint to reduce escapes.",
            
        
    
        
        
            
                "impact_assessment": "May affect throughput; training update required.",
            
        
    
        
        
            
                "requires_validation": true,
            
        
    
        
        
            
                "requires_regulatory_notification": true,
            
        
    
        
        
            
                "requested_at": new Date('2026-02-12T13:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "change_number": "CHG-2026-0003",
            
        
    
        
        
            
                "change_type": "other",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason_for_change": "Standardize training evidence capture including quiz score field.",
            
        
    
        
        
            
                "impact_assessment": "Moderate; updates to course and assignment workflow.",
            
        
    
        
        
            
                "requires_validation": true,
            
        
    
        
        
            
                "requires_regulatory_notification": false,
            
        
    
        
        
            
                "requested_at": new Date('2026-03-01T10:15:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-03-28T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "change_number": "CHG-2026-0004",
            
        
    
        
        
            
                "change_type": "form_change",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason_for_change": "Update labeling references for UDI consistency.",
            
        
    
        
        
            
                "impact_assessment": "Requires revision of labeling document; no design change.",
            
        
    
        
        
            
                "requires_validation": true,
            
        
    
        
        
            
                "requires_regulatory_notification": false,
            
        
    
        
        
            
                "requested_at": new Date('2026-01-25T09:05:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-02-28T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-03-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                "change_number": "CHG-2026-0005",
            
        
    
        
        
            
                "change_type": "process_change",
            
        
    
        
        
            
                "status": "in_assessment",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reason_for_change": "Add requirement for automated audit log review in system.",
            
        
    
        
        
            
                "impact_assessment": "May require workflow adjustments and periodic review task.",
            
        
    
        
        
            
                "requires_validation": true,
            
        
    
        
        
            
                "requires_regulatory_notification": true,
            
        
    
        
        
            
                "requested_at": new Date('2026-03-18T15:20:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-05-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-30T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ApprovalWorkflowsData = [
    
    {
    
        
        
            
                "name": "Document Draft to Effective",
            
        
    
        
        
            
                "applies_to": "nonconformance",
            
        
    
        
        
            
                "requires_esignature": true,
            
        
    
        
        
            
                "requires_two_factor": false,
            
        
    
        
        
            
                "min_approvals": 2,
            
        
    
        
        
            
                "instructions": "Author submits, QA review, RA approval; signatures required for approval.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Change Request Review",
            
        
    
        
        
            
                "applies_to": "document",
            
        
    
        
        
            
                "requires_esignature": true,
            
        
    
        
        
            
                "requires_two_factor": false,
            
        
    
        
        
            
                "min_approvals": 1,
            
        
    
        
        
            
                "instructions": "Assess impact and approve implementation plan.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Training Acknowledgement",
            
        
    
        
        
            
                "applies_to": "training_assignment",
            
        
    
        
        
            
                "requires_esignature": true,
            
        
    
        
        
            
                "requires_two_factor": false,
            
        
    
        
        
            
                "min_approvals": 1,
            
        
    
        
        
            
                "instructions": "Trainee acknowledges training and completes quiz if assigned.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Risk Assessment Approval",
            
        
    
        
        
            
                "applies_to": "risk_assessment",
            
        
    
        
        
            
                "requires_esignature": true,
            
        
    
        
        
            
                "requires_two_factor": true,
            
        
    
        
        
            
                "min_approvals": 2,
            
        
    
        
        
            
                "instructions": "Risk owner prepares; QA and RA approve residual risk acceptance.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "name": "Audit Finding Closure",
            
        
    
        
        
            
                "applies_to": "change_request",
            
        
    
        
        
            
                "requires_esignature": false,
            
        
    
        
        
            
                "requires_two_factor": false,
            
        
    
        
        
            
                "min_approvals": 1,
            
        
    
        
        
            
                "instructions": "Owner provides evidence and lead auditor verifies closure.",
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const ApprovalStepsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "step_order": 1,
            
        
    
        
        
            
                "step_name": "Quality Review",
            
        
    
        
        
            
                "step_type": "quality_review",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "assignment_rule": "department",
            
        
    
        
        
            
                "sla_days": 5,
            
        
    
        
        
            
                "required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "step_order": 2,
            
        
    
        
        
            
                "step_name": "Regulatory Approval",
            
        
    
        
        
            
                "step_type": "regulatory_review",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "assignment_rule": "approver_role",
            
        
    
        
        
            
                "sla_days": 5,
            
        
    
        
        
            
                "required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "step_order": 1,
            
        
    
        
        
            
                "step_name": "Impact Assessment Review",
            
        
    
        
        
            
                "step_type": "review",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "assignment_rule": "document_owner",
            
        
    
        
        
            
                "sla_days": 7,
            
        
    
        
        
            
                "required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "step_order": 1,
            
        
    
        
        
            
                "step_name": "QA Approval",
            
        
    
        
        
            
                "step_type": "approval",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "assignment_rule": "document_owner",
            
        
    
        
        
            
                "sla_days": 7,
            
        
    
        
        
            
                "required": true,
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "step_order": 2,
            
        
    
        
        
            
                "step_name": "RA Approval",
            
        
    
        
        
            
                "step_type": "review",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "assignment_rule": "document_owner",
            
        
    
        
        
            
                "sla_days": 7,
            
        
    
        
        
            
                "required": true,
            
        
    
    },
    
];



const ApprovalTasksData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_type": "document_version",
            
        
    
        
        
            
                "subject_reference": "SOP-0002 Rev A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-05T14:15:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-03-10T09:10:00Z'),
            
        
    
        
        
            
                "decision_comment": "Content complete; ensure training assignment is linked prior to effective date.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_type": "risk_assessment",
            
        
    
        
        
            
                "subject_reference": "SOP-0002 Rev A",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-10T10:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-03-25T16:00:00Z'),
            
        
    
        
        
            
                "decision_comment": "Approved; aligns with record control expectations.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_type": "capa",
            
        
    
        
        
            
                "subject_reference": "CHG-2026-0002",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "assigned_at": new Date('2026-02-12T13:05:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "decision_comment": "Collecting data on inspection escape rate for justification.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_type": "document_version",
            
        
    
        
        
            
                "subject_reference": "RMF-0100",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-18T09:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-03-28T00:00:00Z'),
            
        
    
        
        
            
                "decision_comment": "Pending completion of hazard table and residual risk rationale.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "subject_type": "document_version",
            
        
    
        
        
            
                "subject_reference": "RMF-0100",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "pending",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-28T10:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "decision_comment": "Pending QA approval and final clinical evaluation linkage.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const EsignatureEventsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "approve",
            
        
    
        
        
            
                "subject_type": "document",
            
        
    
        
        
            
                "subject_reference": "SOP-0002 Rev A",
            
        
    
        
        
            
                "signed_at": new Date('2026-03-10T09:10:00Z'),
            
        
    
        
        
            
                "meaning_of_signature": "Quality review approval",
            
        
    
        
        
            
                "authentication_method": "password",
            
        
    
        
        
            
                "ip_address": "10.10.0.12",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "sign",
            
        
    
        
        
            
                "subject_type": "training_assignment",
            
        
    
        
        
            
                "subject_reference": "SOP-0002 Rev A",
            
        
    
        
        
            
                "signed_at": new Date('2026-03-25T16:00:00Z'),
            
        
    
        
        
            
                "meaning_of_signature": "Regulatory approval",
            
        
    
        
        
            
                "authentication_method": "password",
            
        
    
        
        
            
                "ip_address": "10.10.0.18",
            
        
    
        
        
            
                "user_agent": "Chrome on macOS",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "approve",
            
        
    
        
        
            
                "subject_type": "nonconformance",
            
        
    
        
        
            
                "subject_reference": "CHG-2026-0001",
            
        
    
        
        
            
                "signed_at": new Date('2025-12-10T09:35:00Z'),
            
        
    
        
        
            
                "meaning_of_signature": "Submitted change request",
            
        
    
        
        
            
                "authentication_method": "password",
            
        
    
        
        
            
                "ip_address": "10.10.0.22",
            
        
    
        
        
            
                "user_agent": "Edge on Windows",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "acknowledge",
            
        
    
        
        
            
                "subject_type": "nonconformance",
            
        
    
        
        
            
                "subject_reference": "TA-0003",
            
        
    
        
        
            
                "signed_at": new Date('2026-02-20T11:05:00Z'),
            
        
    
        
        
            
                "meaning_of_signature": "Training completed acknowledgement",
            
        
    
        
        
            
                "authentication_method": "password",
            
        
    
        
        
            
                "ip_address": "10.10.0.31",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "action": "acknowledge",
            
        
    
        
        
            
                "subject_type": "nonconformance",
            
        
    
        
        
            
                "subject_reference": "AUD-2026-INT-01",
            
        
    
        
        
            
                "signed_at": new Date('2026-03-12T17:10:00Z'),
            
        
    
        
        
            
                "meaning_of_signature": "Audit report reviewed",
            
        
    
        
        
            
                "authentication_method": "password",
            
        
    
        
        
            
                "ip_address": "203.0.113.55",
            
        
    
        
        
            
                "user_agent": "Chrome on Linux",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const TrainingCoursesData = [
    
    {
    
        
        
            
                "course_name": "Document Control Basics",
            
        
    
        
        
            
                "course_code": "TRN-DC-001",
            
        
    
        
        
            
                "description": "Training on controlled documents, revision history, and obsolescence prevention.",
            
        
    
        
        
            
                "delivery_method": "elearning",
            
        
    
        
        
            
                "duration_hours": 0.5,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "course_name": "ISO 13485 Overview",
            
        
    
        
        
            
                "course_code": "TRN-ISO-001",
            
        
    
        
        
            
                "description": "High-level overview of ISO 13485 requirements and QMS expectations.",
            
        
    
        
        
            
                "delivery_method": "read_and_understand",
            
        
    
        
        
            
                "duration_hours": 1.0,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "course_name": "Risk Management ISO 14971",
            
        
    
        
        
            
                "course_code": "TRN-RISK-001",
            
        
    
        
        
            
                "description": "Risk management process, hazard identification, and residual risk evaluation.",
            
        
    
        
        
            
                "delivery_method": "on_the_job",
            
        
    
        
        
            
                "duration_hours": 1.5,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "course_name": "CAPA Fundamentals",
            
        
    
        
        
            
                "course_code": "TRN-CAPA-001",
            
        
    
        
        
            
                "description": "Problem solving, root cause analysis, action planning, and effectiveness checks.",
            
        
    
        
        
            
                "delivery_method": "on_the_job",
            
        
    
        
        
            
                "duration_hours": 2.0,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "course_name": "21 CFR Part 11 Awareness",
            
        
    
        
        
            
                "course_code": "TRN-P11-001",
            
        
    
        
        
            
                "description": "Electronic records and signatures expectations for regulated environments.",
            
        
    
        
        
            
                "delivery_method": "webinar",
            
        
    
        
        
            
                "duration_hours": 1.0,
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const TrainingAssignmentsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "assigned",
            
        
    
        
        
            
                "assigned_at": new Date('2026-01-16T09:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-01-30T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-01-18T15:20:00Z'),
            
        
    
        
        
            
                "score": 95.0,
            
        
    
        
        
            
                "trainer_notes": "Reviewed SOP-0001 and completed knowledge check.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "assigned",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-02T10:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-03-31T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-05T00:00:00Z'),
            
        
    
        
        
            
                "score": 0.0,
            
        
    
        
        
            
                "trainer_notes": "Complete course prior to risk assessment approval.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "overdue",
            
        
    
        
        
            
                "assigned_at": new Date('2026-01-05T09:30:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-02-05T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-01-10T12:10:00Z'),
            
        
    
        
        
            
                "score": 88.0,
            
        
    
        
        
            
                "trainer_notes": "Awareness completed; apply expectations to e-sign workflows.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "assigned_at": new Date('2026-03-10T08:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-04-10T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "score": 0.0,
            
        
    
        
        
            
                "trainer_notes": "To be completed before SOP effective.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "status": "overdue",
            
        
    
        
        
            
                "assigned_at": new Date('2026-02-01T08:30:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "completed_at": new Date('2026-02-01T08:45:00Z'),
            
        
    
        
        
            
                "score": 0.0,
            
        
    
        
        
            
                "trainer_notes": "External auditor; training not required.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const ProductsData = [
    
    {
    
        
        
            
                "product_name": "Pulse Oximeter PO-100",
            
        
    
        
        
            
                "product_code": "PO-100",
            
        
    
        
        
            
                "intended_use": "Non-invasive spot-check measurement of SpO2 and pulse rate.",
            
        
    
        
        
            
                "risk_classification": "eu_class_i",
            
        
    
        
        
            
                "udi_di": "00850000100012",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "product_name": "Blood Pressure Monitor BP-200",
            
        
    
        
        
            
                "product_code": "BP-200",
            
        
    
        
        
            
                "intended_use": "Non-invasive measurement of systolic and diastolic blood pressure.",
            
        
    
        
        
            
                "risk_classification": "eu_class_iii",
            
        
    
        
        
            
                "udi_di": "00850000200025",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "product_name": "Digital Thermometer TH-10",
            
        
    
        
        
            
                "product_code": "TH-10",
            
        
    
        
        
            
                "intended_use": "Measurement of body temperature for home and clinical settings.",
            
        
    
        
        
            
                "risk_classification": "eu_class_iib",
            
        
    
        
        
            
                "udi_di": "00850000300038",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "product_name": "ECG Patch Monitor ECG-3D",
            
        
    
        
        
            
                "product_code": "ECG-3D",
            
        
    
        
        
            
                "intended_use": "Ambulatory ECG monitoring for up to 7 days.",
            
        
    
        
        
            
                "risk_classification": "eu_class_iib",
            
        
    
        
        
            
                "udi_di": "00850000400041",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "product_name": "Nebulizer Device NB-50",
            
        
    
        
        
            
                "product_code": "NB-50",
            
        
    
        
        
            
                "intended_use": "Delivery of aerosolized medication for respiratory therapy.",
            
        
    
        
        
            
                "risk_classification": "other",
            
        
    
        
        
            
                "udi_di": "00850000500054",
            
        
    
        
        
            
                "active": true,
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const SuppliersData = [
    
    {
    
        
        
            
                "supplier_name": "Precision Plastics Ltd",
            
        
    
        
        
            
                "supplier_code": "SUP-PP-001",
            
        
    
        
        
            
                "supplier_type": "distributor",
            
        
    
        
        
            
                "contact_name": "Jordan Lee",
            
        
    
        
        
            
                "contact_email": "jordan.lee@precisionplastics.example",
            
        
    
        
        
            
                "contact_phone": "+1-555-0101",
            
        
    
        
        
            
                "address": "1200 Industrial Way, Austin, TX",
            
        
    
        
        
            
                "qualification_status": "qualified",
            
        
    
        
        
            
                "last_audit_at": new Date('2025-09-10T00:00:00Z'),
            
        
    
        
        
            
                "next_audit_at": new Date('2026-09-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "supplier_name": "MedLab Testing Services",
            
        
    
        
        
            
                "supplier_code": "SUP-ML-002",
            
        
    
        
        
            
                "supplier_type": "service_provider",
            
        
    
        
        
            
                "contact_name": "Taylor Brooks",
            
        
    
        
        
            
                "contact_email": "taylor.brooks@medlab.example",
            
        
    
        
        
            
                "contact_phone": "+1-555-0102",
            
        
    
        
        
            
                "address": "44 Research Park, Raleigh, NC",
            
        
    
        
        
            
                "qualification_status": "disqualified",
            
        
    
        
        
            
                "last_audit_at": new Date('2025-11-15T00:00:00Z'),
            
        
    
        
        
            
                "next_audit_at": new Date('2026-11-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "supplier_name": "SecureCloud Hosting",
            
        
    
        
        
            
                "supplier_code": "SUP-SC-003",
            
        
    
        
        
            
                "supplier_type": "service_provider",
            
        
    
        
        
            
                "contact_name": "Casey Nguyen",
            
        
    
        
        
            
                "contact_email": "casey.nguyen@securecloud.example",
            
        
    
        
        
            
                "contact_phone": "+1-555-0103",
            
        
    
        
        
            
                "address": "500 Data Center Blvd, Ashburn, VA",
            
        
    
        
        
            
                "qualification_status": "qualified",
            
        
    
        
        
            
                "last_audit_at": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                "next_audit_at": new Date('2026-07-20T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "supplier_name": "Omega Components",
            
        
    
        
        
            
                "supplier_code": "SUP-OC-004",
            
        
    
        
        
            
                "supplier_type": "laboratory",
            
        
    
        
        
            
                "contact_name": "Morgan Davis",
            
        
    
        
        
            
                "contact_email": "morgan.davis@omegacomponents.example",
            
        
    
        
        
            
                "contact_phone": "+1-555-0104",
            
        
    
        
        
            
                "address": "77 Supply Road, San Jose, CA",
            
        
    
        
        
            
                "qualification_status": "disqualified",
            
        
    
        
        
            
                "last_audit_at": new Date('2025-08-05T00:00:00Z'),
            
        
    
        
        
            
                "next_audit_at": new Date('2026-08-05T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
    {
    
        
        
            
                "supplier_name": "Sterile Packaging Co",
            
        
    
        
        
            
                "supplier_code": "SUP-SP-005",
            
        
    
        
        
            
                "supplier_type": "critical_supplier",
            
        
    
        
        
            
                "contact_name": "Riley Kim",
            
        
    
        
        
            
                "contact_email": "riley.kim@sterilepackaging.example",
            
        
    
        
        
            
                "contact_phone": "+1-555-0105",
            
        
    
        
        
            
                "address": "9 Cleanroom Ave, Minneapolis, MN",
            
        
    
        
        
            
                "qualification_status": "conditionally_qualified",
            
        
    
        
        
            
                "last_audit_at": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                "next_audit_at": new Date('2026-05-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "active": true,
            
        
    
    },
    
];



const BatchesData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "batch_number": "PO100-2026-0001",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                "manufacture_start_at": new Date('2026-02-03T08:00:00Z'),
            
        
    
        
        
            
                "manufacture_end_at": new Date('2026-02-05T17:00:00Z'),
            
        
    
        
        
            
                "quantity_planned": 1000.0,
            
        
    
        
        
            
                "quantity_produced": 998.0,
            
        
    
        
        
            
                "quantity_released": 995.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Minor yield loss due to cosmetic defect segregation.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "batch_number": "PO100-2026-0002",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "manufacture_start_at": new Date('2026-03-01T08:00:00Z'),
            
        
    
        
        
            
                "manufacture_end_at": new Date('2026-03-03T17:00:00Z'),
            
        
    
        
        
            
                "quantity_planned": 1200.0,
            
        
    
        
        
            
                "quantity_produced": 1200.0,
            
        
    
        
        
            
                "quantity_released": 0.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Quarantine pending investigation of supplier COA discrepancy.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "batch_number": "BP200-2026-0001",
            
        
    
        
        
            
                "status": "in_process",
            
        
    
        
        
            
                "manufacture_start_at": new Date('2026-01-10T08:00:00Z'),
            
        
    
        
        
            
                "manufacture_end_at": new Date('2026-01-12T16:30:00Z'),
            
        
    
        
        
            
                "quantity_planned": 500.0,
            
        
    
        
        
            
                "quantity_produced": 502.0,
            
        
    
        
        
            
                "quantity_released": 500.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Released after final QC pass.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "batch_number": "TH10-2026-0003",
            
        
    
        
        
            
                "status": "quarantined",
            
        
    
        
        
            
                "manufacture_start_at": new Date('2026-02-15T07:30:00Z'),
            
        
    
        
        
            
                "manufacture_end_at": new Date('2026-02-15T15:00:00Z'),
            
        
    
        
        
            
                "quantity_planned": 2000.0,
            
        
    
        
        
            
                "quantity_produced": 1995.0,
            
        
    
        
        
            
                "quantity_released": 1995.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Closed batch record archived.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "batch_number": "ECG3D-2026-0001",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "manufacture_start_at": new Date('2026-03-18T08:00:00Z'),
            
        
    
        
        
            
                "manufacture_end_at": new Date('2026-03-22T17:00:00Z'),
            
        
    
        
        
            
                "quantity_planned": 300.0,
            
        
    
        
        
            
                "quantity_produced": 0.0,
            
        
    
        
        
            
                "quantity_released": 0.0,
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Work in progress; awaiting incoming inspection results.",
            
        
    
    },
    
];



const CertificatesOfAnalysisData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "coa_number": "COA-OC-PO100-0001",
            
        
    
        
        
            
                "status": "issued",
            
        
    
        
        
            
                "issued_at": new Date('2026-02-06T10:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-02-06T00:00:00Z'),
            
        
    
        
        
            
                "summary": "All tested parameters met acceptance criteria.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "coa_number": "COA-OC-PO100-0002",
            
        
    
        
        
            
                "status": "issued",
            
        
    
        
        
            
                "issued_at": new Date('2026-03-04T10:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-03-04T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Draft pending QA review due to test method note.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "coa_number": "COA-PP-BP200-0001",
            
        
    
        
        
            
                "status": "issued",
            
        
    
        
        
            
                "issued_at": new Date('2026-01-13T09:30:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-01-13T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Incoming material conforms to specification.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "coa_number": "COA-PP-TH10-0003",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "issued_at": new Date('2026-02-16T09:00:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-02-16T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Material and dimensional checks passed.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "coa_number": "COA-ML-ECG3D-0001",
            
        
    
        
        
            
                "status": "void",
            
        
    
        
        
            
                "issued_at": new Date('2026-03-20T11:15:00Z'),
            
        
    
        
        
            
                "expires_at": new Date('2028-03-20T00:00:00Z'),
            
        
    
        
        
            
                "summary": "Bioburden and functional tests within limits.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const DeviceMasterRecordsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "dmr_number": "DMR-PO-100",
            
        
    
        
        
            
                "title": "Device Master Record PO-100",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "effective_at": new Date('2025-11-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Includes drawings, BOM, assembly SOPs, and labeling.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "dmr_number": "DMR-BP-200",
            
        
    
        
        
            
                "title": "Device Master Record BP-200",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                "effective_at": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Pending release after final labeling verification.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "dmr_number": "DMR-TH-10",
            
        
    
        
        
            
                "title": "Device Master Record TH-10",
            
        
    
        
        
            
                "status": "effective",
            
        
    
        
        
            
                "effective_at": new Date('2025-08-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Stable configuration with annual review.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "dmr_number": "DMR-ECG-3D",
            
        
    
        
        
            
                "title": "Device Master Record ECG-3D",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                "effective_at": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "In preparation; clinical and software documentation in progress.",
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "dmr_number": "DMR-NB-50",
            
        
    
        
        
            
                "title": "Device Master Record NB-50",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "effective_at": new Date('2024-05-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                "notes": "Superseded by updated configuration planned for next quarter.",
            
        
    
    },
    
];



const RiskAssessmentsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "risk_file_name": "Risk File PO-100",
            
        
    
        
        
            
                "risk_file_code": "RMF-PO-100",
            
        
    
        
        
            
                "methodology": "iso_14971",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "created_on": new Date('2025-09-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-09-01T00:00:00Z'),
            
        
    
        
        
            
                "scope": "Covers hazards related to sensor accuracy, labeling, and use errors.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "risk_file_name": "Risk File BP-200",
            
        
    
        
        
            
                "risk_file_code": "RMF-BP-200",
            
        
    
        
        
            
                "methodology": "fmea",
            
        
    
        
        
            
                "status": "in_review",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "created_on": new Date('2026-01-15T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2027-01-15T00:00:00Z'),
            
        
    
        
        
            
                "scope": "Focus on cuff integrity, measurement errors, and battery failure modes.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "risk_file_name": "Risk File TH-10",
            
        
    
        
        
            
                "risk_file_code": "RMF-TH-10",
            
        
    
        
        
            
                "methodology": "fmea",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "created_on": new Date('2025-07-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-07-01T00:00:00Z'),
            
        
    
        
        
            
                "scope": "Thermometer risks including misuse and cleaning-related issues.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "risk_file_name": "Risk File ECG-3D",
            
        
    
        
        
            
                "risk_file_code": "RMF-ECG-3D",
            
        
    
        
        
            
                "methodology": "hazop",
            
        
    
        
        
            
                "status": "superseded",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "created_on": new Date('2026-03-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2026-09-01T00:00:00Z'),
            
        
    
        
        
            
                "scope": "Software and connectivity hazards and diagnostic delays.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "risk_file_name": "Risk File NB-50",
            
        
    
        
        
            
                "risk_file_code": "RMF-NB-50",
            
        
    
        
        
            
                "methodology": "hazop",
            
        
    
        
        
            
                "status": "approved",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "created_on": new Date('2024-02-01T00:00:00Z'),
            
        
    
        
        
            
                "review_due_at": new Date('2025-02-01T00:00:00Z'),
            
        
    
        
        
            
                "scope": "Legacy device risk analysis archived after product update.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const RiskItemsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "hazard_id": "HZ-PO100-001",
            
        
    
        
        
            
                "hazard_description": "Incorrect SpO2 reading due to poor sensor contact",
            
        
    
        
        
            
                "sequence_of_events": "User applies sensor incorrectly leading to low signal quality and inaccurate reading",
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "occurrence": "unlikely",
            
        
    
        
        
            
                "detectability": "low",
            
        
    
        
        
            
                "risk_level_initial": "high",
            
        
    
        
        
            
                "risk_controls": "Add sensor placement instructions and signal quality indicator",
            
        
    
        
        
            
                "risk_level_residual": "low",
            
        
    
        
        
            
                "verification_of_controls": "Usability test and signal quality algorithm verification",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "hazard_id": "HZ-PO100-002",
            
        
    
        
        
            
                "hazard_description": "Battery failure during measurement",
            
        
    
        
        
            
                "sequence_of_events": "Low battery not detected causing device shutdown mid-measurement",
            
        
    
        
        
            
                "severity": "negligible",
            
        
    
        
        
            
                "occurrence": "frequent",
            
        
    
        
        
            
                "detectability": "medium",
            
        
    
        
        
            
                "risk_level_initial": "unacceptable",
            
        
    
        
        
            
                "risk_controls": "Low battery warning and minimum voltage cutoff",
            
        
    
        
        
            
                "risk_level_residual": "medium",
            
        
    
        
        
            
                "verification_of_controls": "Electrical verification and labeling review",
            
        
    
        
        
            
                "status": "verified",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "hazard_id": "HZ-BP200-003",
            
        
    
        
        
            
                "hazard_description": "Cuff leak leading to incorrect blood pressure result",
            
        
    
        
        
            
                "sequence_of_events": "Damaged cuff causes under-inflation and inaccurate measurement",
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "occurrence": "likely",
            
        
    
        
        
            
                "detectability": "medium",
            
        
    
        
        
            
                "risk_level_initial": "high",
            
        
    
        
        
            
                "risk_controls": "Incoming inspection and periodic cuff integrity checks",
            
        
    
        
        
            
                "risk_level_residual": "high",
            
        
    
        
        
            
                "verification_of_controls": "Inspection sampling plan and test report",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "hazard_id": "HZ-ECG3D-001",
            
        
    
        
        
            
                "hazard_description": "Delayed alert due to connectivity loss",
            
        
    
        
        
            
                "sequence_of_events": "Device loses connection and fails to transmit event; user not alerted",
            
        
    
        
        
            
                "severity": "catastrophic",
            
        
    
        
        
            
                "occurrence": "remote",
            
        
    
        
        
            
                "detectability": "low",
            
        
    
        
        
            
                "risk_level_initial": "low",
            
        
    
        
        
            
                "risk_controls": "Local storage with retransmission and user notification",
            
        
    
        
        
            
                "risk_level_residual": "high",
            
        
    
        
        
            
                "verification_of_controls": "Connectivity stress testing and software verification",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "hazard_id": "HZ-TH10-002",
            
        
    
        
        
            
                "hazard_description": "Cross-contamination due to inadequate cleaning",
            
        
    
        
        
            
                "sequence_of_events": "User reuses device without cleaning leading to pathogen transfer",
            
        
    
        
        
            
                "severity": "negligible",
            
        
    
        
        
            
                "occurrence": "remote",
            
        
    
        
        
            
                "detectability": "low",
            
        
    
        
        
            
                "risk_level_initial": "medium",
            
        
    
        
        
            
                "risk_controls": "Cleaning instructions and disposable probe covers",
            
        
    
        
        
            
                "risk_level_residual": "high",
            
        
    
        
        
            
                "verification_of_controls": "Labeling validation and biocompatibility review for covers",
            
        
    
        
        
            
                "status": "mitigating",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const CapasData = [
    
    {
    
        
        
            
                "capa_number": "CAPA-2026-001",
            
        
    
        
        
            
                "source": "process_monitoring",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_statement": "Audit noted inconsistent use of approved templates across departments.",
            
        
    
        
        
            
                "root_cause": "Lack of standardized template selection guidance and training.",
            
        
    
        
        
            
                "corrective_actions": "Update SOP-0001 to reference template library and add training.",
            
        
    
        
        
            
                "preventive_actions": "Implement periodic template usage review and dashboard monitoring.",
            
        
    
        
        
            
                "opened_at": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-04-30T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-06-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "capa_number": "CAPA-2026-002",
            
        
    
        
        
            
                "source": "audit",
            
        
    
        
        
            
                "status": "containment",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_statement": "Batch record missing one in-process signature on multiple travelers.",
            
        
    
        
        
            
                "root_cause": "Work instruction ambiguity and insufficient supervisor review.",
            
        
    
        
        
            
                "corrective_actions": "Revise BMR signature section and retrain operators.",
            
        
    
        
        
            
                "preventive_actions": "Add end-of-shift checklist for record completeness.",
            
        
    
        
        
            
                "opened_at": new Date('2026-02-18T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-05-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-07-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "capa_number": "CAPA-2026-003",
            
        
    
        
        
            
                "source": "supplier",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_statement": "Complaint trend indicates labeling confusion for device orientation.",
            
        
    
        
        
            
                "root_cause": "Labeling icon not sufficiently clear in low-light conditions.",
            
        
    
        
        
            
                "corrective_actions": "Update labeling artwork and IFU section for clarity.",
            
        
    
        
        
            
                "preventive_actions": "Add usability check for labeling legibility in design reviews.",
            
        
    
        
        
            
                "opened_at": new Date('2026-01-05T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-03-31T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-05-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "capa_number": "CAPA-2026-004",
            
        
    
        
        
            
                "source": "risk_management",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_statement": "Supplier provided COA with outdated test method reference.",
            
        
    
        
        
            
                "root_cause": "Supplier document change not communicated to receiving inspection.",
            
        
    
        
        
            
                "corrective_actions": "Request updated method and revise receiving checklist.",
            
        
    
        
        
            
                "preventive_actions": "Add supplier change notification requirement to supplier quality agreement.",
            
        
    
        
        
            
                "opened_at": new Date('2026-03-03T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-06-01T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-08-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "capa_number": "CAPA-2026-005",
            
        
    
        
        
            
                "source": "risk_management",
            
        
    
        
        
            
                "status": "containment",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "problem_statement": "Management review noted overdue training assignments in prior quarter.",
            
        
    
        
        
            
                "root_cause": "No automated reminders and unclear escalation path.",
            
        
    
        
        
            
                "corrective_actions": "Enable reminders and define escalation in SOP-0002.",
            
        
    
        
        
            
                "preventive_actions": "Monthly training KPI review in management review agenda.",
            
        
    
        
        
            
                "opened_at": new Date('2025-12-01T00:00:00Z'),
            
        
    
        
        
            
                "due_at": new Date('2026-02-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-02-20T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const NonconformancesData = [
    
    {
    
        
        
            
                "nc_number": "NC-2026-0001",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "nonconformance_type": "training",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "One traveler page missing date next to operator signature.",
            
        
    
        
        
            
                "disposition": "use_as_is",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "detected_at": new Date('2026-02-05T15:45:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "nc_number": "NC-2026-0002",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "nonconformance_type": "training",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Incoming material COA lists test method revision not matching specification.",
            
        
    
        
        
            
                "disposition": "other",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "detected_at": new Date('2026-03-04T09:20:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-04-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "nc_number": "NC-2026-0003",
            
        
    
        
        
            
                "status": "dispositioned",
            
        
    
        
        
            
                "nonconformance_type": "process",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Cosmetic blemish observed on housing above acceptance limit for 3 units.",
            
        
    
        
        
            
                "disposition": "other",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "detected_at": new Date('2026-01-12T14:30:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-01-20T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "nc_number": "NC-2026-0004",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "nonconformance_type": "supplier",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Test fixture calibration label found expired at start of shift.",
            
        
    
        
        
            
                "disposition": "return_to_supplier",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "detected_at": new Date('2026-03-19T08:10:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-03-30T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "nc_number": "NC-2026-0005",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                "nonconformance_type": "documentation",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "description": "Reported system slowness during document search; investigation found no nonconformance.",
            
        
    
        
        
            
                "disposition": "rework",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "detected_at": new Date('2026-02-16T10:45:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-02-18T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const ComplaintsData = [
    
    {
    
        
        
            
                "complaint_number": "CMP-2026-0001",
            
        
    
        
        
            
                "status": "triaged",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reporter_name": "Clinic A Biomedical Team",
            
        
    
        
        
            
                "reporter_contact": "biomed@clinic-a.example",
            
        
    
        
        
            
                "complaint_description": "User reports intermittent low signal quality warnings with new sensors.",
            
        
    
        
        
            
                "serious_injury_or_death": false,
            
        
    
        
        
            
                "malfunction": true,
            
        
    
        
        
            
                "reportable_to_authority": false,
            
        
    
        
        
            
                "received_at": new Date('2026-02-22T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "complaint_number": "CMP-2026-0002",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reporter_name": "Home User",
            
        
    
        
        
            
                "reporter_contact": "support.ticket.18452@example",
            
        
    
        
        
            
                "complaint_description": "Battery compartment cover difficult to open; no functional failure.",
            
        
    
        
        
            
                "serious_injury_or_death": false,
            
        
    
        
        
            
                "malfunction": true,
            
        
    
        
        
            
                "reportable_to_authority": false,
            
        
    
        
        
            
                "received_at": new Date('2026-01-08T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-01-25T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "complaint_number": "CMP-2026-0003",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reporter_name": "Distributor Support",
            
        
    
        
        
            
                "reporter_contact": "qa@distributor.example",
            
        
    
        
        
            
                "complaint_description": "Packaging seal observed partially open on arrival for one carton.",
            
        
    
        
        
            
                "serious_injury_or_death": false,
            
        
    
        
        
            
                "malfunction": false,
            
        
    
        
        
            
                "reportable_to_authority": true,
            
        
    
        
        
            
                "received_at": new Date('2026-03-02T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-03-20T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "complaint_number": "CMP-2026-0004",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reporter_name": "Hospital Cardiology Lab",
            
        
    
        
        
            
                "reporter_contact": "cardio.lab@hospital.example",
            
        
    
        
        
            
                "complaint_description": "Report generation appears delayed after long wear period.",
            
        
    
        
        
            
                "serious_injury_or_death": true,
            
        
    
        
        
            
                "malfunction": true,
            
        
    
        
        
            
                "reportable_to_authority": true,
            
        
    
        
        
            
                "received_at": new Date('2026-03-18T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-04-30T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "complaint_number": "CMP-2026-0005",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "reporter_name": "Service Center",
            
        
    
        
        
            
                "reporter_contact": "service@repair-center.example",
            
        
    
        
        
            
                "complaint_description": "One unit returned with cracked enclosure; likely shipping damage.",
            
        
    
        
        
            
                "serious_injury_or_death": false,
            
        
    
        
        
            
                "malfunction": false,
            
        
    
        
        
            
                "reportable_to_authority": true,
            
        
    
        
        
            
                "received_at": new Date('2026-02-05T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-02-12T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const AuditsData = [
    
    {
    
        
        
            
                "audit_number": "AUD-2026-INT-01",
            
        
    
        
        
            
                "audit_type": "regulatory",
            
        
    
        
        
            
                "status": "cancelled",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_at": new Date('2026-03-10T09:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-03-12T17:00:00Z'),
            
        
    
        
        
            
                "scope": "Document control, training records, and audit trail review.",
            
        
    
        
        
            
                "summary": "Overall compliant with minor observations on training reminders.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                "audit_number": "AUD-2026-SUP-01",
            
        
    
        
        
            
                "audit_type": "other",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_at": new Date('2026-09-09T09:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-09-10T16:00:00Z'),
            
        
    
        
        
            
                "scope": "Supplier quality controls, COA integrity, and change notification.",
            
        
    
        
        
            
                "summary": "Planned annual supplier audit.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                "audit_number": "AUD-2026-REG-01",
            
        
    
        
        
            
                "audit_type": "other",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_at": new Date('2026-06-05T09:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-06-05T15:00:00Z'),
            
        
    
        
        
            
                "scope": "Readiness review for FDA expectations and Part 11 controls.",
            
        
    
        
        
            
                "summary": "Mock inspection focusing on e-signature and records integrity.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                "audit_number": "AUD-2025-INT-04",
            
        
    
        
        
            
                "audit_type": "other",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_at": new Date('2025-11-01T09:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2025-11-01T17:00:00Z'),
            
        
    
        
        
            
                "scope": "BMR completeness and batch release records review.",
            
        
    
        
        
            
                "summary": "Closed with one observation addressed via CAPA.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
    {
    
        
        
            
                "audit_number": "AUD-2026-NB-01",
            
        
    
        
        
            
                "audit_type": "internal",
            
        
    
        
        
            
                "status": "planned",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "start_at": new Date('2026-03-20T09:00:00Z'),
            
        
    
        
        
            
                "end_at": new Date('2026-03-22T16:00:00Z'),
            
        
    
        
        
            
                "scope": "ISO 13485 surveillance audit preparation and evidence compilation.",
            
        
    
        
        
            
                "summary": "Evidence collection ongoing.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_many" field
            
        
    
    },
    
];



const AuditFindingsData = [
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "finding_number": "FND-2026-INT-01-001",
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "description": "Training reminders not consistently issued for overdue assignments.",
            
        
    
        
        
            
                "objective_evidence": "Two assignments exceeded due date without escalation evidence.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "due_at": new Date('2026-04-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-05-10T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "finding_number": "FND-2026-INT-01-002",
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "description": "Some document templates not mapped to clauses consistently.",
            
        
    
        
        
            
                "objective_evidence": "Template entries missing clause mapping fields for two templates.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "due_at": new Date('2026-03-31T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-03-28T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "finding_number": "FND-2025-INT-04-001",
            
        
    
        
        
            
                "severity": "observation",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "description": "One batch record missing supervisor review signature at time of audit.",
            
        
    
        
        
            
                "objective_evidence": "Traveler for PO100-2025-0010 missing supervisor sign-off line.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "due_at": new Date('2025-12-15T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-01-05T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "finding_number": "FND-2026-REG-01-001",
            
        
    
        
        
            
                "severity": "minor",
            
        
    
        
        
            
                "status": "open",
            
        
    
        
        
            
                "description": "Need documented rationale for electronic signature meaning and manifestation in approval records.",
            
        
    
        
        
            
                "objective_evidence": "Signature meaning field not consistently populated across approvals.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "due_at": new Date('2026-06-30T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-08-15T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
    {
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "finding_number": "FND-2026-SUP-01-001",
            
        
    
        
        
            
                "severity": "critical",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                "description": "Supplier change notification clause should be added to quality agreement.",
            
        
    
        
        
            
                "objective_evidence": "Quality agreement lacks explicit notification timeline for test method changes.",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "due_at": new Date('2026-10-01T00:00:00Z'),
            
        
    
        
        
            
                "closed_at": new Date('2026-11-01T00:00:00Z'),
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
    },
    
];



const ManagementReviewsData = [
    
    {
    
        
        
            
                "review_title": "Management Review Q1 2026",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "meeting_start_at": new Date('2026-03-28T13:00:00Z'),
            
        
    
        
        
            
                "meeting_end_at": new Date('2026-03-28T15:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "agenda": "KPIs, audit results, CAPA status, complaints trending, supplier performance, training compliance",
            
        
    
        
        
            
                "minutes": "Reviewed KPIs; agreed to improve training reminders and close open audit findings.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "review_title": "Management Review Q4 2025",
            
        
    
        
        
            
                "status": "completed",
            
        
    
        
        
            
                "meeting_start_at": new Date('2025-12-15T13:00:00Z'),
            
        
    
        
        
            
                "meeting_end_at": new Date('2025-12-15T14:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "agenda": "Annual review of QMS performance and objectives",
            
        
    
        
        
            
                "minutes": "Approved objectives for 2026 and reviewed resource needs.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "review_title": "Management Review Special Session CAPA",
            
        
    
        
        
            
                "status": "archived",
            
        
    
        
        
            
                "meeting_start_at": new Date('2026-02-20T10:00:00Z'),
            
        
    
        
        
            
                "meeting_end_at": new Date('2026-02-20T11:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "agenda": "CAPA backlog and prioritization",
            
        
    
        
        
            
                "minutes": "Assigned owners and due dates; agreed to add escalation for overdue actions.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "review_title": "Management Review Supplier Performance",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "meeting_start_at": new Date('2026-04-25T09:00:00Z'),
            
        
    
        
        
            
                "meeting_end_at": new Date('2026-04-25T10:00:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "agenda": "Supplier scorecards and audit schedule",
            
        
    
        
        
            
                "minutes": "To be recorded after meeting.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "review_title": "Management Review Risk Management",
            
        
    
        
        
            
                "status": "in_progress",
            
        
    
        
        
            
                "meeting_start_at": new Date('2026-03-15T14:00:00Z'),
            
        
    
        
        
            
                "meeting_end_at": new Date('2026-03-15T15:30:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "agenda": "Risk acceptability criteria and post-market inputs",
            
        
    
        
        
            
                "minutes": "Discussion in progress; action items pending.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const RegulatorySubmissionsData = [
    
    {
    
        
        
            
                "submission_name": "EU MDR Technical Documentation PO-100",
            
        
    
        
        
            
                "jurisdiction": "us_fda",
            
        
    
        
        
            
                "submission_type": "510k",
            
        
    
        
        
            
                "status": "draft",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_submission_at": new Date('2026-06-15T00:00:00Z'),
            
        
    
        
        
            
                "submitted_at": new Date('2026-07-01T00:00:00Z'),
            
        
    
        
        
            
                "decision_at": new Date('2026-09-30T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Align risk file and labeling references before submission.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "submission_name": "FDA 510k PO-100",
            
        
    
        
        
            
                "jurisdiction": "uk_mhra",
            
        
    
        
        
            
                "submission_type": "510k",
            
        
    
        
        
            
                "status": "submitted",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_submission_at": new Date('2026-10-01T00:00:00Z'),
            
        
    
        
        
            
                "submitted_at": new Date('2026-10-15T00:00:00Z'),
            
        
    
        
        
            
                "decision_at": new Date('2027-01-15T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Prepare performance testing summary and predicate comparison.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "submission_name": "EU MDR PMS Report TH-10 2025",
            
        
    
        
        
            
                "jurisdiction": "us_fda",
            
        
    
        
        
            
                "submission_type": "cer",
            
        
    
        
        
            
                "status": "questions_received",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_submission_at": new Date('2026-02-01T00:00:00Z'),
            
        
    
        
        
            
                "submitted_at": new Date('2026-02-10T00:00:00Z'),
            
        
    
        
        
            
                "decision_at": new Date('2026-02-20T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Completed annual PMS report and archived supporting evidence.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "submission_name": "FDA Registration and Listing 2026",
            
        
    
        
        
            
                "jurisdiction": "us_fda",
            
        
    
        
        
            
                "submission_type": "technical_documentation",
            
        
    
        
        
            
                "status": "rejected",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_submission_at": new Date('2026-12-01T00:00:00Z'),
            
        
    
        
        
            
                "submitted_at": new Date('2026-12-05T00:00:00Z'),
            
        
    
        
        
            
                "decision_at": new Date('2026-12-20T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Submitted annual registration; awaiting confirmation.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
    {
    
        
        
            
                "submission_name": "EU MDR PSUR ECG-3D",
            
        
    
        
        
            
                "jurisdiction": "eu_mdr",
            
        
    
        
        
            
                "submission_type": "technical_documentation",
            
        
    
        
        
            
                "status": "closed",
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "planned_submission_at": new Date('2026-08-01T00:00:00Z'),
            
        
    
        
        
            
                "submitted_at": new Date('2026-08-15T00:00:00Z'),
            
        
    
        
        
            
                "decision_at": new Date('2026-10-01T00:00:00Z'),
            
        
    
        
        
            
                "notes": "Draft PSUR; incorporate complaint trend analysis and CAPA links.",
            
        
    
        
        
            
                // type code here for "files" field
            
        
    
    },
    
];



const AuditLogsData = [
    
    {
    
        
        
            
                "event_at": new Date('2026-03-21T14:06:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "export",
            
        
    
        
        
            
                "subject_type": "audit",
            
        
    
        
        
            
                "subject_reference": "SOP-0001",
            
        
    
        
        
            
                "details": "Viewed effective document for audit preparation",
            
        
    
        
        
            
                "ip_address": "10.10.0.18",
            
        
    
        
        
            
                "user_agent": "Chrome on macOS",
            
        
    
    },
    
    {
    
        
        
            
                "event_at": new Date('2026-03-05T14:16:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "download",
            
        
    
        
        
            
                "subject_type": "risk_item",
            
        
    
        
        
            
                "subject_reference": "SOP-0002 Rev A",
            
        
    
        
        
            
                "details": "Assigned Quality Review step to QA reviewer",
            
        
    
        
        
            
                "ip_address": "10.10.0.12",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
    },
    
    {
    
        
        
            
                "event_at": new Date('2026-01-10T13:16:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "update",
            
        
    
        
        
            
                "subject_type": "audit",
            
        
    
        
        
            
                "subject_reference": "SOP-0001 Rev B",
            
        
    
        
        
            
                "details": "Approved revision for effective release",
            
        
    
        
        
            
                "ip_address": "10.10.0.18",
            
        
    
        
        
            
                "user_agent": "Chrome on macOS",
            
        
    
    },
    
    {
    
        
        
            
                "event_at": new Date('2026-02-18T10:20:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "upload",
            
        
    
        
        
            
                "subject_type": "management_review",
            
        
    
        
        
            
                "subject_reference": "CAPA-2026-002",
            
        
    
        
        
            
                "details": "Opened CAPA from nonconformance trend",
            
        
    
        
        
            
                "ip_address": "10.10.0.31",
            
        
    
        
        
            
                "user_agent": "Chrome on Windows",
            
        
    
    },
    
    {
    
        
        
            
                "event_at": new Date('2026-03-12T17:15:00Z'),
            
        
    
        
        
            
                // type code here for "relation_one" field
            
        
    
        
        
            
                "event_type": "reject",
            
        
    
        
        
            
                "subject_type": "audit_finding",
            
        
    
        
        
            
                "subject_reference": "AUD-2026-INT-01",
            
        
    
        
        
            
                "details": "Exported audit report PDF for records",
            
        
    
        
        
            
                "ip_address": "203.0.113.55",
            
        
    
        
        
            
                "user_agent": "Chrome on Linux",
            
        
    
    },
    
];




    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
    
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateClausWithStandard() {
            
                const relatedStandard0 = await Standards.findOne({
                    offset: Math.floor(Math.random() * (await Standards.count())),
                });
                const Claus0 = await Clauses.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Claus0?.setStandard)
                {
                    await
                    Claus0.
                    setStandard(relatedStandard0);
                }
            
                const relatedStandard1 = await Standards.findOne({
                    offset: Math.floor(Math.random() * (await Standards.count())),
                });
                const Claus1 = await Clauses.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Claus1?.setStandard)
                {
                    await
                    Claus1.
                    setStandard(relatedStandard1);
                }
            
                const relatedStandard2 = await Standards.findOne({
                    offset: Math.floor(Math.random() * (await Standards.count())),
                });
                const Claus2 = await Clauses.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Claus2?.setStandard)
                {
                    await
                    Claus2.
                    setStandard(relatedStandard2);
                }
            
                const relatedStandard3 = await Standards.findOne({
                    offset: Math.floor(Math.random() * (await Standards.count())),
                });
                const Claus3 = await Clauses.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Claus3?.setStandard)
                {
                    await
                    Claus3.
                    setStandard(relatedStandard3);
                }
            
                const relatedStandard4 = await Standards.findOne({
                    offset: Math.floor(Math.random() * (await Standards.count())),
                });
                const Claus4 = await Clauses.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Claus4?.setStandard)
                {
                    await
                    Claus4.
                    setStandard(relatedStandard4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateDocumentTemplateWithDocument_type() {
            
                const relatedDocument_type0 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const DocumentTemplate0 = await DocumentTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DocumentTemplate0?.setDocument_type)
                {
                    await
                    DocumentTemplate0.
                    setDocument_type(relatedDocument_type0);
                }
            
                const relatedDocument_type1 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const DocumentTemplate1 = await DocumentTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DocumentTemplate1?.setDocument_type)
                {
                    await
                    DocumentTemplate1.
                    setDocument_type(relatedDocument_type1);
                }
            
                const relatedDocument_type2 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const DocumentTemplate2 = await DocumentTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DocumentTemplate2?.setDocument_type)
                {
                    await
                    DocumentTemplate2.
                    setDocument_type(relatedDocument_type2);
                }
            
                const relatedDocument_type3 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const DocumentTemplate3 = await DocumentTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DocumentTemplate3?.setDocument_type)
                {
                    await
                    DocumentTemplate3.
                    setDocument_type(relatedDocument_type3);
                }
            
                const relatedDocument_type4 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const DocumentTemplate4 = await DocumentTemplates.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (DocumentTemplate4?.setDocument_type)
                {
                    await
                    DocumentTemplate4.
                    setDocument_type(relatedDocument_type4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
        
            
            async function associateDocumentWithDocument_type() {
            
                const relatedDocument_type0 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setDocument_type)
                {
                    await
                    Document0.
                    setDocument_type(relatedDocument_type0);
                }
            
                const relatedDocument_type1 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setDocument_type)
                {
                    await
                    Document1.
                    setDocument_type(relatedDocument_type1);
                }
            
                const relatedDocument_type2 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setDocument_type)
                {
                    await
                    Document2.
                    setDocument_type(relatedDocument_type2);
                }
            
                const relatedDocument_type3 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setDocument_type)
                {
                    await
                    Document3.
                    setDocument_type(relatedDocument_type3);
                }
            
                const relatedDocument_type4 = await DocumentTypes.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTypes.count())),
                });
                const Document4 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Document4?.setDocument_type)
                {
                    await
                    Document4.
                    setDocument_type(relatedDocument_type4);
                }
            
        }
        
    
        
            
            async function associateDocumentWithTemplate() {
            
                const relatedTemplate0 = await DocumentTemplates.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTemplates.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setTemplate)
                {
                    await
                    Document0.
                    setTemplate(relatedTemplate0);
                }
            
                const relatedTemplate1 = await DocumentTemplates.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTemplates.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setTemplate)
                {
                    await
                    Document1.
                    setTemplate(relatedTemplate1);
                }
            
                const relatedTemplate2 = await DocumentTemplates.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTemplates.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setTemplate)
                {
                    await
                    Document2.
                    setTemplate(relatedTemplate2);
                }
            
                const relatedTemplate3 = await DocumentTemplates.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTemplates.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setTemplate)
                {
                    await
                    Document3.
                    setTemplate(relatedTemplate3);
                }
            
                const relatedTemplate4 = await DocumentTemplates.findOne({
                    offset: Math.floor(Math.random() * (await DocumentTemplates.count())),
                });
                const Document4 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Document4?.setTemplate)
                {
                    await
                    Document4.
                    setTemplate(relatedTemplate4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateDocumentWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setOwner)
                {
                    await
                    Document0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setOwner)
                {
                    await
                    Document1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setOwner)
                {
                    await
                    Document2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setOwner)
                {
                    await
                    Document3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document4 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Document4?.setOwner)
                {
                    await
                    Document4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
            
            async function associateDocumentWithApprover() {
            
                const relatedApprover0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document0 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Document0?.setApprover)
                {
                    await
                    Document0.
                    setApprover(relatedApprover0);
                }
            
                const relatedApprover1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document1 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Document1?.setApprover)
                {
                    await
                    Document1.
                    setApprover(relatedApprover1);
                }
            
                const relatedApprover2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document2 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Document2?.setApprover)
                {
                    await
                    Document2.
                    setApprover(relatedApprover2);
                }
            
                const relatedApprover3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document3 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Document3?.setApprover)
                {
                    await
                    Document3.
                    setApprover(relatedApprover3);
                }
            
                const relatedApprover4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Document4 = await Documents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Document4?.setApprover)
                {
                    await
                    Document4.
                    setApprover(relatedApprover4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    
        
    

    
    
    
        
            
            async function associateDocumentVersionWithDocument() {
            
                const relatedDocument0 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const DocumentVersion0 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DocumentVersion0?.setDocument)
                {
                    await
                    DocumentVersion0.
                    setDocument(relatedDocument0);
                }
            
                const relatedDocument1 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const DocumentVersion1 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DocumentVersion1?.setDocument)
                {
                    await
                    DocumentVersion1.
                    setDocument(relatedDocument1);
                }
            
                const relatedDocument2 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const DocumentVersion2 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DocumentVersion2?.setDocument)
                {
                    await
                    DocumentVersion2.
                    setDocument(relatedDocument2);
                }
            
                const relatedDocument3 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const DocumentVersion3 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DocumentVersion3?.setDocument)
                {
                    await
                    DocumentVersion3.
                    setDocument(relatedDocument3);
                }
            
                const relatedDocument4 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const DocumentVersion4 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (DocumentVersion4?.setDocument)
                {
                    await
                    DocumentVersion4.
                    setDocument(relatedDocument4);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateDocumentVersionWithAuthor() {
            
                const relatedAuthor0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DocumentVersion0 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DocumentVersion0?.setAuthor)
                {
                    await
                    DocumentVersion0.
                    setAuthor(relatedAuthor0);
                }
            
                const relatedAuthor1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DocumentVersion1 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DocumentVersion1?.setAuthor)
                {
                    await
                    DocumentVersion1.
                    setAuthor(relatedAuthor1);
                }
            
                const relatedAuthor2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DocumentVersion2 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DocumentVersion2?.setAuthor)
                {
                    await
                    DocumentVersion2.
                    setAuthor(relatedAuthor2);
                }
            
                const relatedAuthor3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DocumentVersion3 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DocumentVersion3?.setAuthor)
                {
                    await
                    DocumentVersion3.
                    setAuthor(relatedAuthor3);
                }
            
                const relatedAuthor4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const DocumentVersion4 = await DocumentVersions.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (DocumentVersion4?.setAuthor)
                {
                    await
                    DocumentVersion4.
                    setAuthor(relatedAuthor4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateChangeRequestWithRequester() {
            
                const relatedRequester0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest0 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ChangeRequest0?.setRequester)
                {
                    await
                    ChangeRequest0.
                    setRequester(relatedRequester0);
                }
            
                const relatedRequester1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest1 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ChangeRequest1?.setRequester)
                {
                    await
                    ChangeRequest1.
                    setRequester(relatedRequester1);
                }
            
                const relatedRequester2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest2 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ChangeRequest2?.setRequester)
                {
                    await
                    ChangeRequest2.
                    setRequester(relatedRequester2);
                }
            
                const relatedRequester3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest3 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ChangeRequest3?.setRequester)
                {
                    await
                    ChangeRequest3.
                    setRequester(relatedRequester3);
                }
            
                const relatedRequester4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest4 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ChangeRequest4?.setRequester)
                {
                    await
                    ChangeRequest4.
                    setRequester(relatedRequester4);
                }
            
        }
        
    
        
            
            async function associateChangeRequestWithDocument() {
            
                const relatedDocument0 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const ChangeRequest0 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ChangeRequest0?.setDocument)
                {
                    await
                    ChangeRequest0.
                    setDocument(relatedDocument0);
                }
            
                const relatedDocument1 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const ChangeRequest1 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ChangeRequest1?.setDocument)
                {
                    await
                    ChangeRequest1.
                    setDocument(relatedDocument1);
                }
            
                const relatedDocument2 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const ChangeRequest2 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ChangeRequest2?.setDocument)
                {
                    await
                    ChangeRequest2.
                    setDocument(relatedDocument2);
                }
            
                const relatedDocument3 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const ChangeRequest3 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ChangeRequest3?.setDocument)
                {
                    await
                    ChangeRequest3.
                    setDocument(relatedDocument3);
                }
            
                const relatedDocument4 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const ChangeRequest4 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ChangeRequest4?.setDocument)
                {
                    await
                    ChangeRequest4.
                    setDocument(relatedDocument4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateChangeRequestWithAssigned_to() {
            
                const relatedAssigned_to0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest0 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ChangeRequest0?.setAssigned_to)
                {
                    await
                    ChangeRequest0.
                    setAssigned_to(relatedAssigned_to0);
                }
            
                const relatedAssigned_to1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest1 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ChangeRequest1?.setAssigned_to)
                {
                    await
                    ChangeRequest1.
                    setAssigned_to(relatedAssigned_to1);
                }
            
                const relatedAssigned_to2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest2 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ChangeRequest2?.setAssigned_to)
                {
                    await
                    ChangeRequest2.
                    setAssigned_to(relatedAssigned_to2);
                }
            
                const relatedAssigned_to3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest3 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ChangeRequest3?.setAssigned_to)
                {
                    await
                    ChangeRequest3.
                    setAssigned_to(relatedAssigned_to3);
                }
            
                const relatedAssigned_to4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ChangeRequest4 = await ChangeRequests.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ChangeRequest4?.setAssigned_to)
                {
                    await
                    ChangeRequest4.
                    setAssigned_to(relatedAssigned_to4);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateApprovalStepWithWorkflow() {
            
                const relatedWorkflow0 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalStep0 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApprovalStep0?.setWorkflow)
                {
                    await
                    ApprovalStep0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalStep1 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApprovalStep1?.setWorkflow)
                {
                    await
                    ApprovalStep1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalStep2 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApprovalStep2?.setWorkflow)
                {
                    await
                    ApprovalStep2.
                    setWorkflow(relatedWorkflow2);
                }
            
                const relatedWorkflow3 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalStep3 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApprovalStep3?.setWorkflow)
                {
                    await
                    ApprovalStep3.
                    setWorkflow(relatedWorkflow3);
                }
            
                const relatedWorkflow4 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalStep4 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApprovalStep4?.setWorkflow)
                {
                    await
                    ApprovalStep4.
                    setWorkflow(relatedWorkflow4);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateApprovalStepWithAssignee() {
            
                const relatedAssignee0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalStep0 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApprovalStep0?.setAssignee)
                {
                    await
                    ApprovalStep0.
                    setAssignee(relatedAssignee0);
                }
            
                const relatedAssignee1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalStep1 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApprovalStep1?.setAssignee)
                {
                    await
                    ApprovalStep1.
                    setAssignee(relatedAssignee1);
                }
            
                const relatedAssignee2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalStep2 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApprovalStep2?.setAssignee)
                {
                    await
                    ApprovalStep2.
                    setAssignee(relatedAssignee2);
                }
            
                const relatedAssignee3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalStep3 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApprovalStep3?.setAssignee)
                {
                    await
                    ApprovalStep3.
                    setAssignee(relatedAssignee3);
                }
            
                const relatedAssignee4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalStep4 = await ApprovalSteps.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApprovalStep4?.setAssignee)
                {
                    await
                    ApprovalStep4.
                    setAssignee(relatedAssignee4);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateApprovalTaskWithWorkflow() {
            
                const relatedWorkflow0 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalTask0 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApprovalTask0?.setWorkflow)
                {
                    await
                    ApprovalTask0.
                    setWorkflow(relatedWorkflow0);
                }
            
                const relatedWorkflow1 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalTask1 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApprovalTask1?.setWorkflow)
                {
                    await
                    ApprovalTask1.
                    setWorkflow(relatedWorkflow1);
                }
            
                const relatedWorkflow2 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalTask2 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApprovalTask2?.setWorkflow)
                {
                    await
                    ApprovalTask2.
                    setWorkflow(relatedWorkflow2);
                }
            
                const relatedWorkflow3 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalTask3 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApprovalTask3?.setWorkflow)
                {
                    await
                    ApprovalTask3.
                    setWorkflow(relatedWorkflow3);
                }
            
                const relatedWorkflow4 = await ApprovalWorkflows.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalWorkflows.count())),
                });
                const ApprovalTask4 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApprovalTask4?.setWorkflow)
                {
                    await
                    ApprovalTask4.
                    setWorkflow(relatedWorkflow4);
                }
            
        }
        
    
        
            
            async function associateApprovalTaskWithStep() {
            
                const relatedStep0 = await ApprovalSteps.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalSteps.count())),
                });
                const ApprovalTask0 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApprovalTask0?.setStep)
                {
                    await
                    ApprovalTask0.
                    setStep(relatedStep0);
                }
            
                const relatedStep1 = await ApprovalSteps.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalSteps.count())),
                });
                const ApprovalTask1 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApprovalTask1?.setStep)
                {
                    await
                    ApprovalTask1.
                    setStep(relatedStep1);
                }
            
                const relatedStep2 = await ApprovalSteps.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalSteps.count())),
                });
                const ApprovalTask2 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApprovalTask2?.setStep)
                {
                    await
                    ApprovalTask2.
                    setStep(relatedStep2);
                }
            
                const relatedStep3 = await ApprovalSteps.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalSteps.count())),
                });
                const ApprovalTask3 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApprovalTask3?.setStep)
                {
                    await
                    ApprovalTask3.
                    setStep(relatedStep3);
                }
            
                const relatedStep4 = await ApprovalSteps.findOne({
                    offset: Math.floor(Math.random() * (await ApprovalSteps.count())),
                });
                const ApprovalTask4 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApprovalTask4?.setStep)
                {
                    await
                    ApprovalTask4.
                    setStep(relatedStep4);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateApprovalTaskWithAssignee() {
            
                const relatedAssignee0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalTask0 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ApprovalTask0?.setAssignee)
                {
                    await
                    ApprovalTask0.
                    setAssignee(relatedAssignee0);
                }
            
                const relatedAssignee1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalTask1 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ApprovalTask1?.setAssignee)
                {
                    await
                    ApprovalTask1.
                    setAssignee(relatedAssignee1);
                }
            
                const relatedAssignee2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalTask2 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ApprovalTask2?.setAssignee)
                {
                    await
                    ApprovalTask2.
                    setAssignee(relatedAssignee2);
                }
            
                const relatedAssignee3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalTask3 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ApprovalTask3?.setAssignee)
                {
                    await
                    ApprovalTask3.
                    setAssignee(relatedAssignee3);
                }
            
                const relatedAssignee4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ApprovalTask4 = await ApprovalTasks.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ApprovalTask4?.setAssignee)
                {
                    await
                    ApprovalTask4.
                    setAssignee(relatedAssignee4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateEsignatureEventWithUser() {
            
                const relatedUser0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EsignatureEvent0 = await EsignatureEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (EsignatureEvent0?.setUser)
                {
                    await
                    EsignatureEvent0.
                    setUser(relatedUser0);
                }
            
                const relatedUser1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EsignatureEvent1 = await EsignatureEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (EsignatureEvent1?.setUser)
                {
                    await
                    EsignatureEvent1.
                    setUser(relatedUser1);
                }
            
                const relatedUser2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EsignatureEvent2 = await EsignatureEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (EsignatureEvent2?.setUser)
                {
                    await
                    EsignatureEvent2.
                    setUser(relatedUser2);
                }
            
                const relatedUser3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EsignatureEvent3 = await EsignatureEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (EsignatureEvent3?.setUser)
                {
                    await
                    EsignatureEvent3.
                    setUser(relatedUser3);
                }
            
                const relatedUser4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const EsignatureEvent4 = await EsignatureEvents.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (EsignatureEvent4?.setUser)
                {
                    await
                    EsignatureEvent4.
                    setUser(relatedUser4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateTrainingAssignmentWithUser() {
            
                const relatedUser0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TrainingAssignment0 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrainingAssignment0?.setUser)
                {
                    await
                    TrainingAssignment0.
                    setUser(relatedUser0);
                }
            
                const relatedUser1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TrainingAssignment1 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrainingAssignment1?.setUser)
                {
                    await
                    TrainingAssignment1.
                    setUser(relatedUser1);
                }
            
                const relatedUser2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TrainingAssignment2 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrainingAssignment2?.setUser)
                {
                    await
                    TrainingAssignment2.
                    setUser(relatedUser2);
                }
            
                const relatedUser3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TrainingAssignment3 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrainingAssignment3?.setUser)
                {
                    await
                    TrainingAssignment3.
                    setUser(relatedUser3);
                }
            
                const relatedUser4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const TrainingAssignment4 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrainingAssignment4?.setUser)
                {
                    await
                    TrainingAssignment4.
                    setUser(relatedUser4);
                }
            
        }
        
    
        
            
            async function associateTrainingAssignmentWithCourse() {
            
                const relatedCourse0 = await TrainingCourses.findOne({
                    offset: Math.floor(Math.random() * (await TrainingCourses.count())),
                });
                const TrainingAssignment0 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrainingAssignment0?.setCourse)
                {
                    await
                    TrainingAssignment0.
                    setCourse(relatedCourse0);
                }
            
                const relatedCourse1 = await TrainingCourses.findOne({
                    offset: Math.floor(Math.random() * (await TrainingCourses.count())),
                });
                const TrainingAssignment1 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrainingAssignment1?.setCourse)
                {
                    await
                    TrainingAssignment1.
                    setCourse(relatedCourse1);
                }
            
                const relatedCourse2 = await TrainingCourses.findOne({
                    offset: Math.floor(Math.random() * (await TrainingCourses.count())),
                });
                const TrainingAssignment2 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrainingAssignment2?.setCourse)
                {
                    await
                    TrainingAssignment2.
                    setCourse(relatedCourse2);
                }
            
                const relatedCourse3 = await TrainingCourses.findOne({
                    offset: Math.floor(Math.random() * (await TrainingCourses.count())),
                });
                const TrainingAssignment3 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrainingAssignment3?.setCourse)
                {
                    await
                    TrainingAssignment3.
                    setCourse(relatedCourse3);
                }
            
                const relatedCourse4 = await TrainingCourses.findOne({
                    offset: Math.floor(Math.random() * (await TrainingCourses.count())),
                });
                const TrainingAssignment4 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrainingAssignment4?.setCourse)
                {
                    await
                    TrainingAssignment4.
                    setCourse(relatedCourse4);
                }
            
        }
        
    
        
            
            async function associateTrainingAssignmentWithDocument() {
            
                const relatedDocument0 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const TrainingAssignment0 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (TrainingAssignment0?.setDocument)
                {
                    await
                    TrainingAssignment0.
                    setDocument(relatedDocument0);
                }
            
                const relatedDocument1 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const TrainingAssignment1 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (TrainingAssignment1?.setDocument)
                {
                    await
                    TrainingAssignment1.
                    setDocument(relatedDocument1);
                }
            
                const relatedDocument2 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const TrainingAssignment2 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (TrainingAssignment2?.setDocument)
                {
                    await
                    TrainingAssignment2.
                    setDocument(relatedDocument2);
                }
            
                const relatedDocument3 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const TrainingAssignment3 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (TrainingAssignment3?.setDocument)
                {
                    await
                    TrainingAssignment3.
                    setDocument(relatedDocument3);
                }
            
                const relatedDocument4 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const TrainingAssignment4 = await TrainingAssignments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (TrainingAssignment4?.setDocument)
                {
                    await
                    TrainingAssignment4.
                    setDocument(relatedDocument4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateBatcheWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Batche0 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Batche0?.setProduct)
                {
                    await
                    Batche0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Batche1 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Batche1?.setProduct)
                {
                    await
                    Batche1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Batche2 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Batche2?.setProduct)
                {
                    await
                    Batche2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Batche3 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Batche3?.setProduct)
                {
                    await
                    Batche3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Batche4 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Batche4?.setProduct)
                {
                    await
                    Batche4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateBatcheWithBmr_document() {
            
                const relatedBmr_document0 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Batche0 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Batche0?.setBmr_document)
                {
                    await
                    Batche0.
                    setBmr_document(relatedBmr_document0);
                }
            
                const relatedBmr_document1 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Batche1 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Batche1?.setBmr_document)
                {
                    await
                    Batche1.
                    setBmr_document(relatedBmr_document1);
                }
            
                const relatedBmr_document2 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Batche2 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Batche2?.setBmr_document)
                {
                    await
                    Batche2.
                    setBmr_document(relatedBmr_document2);
                }
            
                const relatedBmr_document3 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Batche3 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Batche3?.setBmr_document)
                {
                    await
                    Batche3.
                    setBmr_document(relatedBmr_document3);
                }
            
                const relatedBmr_document4 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Batche4 = await Batches.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Batche4?.setBmr_document)
                {
                    await
                    Batche4.
                    setBmr_document(relatedBmr_document4);
                }
            
        }
        
    
        
    
        
    

    
    
    
        
            
            async function associateCertificatesOfAnalysiWithBatch() {
            
                const relatedBatch0 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const CertificatesOfAnalysi0 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CertificatesOfAnalysi0?.setBatch)
                {
                    await
                    CertificatesOfAnalysi0.
                    setBatch(relatedBatch0);
                }
            
                const relatedBatch1 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const CertificatesOfAnalysi1 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CertificatesOfAnalysi1?.setBatch)
                {
                    await
                    CertificatesOfAnalysi1.
                    setBatch(relatedBatch1);
                }
            
                const relatedBatch2 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const CertificatesOfAnalysi2 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CertificatesOfAnalysi2?.setBatch)
                {
                    await
                    CertificatesOfAnalysi2.
                    setBatch(relatedBatch2);
                }
            
                const relatedBatch3 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const CertificatesOfAnalysi3 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (CertificatesOfAnalysi3?.setBatch)
                {
                    await
                    CertificatesOfAnalysi3.
                    setBatch(relatedBatch3);
                }
            
                const relatedBatch4 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const CertificatesOfAnalysi4 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (CertificatesOfAnalysi4?.setBatch)
                {
                    await
                    CertificatesOfAnalysi4.
                    setBatch(relatedBatch4);
                }
            
        }
        
    
        
            
            async function associateCertificatesOfAnalysiWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const CertificatesOfAnalysi0 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CertificatesOfAnalysi0?.setSupplier)
                {
                    await
                    CertificatesOfAnalysi0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const CertificatesOfAnalysi1 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CertificatesOfAnalysi1?.setSupplier)
                {
                    await
                    CertificatesOfAnalysi1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const CertificatesOfAnalysi2 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CertificatesOfAnalysi2?.setSupplier)
                {
                    await
                    CertificatesOfAnalysi2.
                    setSupplier(relatedSupplier2);
                }
            
                const relatedSupplier3 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const CertificatesOfAnalysi3 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (CertificatesOfAnalysi3?.setSupplier)
                {
                    await
                    CertificatesOfAnalysi3.
                    setSupplier(relatedSupplier3);
                }
            
                const relatedSupplier4 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const CertificatesOfAnalysi4 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (CertificatesOfAnalysi4?.setSupplier)
                {
                    await
                    CertificatesOfAnalysi4.
                    setSupplier(relatedSupplier4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateCertificatesOfAnalysiWithIssued_by() {
            
                const relatedIssued_by0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CertificatesOfAnalysi0 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (CertificatesOfAnalysi0?.setIssued_by)
                {
                    await
                    CertificatesOfAnalysi0.
                    setIssued_by(relatedIssued_by0);
                }
            
                const relatedIssued_by1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CertificatesOfAnalysi1 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (CertificatesOfAnalysi1?.setIssued_by)
                {
                    await
                    CertificatesOfAnalysi1.
                    setIssued_by(relatedIssued_by1);
                }
            
                const relatedIssued_by2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CertificatesOfAnalysi2 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (CertificatesOfAnalysi2?.setIssued_by)
                {
                    await
                    CertificatesOfAnalysi2.
                    setIssued_by(relatedIssued_by2);
                }
            
                const relatedIssued_by3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CertificatesOfAnalysi3 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (CertificatesOfAnalysi3?.setIssued_by)
                {
                    await
                    CertificatesOfAnalysi3.
                    setIssued_by(relatedIssued_by3);
                }
            
                const relatedIssued_by4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const CertificatesOfAnalysi4 = await CertificatesOfAnalysis.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (CertificatesOfAnalysi4?.setIssued_by)
                {
                    await
                    CertificatesOfAnalysi4.
                    setIssued_by(relatedIssued_by4);
                }
            
        }
        
    

    
    
    
        
            
            async function associateDeviceMasterRecordWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeviceMasterRecord0 = await DeviceMasterRecords.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (DeviceMasterRecord0?.setProduct)
                {
                    await
                    DeviceMasterRecord0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeviceMasterRecord1 = await DeviceMasterRecords.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (DeviceMasterRecord1?.setProduct)
                {
                    await
                    DeviceMasterRecord1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeviceMasterRecord2 = await DeviceMasterRecords.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (DeviceMasterRecord2?.setProduct)
                {
                    await
                    DeviceMasterRecord2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeviceMasterRecord3 = await DeviceMasterRecords.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (DeviceMasterRecord3?.setProduct)
                {
                    await
                    DeviceMasterRecord3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const DeviceMasterRecord4 = await DeviceMasterRecords.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (DeviceMasterRecord4?.setProduct)
                {
                    await
                    DeviceMasterRecord4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateRiskAssessmentWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RiskAssessment0 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RiskAssessment0?.setProduct)
                {
                    await
                    RiskAssessment0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RiskAssessment1 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RiskAssessment1?.setProduct)
                {
                    await
                    RiskAssessment1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RiskAssessment2 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RiskAssessment2?.setProduct)
                {
                    await
                    RiskAssessment2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RiskAssessment3 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RiskAssessment3?.setProduct)
                {
                    await
                    RiskAssessment3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RiskAssessment4 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RiskAssessment4?.setProduct)
                {
                    await
                    RiskAssessment4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateRiskAssessmentWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RiskAssessment0 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RiskAssessment0?.setOwner)
                {
                    await
                    RiskAssessment0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RiskAssessment1 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RiskAssessment1?.setOwner)
                {
                    await
                    RiskAssessment1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RiskAssessment2 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RiskAssessment2?.setOwner)
                {
                    await
                    RiskAssessment2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RiskAssessment3 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RiskAssessment3?.setOwner)
                {
                    await
                    RiskAssessment3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RiskAssessment4 = await RiskAssessments.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RiskAssessment4?.setOwner)
                {
                    await
                    RiskAssessment4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    

    
    
    
        
            
            async function associateRiskItemWithRisk_assessment() {
            
                const relatedRisk_assessment0 = await RiskAssessments.findOne({
                    offset: Math.floor(Math.random() * (await RiskAssessments.count())),
                });
                const RiskItem0 = await RiskItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RiskItem0?.setRisk_assessment)
                {
                    await
                    RiskItem0.
                    setRisk_assessment(relatedRisk_assessment0);
                }
            
                const relatedRisk_assessment1 = await RiskAssessments.findOne({
                    offset: Math.floor(Math.random() * (await RiskAssessments.count())),
                });
                const RiskItem1 = await RiskItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RiskItem1?.setRisk_assessment)
                {
                    await
                    RiskItem1.
                    setRisk_assessment(relatedRisk_assessment1);
                }
            
                const relatedRisk_assessment2 = await RiskAssessments.findOne({
                    offset: Math.floor(Math.random() * (await RiskAssessments.count())),
                });
                const RiskItem2 = await RiskItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RiskItem2?.setRisk_assessment)
                {
                    await
                    RiskItem2.
                    setRisk_assessment(relatedRisk_assessment2);
                }
            
                const relatedRisk_assessment3 = await RiskAssessments.findOne({
                    offset: Math.floor(Math.random() * (await RiskAssessments.count())),
                });
                const RiskItem3 = await RiskItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RiskItem3?.setRisk_assessment)
                {
                    await
                    RiskItem3.
                    setRisk_assessment(relatedRisk_assessment3);
                }
            
                const relatedRisk_assessment4 = await RiskAssessments.findOne({
                    offset: Math.floor(Math.random() * (await RiskAssessments.count())),
                });
                const RiskItem4 = await RiskItems.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RiskItem4?.setRisk_assessment)
                {
                    await
                    RiskItem4.
                    setRisk_assessment(relatedRisk_assessment4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateCapaWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Capa0 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Capa0?.setOwner)
                {
                    await
                    Capa0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Capa1 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Capa1?.setOwner)
                {
                    await
                    Capa1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Capa2 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Capa2?.setOwner)
                {
                    await
                    Capa2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Capa3 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Capa3?.setOwner)
                {
                    await
                    Capa3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Capa4 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Capa4?.setOwner)
                {
                    await
                    Capa4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
            
            async function associateCapaWithRelated_document() {
            
                const relatedRelated_document0 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Capa0 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Capa0?.setRelated_document)
                {
                    await
                    Capa0.
                    setRelated_document(relatedRelated_document0);
                }
            
                const relatedRelated_document1 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Capa1 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Capa1?.setRelated_document)
                {
                    await
                    Capa1.
                    setRelated_document(relatedRelated_document1);
                }
            
                const relatedRelated_document2 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Capa2 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Capa2?.setRelated_document)
                {
                    await
                    Capa2.
                    setRelated_document(relatedRelated_document2);
                }
            
                const relatedRelated_document3 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Capa3 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Capa3?.setRelated_document)
                {
                    await
                    Capa3.
                    setRelated_document(relatedRelated_document3);
                }
            
                const relatedRelated_document4 = await Documents.findOne({
                    offset: Math.floor(Math.random() * (await Documents.count())),
                });
                const Capa4 = await Capas.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Capa4?.setRelated_document)
                {
                    await
                    Capa4.
                    setRelated_document(relatedRelated_document4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setProduct)
                {
                    await
                    Nonconformance0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setProduct)
                {
                    await
                    Nonconformance1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setProduct)
                {
                    await
                    Nonconformance2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setProduct)
                {
                    await
                    Nonconformance3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Nonconformance4 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Nonconformance4?.setProduct)
                {
                    await
                    Nonconformance4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithBatch() {
            
                const relatedBatch0 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setBatch)
                {
                    await
                    Nonconformance0.
                    setBatch(relatedBatch0);
                }
            
                const relatedBatch1 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setBatch)
                {
                    await
                    Nonconformance1.
                    setBatch(relatedBatch1);
                }
            
                const relatedBatch2 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setBatch)
                {
                    await
                    Nonconformance2.
                    setBatch(relatedBatch2);
                }
            
                const relatedBatch3 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setBatch)
                {
                    await
                    Nonconformance3.
                    setBatch(relatedBatch3);
                }
            
                const relatedBatch4 = await Batches.findOne({
                    offset: Math.floor(Math.random() * (await Batches.count())),
                });
                const Nonconformance4 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Nonconformance4?.setBatch)
                {
                    await
                    Nonconformance4.
                    setBatch(relatedBatch4);
                }
            
        }
        
    
        
            
            async function associateNonconformanceWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setSupplier)
                {
                    await
                    Nonconformance0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setSupplier)
                {
                    await
                    Nonconformance1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setSupplier)
                {
                    await
                    Nonconformance2.
                    setSupplier(relatedSupplier2);
                }
            
                const relatedSupplier3 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setSupplier)
                {
                    await
                    Nonconformance3.
                    setSupplier(relatedSupplier3);
                }
            
                const relatedSupplier4 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Nonconformance4 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Nonconformance4?.setSupplier)
                {
                    await
                    Nonconformance4.
                    setSupplier(relatedSupplier4);
                }
            
        }
        
    
        
    
        
    
        
            
            async function associateNonconformanceWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance0 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Nonconformance0?.setOwner)
                {
                    await
                    Nonconformance0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance1 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Nonconformance1?.setOwner)
                {
                    await
                    Nonconformance1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance2 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Nonconformance2?.setOwner)
                {
                    await
                    Nonconformance2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance3 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Nonconformance3?.setOwner)
                {
                    await
                    Nonconformance3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Nonconformance4 = await Nonconformances.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Nonconformance4?.setOwner)
                {
                    await
                    Nonconformance4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
            
            async function associateComplaintWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Complaint0 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Complaint0?.setProduct)
                {
                    await
                    Complaint0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Complaint1 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Complaint1?.setProduct)
                {
                    await
                    Complaint1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Complaint2 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Complaint2?.setProduct)
                {
                    await
                    Complaint2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Complaint3 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Complaint3?.setProduct)
                {
                    await
                    Complaint3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const Complaint4 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Complaint4?.setProduct)
                {
                    await
                    Complaint4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateComplaintWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Complaint0 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Complaint0?.setOwner)
                {
                    await
                    Complaint0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Complaint1 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Complaint1?.setOwner)
                {
                    await
                    Complaint1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Complaint2 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Complaint2?.setOwner)
                {
                    await
                    Complaint2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Complaint3 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Complaint3?.setOwner)
                {
                    await
                    Complaint3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Complaint4 = await Complaints.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Complaint4?.setOwner)
                {
                    await
                    Complaint4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
    

    
    
    
        
    
        
    
        
    
        
            
            async function associateAuditWithLead_auditor() {
            
                const relatedLead_auditor0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Audit0 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Audit0?.setLead_auditor)
                {
                    await
                    Audit0.
                    setLead_auditor(relatedLead_auditor0);
                }
            
                const relatedLead_auditor1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Audit1 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Audit1?.setLead_auditor)
                {
                    await
                    Audit1.
                    setLead_auditor(relatedLead_auditor1);
                }
            
                const relatedLead_auditor2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Audit2 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Audit2?.setLead_auditor)
                {
                    await
                    Audit2.
                    setLead_auditor(relatedLead_auditor2);
                }
            
                const relatedLead_auditor3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Audit3 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Audit3?.setLead_auditor)
                {
                    await
                    Audit3.
                    setLead_auditor(relatedLead_auditor3);
                }
            
                const relatedLead_auditor4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const Audit4 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Audit4?.setLead_auditor)
                {
                    await
                    Audit4.
                    setLead_auditor(relatedLead_auditor4);
                }
            
        }
        
    
        
            
            async function associateAuditWithSupplier() {
            
                const relatedSupplier0 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Audit0 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (Audit0?.setSupplier)
                {
                    await
                    Audit0.
                    setSupplier(relatedSupplier0);
                }
            
                const relatedSupplier1 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Audit1 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (Audit1?.setSupplier)
                {
                    await
                    Audit1.
                    setSupplier(relatedSupplier1);
                }
            
                const relatedSupplier2 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Audit2 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (Audit2?.setSupplier)
                {
                    await
                    Audit2.
                    setSupplier(relatedSupplier2);
                }
            
                const relatedSupplier3 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Audit3 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (Audit3?.setSupplier)
                {
                    await
                    Audit3.
                    setSupplier(relatedSupplier3);
                }
            
                const relatedSupplier4 = await Suppliers.findOne({
                    offset: Math.floor(Math.random() * (await Suppliers.count())),
                });
                const Audit4 = await Audits.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (Audit4?.setSupplier)
                {
                    await
                    Audit4.
                    setSupplier(relatedSupplier4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            // Similar logic for "relation_many"
        
    

    
    
    
        
            
            async function associateAuditFindingWithAudit() {
            
                const relatedAudit0 = await Audits.findOne({
                    offset: Math.floor(Math.random() * (await Audits.count())),
                });
                const AuditFinding0 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditFinding0?.setAudit)
                {
                    await
                    AuditFinding0.
                    setAudit(relatedAudit0);
                }
            
                const relatedAudit1 = await Audits.findOne({
                    offset: Math.floor(Math.random() * (await Audits.count())),
                });
                const AuditFinding1 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditFinding1?.setAudit)
                {
                    await
                    AuditFinding1.
                    setAudit(relatedAudit1);
                }
            
                const relatedAudit2 = await Audits.findOne({
                    offset: Math.floor(Math.random() * (await Audits.count())),
                });
                const AuditFinding2 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditFinding2?.setAudit)
                {
                    await
                    AuditFinding2.
                    setAudit(relatedAudit2);
                }
            
                const relatedAudit3 = await Audits.findOne({
                    offset: Math.floor(Math.random() * (await Audits.count())),
                });
                const AuditFinding3 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AuditFinding3?.setAudit)
                {
                    await
                    AuditFinding3.
                    setAudit(relatedAudit3);
                }
            
                const relatedAudit4 = await Audits.findOne({
                    offset: Math.floor(Math.random() * (await Audits.count())),
                });
                const AuditFinding4 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AuditFinding4?.setAudit)
                {
                    await
                    AuditFinding4.
                    setAudit(relatedAudit4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            async function associateAuditFindingWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditFinding0 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditFinding0?.setOwner)
                {
                    await
                    AuditFinding0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditFinding1 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditFinding1?.setOwner)
                {
                    await
                    AuditFinding1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditFinding2 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditFinding2?.setOwner)
                {
                    await
                    AuditFinding2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditFinding3 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AuditFinding3?.setOwner)
                {
                    await
                    AuditFinding3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditFinding4 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AuditFinding4?.setOwner)
                {
                    await
                    AuditFinding4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
    
        
    
        
    
        
            
            async function associateAuditFindingWithRelated_capa() {
            
                const relatedRelated_capa0 = await Capas.findOne({
                    offset: Math.floor(Math.random() * (await Capas.count())),
                });
                const AuditFinding0 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditFinding0?.setRelated_capa)
                {
                    await
                    AuditFinding0.
                    setRelated_capa(relatedRelated_capa0);
                }
            
                const relatedRelated_capa1 = await Capas.findOne({
                    offset: Math.floor(Math.random() * (await Capas.count())),
                });
                const AuditFinding1 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditFinding1?.setRelated_capa)
                {
                    await
                    AuditFinding1.
                    setRelated_capa(relatedRelated_capa1);
                }
            
                const relatedRelated_capa2 = await Capas.findOne({
                    offset: Math.floor(Math.random() * (await Capas.count())),
                });
                const AuditFinding2 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditFinding2?.setRelated_capa)
                {
                    await
                    AuditFinding2.
                    setRelated_capa(relatedRelated_capa2);
                }
            
                const relatedRelated_capa3 = await Capas.findOne({
                    offset: Math.floor(Math.random() * (await Capas.count())),
                });
                const AuditFinding3 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AuditFinding3?.setRelated_capa)
                {
                    await
                    AuditFinding3.
                    setRelated_capa(relatedRelated_capa3);
                }
            
                const relatedRelated_capa4 = await Capas.findOne({
                    offset: Math.floor(Math.random() * (await Capas.count())),
                });
                const AuditFinding4 = await AuditFindings.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AuditFinding4?.setRelated_capa)
                {
                    await
                    AuditFinding4.
                    setRelated_capa(relatedRelated_capa4);
                }
            
        }
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateManagementReviewWithChairperson() {
            
                const relatedChairperson0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ManagementReview0 = await ManagementReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (ManagementReview0?.setChairperson)
                {
                    await
                    ManagementReview0.
                    setChairperson(relatedChairperson0);
                }
            
                const relatedChairperson1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ManagementReview1 = await ManagementReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (ManagementReview1?.setChairperson)
                {
                    await
                    ManagementReview1.
                    setChairperson(relatedChairperson1);
                }
            
                const relatedChairperson2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ManagementReview2 = await ManagementReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (ManagementReview2?.setChairperson)
                {
                    await
                    ManagementReview2.
                    setChairperson(relatedChairperson2);
                }
            
                const relatedChairperson3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ManagementReview3 = await ManagementReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (ManagementReview3?.setChairperson)
                {
                    await
                    ManagementReview3.
                    setChairperson(relatedChairperson3);
                }
            
                const relatedChairperson4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const ManagementReview4 = await ManagementReviews.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (ManagementReview4?.setChairperson)
                {
                    await
                    ManagementReview4.
                    setChairperson(relatedChairperson4);
                }
            
        }
        
    
        
    
        
    
        
    

    
    
    
        
    
        
    
        
    
        
    
        
            
            async function associateRegulatorySubmissionWithProduct() {
            
                const relatedProduct0 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RegulatorySubmission0 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RegulatorySubmission0?.setProduct)
                {
                    await
                    RegulatorySubmission0.
                    setProduct(relatedProduct0);
                }
            
                const relatedProduct1 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RegulatorySubmission1 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RegulatorySubmission1?.setProduct)
                {
                    await
                    RegulatorySubmission1.
                    setProduct(relatedProduct1);
                }
            
                const relatedProduct2 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RegulatorySubmission2 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RegulatorySubmission2?.setProduct)
                {
                    await
                    RegulatorySubmission2.
                    setProduct(relatedProduct2);
                }
            
                const relatedProduct3 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RegulatorySubmission3 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RegulatorySubmission3?.setProduct)
                {
                    await
                    RegulatorySubmission3.
                    setProduct(relatedProduct3);
                }
            
                const relatedProduct4 = await Products.findOne({
                    offset: Math.floor(Math.random() * (await Products.count())),
                });
                const RegulatorySubmission4 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RegulatorySubmission4?.setProduct)
                {
                    await
                    RegulatorySubmission4.
                    setProduct(relatedProduct4);
                }
            
        }
        
    
        
            
            async function associateRegulatorySubmissionWithOwner() {
            
                const relatedOwner0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RegulatorySubmission0 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (RegulatorySubmission0?.setOwner)
                {
                    await
                    RegulatorySubmission0.
                    setOwner(relatedOwner0);
                }
            
                const relatedOwner1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RegulatorySubmission1 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (RegulatorySubmission1?.setOwner)
                {
                    await
                    RegulatorySubmission1.
                    setOwner(relatedOwner1);
                }
            
                const relatedOwner2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RegulatorySubmission2 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (RegulatorySubmission2?.setOwner)
                {
                    await
                    RegulatorySubmission2.
                    setOwner(relatedOwner2);
                }
            
                const relatedOwner3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RegulatorySubmission3 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (RegulatorySubmission3?.setOwner)
                {
                    await
                    RegulatorySubmission3.
                    setOwner(relatedOwner3);
                }
            
                const relatedOwner4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const RegulatorySubmission4 = await RegulatorySubmissions.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (RegulatorySubmission4?.setOwner)
                {
                    await
                    RegulatorySubmission4.
                    setOwner(relatedOwner4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    

    
    
    
        
    
        
            
            async function associateAuditLogWithActor() {
            
                const relatedActor0 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog0 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 0
                });
                if (AuditLog0?.setActor)
                {
                    await
                    AuditLog0.
                    setActor(relatedActor0);
                }
            
                const relatedActor1 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog1 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 1
                });
                if (AuditLog1?.setActor)
                {
                    await
                    AuditLog1.
                    setActor(relatedActor1);
                }
            
                const relatedActor2 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog2 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 2
                });
                if (AuditLog2?.setActor)
                {
                    await
                    AuditLog2.
                    setActor(relatedActor2);
                }
            
                const relatedActor3 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog3 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 3
                });
                if (AuditLog3?.setActor)
                {
                    await
                    AuditLog3.
                    setActor(relatedActor3);
                }
            
                const relatedActor4 = await Users.findOne({
                    offset: Math.floor(Math.random() * (await Users.count())),
                });
                const AuditLog4 = await AuditLogs.findOne({
                    order: [['id', 'ASC']],
                    offset: 4
                });
                if (AuditLog4?.setActor)
                {
                    await
                    AuditLog4.
                    setActor(relatedActor4);
                }
            
        }
        
    
        
    
        
    
        
    
        
    
        
    
        
    


module.exports = {
    up: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
                
                await DocumentTypes.bulkCreate(DocumentTypesData);
                
            
            
                
                await Standards.bulkCreate(StandardsData);
                
            
            
                
                await Clauses.bulkCreate(ClausesData);
                
            
            
                
                await DocumentTemplates.bulkCreate(DocumentTemplatesData);
                
            
            
                
                await Documents.bulkCreate(DocumentsData);
                
            
            
                
                await DocumentVersions.bulkCreate(DocumentVersionsData);
                
            
            
                
                await ChangeRequests.bulkCreate(ChangeRequestsData);
                
            
            
                
                await ApprovalWorkflows.bulkCreate(ApprovalWorkflowsData);
                
            
            
                
                await ApprovalSteps.bulkCreate(ApprovalStepsData);
                
            
            
                
                await ApprovalTasks.bulkCreate(ApprovalTasksData);
                
            
            
                
                await EsignatureEvents.bulkCreate(EsignatureEventsData);
                
            
            
                
                await TrainingCourses.bulkCreate(TrainingCoursesData);
                
            
            
                
                await TrainingAssignments.bulkCreate(TrainingAssignmentsData);
                
            
            
                
                await Products.bulkCreate(ProductsData);
                
            
            
                
                await Suppliers.bulkCreate(SuppliersData);
                
            
            
                
                await Batches.bulkCreate(BatchesData);
                
            
            
                
                await CertificatesOfAnalysis.bulkCreate(CertificatesOfAnalysisData);
                
            
            
                
                await DeviceMasterRecords.bulkCreate(DeviceMasterRecordsData);
                
            
            
                
                await RiskAssessments.bulkCreate(RiskAssessmentsData);
                
            
            
                
                await RiskItems.bulkCreate(RiskItemsData);
                
            
            
                
                await Capas.bulkCreate(CapasData);
                
            
            
                
                await Nonconformances.bulkCreate(NonconformancesData);
                
            
            
                
                await Complaints.bulkCreate(ComplaintsData);
                
            
            
                
                await Audits.bulkCreate(AuditsData);
                
            
            
                
                await AuditFindings.bulkCreate(AuditFindingsData);
                
            
            
                
                await ManagementReviews.bulkCreate(ManagementReviewsData);
                
            
            
                
                await RegulatorySubmissions.bulkCreate(RegulatorySubmissionsData);
                
            
            
                
                await AuditLogs.bulkCreate(AuditLogsData);
                
            
            await Promise.all([
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateClausWithStandard(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateDocumentTemplateWithDocument_type(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                    
                        
                        await associateDocumentWithDocument_type(),
                    
                
                    
                        
                        await associateDocumentWithTemplate(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentWithOwner(),
                    
                
                    
                        
                        await associateDocumentWithApprover(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
                    
                
            
                
                
                    
                        
                        await associateDocumentVersionWithDocument(),
                    
                
                    
                
                    
                
                    
                        
                        await associateDocumentVersionWithAuthor(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateChangeRequestWithRequester(),
                    
                
                    
                        
                        await associateChangeRequestWithDocument(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateChangeRequestWithAssigned_to(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateApprovalStepWithWorkflow(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateApprovalStepWithAssignee(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateApprovalTaskWithWorkflow(),
                    
                
                    
                        
                        await associateApprovalTaskWithStep(),
                    
                
                    
                
                    
                
                    
                        
                        await associateApprovalTaskWithAssignee(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateEsignatureEventWithUser(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateTrainingAssignmentWithUser(),
                    
                
                    
                        
                        await associateTrainingAssignmentWithCourse(),
                    
                
                    
                        
                        await associateTrainingAssignmentWithDocument(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateBatcheWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateBatcheWithBmr_document(),
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateCertificatesOfAnalysiWithBatch(),
                    
                
                    
                        
                        await associateCertificatesOfAnalysiWithSupplier(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCertificatesOfAnalysiWithIssued_by(),
                    
                
            
                
                
                    
                        
                        await associateDeviceMasterRecordWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateRiskAssessmentWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateRiskAssessmentWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                        
                        await associateRiskItemWithRisk_assessment(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateCapaWithOwner(),
                    
                
                    
                        
                        await associateCapaWithRelated_document(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithProduct(),
                    
                
                    
                        
                        await associateNonconformanceWithBatch(),
                    
                
                    
                        
                        await associateNonconformanceWithSupplier(),
                    
                
                    
                
                    
                
                    
                        
                        await associateNonconformanceWithOwner(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                        
                        await associateComplaintWithProduct(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateComplaintWithOwner(),
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                        
                        await associateAuditWithLead_auditor(),
                    
                
                    
                        
                        await associateAuditWithSupplier(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        // Similar logic for "relation_many"
                    
                
            
                
                
                    
                        
                        await associateAuditFindingWithAudit(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateAuditFindingWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateAuditFindingWithRelated_capa(),
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateManagementReviewWithChairperson(),
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                
                    
                
                    
                
                    
                        
                        await associateRegulatorySubmissionWithProduct(),
                    
                
                    
                        
                        await associateRegulatorySubmissionWithOwner(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                
                    
                
                    
                        
                        await associateAuditLogWithActor(),
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            ]);
        
    },

    down: async (queryInterface, Sequelize) => {
        
            
            
            
            
            
            await queryInterface.bulkDelete('document_types', null, {});
            
            
            await queryInterface.bulkDelete('standards', null, {});
            
            
            await queryInterface.bulkDelete('clauses', null, {});
            
            
            await queryInterface.bulkDelete('document_templates', null, {});
            
            
            await queryInterface.bulkDelete('documents', null, {});
            
            
            await queryInterface.bulkDelete('document_versions', null, {});
            
            
            await queryInterface.bulkDelete('change_requests', null, {});
            
            
            await queryInterface.bulkDelete('approval_workflows', null, {});
            
            
            await queryInterface.bulkDelete('approval_steps', null, {});
            
            
            await queryInterface.bulkDelete('approval_tasks', null, {});
            
            
            await queryInterface.bulkDelete('esignature_events', null, {});
            
            
            await queryInterface.bulkDelete('training_courses', null, {});
            
            
            await queryInterface.bulkDelete('training_assignments', null, {});
            
            
            await queryInterface.bulkDelete('products', null, {});
            
            
            await queryInterface.bulkDelete('suppliers', null, {});
            
            
            await queryInterface.bulkDelete('batches', null, {});
            
            
            await queryInterface.bulkDelete('certificates_of_analysis', null, {});
            
            
            await queryInterface.bulkDelete('device_master_records', null, {});
            
            
            await queryInterface.bulkDelete('risk_assessments', null, {});
            
            
            await queryInterface.bulkDelete('risk_items', null, {});
            
            
            await queryInterface.bulkDelete('capas', null, {});
            
            
            await queryInterface.bulkDelete('nonconformances', null, {});
            
            
            await queryInterface.bulkDelete('complaints', null, {});
            
            
            await queryInterface.bulkDelete('audits', null, {});
            
            
            await queryInterface.bulkDelete('audit_findings', null, {});
            
            
            await queryInterface.bulkDelete('management_reviews', null, {});
            
            
            await queryInterface.bulkDelete('regulatory_submissions', null, {});
            
            
            await queryInterface.bulkDelete('audit_logs', null, {});
            
        
    },
};