Skip to content

Commit 4abafb7

Browse files
fb_snprc update for NAD (#354)
* Updated NewAnimalData for SourceInstitutionLocation 04.05.2021 srr * Updated NewAnimalData for SourceInstitutionLocation Added logic for adding actual location 1 minute later to accommodate the source location move. 04.06.2021 srr
1 parent b176c6e commit 4abafb7

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

snprc_ehr/resources/source_queries/create_CAMP_NewAnimalData.sql

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,34 @@ FROM inserted i
274274
ON i.tid = t.tid;
275275

276276

277-
278277
-- move to SNPRC loc
278+
-- move to SNPRC loc
279+
-- Move to source location for non TxBiomed births
280+
/********************************
281+
To allow for a move to a source location, actual
282+
onCampus move will be 1 minute after the AcquisitionDate
283+
srr 04.05.2021
284+
********************************/
285+
-- move to ori source location
286+
IF UPDATE(SourceInstitutionLocation)
287+
BEGIN
288+
INSERT INTO dbo.location
289+
( id ,
290+
move_date_tm ,
291+
location,
292+
user_name,
293+
entry_date_tm
294+
)
295+
SELECT t.id,
296+
i.AcquisitionDate,
297+
CAST(i.SourceInstitutionLocation AS NUMERIC(7,2)),
298+
t.CreatedBy, @insertDateTime
299+
FROM inserted i
300+
INNER JOIN @TxIds t
301+
ON i.tid = t.tid
302+
WHERE i.SourceInstitutionLocation IS NOT NULL;
303+
END
304+
-- Current Location
279305
INSERT INTO dbo.location
280306
( id ,
281307
move_date_tm ,
@@ -284,12 +310,18 @@ INSERT INTO dbo.location
284310
entry_date_tm
285311
)
286312
-- insert shim
287-
SELECT t.id, i.AcquisitionDate, CAST(i.Room AS NUMERIC(7,2)),
313+
SELECT t.id,
314+
CASE WHEN i.SourceInstitutionLocation IS NOT NULL THEN DATEADD(MINUTE,1, i.AcquisitionDate)
315+
ELSE i.AcquisitionDate
316+
END AcquisitionDate,
317+
CAST(i.Room AS NUMERIC(7,2)),
288318
t.CreatedBy, @insertDateTime
289319
FROM inserted i
290320
INNER JOIN @TxIds t
291321
ON i.tid = t.tid;
292322

323+
324+
293325
-- add Primary ID to id_history
294326
INSERT INTO dbo.id_history
295327
( sfbr_id ,

0 commit comments

Comments
 (0)