From 410bcebeab13c6a8e76799b88d109393cb399c34 Mon Sep 17 00:00:00 2001 From: Rida Abou-Haidar Date: Thu, 21 Nov 2024 10:52:59 -0500 Subject: [PATCH] finalized sql --- SQL/0000-00-01-Modules.sql | 1 + SQL/0000-00-02-Permission.sql | 12 +- .../0000-00-06-BiobankTables.sql | 714 ++++++------------ SQL/9999-99-99-drop_tables.sql | 32 + .../2024-11-21_biobank_addmodule.sql | 13 + modules/biobank/jsx/container.js | 2 +- modules/biobank/jsx/containerDisplay.js | 4 +- modules/biobank/jsx/globals.js | 6 +- modules/biobank/jsx/header.js | 6 +- modules/biobank/jsx/specimen.js | 2 +- modules/biobank/jsx/specimenForm.js | 2 +- modules/biobank/jsx/specimenTab.js | 4 +- .../biobank/php/containercontroller.class.inc | 2 +- modules/biobank/php/preparation.class.inc | 3 +- modules/biobank/php/shipment.class.inc | 4 +- .../biobank/php/specimencontroller.class.inc | 2 +- modules/biobank/sql/data.sql | 67 -- modules/biobank/sql/permissions.sql | 33 - 18 files changed, 321 insertions(+), 588 deletions(-) rename modules/biobank/sql/schema.sql => SQL/0000-00-06-BiobankTables.sql (73%) create mode 100644 SQL/New_patches/2024-11-21_biobank_addmodule.sql delete mode 100644 modules/biobank/sql/data.sql delete mode 100644 modules/biobank/sql/permissions.sql diff --git a/SQL/0000-00-01-Modules.sql b/SQL/0000-00-01-Modules.sql index f34f79aef19..ceedec97ca5 100644 --- a/SQL/0000-00-01-Modules.sql +++ b/SQL/0000-00-01-Modules.sql @@ -10,6 +10,7 @@ INSERT INTO modules (Name, Active) VALUES ('acknowledgements', 'Y'); INSERT INTO modules (Name, Active) VALUES ('api', 'Y'); INSERT INTO modules (Name, Active) VALUES ('battery_manager', 'Y'); INSERT INTO modules (Name, Active) VALUES ('behavioural_qc', 'Y'); +INSERT INTO modules (Name, Active) VALUES ('biobank', 'Y'); INSERT INTO modules (Name, Active) VALUES ('brainbrowser', 'Y'); INSERT INTO modules (Name, Active) VALUES ('bvl_feedback', 'Y'); INSERT INTO modules (Name, Active) VALUES ('candidate_list', 'Y'); diff --git a/SQL/0000-00-02-Permission.sql b/SQL/0000-00-02-Permission.sql index ccc635fed30..370ee6628a3 100644 --- a/SQL/0000-00-02-Permission.sql +++ b/SQL/0000-00-02-Permission.sql @@ -136,7 +136,17 @@ INSERT INTO `permissions` VALUES (64,'dataquery_admin','Admin dataquery queries',(SELECT ID FROM modules WHERE Name='dataquery'),NULL,'2'), (65,'schedule_module','Schedule Module - edit and delete the appointment',(SELECT ID FROM modules WHERE Name='schedule_module'),'View/Create/Edit','2'), (66,'document_repository_categories','Categories',(SELECT ID FROM modules WHERE Name='document_repository'), 'Edit/Upload/Delete', '2'), - (67,'document_repository_hidden','Restricted files',(SELECT ID FROM modules WHERE Name='document_repository'), 'View', '2'); + (67,'document_repository_hidden','Restricted files',(SELECT ID FROM modules WHERE Name='document_repository'), 'View', '2'), + (68,'biobank_specimen_view','View Specimen Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (69,'biobank_specimen_create','Create Specimens',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (70,'biobank_specimen_edit','Edit Specimen Data',(SELECT ID FROM modules WHERE Name='biobank'), 'Edit', '2'), + (71,'biobank_container_view','View Container Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (72,'biobank_container_create','Create Containers',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (73,'biobank_container_edit','Edit Container Data',(SELECT ID FROM modules WHERE Name='biobank'), 'Edit', '2'), + (74,'biobank_pool_view','View Pool Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (75,'biobank_pool_create','Create Pools',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (76,'biobank_fullsiteaccess','Full Site Access',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (77,'biobank_fullprojectaccess','Full Project Access',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'); INSERT INTO `user_perm_rel` (userID, permID) SELECT u.ID, p.permID diff --git a/modules/biobank/sql/schema.sql b/SQL/0000-00-06-BiobankTables.sql similarity index 73% rename from modules/biobank/sql/schema.sql rename to SQL/0000-00-06-BiobankTables.sql index 6bd78a6254f..af9efd1d01f 100644 --- a/modules/biobank/sql/schema.sql +++ b/SQL/0000-00-06-BiobankTables.sql @@ -1,75 +1,16 @@ --- MySQL dump 10.13 Distrib 8.0.39, for Linux (x86_64) -- --- Host: mariadb-dev0.acelab.ca Database: hrabalais_dev --- ------------------------------------------------------ --- Server version 5.5.5-10.5.26-MariaDB - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Table structure for table `biobank_container` --- - -DROP TABLE IF EXISTS `biobank_container`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_container` ( - `ContainerID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Barcode` varchar(40) NOT NULL, - `ContainerTypeID` int(10) unsigned NOT NULL, - `Temperature` decimal(5,2) NOT NULL DEFAULT 20.00, - `ContainerStatusID` int(10) unsigned NOT NULL, - `CenterID` int(10) unsigned DEFAULT NULL, - `LotNumber` varchar(40) DEFAULT NULL, - `ExpirationDate` date DEFAULT NULL, - `Comments` varchar(255) DEFAULT NULL, - `DateTimeCreate` datetime NOT NULL DEFAULT current_timestamp(), - `DateTimeUpdate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - PRIMARY KEY (`ContainerID`), - UNIQUE KEY `UK_biobank_container_Barcode` (`Barcode`), - KEY `FK_biobank_container_ContainerTypeID` (`ContainerTypeID`), - KEY `FK_biobank_container_ContainerStatusID` (`ContainerStatusID`), - KEY `FK_biobank_container_CurrentCenterID` (`CenterID`), - CONSTRAINT `FK_biobank_container_CenterID` FOREIGN KEY (`CenterID`) REFERENCES `psc` (`CenterID`) ON UPDATE CASCADE, - CONSTRAINT `FK_biobank_container_ContainerStatusID` FOREIGN KEY (`ContainerStatusID`) REFERENCES `biobank_container_status` (`ContainerStatusID`), - CONSTRAINT `FK_biobank_container_ContainerTypeID` FOREIGN KEY (`ContainerTypeID`) REFERENCES `biobank_container_type` (`ContainerTypeID`) -) ENGINE=InnoDB AUTO_INCREMENT=154926 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_container_capacity` +-- Biobank Schema -- -DROP TABLE IF EXISTS `biobank_container_capacity`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_container_capacity` ( - `ContainerCapacityID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Quantity` decimal(10,3) NOT NULL, - `UnitID` int(10) unsigned NOT NULL, - PRIMARY KEY (`ContainerCapacityID`), - UNIQUE KEY `UK_biobank_container_capacity_Quantity_UnitID` (`Quantity`,`UnitID`), - KEY `FK_biobank_container_capacity_UnitID` (`UnitID`), - CONSTRAINT `FK_biobank_container_capacity_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `biobank_unit` +CREATE TABLE `biobank_unit` ( + `UnitID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(20) NOT NULL, + PRIMARY KEY (`UnitID`), + UNIQUE KEY `Label` (`Label`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- -- Table structure for table `biobank_container_dimension` --- - -DROP TABLE IF EXISTS `biobank_container_dimension`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `biobank_container_dimension` ( `ContainerDimensionID` int(10) unsigned NOT NULL AUTO_INCREMENT, `X` int(10) unsigned NOT NULL, @@ -81,65 +22,27 @@ CREATE TABLE `biobank_container_dimension` ( PRIMARY KEY (`ContainerDimensionID`), UNIQUE KEY `UK_biobank_container_dimension_X_Y_Z` (`X`,`Y`,`Z`) ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_container_parent` --- - -DROP TABLE IF EXISTS `biobank_container_parent`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_container_parent` ( - `ContainerID` int(10) unsigned NOT NULL, - `ParentContainerID` int(10) unsigned NOT NULL, - `Coordinate` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`ContainerID`), - UNIQUE KEY `UK_biobank_container_parent_ParentContainerID_Coordinate` (`ParentContainerID`,`Coordinate`), - CONSTRAINT `FK_biobank_container_parent_ContainerID` FOREIGN KEY (`ContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE, - CONSTRAINT `FK_biobank_container_parent_ParentContainerID` FOREIGN KEY (`ParentContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_container_shipment_rel` --- -DROP TABLE IF EXISTS `biobank_container_shipment_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_container_shipment_rel` ( - `ShipmentID` int(10) unsigned NOT NULL, - `ContainerID` int(10) unsigned NOT NULL, - UNIQUE KEY `UK_biobank_container_shipment_rel_ShipmentID_ContainerID` (`ShipmentID`,`ContainerID`), - KEY `FK_shipment_log_ContainerID` (`ContainerID`), - CONSTRAINT `FK_shipment_log_ContainerID` FOREIGN KEY (`ContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE, - CONSTRAINT `FK_shipment_log_ShipmentID` FOREIGN KEY (`ShipmentID`) REFERENCES `shipment` (`ShipmentID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `biobank_container_capacity` +CREATE TABLE `biobank_container_capacity` ( + `ContainerCapacityID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Quantity` decimal(10,3) NOT NULL, + `UnitID` int(10) unsigned NOT NULL, + PRIMARY KEY (`ContainerCapacityID`), + UNIQUE KEY `UK_biobank_container_capacity_Quantity_UnitID` (`Quantity`,`UnitID`), + KEY `FK_biobank_container_capacity_UnitID` (`UnitID`), + CONSTRAINT `FK_biobank_container_capacity_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- -- Table structure for table `biobank_container_status` --- - -DROP TABLE IF EXISTS `biobank_container_status`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `biobank_container_status` ( `ContainerStatusID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Label` varchar(40) NOT NULL, PRIMARY KEY (`ContainerStatusID`), UNIQUE KEY `UK_biobank_container_status_Label` (`Label`) ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- -- Table structure for table `biobank_container_type` --- - -DROP TABLE IF EXISTS `biobank_container_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `biobank_container_type` ( `ContainerTypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Brand` varchar(50) NOT NULL, @@ -157,36 +60,135 @@ CREATE TABLE `biobank_container_type` ( CONSTRAINT `FK_biobank_container_type_CapacityID` FOREIGN KEY (`ContainerCapacityID`) REFERENCES `biobank_container_capacity` (`ContainerCapacityID`), CONSTRAINT `FK_biobank_container_type_DimensionID` FOREIGN KEY (`ContainerDimensionID`) REFERENCES `biobank_container_dimension` (`ContainerDimensionID`) ) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `biobank_pool` --- +-- Table structure for table `biobank_container` +CREATE TABLE `biobank_container` ( + `ContainerID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Barcode` varchar(40) NOT NULL, + `ContainerTypeID` int(10) unsigned NOT NULL, + `Temperature` decimal(5,2) NOT NULL DEFAULT 20.00, + `ContainerStatusID` int(10) unsigned NOT NULL, + `CenterID` int(10) unsigned DEFAULT NULL, + `LotNumber` varchar(40) DEFAULT NULL, + `ExpirationDate` date DEFAULT NULL, + `Comments` varchar(255) DEFAULT NULL, + `DateTimeCreate` datetime NOT NULL DEFAULT current_timestamp(), + `DateTimeUpdate` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`ContainerID`), + UNIQUE KEY `UK_biobank_container_Barcode` (`Barcode`), + KEY `FK_biobank_container_ContainerTypeID` (`ContainerTypeID`), + KEY `FK_biobank_container_ContainerStatusID` (`ContainerStatusID`), + KEY `FK_biobank_container_CurrentCenterID` (`CenterID`), + CONSTRAINT `FK_biobank_container_CenterID` FOREIGN KEY (`CenterID`) REFERENCES `psc` (`CenterID`) ON UPDATE CASCADE, + CONSTRAINT `FK_biobank_container_ContainerStatusID` FOREIGN KEY (`ContainerStatusID`) REFERENCES `biobank_container_status` (`ContainerStatusID`), + CONSTRAINT `FK_biobank_container_ContainerTypeID` FOREIGN KEY (`ContainerTypeID`) REFERENCES `biobank_container_type` (`ContainerTypeID`) +) ENGINE=InnoDB AUTO_INCREMENT=154926 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `biobank_pool`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_pool` ( - `PoolID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(40) NOT NULL, - `Quantity` decimal(10,3) NOT NULL, +-- Table structure for table `biobank_container_parent` +CREATE TABLE `biobank_container_parent` ( + `ContainerID` int(10) unsigned NOT NULL, + `ParentContainerID` int(10) unsigned NOT NULL, + `Coordinate` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`ContainerID`), + UNIQUE KEY `UK_biobank_container_parent_ParentContainerID_Coordinate` (`ParentContainerID`,`Coordinate`), + CONSTRAINT `FK_biobank_container_parent_ContainerID` FOREIGN KEY (`ContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE, + CONSTRAINT `FK_biobank_container_parent_ParentContainerID` FOREIGN KEY (`ParentContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_type` +CREATE TABLE `biobank_specimen_type` ( + `SpecimenTypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(50) NOT NULL, + `FreezeThaw` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`SpecimenTypeID`), + UNIQUE KEY `UK_biobank_specimen_type_Label` (`Label`) +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_type_unit_rel` +CREATE TABLE `biobank_specimen_type_unit_rel` ( + `SpecimenTypeID` int(10) unsigned NOT NULL, `UnitID` int(10) unsigned NOT NULL, - `Date` date NOT NULL, - `Time` time NOT NULL, - PRIMARY KEY (`PoolID`), - UNIQUE KEY `UK_biobank_pool_Label` (`Label`), - KEY `FK_biobank_pool_UnitID` (`UnitID`), - CONSTRAINT `FK_biobank_pool_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) -) ENGINE=InnoDB AUTO_INCREMENT=3703 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; + PRIMARY KEY (`SpecimenTypeID`,`UnitID`), + KEY `FK_biobank_specimen_type_unit_rel_SourceID` (`UnitID`), + CONSTRAINT `FK_biobank_specimen_type_unit_rel_SourceID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`), + CONSTRAINT `FK_biobank_specimen_type_unit_rel_TypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- --- Table structure for table `biobank_specimen` --- +-- Table structure for table `biobank_specimen_type_container_type_rel` +CREATE TABLE `biobank_specimen_type_container_type_rel` ( + `SpecimenTypeID` int(10) unsigned NOT NULL, + `ContainerTypeID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenTypeID`,`ContainerTypeID`), + KEY `FK_biobank_validate_identifier_ContainerTypeID` (`ContainerTypeID`), + CONSTRAINT `FK_biobank_specimen_type_container_type_rel_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`), + CONSTRAINT `FK_biobank_validate_identifier_ContainerTypeID` FOREIGN KEY (`ContainerTypeID`) REFERENCES `biobank_container_type` (`ContainerTypeID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + + +-- Table structure for table `biobank_specimen_type_parent` +CREATE TABLE `biobank_specimen_type_parent` ( + `SpecimenTypeID` int(10) unsigned NOT NULL, + `ParentSpecimenTypeID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenTypeID`,`ParentSpecimenTypeID`), + KEY `FK_biobank_specimen_type_parent_ParentSpecimenTypeID` (`ParentSpecimenTypeID`), + CONSTRAINT `FK_biobank_specimen_type_parent_ParentSpecimenTypeID` FOREIGN KEY (`ParentSpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`), + CONSTRAINT `FK_biobank_specimen_type_parent_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_process` +CREATE TABLE `biobank_specimen_process` ( + `SpecimenProcessID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(50) NOT NULL, + PRIMARY KEY (`SpecimenProcessID`), + UNIQUE KEY `UK_biobank_specimen_process_Label` (`Label`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; + +-- Table structure for table `biobank_specimen_attribute_datatype` +CREATE TABLE `biobank_specimen_attribute_datatype` ( + `DatatypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Datatype` varchar(20) NOT NULL, + PRIMARY KEY (`DatatypeID`), + UNIQUE KEY `Datatype` (`Datatype`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_attribute` +CREATE TABLE `biobank_specimen_attribute` ( + `SpecimenAttributeID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(255) NOT NULL, + `DatatypeID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenAttributeID`), + UNIQUE KEY `UK_biobank_specimen_attribute_Label` (`Label`), + KEY `FK_biobank_specimen_attribute_DatatypeID` (`DatatypeID`), + CONSTRAINT `FK_biobank_specimen_attribute_DatatypeID` FOREIGN KEY (`DatatypeID`) REFERENCES `biobank_specimen_attribute_datatype` (`DatatypeID`) +) ENGINE=InnoDB AUTO_INCREMENT=180 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_protocol` +CREATE TABLE `biobank_specimen_protocol` ( + `SpecimenProtocolID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(100) NOT NULL, + `SpecimenProcessID` int(10) unsigned NOT NULL, + `SpecimenTypeID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenProtocolID`), + UNIQUE KEY `UK_biobank_specimen_protocol_Label_SpecimenProcessID` (`Label`,`SpecimenProcessID`), + KEY `FK_biobank_specimen_protocol_SpecimenProcessID` (`SpecimenProcessID`), + KEY `FK_biobank_specimen_protocol_SpecimenTypeID` (`SpecimenTypeID`), + CONSTRAINT `FK_biobank_specimen_protocol_SpecimenProcessID` FOREIGN KEY (`SpecimenProcessID`) REFERENCES `biobank_specimen_process` (`SpecimenProcessID`), + CONSTRAINT `FK_biobank_specimen_protocol_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) +) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- Table structure for table `biobank_specimen_protocol_attribute_rel` +CREATE TABLE `biobank_specimen_protocol_attribute_rel` ( + `SpecimenProtocolID` int(10) unsigned NOT NULL, + `SpecimenAttributeID` int(10) unsigned NOT NULL, + `Required` tinyint(1) DEFAULT NULL, + `showInDataTable` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`SpecimenProtocolID`,`SpecimenAttributeID`), + KEY `FK_biobank_specimen_protocol_attribute_rel_SpecimenAttributeID` (`SpecimenAttributeID`), + CONSTRAINT `FK_biobank_specimen_protocol_attribute__rel_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`), + CONSTRAINT `FK_biobank_specimen_protocol_attribute_rel_SpecimenAttributeID` FOREIGN KEY (`SpecimenAttributeID`) REFERENCES `biobank_specimen_attribute` (`SpecimenAttributeID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `biobank_specimen`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; +-- Table structure for table `biobank_specimen` CREATE TABLE `biobank_specimen` ( `SpecimenID` int(10) unsigned NOT NULL AUTO_INCREMENT, `ContainerID` int(10) unsigned NOT NULL, @@ -205,80 +207,22 @@ CREATE TABLE `biobank_specimen` ( CONSTRAINT `FK_biobank_specimen_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`), CONSTRAINT `FK_biobank_specimen_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) ) ENGINE=InnoDB AUTO_INCREMENT=153402 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `biobank_specimen_analysis` --- +-- Table structure for table `biobank_specimen_freezethaw` +CREATE TABLE `biobank_specimen_freezethaw` ( + `SpecimenID` int(10) unsigned NOT NULL, + `FreezeThawCycle` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenID`), + CONSTRAINT `FK_biobank_specimen_freezethaw_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `biobank_specimen_analysis`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_analysis` ( + +-- Table structure for table `biobank_specimen_collection` +CREATE TABLE `biobank_specimen_collection` ( `SpecimenID` int(10) unsigned NOT NULL, `SpecimenProtocolID` int(10) unsigned NOT NULL, - `CenterID` int(10) unsigned NOT NULL, - `ExaminerID` int(10) unsigned NOT NULL, - `Date` date NOT NULL, - `Time` time NOT NULL, - `Comments` varchar(500) DEFAULT NULL, - `Data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, - PRIMARY KEY (`SpecimenID`), - KEY `FK_biobank_specimen_analysis_SpecimenProtocolID` (`SpecimenProtocolID`), - KEY `FK_biobank_specimen_analysis_CenterID` (`CenterID`), - KEY `FK_biobank_specimen_analysis_ExaminerID` (`ExaminerID`), - CONSTRAINT `FK_biobank_specimen_analysis_CenterID` FOREIGN KEY (`CenterID`) REFERENCES `psc` (`CenterID`), - CONSTRAINT `FK_biobank_specimen_analysis_ExaminerID` FOREIGN KEY (`ExaminerID`) REFERENCES `examiners` (`examinerID`), - CONSTRAINT `FK_biobank_specimen_analysis_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE, - CONSTRAINT `FK_biobank_specimen_analysis_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_attribute` --- - -DROP TABLE IF EXISTS `biobank_specimen_attribute`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_attribute` ( - `SpecimenAttributeID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(255) NOT NULL, - `DatatypeID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenAttributeID`), - UNIQUE KEY `UK_biobank_specimen_attribute_Label` (`Label`), - KEY `FK_biobank_specimen_attribute_DatatypeID` (`DatatypeID`), - CONSTRAINT `FK_biobank_specimen_attribute_DatatypeID` FOREIGN KEY (`DatatypeID`) REFERENCES `biobank_specimen_attribute_datatype` (`DatatypeID`) -) ENGINE=InnoDB AUTO_INCREMENT=180 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_attribute_datatype` --- - -DROP TABLE IF EXISTS `biobank_specimen_attribute_datatype`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_attribute_datatype` ( - `DatatypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Datatype` varchar(20) NOT NULL, - PRIMARY KEY (`DatatypeID`), - UNIQUE KEY `Datatype` (`Datatype`) -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_collection` --- - -DROP TABLE IF EXISTS `biobank_specimen_collection`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_collection` ( - `SpecimenID` int(10) unsigned NOT NULL, - `SpecimenProtocolID` int(10) unsigned NOT NULL, - `Quantity` decimal(10,3) NOT NULL, - `UnitID` int(10) unsigned NOT NULL, + `Quantity` decimal(10,3) NOT NULL, + `UnitID` int(10) unsigned NOT NULL, `CenterID` int(10) unsigned NOT NULL, `ExaminerID` int(10) unsigned NOT NULL, `Date` date NOT NULL, @@ -296,64 +240,8 @@ CREATE TABLE `biobank_specimen_collection` ( CONSTRAINT `FK_biobank_specimen_collection_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`), CONSTRAINT `FK_biobank_specimen_collection_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_freezethaw` --- - -DROP TABLE IF EXISTS `biobank_specimen_freezethaw`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_freezethaw` ( - `SpecimenID` int(10) unsigned NOT NULL, - `FreezeThawCycle` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenID`), - CONSTRAINT `FK_biobank_specimen_freezethaw_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_parent` --- - -DROP TABLE IF EXISTS `biobank_specimen_parent`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_parent` ( - `SpecimenID` int(10) unsigned NOT NULL, - `ParentSpecimenID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenID`,`ParentSpecimenID`), - KEY `FK_biobank_specimen_parent_ParentSpecimenID` (`ParentSpecimenID`), - CONSTRAINT `FK_biobank_specimen_parent_ParentSpecimenID` FOREIGN KEY (`ParentSpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE, - CONSTRAINT `FK_biobank_specimen_parent_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `biobank_specimen_pool_rel` --- - -DROP TABLE IF EXISTS `biobank_specimen_pool_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_pool_rel` ( - `SpecimenID` int(10) unsigned NOT NULL, - `PoolID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenID`), - KEY `FK_biobank_specimen_pool_rel_PoolID` (`PoolID`), - CONSTRAINT `FK_biobank_specimen_pool_rel_PoolID` FOREIGN KEY (`PoolID`) REFERENCES `biobank_pool` (`PoolID`) ON DELETE CASCADE, - CONSTRAINT `FK_biobank_specimen_pool_rel_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- -- Table structure for table `biobank_specimen_preparation` --- - -DROP TABLE IF EXISTS `biobank_specimen_preparation`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `biobank_specimen_preparation` ( `SpecimenID` int(10) unsigned NOT NULL, `SpecimenProtocolID` int(10) unsigned NOT NULL, @@ -372,30 +260,38 @@ CREATE TABLE `biobank_specimen_preparation` ( CONSTRAINT `FK_biobank_specimen_preparation_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE, CONSTRAINT `FK_biobank_specimen_preparation_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `biobank_specimen_process` --- +-- Table structure for table `biobank_specimen_analysis` +CREATE TABLE `biobank_specimen_analysis` ( + `SpecimenID` int(10) unsigned NOT NULL, + `SpecimenProtocolID` int(10) unsigned NOT NULL, + `CenterID` int(10) unsigned NOT NULL, + `ExaminerID` int(10) unsigned NOT NULL, + `Date` date NOT NULL, + `Time` time NOT NULL, + `Comments` varchar(500) DEFAULT NULL, + `Data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, + PRIMARY KEY (`SpecimenID`), + KEY `FK_biobank_specimen_analysis_SpecimenProtocolID` (`SpecimenProtocolID`), + KEY `FK_biobank_specimen_analysis_CenterID` (`CenterID`), + KEY `FK_biobank_specimen_analysis_ExaminerID` (`ExaminerID`), + CONSTRAINT `FK_biobank_specimen_analysis_CenterID` FOREIGN KEY (`CenterID`) REFERENCES `psc` (`CenterID`), + CONSTRAINT `FK_biobank_specimen_analysis_ExaminerID` FOREIGN KEY (`ExaminerID`) REFERENCES `examiners` (`examinerID`), + CONSTRAINT `FK_biobank_specimen_analysis_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE, + CONSTRAINT `FK_biobank_specimen_analysis_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `biobank_specimen_process`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_process` ( - `SpecimenProcessID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(50) NOT NULL, - PRIMARY KEY (`SpecimenProcessID`), - UNIQUE KEY `UK_biobank_specimen_process_Label` (`Label`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `biobank_specimen_parent` +CREATE TABLE `biobank_specimen_parent` ( + `SpecimenID` int(10) unsigned NOT NULL, + `ParentSpecimenID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenID`,`ParentSpecimenID`), + KEY `FK_biobank_specimen_parent_ParentSpecimenID` (`ParentSpecimenID`), + CONSTRAINT `FK_biobank_specimen_parent_ParentSpecimenID` FOREIGN KEY (`ParentSpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE, + CONSTRAINT `FK_biobank_specimen_parent_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- -- Table structure for table `biobank_specimen_project_rel` --- - -DROP TABLE IF EXISTS `biobank_specimen_project_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `biobank_specimen_project_rel` ( `SpecimenID` int(10) unsigned NOT NULL, `ProjectID` int(10) unsigned NOT NULL, @@ -404,158 +300,48 @@ CREATE TABLE `biobank_specimen_project_rel` ( CONSTRAINT `FK_biobank_specimen_project_rel_ProjectID` FOREIGN KEY (`ProjectID`) REFERENCES `Project` (`ProjectID`), CONSTRAINT `FK_biobank_specimen_project_rel_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_protocol` --- - -DROP TABLE IF EXISTS `biobank_specimen_protocol`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_protocol` ( - `SpecimenProtocolID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(100) NOT NULL, - `SpecimenProcessID` int(10) unsigned NOT NULL, - `SpecimenTypeID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenProtocolID`), - UNIQUE KEY `UK_biobank_specimen_protocol_Label_SpecimenProcessID` (`Label`,`SpecimenProcessID`), - KEY `FK_biobank_specimen_protocol_SpecimenProcessID` (`SpecimenProcessID`), - KEY `FK_biobank_specimen_protocol_SpecimenTypeID` (`SpecimenTypeID`), - CONSTRAINT `FK_biobank_specimen_protocol_SpecimenProcessID` FOREIGN KEY (`SpecimenProcessID`) REFERENCES `biobank_specimen_process` (`SpecimenProcessID`), - CONSTRAINT `FK_biobank_specimen_protocol_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) -) ENGINE=InnoDB AUTO_INCREMENT=120 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_protocol_attribute_rel` --- - -DROP TABLE IF EXISTS `biobank_specimen_protocol_attribute_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_protocol_attribute_rel` ( - `SpecimenProtocolID` int(10) unsigned NOT NULL, - `SpecimenAttributeID` int(10) unsigned NOT NULL, - `Required` tinyint(1) DEFAULT NULL, - `showInDataTable` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`SpecimenProtocolID`,`SpecimenAttributeID`), - KEY `FK_biobank_specimen_protocol_attribute_rel_SpecimenAttributeID` (`SpecimenAttributeID`), - CONSTRAINT `FK_biobank_specimen_protocol_attribute__rel_SpecimenProtocolID` FOREIGN KEY (`SpecimenProtocolID`) REFERENCES `biobank_specimen_protocol` (`SpecimenProtocolID`), - CONSTRAINT `FK_biobank_specimen_protocol_attribute_rel_SpecimenAttributeID` FOREIGN KEY (`SpecimenAttributeID`) REFERENCES `biobank_specimen_attribute` (`SpecimenAttributeID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `biobank_specimen_type` --- - -DROP TABLE IF EXISTS `biobank_specimen_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_type` ( - `SpecimenTypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(50) NOT NULL, - `FreezeThaw` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`SpecimenTypeID`), - UNIQUE KEY `UK_biobank_specimen_type_Label` (`Label`) -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_type_container_type_rel` --- - -DROP TABLE IF EXISTS `biobank_specimen_type_container_type_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_type_container_type_rel` ( - `SpecimenTypeID` int(10) unsigned NOT NULL, - `ContainerTypeID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenTypeID`,`ContainerTypeID`), - KEY `FK_biobank_validate_identifier_ContainerTypeID` (`ContainerTypeID`), - CONSTRAINT `FK_biobank_specimen_type_container_type_rel_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`), - CONSTRAINT `FK_biobank_validate_identifier_ContainerTypeID` FOREIGN KEY (`ContainerTypeID`) REFERENCES `biobank_container_type` (`ContainerTypeID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_type_parent` --- - -DROP TABLE IF EXISTS `biobank_specimen_type_parent`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_type_parent` ( - `SpecimenTypeID` int(10) unsigned NOT NULL, - `ParentSpecimenTypeID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenTypeID`,`ParentSpecimenTypeID`), - KEY `FK_biobank_specimen_type_parent_ParentSpecimenTypeID` (`ParentSpecimenTypeID`), - CONSTRAINT `FK_biobank_specimen_type_parent_ParentSpecimenTypeID` FOREIGN KEY (`ParentSpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`), - CONSTRAINT `FK_biobank_specimen_type_parent_SpecimenTypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_specimen_type_unit_rel` --- - -DROP TABLE IF EXISTS `biobank_specimen_type_unit_rel`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_specimen_type_unit_rel` ( - `SpecimenTypeID` int(10) unsigned NOT NULL, +-- Table structure for table `biobank_pool` +CREATE TABLE `biobank_pool` ( + `PoolID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(40) NOT NULL, + `Quantity` decimal(10,3) NOT NULL, `UnitID` int(10) unsigned NOT NULL, - PRIMARY KEY (`SpecimenTypeID`,`UnitID`), - KEY `FK_biobank_specimen_type_unit_rel_SourceID` (`UnitID`), - CONSTRAINT `FK_biobank_specimen_type_unit_rel_SourceID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`), - CONSTRAINT `FK_biobank_specimen_type_unit_rel_TypeID` FOREIGN KEY (`SpecimenTypeID`) REFERENCES `biobank_specimen_type` (`SpecimenTypeID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `biobank_unit` --- + `Date` date NOT NULL, + `Time` time NOT NULL, + PRIMARY KEY (`PoolID`), + UNIQUE KEY `UK_biobank_pool_Label` (`Label`), + KEY `FK_biobank_pool_UnitID` (`UnitID`), + CONSTRAINT `FK_biobank_pool_UnitID` FOREIGN KEY (`UnitID`) REFERENCES `biobank_unit` (`UnitID`) +) ENGINE=InnoDB AUTO_INCREMENT=3703 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `biobank_unit`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `biobank_unit` ( - `UnitID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(20) NOT NULL, - PRIMARY KEY (`UnitID`), - UNIQUE KEY `Label` (`Label`) -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `biobank_specimen_pool_rel` +CREATE TABLE `biobank_specimen_pool_rel` ( + `SpecimenID` int(10) unsigned NOT NULL, + `PoolID` int(10) unsigned NOT NULL, + PRIMARY KEY (`SpecimenID`), + KEY `FK_biobank_specimen_pool_rel_PoolID` (`PoolID`), + CONSTRAINT `FK_biobank_specimen_pool_rel_PoolID` FOREIGN KEY (`PoolID`) REFERENCES `biobank_pool` (`PoolID`) ON DELETE CASCADE, + CONSTRAINT `FK_biobank_specimen_pool_rel_SpecimenID` FOREIGN KEY (`SpecimenID`) REFERENCES `biobank_specimen` (`SpecimenID`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- --- Table structure for table `shipment` --- +-- Table structure for table `shipment_type` +CREATE TABLE `shipment_type` ( + `ShipmentTypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(255) NOT NULL, + PRIMARY KEY (`ShipmentTypeID`), + UNIQUE KEY `UK_shipment_type_Label` (`Label`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `shipment`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `shipment` ( - `ShipmentID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Barcode` varchar(50) NOT NULL, - `ShipmentTypeID` int(10) unsigned NOT NULL, - `DestinationCenterID` int(10) unsigned NOT NULL, - PRIMARY KEY (`ShipmentID`), - UNIQUE KEY `UK_shipment_Barcode` (`Barcode`), - KEY `FK_shipment_ShipmentTypeID` (`ShipmentTypeID`), - KEY `FK_shipment_DestinationCentrID` (`DestinationCenterID`), - CONSTRAINT `FK_shipment_DestinationCentrID` FOREIGN KEY (`DestinationCenterID`) REFERENCES `psc` (`CenterID`), - CONSTRAINT `FK_shipment_ShipmentTypeID` FOREIGN KEY (`ShipmentTypeID`) REFERENCES `shipment_type` (`ShipmentTypeID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `shipment_status` +CREATE TABLE `shipment_status` ( + `StatusID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Label` varchar(255) NOT NULL, + PRIMARY KEY (`StatusID`), + UNIQUE KEY `UK_shipment_status_Label` (`Label`) +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- -- Table structure for table `shipment_log` --- - -DROP TABLE IF EXISTS `shipment_log`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; CREATE TABLE `shipment_log` ( `ShipmentID` int(10) unsigned NOT NULL, `CenterID` int(10) unsigned NOT NULL, @@ -575,45 +361,33 @@ CREATE TABLE `shipment_log` ( CONSTRAINT `FK_shipment_log_StatusID` FOREIGN KEY (`StatusID`) REFERENCES `shipment_status` (`StatusID`), CONSTRAINT `FK_shipment_log_UserID` FOREIGN KEY (`UserID`) REFERENCES `users` (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `shipment_status` --- -DROP TABLE IF EXISTS `shipment_status`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `shipment_status` ( - `StatusID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(255) NOT NULL, - PRIMARY KEY (`StatusID`), - UNIQUE KEY `UK_shipment_status_Label` (`Label`) -) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; +-- Table structure for table `shipment` +CREATE TABLE `shipment` ( + `ShipmentID` int(10) unsigned NOT NULL AUTO_INCREMENT, + `Barcode` varchar(50) NOT NULL, + `ShipmentTypeID` int(10) unsigned NOT NULL, + `DestinationCenterID` int(10) unsigned NOT NULL, + PRIMARY KEY (`ShipmentID`), + UNIQUE KEY `UK_shipment_Barcode` (`Barcode`), + KEY `FK_shipment_ShipmentTypeID` (`ShipmentTypeID`), + KEY `FK_shipment_DestinationCentrID` (`DestinationCenterID`), + CONSTRAINT `FK_shipment_DestinationCentrID` FOREIGN KEY (`DestinationCenterID`) REFERENCES `psc` (`CenterID`), + CONSTRAINT `FK_shipment_ShipmentTypeID` FOREIGN KEY (`ShipmentTypeID`) REFERENCES `shipment_type` (`ShipmentTypeID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; --- --- Table structure for table `shipment_type` --- +-- Table structure for table `biobank_container_shipment_rel` +CREATE TABLE `biobank_container_shipment_rel` ( + `ShipmentID` int(10) unsigned NOT NULL, + `ContainerID` int(10) unsigned NOT NULL, + UNIQUE KEY `UK_biobank_container_shipment_rel_ShipmentID_ContainerID` (`ShipmentID`,`ContainerID`), + KEY `FK_shipment_log_ContainerID` (`ContainerID`), + CONSTRAINT `FK_shipment_log_ContainerID` FOREIGN KEY (`ContainerID`) REFERENCES `biobank_container` (`ContainerID`) ON DELETE CASCADE, + CONSTRAINT `FK_shipment_log_ShipmentID` FOREIGN KEY (`ShipmentID`) REFERENCES `shipment` (`ShipmentID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -DROP TABLE IF EXISTS `shipment_type`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!50503 SET character_set_client = utf8mb4 */; -CREATE TABLE `shipment_type` ( - `ShipmentTypeID` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Label` varchar(255) NOT NULL, - PRIMARY KEY (`ShipmentTypeID`), - UNIQUE KEY `UK_shipment_type_Label` (`Label`) -) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; -/*!40101 SET character_set_client = @saved_cs_client */; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2024-11-08 12:10:21 +-- Insert units, processes, container status and shipment status +INSERT INTO `biobank_unit` VALUES (2,'mL'),(8,'piece'),(3,'x 10e6 cells'),(1,'µL'); +INSERT INTO `biobank_specimen_process` VALUES (2,'Analysis'),(1,'Collection'),(3,'Preparation'); +INSERT INTO `biobank_container_status` VALUES (1,'Available'),(4,'Discarded'),(3,'Dispensed'),(2,'Reserved'),(5,'Shipped'); +INSERT INTO `shipment_status` VALUES (10,'cancelled'),(1,'created'),(7,'received'),(13,'returned'),(4,'shipped'); diff --git a/SQL/9999-99-99-drop_tables.sql b/SQL/9999-99-99-drop_tables.sql index c40942b9815..cfbb2b6c9c0 100644 --- a/SQL/9999-99-99-drop_tables.sql +++ b/SQL/9999-99-99-drop_tables.sql @@ -6,6 +6,38 @@ DROP TABLE IF EXISTS dataquery_run_queries; DROP TABLE IF EXISTS dataquery_query_names; DROP TABLE IF EXISTS dataquery_queries; +-- 0000-00-6-BiobankTables.sql +DROP TABLE IF EXISTS `biobank_container_shipment_rel`; +DROP TABLE IF EXISTS `shipment`; +DROP TABLE IF EXISTS `shipment_log`; +DROP TABLE IF EXISTS `shipment_status`; +DROP TABLE IF EXISTS `shipment_type`; +DROP TABLE IF EXISTS `biobank_specimen_pool_rel`; +DROP TABLE IF EXISTS `biobank_pool`; +DROP TABLE IF EXISTS `biobank_specimen_project_rel`; +DROP TABLE IF EXISTS `biobank_specimen_parent`; +DROP TABLE IF EXISTS `biobank_specimen_analysis`; +DROP TABLE IF EXISTS `biobank_specimen_preparation`; +DROP TABLE IF EXISTS `biobank_specimen_collection`; +DROP TABLE IF EXISTS `biobank_specimen_freezethaw`; +DROP TABLE IF EXISTS `biobank_specimen`; +DROP TABLE IF EXISTS `biobank_specimen_protocol_attribute_rel`; +DROP TABLE IF EXISTS `biobank_specimen_protocol`; +DROP TABLE IF EXISTS `biobank_specimen_attribute`; +DROP TABLE IF EXISTS `biobank_specimen_attribute_datatype`; +DROP TABLE IF EXISTS `biobank_specimen_process`; +DROP TABLE IF EXISTS `biobank_specimen_type_parent`; +DROP TABLE IF EXISTS `biobank_specimen_type_container_type_rel`; +DROP TABLE IF EXISTS `biobank_specimen_type_unit_rel`; +DROP TABLE IF EXISTS `biobank_specimen_type`; +DROP TABLE IF EXISTS `biobank_container_parent`; +DROP TABLE IF EXISTS `biobank_container`; +DROP TABLE IF EXISTS `biobank_container_type`; +DROP TABLE IF EXISTS `biobank_container_status`; +DROP TABLE IF EXISTS `biobank_container_capacity`; +DROP TABLE IF EXISTS `biobank_container_dimension`; +DROP TABLE IF EXISTS `biobank_unit`; + -- 0000-00-05-ElectrophysiologyTables.sql DROP TABLE IF EXISTS `physiological_event_parameter_category_level`; DROP TABLE IF EXISTS `physiological_event_parameter`; diff --git a/SQL/New_patches/2024-11-21_biobank_addmodule.sql b/SQL/New_patches/2024-11-21_biobank_addmodule.sql new file mode 100644 index 00000000000..565b2fee945 --- /dev/null +++ b/SQL/New_patches/2024-11-21_biobank_addmodule.sql @@ -0,0 +1,13 @@ +INSERT INTO modules (Name, Active) VALUES ('biobank', 'Y'); + +INSERT INTO `permissions` VALUES + (68,'biobank_specimen_view','View Specimen Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (69,'biobank_specimen_create','Create Specimens',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (70,'biobank_specimen_edit','Edit Specimen Data',(SELECT ID FROM modules WHERE Name='biobank'), 'Edit', '2'), + (71,'biobank_container_view','View Container Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (72,'biobank_container_create','Create Containers',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (73,'biobank_container_edit','Edit Container Data',(SELECT ID FROM modules WHERE Name='biobank'), 'Edit', '2'), + (74,'biobank_pool_view','View Pool Data',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (75,'biobank_pool_create','Create Pools',(SELECT ID FROM modules WHERE Name='biobank'), 'Create', '2'), + (76,'biobank_fullsiteaccess','Full Site Access',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'), + (77,'biobank_fullprojectaccess','Full Project Access',(SELECT ID FROM modules WHERE Name='biobank'), 'View', '2'); diff --git a/modules/biobank/jsx/container.js b/modules/biobank/jsx/container.js index cea30593ba2..49d6c192583 100644 --- a/modules/biobank/jsx/container.js +++ b/modules/biobank/jsx/container.js @@ -45,7 +45,7 @@ class BiobankContainer extends Component { const {current, data, editable, options, container} = this.props; const checkoutButton = () => { - if (!(loris.userHasPermission('biobank_container_update')) + if (!(loris.userHasPermission('biobank_container_edit')) || (data.containers[container.id].childContainerIds.length == 0) ) { return; diff --git a/modules/biobank/jsx/containerDisplay.js b/modules/biobank/jsx/containerDisplay.js index 9dfa30d61a4..fb37e1d0edb 100644 --- a/modules/biobank/jsx/containerDisplay.js +++ b/modules/biobank/jsx/containerDisplay.js @@ -264,7 +264,7 @@ function ContainerDisplay(props) { '
'+optcon.stati[children[coord].statusId].label+'
'; } draggable = !loris.userHasPermission( - 'biobank_container_update') || + 'biobank_container_edit') || editable.loadContainer || editable.containerCheckout ? 'false' : 'true'; @@ -281,7 +281,7 @@ function ContainerDisplay(props) { } onDragOver = null; onDrop = null; - } else if (loris.userHasPermission('biobank_container_update') && + } else if (loris.userHasPermission('biobank_container_edit') && !editable.containerCheckout) { nodeClass = coordinate == current.coordinate ? 'node selected' : 'node load'; diff --git a/modules/biobank/jsx/globals.js b/modules/biobank/jsx/globals.js index 9a4c36d556b..09727b745aa 100644 --- a/modules/biobank/jsx/globals.js +++ b/modules/biobank/jsx/globals.js @@ -33,7 +33,7 @@ function Globals(props) /> ); - const edit = loris.userHasPermission('biobank_specimen_alter') + const edit = loris.userHasPermission('biobank_specimen_edit') && specimen && ( () => { props.edit('containerType'); @@ -118,7 +118,7 @@ function Globals(props) // }; // const increaseCycle = () => changeCycle(1); // const decreaseCycle = () => changeCycle(-1); - // const updateFTCycle = loris.userHasPermission('biobank_specimen_update') ? ( + // const updateFTCycle = loris.userHasPermission('biobank_specimen_edit') ? ( //
// {specimen.fTCycle > 0 ? ( //
@@ -311,7 +311,7 @@ function Globals(props) }; const updateParentContainer = () => { - if (loris.userHasPermission('biobank_container_update')) { + if (loris.userHasPermission('biobank_container_edit')) { return (
diff --git a/modules/biobank/jsx/header.js b/modules/biobank/jsx/header.js index 887b0f7c755..7f5bde62920 100644 --- a/modules/biobank/jsx/header.js +++ b/modules/biobank/jsx/header.js @@ -69,7 +69,7 @@ class Header extends Component { }; const alterLotNumber = () => { - if (loris.userHasPermission('biobank_specimen_alter')) { + if (loris.userHasPermission('biobank_specimen_edit')) { return (
{ - if (loris.userHasPermission('biobank_specimen_alter')) { + if (loris.userHasPermission('biobank_specimen_edit')) { return (
props.updateContainer()); }; - return (loris.userHasPermission('biobank_container_update') && + return (loris.userHasPermission('biobank_container_edit') && props.container.parentContainerId) ? (
props.addProcess(process); panel = ( diff --git a/modules/biobank/jsx/specimenForm.js b/modules/biobank/jsx/specimenForm.js index c4a081a5719..cc82345ec0b 100644 --- a/modules/biobank/jsx/specimenForm.js +++ b/modules/biobank/jsx/specimenForm.js @@ -325,7 +325,7 @@ class SpecimenForm extends React.Component { const renderRemainingQuantityFields = () => { if (parent) { - if (loris.userHasPermission('biobank_specimen_update') + if (loris.userHasPermission('biobank_specimen_edit') && parent.length === 1 ) { const specimenUnits = mapFormOptions( diff --git a/modules/biobank/jsx/specimenTab.js b/modules/biobank/jsx/specimenTab.js index 4bf60f6e165..9d04fd41d9e 100644 --- a/modules/biobank/jsx/specimenTab.js +++ b/modules/biobank/jsx/specimenTab.js @@ -381,7 +381,7 @@ class SpecimenTab extends Component { onClose={this.clearEditable} onSubmit={this.props.createPool} /> : null} - {loris.userHasPermission('biobank_specimen_update') ? + {loris.userHasPermission('biobank_specimen_edit') ? : null} - {loris.userHasPermission('biobank_specimen_update') ? + {loris.userHasPermission('biobank_specimen_edit') ? user->hasPermission('biobank_container_update')) { + if (!$this->user->hasPermission('biobank_container_edit')) { throw new Forbidden('Container: Update Permission Denied'); } break; diff --git a/modules/biobank/php/preparation.class.inc b/modules/biobank/php/preparation.class.inc index d95dbecfaa1..a91d0af0084 100644 --- a/modules/biobank/php/preparation.class.inc +++ b/modules/biobank/php/preparation.class.inc @@ -1,7 +1,8 @@ id = $data['id'] ?? null; $this->barcode = $data['barcode'] ?? null; $this->type = $data['type'] ?? null; - $this->destinationCenterId = new \CenterID($data['destinationCenterId'] ?? null); + $this->destinationCenterId = new \CenterID( + $data['destinationCenterId'] ?? null + ); $this->containerIds = $data['containerIds'] ?? null; $this->containerBarcodes = $data['containerBarcodes'] ?? null; $this->_setLogs($data['logs']) ?? null; diff --git a/modules/biobank/php/specimencontroller.class.inc b/modules/biobank/php/specimencontroller.class.inc index 32579d6a4b2..421badb6edc 100644 --- a/modules/biobank/php/specimencontroller.class.inc +++ b/modules/biobank/php/specimencontroller.class.inc @@ -197,7 +197,7 @@ class SpecimenController } break; case 'update': - if (!$this->user->hasPermission('biobank_specimen_update')) { + if (!$this->user->hasPermission('biobank_specimen_edit')) { throw new Forbidden('Specimen: Update Permission Denied'); } break; diff --git a/modules/biobank/sql/data.sql b/modules/biobank/sql/data.sql deleted file mode 100644 index 77e1b7c132d..00000000000 --- a/modules/biobank/sql/data.sql +++ /dev/null @@ -1,67 +0,0 @@ --- MySQL dump 10.13 Distrib 8.0.39, for Linux (x86_64) --- --- Host: mariadb-dev0.acelab.ca Database: hrabalais_dev --- ------------------------------------------------------ --- Server version 5.5.5-10.5.26-MariaDB - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!50503 SET NAMES utf8mb4 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Dumping data for table `biobank_unit` --- - -LOCK TABLES `biobank_unit` WRITE; -/*!40000 ALTER TABLE `biobank_unit` DISABLE KEYS */; -INSERT INTO `biobank_unit` VALUES (2,'mL'),(8,'piece'),(3,'x 10e6 cells'),(1,'µL'); -/*!40000 ALTER TABLE `biobank_unit` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `biobank_specimen_process` --- - -LOCK TABLES `biobank_specimen_process` WRITE; -/*!40000 ALTER TABLE `biobank_specimen_process` DISABLE KEYS */; -INSERT INTO `biobank_specimen_process` VALUES (2,'Analysis'),(1,'Collection'),(3,'Preparation'); -/*!40000 ALTER TABLE `biobank_specimen_process` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `biobank_container_status` --- - -LOCK TABLES `biobank_container_status` WRITE; -/*!40000 ALTER TABLE `biobank_container_status` DISABLE KEYS */; -INSERT INTO `biobank_container_status` VALUES (1,'Available'),(4,'Discarded'),(3,'Dispensed'),(2,'Reserved'),(5,'Shipped'); -/*!40000 ALTER TABLE `biobank_container_status` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `shipment_status` --- - -LOCK TABLES `shipment_status` WRITE; -/*!40000 ALTER TABLE `shipment_status` DISABLE KEYS */; -INSERT INTO `shipment_status` VALUES (10,'cancelled'),(1,'created'),(7,'received'),(13,'returned'),(4,'shipped'); -/*!40000 ALTER TABLE `shipment_status` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2024-11-08 12:10:26 diff --git a/modules/biobank/sql/permissions.sql b/modules/biobank/sql/permissions.sql deleted file mode 100644 index 1b27afb2cb7..00000000000 --- a/modules/biobank/sql/permissions.sql +++ /dev/null @@ -1,33 +0,0 @@ --- SQL Patch: Add Biobank Module and Permissions - --- Start a transaction to ensure atomicity -START TRANSACTION; - --- 1. Insert 'biobank' module if it doesn't already exist and set it to active -INSERT INTO `modules` (`Name`, `Active`) -VALUES ('biobank', 'Y') -ON DUPLICATE KEY UPDATE `Active` = 'Y'; - --- 2. Retrieve the moduleID of the 'biobank' module -SET @biobank_module_id = (SELECT `ID` FROM `modules` WHERE `Name` = 'biobank' LIMIT 1); - --- 3. Retrieve the categoryID for 'Permission' from permissions_category table -SET @permission_category_id = (SELECT `ID` FROM `permissions_category` WHERE `Description` = 'Permission' LIMIT 1); - --- 4. Insert permissions associated with the 'biobank' module --- Using INSERT IGNORE to prevent duplicate entries based on the UNIQUE constraint on `code` -INSERT IGNORE INTO `permissions` (`code`, `description`, `moduleID`, `action`, `categoryID`) VALUES -('biobank_specimen_view', 'View Specimen Data', @biobank_module_id, 'View', @permission_category_id), -('biobank_specimen_create', 'Create Specimens', @biobank_module_id, 'Create', @permission_category_id), -('biobank_specimen_update', 'Edit/Upload Specimen Data', @biobank_module_id, 'Edit/Upload', @permission_category_id), -('biobank_specimen_alter', 'Alter Specimen Data', @biobank_module_id, 'Edit', @permission_category_id), -('biobank_container_view', 'View Container Data', @biobank_module_id, 'View', @permission_category_id), -('biobank_container_create', 'Create Containers', @biobank_module_id, 'Create', @permission_category_id), -('biobank_container_update', 'Edit Container Data', @biobank_module_id, 'Edit', @permission_category_id), -('biobank_pool_view', 'View Pool Data', @biobank_module_id, 'View', @permission_category_id), -('biobank_pool_create', 'Create Pools', @biobank_module_id, 'Create', @permission_category_id), -('biobank_fullsiteaccess', 'Full Site Access', @biobank_module_id, 'View', @permission_category_id), -('biobank_fullprojectaccess', 'Full Project Access', @biobank_module_id, 'View', @permission_category_id); - --- Commit the transaction to apply changes -COMMIT;