Skip to content

Commit ccf48dc

Browse files
Merge 25.7 to 25.11
2 parents eafd517 + ca217d6 commit ccf48dc

File tree

5 files changed

+89
-17
lines changed

5 files changed

+89
-17
lines changed

snprc_ehr/resources/queries/study/BrowseDataSets.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ UNION
6868
select 'ehr' as schema, 'Colony Management' as CategoryId,'Kinship' as Label, 'kinship' as Name, true as ShowByDefault, true as isAnimal
6969
UNION
7070
select 'ehr' as schema, 'Colony Management' as CategoryId,'Project' as Label, 'project' as Name, true as ShowByDefault, false as isAnimal
71+
UNION
72+
select 'study' as schema, 'Colony Management' as CategoryId,'Offspring' as Label, 'demographicsOffspring' as Name, true as ShowByDefault, true as isAnimal
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2017-2018 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
SELECT
7+
d.Id AS Id,
8+
h.date as FirstHousingDate,
9+
h.room as FirstHousingRoom,
10+
h.room.area.description as FirstHousingRoomDescription
11+
FROM study.demographics d
12+
13+
14+
--date of first housing
15+
LEFT JOIN study.housing as h on h.id = d.id and h.qcstate.publicdata = true
16+
and h.date = (select min(c1.date) from study.housing as c1
17+
where h.id = c1.id)

snprc_ehr/src/org/labkey/snprc_ehr/SNPRC_EHRModule.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import org.labkey.snprc_ehr.demographics.CurrentDietDemographicsProvider;
6666
import org.labkey.snprc_ehr.demographics.CurrentPedigreeDemographicsProvider;
6767
import org.labkey.snprc_ehr.demographics.DeathsDemographicsProvider;
68+
import org.labkey.snprc_ehr.demographics.EarliestHousingDemographicsProvider;
6869
import org.labkey.snprc_ehr.demographics.IdHistoryDemographicsProvider;
6970
import org.labkey.snprc_ehr.demographics.LastBcsDemographicsProvider;
7071
import org.labkey.snprc_ehr.demographics.LastHousingDemographicsProvider;
@@ -195,6 +196,9 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
195196
EHRService.get().registerDemographicsProvider(new LastHousingDemographicsProvider(this));
196197
EHRService.get().registerDemographicsProvider(new LastBcsDemographicsProvider(this));
197198

199+
// Commented out until we need to add the EarliestHousing to the snapshot view. tjh
200+
//EHRService.get().registerDemographicsProvider(new EarliestHousingDemographicsProvider(this));
201+
198202
EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "Find Animals Housed In A Given Room/Cage At A Specific Time", this, DetailsURL.fromString("/ehr-housingOverlaps.view?groupById=1"), "Commonly Used Queries");
199203
EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.animalSearch, "Population Summary By Species, Gender and Age", this, DetailsURL.fromString("/query-executeQuery.view?schemaName=study&query.queryName=colonyPopulationByAge"), "Other Searches");
200204
EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.animalSearch, "Find Animals Housed At The Center Over A Date Range", this, DetailsURL.fromString("/ehr-housingOverlaps.view?groupById=1"), "Other Searches");
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.labkey.snprc_ehr.demographics;
2+
3+
import org.labkey.api.ehr.demographics.AbstractListDemographicsProvider;
4+
import org.labkey.api.module.Module;
5+
import org.labkey.api.query.FieldKey;
6+
7+
import java.util.Collection;
8+
import java.util.HashSet;
9+
import java.util.Set;
10+
11+
public class EarliestHousingDemographicsProvider extends AbstractListDemographicsProvider
12+
13+
{
14+
15+
public EarliestHousingDemographicsProvider(Module owner)
16+
{
17+
super(owner, "study", "demographicsEarliestHousing", "earliestHousing");
18+
_supportsQCState = false;
19+
}
20+
21+
@Override
22+
public String getName()
23+
{
24+
return "Earliest Housing";
25+
}
26+
27+
@Override
28+
protected Collection<FieldKey> getFieldKeys()
29+
{
30+
Set<FieldKey> keys = new HashSet<>();
31+
keys.add(FieldKey.fromString("FirstHousingDate"));
32+
keys.add(FieldKey.fromString("FirstHousingRoom"));
33+
keys.add(FieldKey.fromString("FirstHousingRoomDescription"));
34+
35+
return keys;
36+
}
37+
38+
@Override
39+
public boolean requiresRecalc(String schema, String query)
40+
{
41+
return ("study".equalsIgnoreCase(schema) && "Housing".equalsIgnoreCase(query));
42+
}
43+
}

snprc_ehr/src/org/labkey/snprc_ehr/table/SNPRC_EHRCustomizer.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.labkey.snprc_ehr.SNPRC_EHRSchema;
4646
import org.labkey.snprc_ehr.helpers.CustomizerQueryProvider;
4747
import org.labkey.snprc_ehr.model.CalculatedColumn;
48-
4948
import static org.labkey.snprc_ehr.constants.QueryConstants.*;
5049

