Skip to content

Commit bb43d53

Browse files
snprc ExportNewAnimalData to CAMP (#260)
* snprc ExportNewAnimalData to CAMP 07.09.2020 * snprc ExportNewAnimalData to CAMP Cage position added 07.09.2020
1 parent 5394269 commit bb43d53

3 files changed

Lines changed: 91 additions & 10 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<etl xmlns="http://labkey.org/etl/xml">
2+
<name>ExportNewAnimalData</name>
3+
<description>Sync New Animal Data to CAMP</description>
4+
<transforms>
5+
<transform id="step1" type="org.labkey.di.pipeline.TransformTask">
6+
<description>Copy to target</description>
7+
<source schemaName="snprc_ehr" queryName="ExportNewAnimalData" />
8+
<destination schemaName="snprcSrc" queryName="NewAnimalData" bulkLoad="true" targetOption="merge">
9+
<alternateKeys>
10+
<column name="objectid"/>
11+
</alternateKeys>
12+
<columnTransforms>
13+
<column source="createdBy" target="createdBy" transformClass="org.labkey.snprc_ehr.columnTransforms.UserTransform"/>
14+
<column source="modifiedBy" target="modifiedBy" transformClass="org.labkey.snprc_ehr.columnTransforms.UserTransform"/>
15+
</columnTransforms>
16+
</destination>
17+
</transform>
18+
</transforms>
19+
<incrementalFilter className="ModifiedSinceFilterStrategy" timestampColumnName="modified">
20+
</incrementalFilter>
21+
<schedule>
22+
<poll interval="365d" />
23+
</schedule>
24+
</etl>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/********************************************************
2+
Query will feed the export ETL back to CAMP.
3+
CampNewAnimalData
4+
5+
6+
srr 07.07.2020
7+
********************************************************/
8+
9+
SELECT
10+
n.Id,
11+
n.BirthDate,
12+
n.BirthCode as Bd_Status,
13+
n.AcquisitionType,
14+
n.AcqDate AS AcquisitionDate,
15+
n.species,
16+
n.Gender,
17+
n.sire,
18+
n.dam,
19+
n.Diet as DietInt,
20+
n.Diet.diet AS DietText,
21+
--CAST(diet AS INTEGER) AS DietTid,
22+
n.pedigree.name AS PedigreeText,
23+
n.pedigree AS PedigreeInt,
24+
--n.Colony AS ColonyInt, -- not in valid_colony
25+
n.Colony.Name AS ColonyText,
26+
n.AnimalAccount,
27+
--n.AnimalAccount.Account AS AccountText,
28+
--CAST(n.AnimalAccount AS INTEGER) AnimalAccountInt,
29+
--n.room, -- not in valid_locations
30+
n.IACUC,
31+
n.room.room,
32+
n.cage,
33+
n.OwnerInstitution,
34+
n.ResponsibleInstitution,
35+
n.Objectid,
36+
n.Modified,
37+
n.ModifiedBy,
38+
n.ModifiedBy.email AS ModifiedByEmail,
39+
n.Created,
40+
n.CreatedBy,
41+
n.CreatedBy.email AS CreatedByEmail,
42+
n.CreatedBy.displayname
43+
44+
FROM snprc_ehr.NewAnimalData n

snprc_ehr/resources/source_queries/create_CAMP_NewAnimalData.sql

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,55 @@ Creates TAC schema if needed, then table to hold new animal data
44
55
66
06.22.2020 srr
7+
8+
Changed the schema back to labkey_etl for simplicity.
9+
May revert back to TAC schema at a later date if there
10+
are more tables and better organization is needed.
11+
Left PK as PK_TAC_NEWANIMALDATA
12+
07.06.2020 srr
713
*******************************************************************/
814

15+
/*
916
-- Create TAC schema if not exists
1017
IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = 'TAC')
1118
BEGIN
1219
-- The schema must be run in its own batch!
1320
EXEC( 'CREATE SCHEMA TAC' );
1421
END
22+
*/
1523

24+
-- NOTE SQL Server 2016 and after
25+
DROP TABLE IF EXISTS labkey_etl.NewAnimalData
1626

17-
18-
CREATE TABLE TAC.NewAnimalData
27+
CREATE TABLE labkey_etl.NewAnimalData
1928
(
2029
Id VARCHAR(6) NOT NULL,
2130
BirthDate DATETIME NULL,
22-
BirthDateType INT NULL,
31+
Bd_Status INT NULL,
2332
AcquisitionType INT NULL,
24-
AcqDate DATETIME NULL, -- Start date for Data Tables
33+
AcquisitionDate DATETIME NULL, -- Start date for Data Tables
2534
Gender CHAR(1) NULL,
2635
Sire VARCHAR(6) NULL,
2736
Dam VARCHAR(6) NULL,
2837
Species VARCHAR(3) NULL,
29-
Colony VARCHAR(30) NULL,
30-
Pedigree VARCHAR(20) NULL,
38+
ColonyText VARCHAR(30),
39+
PedigreeText VARCHAR(20) NULL,
40+
PedigreeInt INT NULL,
3141
AnimalAccount VARCHAR(15) NULL,
3242
OwnerInstitution INT NULL,
3343
ResponsibleInstitution INT NULL,
34-
Area VARCHAR(10) NULL, --building
3544
Room VARCHAR(10) NULL, -- Bay
3645
Cage INT NULL,
37-
Diet VARCHAR(20) NULL,
46+
DietInt INT NULL,
47+
DietText VARCHAR(20) NULL,
3848
IACUC VARCHAR(7) NULL,
3949
Created DATETIME NULL,
40-
CreatedBy VARCHAR(128) NULL,
50+
CreatedBy Int NULL,
51+
CreatedByEmail VARCHAR(128) NULL,
4152
Modified DATETIME NULL,
42-
ModifiedBy VARCHAR(128) NULL,
53+
ModifiedBy Int NULL,
54+
ModifiedByEmail varchar(128) NULL,
55+
ProcessedDate DateTime NULL,
4356
Container UNIQUEIDENTIFIER NOT NULL,
4457
objectid UNIQUEIDENTIFIER NOT NULL,
4558
CONSTRAINT PK_TAC_NEWANIMALDATA

0 commit comments

Comments
 (0)