Skip to content

Commit c8ab41f

Browse files
Add the 'Name' alias directly in the Treatment Schedule query (#574)
1 parent ad6ffd8 commit c8ab41f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

nirc_ehr/resources/queries/study/treatmentSchedule.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
SELECT
33
d.id,
4+
d_alias.alias AS Name,
45
d.calculated_status,
56
s.*,
67
s.objectid AS treatmentid,
@@ -63,6 +64,6 @@ JOIN(
6364

6465
) s ON (s.animalid = d.id)
6566
LEFT JOIN study.drug drug ON s.objectid = drug.treatmentid AND s.date = IFDEFINED(drug.scheduledDate)
66-
67+
LEFT JOIN (SELECT Id, GROUP_CONCAT(alias, ', ') alias FROM alias WHERE category.title = 'Name' GROUP BY Id) d_alias ON d.id = d_alias.id
6768
WHERE (d.lastDayatCenter IS NULL OR d.lastDayAtCenter > s.enddate OR s.enddate IS NULL)
6869
AND s.date >= s.startDate AND (s.enddate IS NULL OR s.date <= s.enddate)

0 commit comments

Comments
 (0)