1+ -- =======================================================================================================================================
2+ -- Author: Lakshmi Kolli
3+ -- Create date: 2025-03-04
4+ -- Description: Db tables creation for Prima cassette project. Created all the Prima tables in Prime onprc_ehr schema folder.
5+ -- Refer to tkt #11937
6+ -- =======================================================================================================================================
7+
8+ -- Drop if exists. We are using these 4 tables for the Cassette Project
9+ EXEC core .fn_dropifexists ' Prima_Animals' ,' onprc_ehr' ,' TABLE' ;
10+ EXEC core .fn_dropifexists ' Prima_CassetteBases' ,' onprc_ehr' ,' TABLE' ; -- Drop this table and create again
11+ EXEC core .fn_dropifexists ' Prima_TissueCollections' ,' onprc_ehr' ,' TABLE' ;
12+ EXEC core .fn_dropifexists ' Prima_CaseBase' ,' onprc_ehr' ,' TABLE' ; -- Drop this table and create again
13+
14+ -- Drop these tables permanently. We are not using these tables in onprc_ehr.
15+ EXEC core .fn_dropifexists ' Prima_VeterinaryResearchCase' ,' onprc_ehr' ,' TABLE' ; -- This table doesn't exist anymore in Prima DB
16+ EXEC core .fn_dropifexists ' Prima_CassetteEvents' ,' onprc_ehr' ,' TABLE' ;
17+ EXEC core .fn_dropifexists ' Prima_CassetteEventLocations' ,' onprc_ehr' ,' TABLE' ;
18+ EXEC core .fn_dropifexists ' Prima_LabstationTypes' ,' onprc_ehr' ,' TABLE' ;
19+ EXEC core .fn_dropifexists ' Prima_SlideBases' ,' onprc_ehr' ,' TABLE' ;
20+ EXEC core .fn_dropifexists ' Prima_SlideEvents' ,' onprc_ehr' ,' TABLE' ;
21+ EXEC core .fn_dropifexists ' Prima_SlideEventLocations' ,' onprc_ehr' ,' TABLE' ;
22+ EXEC core .fn_dropifexists ' Prima_StainTests' ,' onprc_ehr' ,' TABLE' ;
23+ EXEC core .fn_dropifexists ' Prima_SurgicalWheels' ,' onprc_ehr' ,' TABLE' ;
24+ EXEC core .fn_dropifexists ' Prima_UserPersons' ,' onprc_ehr' ,' TABLE' ;
25+
26+ GO
27+
28+ -- Create tables
29+ -- 1. Animals table
30+ /* ***** Object: Table [onprc_ehr].[Prima_Animals] ******/
31+ CREATE TABLE [onprc_ehr].[Prima_Animals](
32+ [Id] [int] NOT NULL ,
33+ [AlternateIdentifier] [nvarchar](63 ) NULL ,
34+ [BreedId] [int] NULL ,
35+ [DateOfBirth] [datetime] NULL ,
36+ [FecesId] [int] NULL ,
37+ [Gender] [tinyint] NOT NULL ,
38+ [GeneTarget] [nvarchar](127 ) NULL ,
39+ [GeneticLine] [nvarchar](127 ) NULL ,
40+ [Genotype] [nvarchar](127 ) NULL ,
41+ [Identifier] [nvarchar](127 ) NULL ,
42+ [MannerOfDeathId] [int] NULL ,
43+ [RoomNumber] [nvarchar](9 ) NULL ,
44+ [SpeciesId] [int] NOT NULL ,
45+ [StomachContentsId] [int] NULL ,
46+ [StrainId] [int] NULL ,
47+ [DateOfDeath] [datetime] NULL ,
48+ [Created] [datetimeoffset](7 ) NOT NULL ,
49+ [OwnerId] [int] NULL ,
50+ [Perfuse] [bit] NOT NULL ,
51+ [SampleType] [tinyint] NOT NULL
52+ )
53+ ;
54+
55+ -- 2. TissueCollections table
56+ /* ***** Object: Table [onprc_ehr].[Prima_TissueCollections] ******/
57+ CREATE TABLE [onprc_ehr].[Prima_TissueCollections](
58+ [Id] [int] NOT NULL ,
59+ [Constant] [tinyint] NULL ,
60+ [IsWholeAnimal] [bit] NOT NULL ,
61+ [SpeciesId] [int] NOT NULL ,
62+ [SpecimenType] [int] NOT NULL ,
63+ [CreatedByUserId] [int] NOT NULL ,
64+ [Deleted] [datetimeoffset](7 ) NULL ,
65+ [DeletedByUserId] [int] NULL ,
66+ [NextVersionId] [int] NULL ,
67+ [PreviousVersionId] [int] NULL ,
68+ [Title] [nvarchar](127 ) NOT NULL ,
69+ [Created] [datetimeoffset](7 ) NOT NULL ,
70+ [LastModified] [timestamp] NOT NULL ,
71+ [Abbreviation] [nvarchar](127 ) NULL
72+ )
73+ ;
74+
75+ -- 3. CaseBase table
76+ /* ***** Object: Table [onprc_ehr].[Prima_CaseBase] ******/
77+ CREATE TABLE [onprc_ehr].[Prima_CaseBase](
78+ [Id] [int] NOT NULL ,
79+ [DifferentialDiagnosisId] [int] NULL ,
80+ [PathologistId] [int] NULL ,
81+ [PriorityLevelId] [int] NOT NULL ,
82+ [ResidentPathologistId] [int] NULL ,
83+ [SerialNumber] [int] NOT NULL ,
84+ [SurgeryDate] [datetime] NULL ,
85+ [SurgicalWheelId] [int] NOT NULL ,
86+ [Created] [datetimeoffset](7 ) NOT NULL ,
87+ [ResearcherId] [int] NULL ,
88+ [StudyId] [int] NULL ,
89+ [Discriminator] [nvarchar](128 ) NULL ,
90+ [StudyPhaseId] [int] NULL ,
91+ [CohortId] [int] NULL ,
92+ [SavedIdentifier] [nvarchar](max ) NULL ,
93+ [Status] [tinyint] NOT NULL ,
94+ [AlternateIdentifier] [nvarchar](24 ) NULL ,
95+ [SurgeryLocationId] [int] NULL ,
96+ [ResearchPatientId] [int] NULL ,
97+ [AnimalId] [int] NULL ,
98+ [ClinicalPatientId] [int] NULL ,
99+ [SurgeryAge] [nvarchar](31 ) NULL
100+ )
101+ ;
102+
103+ -- 4. CassetteBases table
104+ /* ***** Object: Table [onprc_ehr].[Prima_CassetteBases] ******/
105+ CREATE TABLE [onprc_ehr].[Prima_CassetteBases](
106+ [Id] [bigint] NOT NULL ,
107+ [CassetteColorId] [int] NOT NULL ,
108+ [EmbeddingInstructionId] [int] NOT NULL ,
109+ [HasTissue] [bit] NOT NULL ,
110+ [ProtocolCassetteId] [int] NULL ,
111+ [SpecimenBaseId] [bigint] NOT NULL ,
112+ [TissueCollectionId] [int] NULL ,
113+ [TissueProcessorProgramId] [int] NULL ,
114+ [TissueQuantity] [smallint] NOT NULL ,
115+ [CaseBaseId] [int] NOT NULL ,
116+ [PriorityLevelId] [int] NOT NULL ,
117+ [QcStatus] [tinyint] NOT NULL ,
118+ [SurgicalSerialPart] [smallint] NOT NULL ,
119+ [Created] [datetimeoffset](7 ) NOT NULL ,
120+ [OrderedStatus] [tinyint] NOT NULL ,
121+ [SavedIdentifier] [nvarchar](24 ) NULL ,
122+ [BarcodeContent] [nvarchar](72 ) NULL ,
123+ [AlternateIdentifier] [nvarchar](63 ) NULL ,
124+ [PrintStatus] [tinyint] NOT NULL ,
125+ [ItemStatus] [smallint] NOT NULL ,
126+ [Hazard] [tinyint] NOT NULL ,
127+ [CurrentContainerId] [int] NULL
128+ )
129+ ;
130+
131+ GO
0 commit comments