From f793763efc1c326193ede0184dc1ad112059127f Mon Sep 17 00:00:00 2001 From: NIRC-IT <87669815+NIRC-IT@users.noreply.github.com> Date: Mon, 27 Jul 2026 09:44:16 -0500 Subject: [PATCH] Updated source query to pull last location instead of all locations. (#731) ## Rationale The source query for the orchard file generator pulled the location history for an animal instead of the last location that then sent the location history to the LIS. ## Changes Change housing table join to demographicsLastLocation join. --- nirc_ehr/resources/queries/study/orchardData.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nirc_ehr/resources/queries/study/orchardData.sql b/nirc_ehr/resources/queries/study/orchardData.sql index 7597aa15..74b40b5d 100644 --- a/nirc_ehr/resources/queries/study/orchardData.sql +++ b/nirc_ehr/resources/queries/study/orchardData.sql @@ -11,8 +11,8 @@ SELECT pa.protocol.title as protocol, InitCap(pa.protocol.InvestigatorId.LastName) || ', ' || InitCap(pa.protocol.InvestigatorId.FirstName) as PI, InitCap(pa.protocol.AuthorId.LastName) || ', ' || InitCap(pa.protocol.AuthorId.FirstName) as Vet, - h.cage.cage as cage, + dlh.cage.cage as cage, d.calculated_status as alive FROM demographics d -LEFT JOIN housing h ON d.Id = h.Id +LEFT JOIN demographicsLastHousing dlh ON d.Id = dlh.Id LEFT JOIN protocolAssignment pa ON d.Id = pa.Id AND pa.endDate is null \ No newline at end of file