Skip to content

Commit f3fb82d

Browse files
authored
Prima cassette project (#1332)
* Prima cassette project * Prima cassette project updated with the queries.
1 parent b285ec3 commit f3fb82d

6 files changed

Lines changed: 218 additions & 208 deletions

File tree

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--Copy Prima tables into Prime. Runs daily at 3AM -->
3-
<!--Added By Kollil, 7/26/2021 -->
2+
<!--Copy Prima tables into Prime. Runs daily at 9am and 5pm, Refer to tkt #11937 -->
3+
<!--Added By Kollil, 7/26/2021 , Modified by Kollil, 03-02-2025-->
44
<!--NOTES: The source DB name is "Prima" in production and "PrimaTest" on other servers -->
55

66
<etl xmlns="http://labkey.org/etl/xml">
77
<name>PrimatoPrime</name>
8-
<description>Transfers data from the Prima tables to the Prime tables in ONPRC_EHR</description>
8+
<description>Transfers data from the Prima tables to the Prime in ONPRC_EHR</description>
99
<transforms>
1010
<transform id="step1a">
11-
<description>Transfer to UserPersons</description>
12-
<source queryName="UserPersons" schemaName="Prima"/>
13-
<destination queryName="Prima_UserPersons" schemaName="ONPRC_EHR" targetOption="truncate"/>
11+
<description>Transfer CassetteBases into onprc_ehr table</description>
12+
<source queryName="CassetteBases" schemaName="Prima"/>
13+
<destination queryName="Prima_CassetteBases" schemaName="onprc_ehr" targetOption="truncate"/>
1414
</transform>
1515
<transform id="step2a">
16-
<description>Transfer to SurgicalWheels</description>
17-
<source queryName="SurgicalWheels" schemaName="Prima"/>
18-
<destination queryName="Prima_SurgicalWheels" schemaName="ONPRC_EHR" targetOption="truncate"/>
16+
<description>Transfer to TissueCollections</description>
17+
<source queryName="TissueCollections" schemaName="Prima"/>
18+
<destination queryName="Prima_TissueCollections" schemaName="onprc_ehr" targetOption="truncate"/>
1919
</transform>
2020
<transform id="step3a">
21-
<description>Transfer to StainTests</description>
22-
<source queryName="StainTests" schemaName="Prima"/>
23-
<destination queryName="Prima_StainTests" schemaName="ONPRC_EHR" targetOption="truncate"/>
21+
<description>Transfer to Animals</description>
22+
<source queryName="Animals" schemaName="Prima"/>
23+
<destination queryName="Prima_Animals" schemaName="onprc_ehr" targetOption="truncate"/>
2424
</transform>
2525
<transform id="step4a">
26-
<description>Transfer to SlideBases</description>
27-
<source queryName="SlideBases" schemaName="Prima"/>
28-
<destination queryName="Prima_SlideBases" schemaName="ONPRC_EHR" targetOption="truncate"/>
29-
</transform>
30-
<transform id="step5a">
3126
<description>Transfer to CaseBase</description>
3227
<source queryName="CaseBase" schemaName="Prima"/>
3328
<destination queryName="Prima_CaseBase" schemaName="ONPRC_EHR" targetOption="truncate"/>
3429
</transform>
35-
<transform id="step6a">
36-
<description>Transfer to CassetteEvents</description>
37-
<source queryName="CassetteEvents" schemaName="Prima"/>
38-
<destination queryName="Prima_CassetteEvents" schemaName="ONPRC_EHR" targetOption="truncate"/>
39-
</transform>
40-
<transform id="step7a">
41-
<description>Transfer to CassetteEventLocations</description>
42-
<source queryName="CassetteEventLocations" schemaName="Prima"/>
43-
<destination queryName="Prima_CassetteEventLocations" schemaName="ONPRC_EHR" targetOption="truncate"/>
44-
</transform>
45-
<transform id="step8a">
46-
<description>Transfer to CassetteBases</description>
47-
<source queryName="CassetteBases" schemaName="Prima"/>
48-
<destination queryName="Prima_CassetteBases" schemaName="ONPRC_EHR" targetOption="truncate"/>
49-
</transform>
50-
<transform id="step9a">
51-
<description>Transfer to LabstationTypes</description>
52-
<source queryName="LabstationTypes" schemaName="Prima"/>
53-
<destination queryName="Prima_LabstationTypes" schemaName="ONPRC_EHR" targetOption="truncate"/>
54-
</transform>
55-
<transform id="step10a">
56-
<description>Transfer to SlideEvents</description>
57-
<source queryName="SlideEvents" schemaName="Prima"/>
58-
<destination queryName="Prima_SlideEvents" schemaName="ONPRC_EHR" targetOption="truncate"/>
59-
</transform>
60-
<transform id="step11a">
61-
<description>Transfer to SlideEventLoctions</description>
62-
<source queryName="SlideEventLocations" schemaName="Prima"/>
63-
<destination queryName="Prima_SlideEventLocations" schemaName="ONPRC_EHR" targetOption="truncate"/>
64-
</transform>
30+
6531

6632
</transforms>
6733
<schedule>
68-
<!--Runs daily 3AM-->
69-
<cron expression="0 50 03 * * ?"/>
34+
<!--Runs daily 9Am and 5pm-->
35+
<cron expression="0 0 9,17 * * ?"/>
7036
</schedule>
7137

7238
</etl>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Added by Kollil April, 2025
3+
This query will join the cassette data with EHR data. Refer to tkt #11937
4+
*/
5+
Select
6+
sd.id, -- ONPRC AnimalId
7+
pc.CassetteAccessionNumber,
8+
pc.TissueType,
9+
pc.TissueTypeAbbreviation,
10+
pc.TissueAlternateIdentifier
11+
From PrimatoPrimeCassetteData pc, study.Demographics sd
12+
Where pc.id = sd.id
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Added by Kollil April, 2025
3+
This query will extract the cassette data from the ETLed db tables from Prima db. Refer to tkt #11937
4+
*/
5+
SELECT
6+
an.Identifier as Id,
7+
--an.AlternateIdentifier as AnimalAlternateIdentifier,
8+
ctb.SavedIdentifier as CassetteAccessionNumber,
9+
ctb.AlternateIdentifier as TissueAlternateIdentifier,
10+
tc.Title as TissueType,
11+
tc.Abbreviation as TissueTypeAbbreviation
12+
--cb.Id as CaseId
13+
FROM Prima_CassetteBases as ctb
14+
join Prima_TissueCollections tc on ctb.TissueCollectionId = tc.Id
15+
join Prima_CaseBase cb on cb.Id = ctb.CaseBaseId
16+
Join Prima_Animals an on cb.AnimalId = an.Id
17+
Where ctb.SavedIdentifier NOT LIKE 'IPC%'
18+
And ctb.SavedIdentifier NOT LIKE '19[0-9][0-9]%'
19+
And ctb.SavedIdentifier NOT LIKE '20[0-9][0-9]%'
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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

Comments
 (0)