Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions nirc_ehr/resources/queries/study/orchardData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
SELECT
SELECT DISTINCT
d.Id,
d.gender,
d.birth,
d.species.scientific_name as species,
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,
dlh.cage.cage as cage,
dlp.protocol.title as protocol,
InitCap(dlp.protocol.InvestigatorId.LastName) || ', ' || InitCap(dlp.protocol.InvestigatorId.FirstName) as PI,
InitCap(dlp.protocol.AuthorId.LastName) || ', ' || InitCap(dlp.protocol.AuthorId.FirstName) as Vet,
d.Id.lastHousing.cage.cage as cage,
d.calculated_status as alive
FROM demographics d
LEFT JOIN demographicsLastHousing dlh ON d.Id = dlh.Id
LEFT JOIN protocolAssignment pa ON d.Id = pa.Id AND pa.endDate is null
LEFT JOIN demographicsLastProtocol dlp ON d.Id = dlp.Id
13 changes: 8 additions & 5 deletions nirc_ehr/src/org/labkey/nirc_ehr/NIRCOrchardFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,22 @@ public void run()
else if (Objects.equals(rs.getString("gender"), "3"))
sb.append("M");
else sb.append("U");
sb.append("||NHP|"); //could change if more species
sb.append(rs.getString("cage"));
sb.append("||NHP|"); //build out if other than non-human primate
sb.append(rs.getString("cage") == null ? "" : rs.getString("cage"));
sb.append("^New Iberia^LA^70506|||||||||||");
sb.append(rs.getString("species")).append("|");
sb.append(rs.getString("protocol")).append("|||||||");
if (Objects.equals(rs.getString("alive"),"Shipped"))
sb.append("OFFSITE").append("|||||||");
else
sb.append(rs.getString("protocol") == null ? "" : rs.getString("protocol")).append("|||||||");
if (Objects.equals(rs.getString("alive"), "Alive"))
sb.append("N");
else
sb.append("Y");
sb.append(System.lineSeparator());
sb.append("ZCP|Veterinarian|").append(rs.getString("Vet")).append("|");
sb.append("ZCP|Veterinarian|").append(rs.getString("Vet") == null ? "" : rs.getString("Vet")).append("|");
sb.append(System.lineSeparator());
sb.append("PD1||||").append(rs.getString("PI")).append("|");
sb.append("PD1||||").append(rs.getString("PI") == null ? "" : rs.getString("PI")).append("|");
sb.append(System.lineSeparator());
});

Expand Down