# CLQMS Database Tables - ERD Source Document ## Overview This document contains all database tables extracted from prj_3c.md for ERD creation in Figma. --- ## Table 1: Organization Structure ### account | Column | Type | Description | |--------|------|-------------| | AccountID | int | Primary key - from SMCRM | | AccountName | string | Organization name | | ParentAccountID | int | Parent organization (for chain labs) | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### site | Column | Type | Description | |--------|------|-------------| | SiteID | int | Primary key - from SMCRM | | AccountID | int | Foreign key to account | | SiteName | string | Location name | | Location | string | Geographic coordinates | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### discipline | Column | Type | Description | |--------|------|-------------| | DisciplineID | int | Primary key | | DisciplineName | string | e.g., Microbiology, Hematology, Immunology | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### department | Column | Type | Description | |--------|------|-------------| | DepartmentID | int | Primary key | | DepartmentName | string | Department name | | DisciplineID | int | Foreign key to discipline | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### workstation | Column | Type | Description | |--------|------|-------------| | WorkstationID | int | Primary key | | SiteID | int | Foreign key to site | | DepartmentID | int | Foreign key to department | | WorkstationName | string | Workstation identifier | | LocalDB | boolean | Has local database | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### instrument | Column | Type | Description | |--------|------|-------------| | InstrumentID | int | Primary key | | SiteID | int | Foreign key to site | | WorkstationID | int | Foreign key to workstation | | InstrumentAlias | string | Instrument identifier for interfacing | | InstrumentName | string | Manufacturer model name | | InstrumentType | string | IVD equipment type | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | --- ## Table 2: Personnel ### personnel | Column | Type | Description | |--------|------|-------------| | PersonnelID | int | Primary key | | SiteID | int | Foreign key to site | | PersonnelName | string | Full name | | Position | string | Job title/position | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### personneldocument | Column | Type | Description | |--------|------|-------------| | DocID | int | Primary key | | PersonnelID | int | Foreign key to personnel | | DocType | string | Document type (e.g., training certificate) | | DocFile | blob | Document file | | ExpiryDate | datetime | Document expiry | | CreateDate | datetime | UTC+0 | ### personnelaccess | Column | Type | Description | |--------|------|-------------| | AccessID | int | Primary key | | PersonnelID | int | Foreign key to personnel | | Role | string | Access role | | Permissions | string | JSON permissions | | CreateDate | datetime | UTC+0 | --- ## Table 3: Location Management ### locationtype | Column | Type | Description | |--------|------|-------------| | LocationTypeID | int | Primary key | | LocationTypeName | string | e.g., floor, point of care, room, bed, mobile, remote | | CreateDate | datetime | UTC+0 | ### location | Column | Type | Description | |--------|------|-------------| | LocationID | int | Primary key | | SiteID | int | Foreign key to site | | ParentLocationID | int | Parent location (cascade) | | LocationTypeID | int | Foreign key to locationtype | | LocationName | string | Location name | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### locationaddress | Column | Type | Description | |--------|------|-------------| | AddressID | int | Primary key | | LocationID | int | Foreign key to location | | AddressLine1 | string | Address line 1 | | AddressLine2 | string | Address line 2 | | City | string | City | | PostalCode | string | Postal code | | CreateDate | datetime | UTC+0 | --- ## Table 4: Patient Registration ### patient | Column | Type | Description | |--------|------|-------------| | PatientID | int | Primary key - external ID | | SiteID | int | Foreign key to site | | InternalPID | int | Internal patient ID (auto-increment) | | FirstName | string | First name (encrypted) | | LastName | string | Last name (encrypted) | | DateOfBirth | datetime | Date of birth (stored as-is) | | Sex | string | Gender code | | Race | string | Race code | | Ethnicity | string | Ethnicity code | | Religion | string | Religion code | | CreateDate | datetime | UTC+0 | | DelDate | datetime | UTC+0 | ### patientcontact | Column | Type | Description | |--------|------|-------------| | ContactID | int | Primary key | | InternalPID | int | Foreign key to patient | | ContactType | string | e.g., phone, email, address | | ContactValue | string | Contact information (encrypted) | | CreateDate | datetime | UTC+0 | ### patientinsurance | Column | Type | Description | |--------|------|-------------| | InsuranceID | int | Primary key | | InternalPID | int | Foreign key to patient | | InsuranceProvider | string | Insurance company | | PolicyNumber | string | Policy number | | GroupNumber | string | Group number | | EffectiveDate | datetime | Policy effective date | | ExpiryDate | datetime | Policy expiry date | | CreateDate | datetime | UTC+0 | ### patientvisit | Column | Type | Description | |--------|------|-------------| | VisitID | int | Primary key | | InternalPID | int | Foreign key to patient | | SiteID | int | Foreign key to site | | VisitClass | string | Visit classification | | VisitType | string | Visit type | | VisitDate | datetime | Visit datetime | | DischargeDate | datetime | Discharge datetime | | CreateDate | datetime | UTC+0 | --- ## Table 5: Patient Admission ### admission | Column | Type | Description | |--------|------|-------------| | AdmissionID | int | Primary key | | VisitID | int | Foreign key to patientvisit | | PatientID | int | Foreign key to patient | | SiteID | int | Foreign key to site | | AdmissionDate | datetime | Admission datetime | | DischargeDate | datetime | Discharge datetime | | ADTCode | string | Admission-Discharge-Transfer code | | ReferringParty | string | Referring party | | BillingAccount | string | Billing account | | AttendingDoctor | string | Attending doctor | | ReferringDoctor | string | Referring doctor | | VitalSigns | json | Heart rate, BP, weight, height | | CreateDate | datetime | UTC+0 | ### admissionlocation | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | AdmissionID | int | Foreign key to admission | | LocationID | int | Foreign key to location | | TransferDate | datetime | Transfer datetime | | CreateDate | datetime | UTC+0 | --- ## Table 6: Test Ordering ### testorder | Column | Type | Description | |--------|------|-------------| | OrderID | string | Primary key - LLYYMMDDXXXXX format | | SiteID | int | Foreign key to site (source site) | | PatientID | int | Foreign key to patient | | VisitID | int | Foreign key to patientvisit | | OrderDate | datetime | Order datetime | | Urgency | string | Order urgency level | | Status | string | Order status | | OrderingProvider | string | Ordering doctor | | ProductionSiteID | int | Foreign key to site (production site) | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### testorderdetail | Column | Type | Description | |--------|------|-------------| | OrderDetailID | int | Primary key | | OrderID | string | Foreign key to testorder | | TestID | int | Foreign key to testdef | | Priority | int | Test priority | | Status | string | Test order status | | CreateDate | datetime | UTC+0 | ### orderstatus | Column | Type | Description | |--------|------|-------------| | StatusID | int | Primary key | | StatusName | string | Status name | | Description | string | Status description | | Active | boolean | Is active | --- ## Table 7: Specimen Management ### specimen | Column | Type | Description | |--------|------|-------------| | SID | string | Primary key - OrderID + SSS + C (17 chars) | | OrderID | string | Foreign key to testorder | | SpecimenDefID | int | Foreign key to specimendefinition | | ParentSID | string | Parent specimen (for secondary specimens) | | SpecimenType | string | Specimen type code | | SpecimenRole | string | e.g., patient, EQC, blood bag, internal QC | | CollectionDate | datetime | Collection datetime | | CollectionSite | int | Collection site | | CollectedBy | int | Personnel ID | | ContainerType | string | Container type code | | Additive | string | Additive code | | CollectionMethod | string | Collection method code | | BodySite | string | Body site code | | SpecimenCondition | string | Specimen condition | | Status | string | Current specimen status | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### specimencollection | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | SID | string | Foreign key to specimen | | Activity | string | Activity code | | ActivityName | string | Activity name | | ActRes | string | Activity result | | LocationID | int | Foreign key to location | | EquipmentID | int | Foreign key to instrument | | PersonnelID | int | Personnel performing activity | | ActivityDate | datetime | Activity datetime | | Notes | string | Activity notes | | CreateDate | datetime | UTC+0 | ### specimenstatus | Column | Type | Description | |--------|------|-------------| | StatusID | int | Primary key | | SiteID | int | Site ID | | LocationID | int | Location ID | | EquipmentID | int | Instrument ID | | Activity | string | Activity code | | ActivityName | string | Activity name | | ActRes | string | Activity result | | SpecimenStatus | string | Specimen status name | | Description | string | Status description | ### specimentransport | Column | Type | Description | |--------|------|-------------| | TransportID | int | Primary key | | SID | string | Foreign key to specimen | | SenderID | int | Sender personnel ID | | ReceiverID | int | Receiver personnel ID | | TransportDate | datetime | Transport datetime | | Condition | json | Transport conditions (temperature, etc.) | | PackagingID | string | Packaging identification | | FromLocation | int | From location | | ToLocation | int | To location | | CreateDate | datetime | UTC+0 | ### specimenstorage | Column | Type | Description | |--------|------|-------------| | StorageID | int | Primary key | | SID | string | Foreign key to specimen | | LocationID | int | Storage location ID | | StorageTemperature | decimal | Storage temperature | | StorageDate | datetime | Storage datetime | | ThawCount | int | Number of thaws | | ExpiryDate | datetime | Storage expiry | | CreateDate | datetime | UTC+0 | --- ## Table 8: Specimen Definitions ### specimendefinition | Column | Type | Description | |--------|------|-------------| | SpecimenDefID | int | Primary key | | SpecimenName | string | Specimen name | | SpecimenCode | string | Specimen code | | SpecimenTypeID | int | Foreign key to specimentype | | ContainerTypeID | int | Foreign key to containertype | | AdditiveID | int | Foreign key to additive | | CollectionMethodID | int | Foreign key to collectionmethod | | Volume | decimal | Required volume | | VolumeUnit | string | Volume unit | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### specimentype | Column | Type | Description | |--------|------|-------------| | SpecimenTypeID | int | Primary key | | SpecimenTypeName | string | e.g., blood, urine, stool, tissue | | CodingSystem | string | Coding system (LOINC, etc.) | | Code | string | Code value | | CreateDate | datetime | UTC+0 | ### containertype | Column | Type | Description | |--------|------|-------------| | ContainerTypeID | int | Primary key | | ContainerName | string | Container name | | ContainerCode | string | Container code | | Volume | decimal | Container volume | | VolumeUnit | string | Volume unit | | CreateDate | datetime | UTC+0 | ### additive | Column | Type | Description | |--------|------|-------------| | AdditiveID | int | Primary key | | AdditiveName | string | Additive name | | AdditiveCode | string | Additive code | | Description | string | Additive description | | CreateDate | datetime | UTC+0 | ### collectionmethod | Column | Type | Description | |--------|------|-------------| | MethodID | int | Primary key | | MethodName | string | Method name | | MethodCode | string | Method code | | Description | string | Method description | | CreateDate | datetime | UTC+0 | ### bodysite | Column | Type | Description | |--------|------|-------------| | BodySiteID | int | Primary key | | BodySiteName | string | Body site name | | CodingSystem | string | Coding system | | Code | string | Code value | | CreateDate | datetime | UTC+0 | ### specimenrole | Column | Type | Description | |--------|------|-------------| | RoleID | int | Primary key | | RoleName | string | Role name | | RoleCode | string | Role code | | Description | string | Role description | | CreateDate | datetime | UTC+0 | ### specimencondition | Column | Type | Description | |--------|------|-------------| | ConditionID | int | Primary key | | ConditionName | string | Condition name | | ConditionCode | string | Condition code | | Description | string | Condition description | | CreateDate | datetime | UTC+0 | --- ## Table 9: Test Management ### testdef | Column | Type | Description | |--------|------|-------------| | TestID | int | Primary key | | TestName | string | Test name | | TestCode | string | Test code | | LOINCCode | string | LOINC code | | TestType | string | Test type (atomic, calculated, profile, etc.) | | DisciplineID | int | Foreign key to discipline | | SpecimenTypeID | int | Foreign key to specimentype | | ContainerTypeID | int | Foreign key to containertype | | ResultType | string | Result type (numeric, range, text, valueset) | | ResultUnit | string | Result unit (UCUM) | | Methodology | string | Test methodology | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### testdefsite | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | TestID | int | Foreign key to testdef | | SiteID | int | Foreign key to site | | TestNameLocal | string | Local test name | | TestCodeLocal | string | Local test code | | WorkstationID | int | Default workstation | | InstrumentID | int | Default instrument | | Active | boolean | Is active | | CreateDate | datetime | UTC+0 | ### testdeftech | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | TestID | int | Foreign key to testdef | | InstrumentID | int | Foreign key to instrument | | InstrumentTestCode | string | Test code on instrument | | TestMapping | string | Test mapping (one-to-many) | | Active | boolean | Is active | | CreateDate | datetime | UTC+0 | ### calculatedtest | Column | Type | Description | |--------|------|-------------| | CalculatedTestID | int | Primary key | | TestID | int | Foreign key to testdef | | Formula | string | Calculation formula | | ParamTestID1 | int | Parameter test 1 | | ParamTestID2 | int | Parameter test 2 | | ParamTestID3 | int | Parameter test 3 | | ParamTestID4 | int | Parameter test 4 | | CreateDate | datetime | UTC+0 | ### grouptest | Column | Type | Description | |--------|------|-------------| | GroupTestID | int | Primary key | | GroupTestName | string | Group test name | | GroupTestType | string | Type (Profile, Functional Procedure, Superset) | | CreateDate | datetime | UTC+0 | ### grouptestmember | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | GroupTestID | int | Foreign key to grouptest | | TestID | int | Foreign key to testdef | | Sequence | int | Display sequence | | CreateDate | datetime | UTC+0 | ### panel | Column | Type | Description | |--------|------|-------------| | PanelID | int | Primary key | | PanelName | string | Panel name | | PanelType | string | Fixed or Flexible | | ParentPanelID | int | Parent panel (for nested panels) | | DisciplineID | int | Foreign key to discipline | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### panelmember | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | PanelID | int | Foreign key to panel | | TestID | int | Foreign key to testdef | | Sequence | int | Display sequence | | CreateDate | datetime | UTC+0 | --- ## Table 10: Reference Range ### referencerangenumeric | Column | Type | Description | |--------|------|-------------| | RefRangeID | int | Primary key | | TestID | int | Foreign key to testdef | | AgeFrom | int | Age from (years) | | AgeTo | int | Age to (years) | | Sex | string | Gender | | LowValue | decimal | Low reference value | | HighValue | decimal | High reference value | | Unit | string | Unit | | SpecimenTypeID | int | Foreign key to specimentype | | SiteID | int | Foreign key to site | | EffectiveDate | datetime | Effective date | | ExpiryDate | datetime | Expiry date | | CreateDate | datetime | UTC+0 | ### referencerangethreshold | Column | Type | Description | |--------|------|-------------| | RefRangeID | int | Primary key | | TestID | int | Foreign key to testdef | | AgeFrom | int | Age from (years) | | AgeTo | int | Age to (years) | | Sex | string | Gender | | CutOffLow | decimal | Low cut-off | | CutOffHigh | decimal | High cut-off | | GrayZoneLow | decimal | Low gray zone | | GrayZoneHigh | decimal | High gray zone | | SpecimenTypeID | int | Foreign key to specimentype | | SiteID | int | Foreign key to site | | EffectiveDate | datetime | Effective date | | ExpiryDate | datetime | Expiry date | | CreateDate | datetime | UTC+0 | ### referencerangetext | Column | Type | Description | |--------|------|-------------| | RefRangeID | int | Primary key | | TestID | int | Foreign key to testdef | | AgeFrom | int | Age from (years) | | AgeTo | int | Age to (years) | | Sex | string | Gender | | TextValue | string | Text reference value | | SpecimenTypeID | int | Foreign key to specimentype | | SiteID | int | Foreign key to site | | EffectiveDate | datetime | Effective date | | ExpiryDate | datetime | Expiry date | | CreateDate | datetime | UTC+0 | --- ## Table 11: Calibration ### calibrator | Column | Type | Description | |--------|------|-------------| | CalibratorID | int | Primary key | | CalibratorName | string | Calibrator name | | Manufacturer | string | Manufacturer | | LotNumber | string | Lot number | | ExpiryDate | datetime | Expiry date | | TestID | int | Foreign key to testdef | | CreateDate | datetime | UTC+0 | ### calibration | Column | Type | Description | |--------|------|-------------| | CalibrationID | int | Primary key | | InstrumentID | int | Foreign key to instrument | | TestID | int | Foreign key to testdef | | CalibratorID | int | Foreign key to calibrator | | Level | int | Calibration level | | CalibrationDate | datetime | Calibration datetime | | Factor | decimal | Calibration factor | | Absorbance | decimal | Absorbance value | | TargetValue | decimal | Target value | | TargetUnit | string | Target unit | | PersonnelID | int | Personnel performing calibration | | Status | string | Calibration status | | CreateDate | datetime | UTC+0 | ### caldef | Column | Type | Description | |--------|------|-------------| | CalDefID | int | Primary key | | Calibrator | string | Calibrator name | | LotNumber | string | Lot number | | ExpiryDate | datetime | Expiry date | | Reagent | string | Reagent name | | SpcTypeID | int | Specimen type ID | | Level | int | Level | | Value | decimal | Value | | Unit | string | Unit | | InstrumentAlias | string | Instrument alias | | CreateDate | datetime | UTC+0 | ### calparinst | Column | Type | Description | |--------|------|-------------| | CalParInstID | int | Primary key | | EquipmentID | int | Foreign key to instrument | | Calibrator | string | Calibrator name | | LotNo | string | Lot number | | ExpiryDate | datetime | Expiry date | | TestInstID1 | int | Test instrument ID 1 | | SampleType | string | Sample type | | Level | int | Level | | Concentration | decimal | Concentration | | CalUnit | string | Calibration unit | | CreateDate | datetime | UTC+0 | --- ## Table 12: Quality Control ### qcmaterial | Column | Type | Description | |--------|------|-------------| | QCMaterialID | int | Primary key | | MaterialName | string | QC material name | | Manufacturer | string | Manufacturer | | LotNumber | string | Lot number | | ExpiryDate | datetime | Expiry date | | Level | int | QC level | | TestID | int | Foreign key to testdef | | TargetMean | decimal | Target mean | | TargetSD | decimal | Target SD | | TargetCV | decimal | Target CV | | CreateDate | datetime | UTC+0 | ### qcresult | Column | Type | Description | |--------|------|-------------| | QCResultID | int | Primary key | | InstrumentID | int | Foreign key to instrument | | TestID | int | Foreign key to testdef | | QCMaterialID | int | Foreign key to qcmaterial | | Level | int | QC level | | QCDate | datetime | QC datetime | | ResultValue | decimal | QC result value | | Mean | decimal | Mean | | SD | decimal | Standard deviation | | CV | decimal | Coefficient of variation | | Sigma | decimal | Sigma score | | ZScore | decimal | Z-score | | Flag | string | Result flag | | PersonnelID | int | Personnel performing QC | | Status | string | QC status | | CreateDate | datetime | UTC+0 | ### qcstatistic | Column | Type | Description | |--------|------|-------------| | StatisticID | int | Primary key | | InstrumentID | int | Foreign key to instrument | | TestID | int | Foreign key to testdef | | QCMaterialID | int | Foreign key to qcmaterial | | Level | int | QC level | | StatisticDate | datetime | Statistic date | | Mean | decimal | Calculated mean | | SD | decimal | Calculated SD | | CV | decimal | Calculated CV | | SampleSize | int | Sample size | | CreateDate | datetime | UTC+0 | --- ## Table 13: Test Results ### patres | Column | Type | Description | |--------|------|-------------| | ResultID | int | Primary key | | SID | string | Foreign key to specimen | | TestID | int | Foreign key to testdef | | OrderID | string | Foreign key to testorder | | ResultValue | string | Result value | | ResultNumeric | decimal | Numeric result | | ResultText | string | Text result | | ResultUnit | string | Result unit | | ResultStatus | string | Result status | | PersonnelID | int | Personnel entering result | | VerificationDate | datetime | Verification datetime | | VerificationPersonnel | int | Verifying personnel | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### patrestech | Column | Type | Description | |--------|------|-------------| | TechResultID | int | Primary key | | ResultID | int | Foreign key to patres | | InstrumentID | int | Foreign key to instrument | | RawResult | string | Raw instrument result | | ResultDate | datetime | Result datetime | | RerunCount | int | Rerun count | | Dilution | decimal | Dilution factor | | CreateDate | datetime | UTC+0 | ### patresflag | Column | Type | Description | |--------|------|-------------| | FlagID | int | Primary key | | ResultID | int | Foreign key to patres | | FlagType | string | Flag type (H, L, A, etc.) | | FlagDescription | string | Flag description | | CreateDate | datetime | UTC+0 | ### resultdistribution | Column | Type | Description | |--------|------|-------------| | DistributionID | int | Primary key | | ResultID | int | Foreign key to patres | | RecipientType | string | Recipient type | | RecipientID | int | Recipient ID | | DistributionDate | datetime | Distribution datetime | | DistributionMethod | string | Distribution method | | Status | string | Distribution status | | CreateDate | datetime | UTC+0 | --- ## Table 14: Value Set ### valueset | Column | Type | Description | |--------|------|-------------| | ValueSetID | int | Primary key | | ValueSetName | string | Value set name | | ValueSetCode | string | Value set code | | Description | string | Description | | CodingSystem | string | Coding system | | CreateDate | datetime | UTC+0 | ### valuesetmember | Column | Type | Description | |--------|------|-------------| | MemberID | int | Primary key | | ValueSetID | int | Foreign key to valueset | | MemberCode | string | Member code | | MemberValue | string | Member value | | DisplayOrder | int | Display order | | Active | boolean | Is active | | CreateDate | datetime | UTC+0 | --- ## Table 15: Reagent & Inventory ### reagent | Column | Type | Description | |--------|------|-------------| | ReagentID | int | Primary key | | ReagentName | string | Reagent name | | Manufacturer | string | Manufacturer | | CatalogNumber | string | Catalog number | | LotNumber | string | Lot number | | ExpiryDate | datetime | Expiry date | | TestID | int | Foreign key to testdef | | InstrumentID | int | Foreign key to instrument | | CreateDate | datetime | UTC+0 | ### reagentusage | Column | Type | Description | |--------|------|-------------| | UsageID | int | Primary key | | ReagentID | int | Foreign key to reagent | | TestID | int | Foreign key to testdef | | UsageDate | datetime | Usage datetime | | QuantityUsed | decimal | Quantity used | | PersonnelID | int | Personnel using reagent | | OrderID | string | Related order ID | | SID | string | Related specimen ID | | CreateDate | datetime | UTC+0 | ### productcatalog | Column | Type | Description | |--------|------|-------------| | ProductID | int | Primary key | | ProductName | string | Product name | | ProductCode | string | Product code | | Category | string | Product category | | Manufacturer | string | Manufacturer | | SMCRMRef | string | Reference to SMCRM | | CreateDate | datetime | UTC+0 | ### product | Column | Type | Description | |--------|------|-------------| | ProductID | int | Primary key | | CatalogID | int | Foreign key to productcatalog | | SiteID | int | Foreign key to site | | LotNumber | string | Lot number | | ExpiryDate | datetime | Expiry date | | Quantity | int | Quantity on hand | | ReorderLevel | int | Reorder level | | LocationID | int | Storage location | | CreateDate | datetime | UTC+0 | ### inventorytransaction | Column | Type | Description | |--------|------|-------------| | TransactionID | int | Primary key | | ProductID | int | Foreign key to product | | TransactionType | string | Transaction type (receipt, use, adjust) | | Quantity | int | Transaction quantity | | TransactionDate | datetime | Transaction datetime | | PersonnelID | int | Personnel | | ReferenceID | string | Reference ID | | Notes | string | Transaction notes | | CreateDate | datetime | UTC+0 | --- ## Table 16: Equipment Management ### equipment | Column | Type | Description | |--------|------|-------------| | EquipmentID | int | Primary key | | EquipmentName | string | Equipment name | | EquipmentType | string | Equipment type (IVD, non-IVD) | | Manufacturer | string | Manufacturer | | Model | string | Model number | | SerialNumber | string | Serial number | | SiteID | int | Foreign key to site | | LocationID | int | Foreign key to location | | Status | string | Equipment status | | InstallDate | datetime | Installation date | | DecommissionDate | datetime | Decommission date | | CreateDate | datetime | UTC+0 | ### equipmentmaintenance | Column | Type | Description | |--------|------|-------------| | MaintenanceID | int | Primary key | | EquipmentID | int | Foreign key to equipment | | MaintenanceType | string | Maintenance type | | MaintenanceDate | datetime | Maintenance datetime | | Description | string | Maintenance description | | PerformedBy | string | Performed by | | NextMaintenanceDate | datetime | Next maintenance date | | CreateDate | datetime | UTC+0 | ### equipmentactivity | Column | Type | Description | |--------|------|-------------| | ActivityID | int | Primary key | | EquipmentID | int | Foreign key to equipment | | ActivityType | string | Activity type | | ActivityDate | datetime | Activity datetime | | ActivityResult | string | Activity result | | PersonnelID | int | Personnel | | Notes | string | Activity notes | | CreateDate | datetime | UTC+0 | ### equipmenttestcount | Column | Type | Description | |--------|------|-------------| | ID | int | Primary key | | EquipmentID | int | Foreign key to equipment | | TestDate | datetime | Test date | | TestType | string | Test type (calibration, QC, patient, other) | | TestCount | int | Number of tests | | CreateDate | datetime | UTC+0 | --- ## Table 17: Doctor & Contact ### doctor | Column | Type | Description | |--------|------|-------------| | DoctorID | int | Primary key | | DoctorName | string | Doctor name | | DoctorCode | string | Doctor code | | Specialty | string | Specialty | | SIP | string | SIP number | | PracticeLocation | string | Practice location | | ContactID | int | Foreign key to contact | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### contact | Column | Type | Description | |--------|------|-------------| | ContactID | int | Primary key | | ContactName | string | Contact name | | ContactType | string | Contact type (person, organization) | | Phone | string | Phone | | Email | string | Email | | Address | string | Address | | SMCRMRef | string | Reference to SMCRM | | CreateDate | datetime | UTC+0 | ### contactdetail | Column | Type | Description | |--------|------|-------------| | DetailID | int | Primary key | | ContactID | int | Foreign key to contact | | DetailType | string | Detail type | | DetailValue | string | Detail value | | CreateDate | datetime | UTC+0 | --- ## Table 18: Coding System ### codingsystem | Column | Type | Description | |--------|------|-------------| | SystemID | int | Primary key | | SystemName | string | System name | | SystemCode | string | System code | | Description | string | Description | | URL | string | System URL | | CreateDate | datetime | UTC+0 | ### codemapping | Column | Type | Description | |--------|------|-------------| | MappingID | int | Primary key | | SourceSystem | string | Source coding system | | SourceCode | string | Source code | | TargetSystem | string | Target coding system | | TargetCode | string | Target code | | EntityType | string | Entity type (test, specimen, etc.) | | CreateDate | datetime | UTC+0 | --- ## Table 19: Audit ### auditlog | Column | Type | Description | |--------|------|-------------| | AuditID | int | Primary key | | UserID | int | User ID | | Action | string | Action performed | | EntityType | string | Entity type | | EntityID | string | Entity ID | | OldValue | string | Old value | | NewValue | string | New value | | IPAddress | string | IP address | | Timestamp | datetime | UTC+0 | | CreateDate | datetime | UTC+0 | ### auditarchive | Column | Type | Description | |--------|------|-------------| | ArchiveID | int | Primary key | | AuditID | int | Foreign key to auditlog | | ArchiveDate | datetime | Archive date | | ArchiveLocation | string | Archive location | | CreateDate | datetime | UTC+0 | --- ## Table 20: User & Authentication ### user | Column | Type | Description | |--------|------|-------------| | UserID | int | Primary key | | Username | string | Username | | PasswordHash | string | Password hash | | PersonnelID | int | Foreign key to personnel | | Role | string | User role | | Status | string | User status | | LastLogin | datetime | Last login datetime | | CreateDate | datetime | UTC+0 | ### usersession | Column | Type | Description | |--------|------|-------------| | SessionID | int | Primary key | | UserID | int | Foreign key to user | | SessionToken | string | Session token | | ExpiryDate | datetime | Session expiry | | IPAddress | string | IP address | | CreateDate | datetime | UTC+0 | --- ## Table 21: Visualization & Reporting ### reporttemplate | Column | Type | Description | |--------|------|-------------| | TemplateID | int | Primary key | | TemplateName | string | Template name | | TemplateType | string | Template type | | DisciplineID | int | Foreign key to discipline | | TemplateConfig | json | Template configuration | | CreateDate | datetime | UTC+0 | | EndDate | datetime | UTC+0 | ### reportoutput | Column | Type | Description | |--------|------|-------------| | OutputID | int | Primary key | | TemplateID | int | Foreign key to reporttemplate | | OrderID | string | Foreign key to testorder | | OutputFormat | string | Output format | | OutputData | blob | Output data | | GeneratedDate | datetime | Generation datetime | | PersonnelID | int | Generating personnel | | CreateDate | datetime | UTC+0 | ### visualizationconfig | Column | Type | Description | |--------|------|-------------| | ConfigID | int | Primary key | | ConfigName | string | Config name | | VisualizationType | string | Type (Levey-Jennings, etc.) | | ConfigData | json | Configuration data | | CreateDate | datetime | UTC+0 | --- ## Table 22: Host System Integration ### hostsystem | Column | Type | Description | |--------|------|-------------| | HostID | int | Primary key | | HostName | string | Host system name | | HostType | string | Host type (HIS, EMR, etc.) | | ConnectionString | string | Database connection string | | Protocol | string | Communication protocol | | Status | string | Connection status | | LastSync | datetime | Last synchronization | | CreateDate | datetime | UTC+0 | ### hosttestmapping | Column | Type | Description | |--------|------|-------------| | MappingID | int | Primary key | | HostID | int | Foreign key to hostsystem | | HostTestCode | string | Host test code | | LocalTestID | int | Foreign key to testdef | | CreateDate | datetime | UTC+0 | ### hostsynclog | Column | Type | Description | |--------|------|-------------| | LogID | int | Primary key | | HostID | int | Foreign key to hostsystem | | SyncDate | datetime | Sync datetime | | RecordsProcessed | int | Records processed | | Errors | int | Error count | | Status | string | Sync status | | Details | string | Sync details | | CreateDate | datetime | UTC+0 | --- ## Entity Relationships Summary ### Primary Relationships 1. **account → site** (one-to-many) 2. **site → location** (one-to-many) 3. **site → personnel** (one-to-many) 4. **site → equipment** (one-to-many) 5. **site → patient** (one-to-many) 6. **department → discipline** (many-to-many via junction table) 7. **workstation → site** (many-to-one) 8. **instrument → workstation** (many-to-one) 9. **instrument → site** (many-to-one) 10. **patient → patientvisit** (one-to-many) 11. **patientvisit → testorder** (one-to-many) 12. **testorder → specimen** (one-to-many) 13. **specimen → specimencollection** (one-to-many) 14. **specimen → patres** (one-to-many) 15. **testdef → patres** (one-to-many) 16. **testdef → calibration** (one-to-many) 17. **testdef → qcresult** (one-to-many) 18. **instrument → calibration** (one-to-many) 19. **instrument → qcresult** (one-to-many) 20. **valueset → valuesetmember** (one-to-many) ### Key Identifiers - **OrderID**: LLYYMMDDXXXXX (13 characters, special format - remains string) - **SID**: OrderID + SSS + C (17 characters, special format - remains string) - **InternalPID**: Auto-increment internal patient identifier (int) - **SiteID**: System-assigned site code (int) - **AccountID**: System-assigned account identifier (int) - **All other IDs**: Auto-increment integers (int) --- ## Notes for Figma Import ### Recommended Plugins 1. **Database Designer** - Direct import from structured format 2. **ERD (Entity Relationship Diagram)** - Visual ERD creation 3. **DrawSQL Import** - Import table definitions ### Import Format Most Figma ERD plugins accept: - SQL CREATE TABLE statements - JSON format with tables and columns - CSV format (table_name, column_name, data_type, description) ### Relationships to Define 1. Foreign key relationships 2. Cardinality (one-to-many, many-to-many) 3. Identifying vs non-identifying relationships 4. Optional vs mandatory participation --- *Generated from prj_3c.md documentation* *For CLQMS Backend - CodeIgniter 4 Application*