5150
import java.util.Calendar;
@@ -62,6 +61,7 @@ public class SNPRC_EHRCustomizer extends AbstractTableCustomizer
6261

6362
private Set<CalculatedColumn> calculatedColumns;
6463

64+
6565
public SNPRC_EHRCustomizer()
6666
{
6767
_provider = new CustomizerQueryProvider();
@@ -161,8 +161,14 @@ public void doTableSpecificCustomizations(AbstractTableInfo ti)
161161
*/
162162
if (matches(ti, "study", "Animal"))
163163
{
164+
UserSchema us = getEHRUserSchema(ti, STUDY_SCHEMA);
164165
customizeAnimalTable(ti);
166+
var col = getWrappedCol(us, ti, "earliestHousing", "demographicsEarliestHousing", ID_COLUMN, ID_COLUMN);
167+
col.setLabel("Housing - Earliest");
168+
col.setDescription("The calculates the earliest housing location for each living animal.");
169+
ti.addColumn(col);
165170
}
171+
166172
if (matches(ti, "study", "Animal Events") || matches(ti, "study", "encounters"))
167173
{
168174
customizeEncounterTable(ti);
@@ -444,35 +450,35 @@ private void customizeAnimalTable(AbstractTableInfo ds)
444450
}
445451
if (ds.getColumn("flags") == null)
446452
{
447-
var col = getWrappedCol(us, ds, "Flags", "demographicsActiveFlags", "Id", "Id");
453+
var col = getWrappedCol(us, ds, "Flags", "demographicsActiveFlags", ID_COLUMN, ID_COLUMN);
448454
col.setLabel("ActiveFlags");
449455
col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=ehr_lookups&queryName=flag_values&query.Id~eq=${Id}", ds.getContainerContext()));
450456
ds.addColumn(col);
451457
}
452458
if (ds.getColumn("parents") == null)
453459
{
454-
var col = getWrappedCol(us, ds, "parents", "demographicsParents", "Id", "Id");
460+
var col = getWrappedCol(us, ds, "parents", "demographicsParents", ID_COLUMN, ID_COLUMN);
455461
col.setLabel("Parents");
456462
ds.addColumn(col);
457463
}
458464

459465
if (ds.getColumn("mhcSummary") == null)
460466
{
461-
var col = getWrappedCol(us, ds, "mhcSummary", "mhcSummary", "Id", "Id");
467+
var col = getWrappedCol(us, ds, "mhcSummary", "mhcSummary", ID_COLUMN, ID_COLUMN);
462468
col.setLabel("mhcSummary");
463469
ds.addColumn(col);
464470
}
465471
if (ds.getColumn("totalOffspring") == null)
466472
{
467-
var col15 = getWrappedCol(us, ds, "totalOffspring", "demographicsTotalOffspring", "Id", "Id");
473+
var col15 = getWrappedCol(us, ds, "totalOffspring", "demographicsTotalOffspring", ID_COLUMN, ID_COLUMN);
468474
col15.setLabel("Number of Offspring");
469475
col15.setDescription("Shows the total offspring of each animal");
470476
ds.addColumn(col15);
471477
}
472478

473479
if (ds.getColumn("labworkHistory") == null)
474480
{
475-
var col = getWrappedCol(us, ds, "labworkHistory", "demographicsLabwork", "Id", "Id");
481+
var col = getWrappedCol(us, ds, "labworkHistory", "demographicsLabwork", ID_COLUMN, ID_COLUMN);
476482
col.setLabel("Labwork History");
477483
col.setDescription("Shows the date of last labwork for a subsets of tests");
478484
ds.addColumn(col);
@@ -481,15 +487,15 @@ private void customizeAnimalTable(AbstractTableInfo ds)
481487
//do we have freezer samples?
482488
if (ds.getColumn("freezerSamples") == null)
483489
{
484-
var col = getWrappedCol(us, ds, "freezerSamples", "demographicsFreezers", "Id", "Id");
490+
var col = getWrappedCol(us, ds, "freezerSamples", "demographicsFreezers", ID_COLUMN, ID_COLUMN);
485491
col.setLabel("Freezer Samples");
486492
col.setDescription("Shows the number of archived freezer samples");
487493
col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=study&queryName=freezerWorks&query.Id~eq=${Id}", ds.getContainerContext()));
488494
ds.addColumn(col);
489495
}
490496
if (ds.getColumn("idHistoryList") == null)
491497
{
492-
var col = getWrappedCol(us, ds, "idHistoryList", "demographicsIdHistory", "Id", "Id");
498+
var col = getWrappedCol(us, ds, "idHistoryList", "demographicsIdHistory", ID_COLUMN, ID_COLUMN);
493499
col.setLabel("Id Hx List");
494500
col.setDescription("List of Ids assigned to animal");
495501
col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=study&queryName=idHistory&query.Id~eq=${Id}", ds.getContainerContext()));
@@ -498,46 +504,46 @@ private void customizeAnimalTable(AbstractTableInfo ds)
498504

499505
if (ds.getColumn("activeAccounts") == null)
500506
{
501-
var col = getWrappedCol(us, ds, "activeAccounts", "demographicsActiveAccount", "Id", "Id");
507+
var col = getWrappedCol(us, ds, "activeAccounts", "demographicsActiveAccount", ID_COLUMN, ID_COLUMN);
502508
col.setLabel("Accounts - Active");
503509
col.setDescription("Shows all accounts to which the animal is actively assigned on the current date");
504510
ds.addColumn(col);
505511
}
506512

507513
if (ds.getColumn("packageCategory") == null)
508514
{
509-
var col = getWrappedCol(us, ds, "packageCategory", "demographicsPackageCategories", "Id", "Id");
515+
var col = getWrappedCol(us, ds, "packageCategory", "demographicsPackageCategories", ID_COLUMN, ID_COLUMN);
510516
col.setLabel("Package Category");
511517
col.setDescription("Shows the package category for procedures");
512518
ds.addColumn(col);
513519
}
514520

515521
if (ds.getColumn("activeAssignments") == null)
516522
{
517-
var col = getWrappedCol(us, ds, "activeAssignments", "demographicsActiveAssignment", "Id", "Id");
523+
var col = getWrappedCol(us, ds, "activeAssignments", "demographicsActiveAssignment", ID_COLUMN, ID_COLUMN);
518524
col.setLabel("IACUC Assignments - Active");
519525
col.setDescription("Shows all protocols to which the animal is actively assigned on the current date");
520526
ds.addColumn(col);
521527
}
522528

523529
if (ds.getColumn("activeGroups") == null)
524530
{
525-
var col = getWrappedCol(us, ds, "activeGroups", "demographicsAnimalGroups", "Id", "Id");
531+
var col = getWrappedCol(us, ds, "activeGroups", "demographicsAnimalGroups", ID_COLUMN, ID_COLUMN);
526532
col.setLabel("Animal Groups - Active");
527533
col.setDescription("Shows all groups to which the animal is actively assigned on the current date");
528534
ds.addColumn(col);
529535
}
530536

531537
if (ds.getColumn("MostRecentTBDate") == null)
532538
{
533-
var col = getWrappedCol(us, ds, "MostRecentTBDate", "demographicsMostRecentTBDate", "Id", "Id");
539+
var col = getWrappedCol(us, ds, "MostRecentTBDate", "demographicsMostRecentTBDate", ID_COLUMN, ID_COLUMN);
534540
col.setLabel("Most Recent TB");
535541
col.setDescription("Queries the most recent TB date for the animal.");
536542
ds.addColumn(col);
537543
}
538544
if (ds.getColumn("LastBCS") == null)
539545
{
540-
var col = getWrappedCol(us, ds, "LastBCS", "demographicsLastBCS", "Id", "Id");
546+
var col = getWrappedCol(us, ds, "LastBCS", "demographicsLastBCS", ID_COLUMN, ID_COLUMN);
541547
col.setLabel("Most Recent BCS");
542548
col.setDescription("Queries the most recent BCS value for the animal.");
543549
ds.addColumn(col);
@@ -546,7 +552,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
546552
// Change label and description 8/31/2017 tjh
547553
if (ds.getColumn("MostRecentArrival") != null)
548554
{
549-
var col = getWrappedCol(us, ds, "MostRecentArrival", "demographicsArrival", "Id", "Id");
555+
var col = getWrappedCol(us, ds, "MostRecentArrival", "demographicsArrival", ID_COLUMN, ID_COLUMN);
550556
ds.removeColumn(col);
551557
col.setLabel("Acquisition");
552558
col.setDescription("Calculates the earliest and most recent acquisition per animal.");
@@ -556,7 +562,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
556562
// Change label and description 8/31/2017 tjh
557563
if (ds.getColumn("MostRecentDeparture") != null)
558564
{
559-
var col = getWrappedCol(us, ds, "MostRecentDeparture", "demographicsMostRecentDeparture", "Id", "Id");
565+
var col = getWrappedCol(us, ds, "MostRecentDeparture", "demographicsMostRecentDeparture", ID_COLUMN, ID_COLUMN);
560566
ds.removeColumn(col);
561567
col.setLabel("Disposition");
562568
col.setDescription("Calculates the earliest and most recent departure per animal, if applicable, and most recent acquisition.");
@@ -568,7 +574,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
568574
{
569575
if (ds.getColumn("GenDemoCustomizer") == null)
570576
{
571-
var col = getWrappedCol(us, ds, "GenDemoCustomizer", "GenDemoCustomizer", "Id", "Id");
577+
var col = getWrappedCol(us, ds, "GenDemoCustomizer", "GenDemoCustomizer", ID_COLUMN, ID_COLUMN);
572578
col.setLabel("Genetic Assays");
573579
col.setDescription("Show if genetic assays exist for ID");
574580
ds.addColumn(col);

0 commit comments

Comments
 (0)