Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions snprc_ehr/resources/source_queries/create_CAMP_NewAnimalData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,34 @@ FROM inserted i
ON i.tid = t.tid;



-- move to SNPRC loc
-- move to SNPRC loc
-- Move to source location for non TxBiomed births
/********************************
To allow for a move to a source location, actual
onCampus move will be 1 minute after the AcquisitionDate
srr 04.05.2021
********************************/
-- move to ori source location
IF UPDATE(SourceInstitutionLocation)
BEGIN
INSERT INTO dbo.location
( id ,
move_date_tm ,
location,
user_name,
entry_date_tm
)
SELECT t.id,
i.AcquisitionDate,
CAST(i.SourceInstitutionLocation AS NUMERIC(7,2)),
t.CreatedBy, @insertDateTime
FROM inserted i
INNER JOIN @TxIds t
ON i.tid = t.tid
WHERE i.SourceInstitutionLocation IS NOT NULL;
END
-- Current Location
INSERT INTO dbo.location
( id ,
move_date_tm ,
Expand All @@ -284,12 +310,18 @@ INSERT INTO dbo.location
entry_date_tm
)
-- insert shim
SELECT t.id, i.AcquisitionDate, CAST(i.Room AS NUMERIC(7,2)),
SELECT t.id,
CASE WHEN i.SourceInstitutionLocation IS NOT NULL THEN DATEADD(MINUTE,1, i.AcquisitionDate)
ELSE i.AcquisitionDate
END AcquisitionDate,
CAST(i.Room AS NUMERIC(7,2)),
t.CreatedBy, @insertDateTime
FROM inserted i
INNER JOIN @TxIds t
ON i.tid = t.tid;



-- add Primary ID to id_history
INSERT INTO dbo.id_history
( sfbr_id ,
Expand Down