-
Notifications
You must be signed in to change notification settings - Fork 3
Add earliest housing demographics provider #868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5cfa757
Added earliest housing demographics provider and query.
spamhurts 171ee7a
removed redundant column wrapping method and replaced "Id" strings wi…
spamhurts 7c22bdf
actually removed the redundant column wrapping method that was missed…
spamhurts 8431213
- Use the ID_COLUMN constant in QueryConstants.java.
spamhurts c6c0029
commented out earliest housing registration to sort out test issue
spamhurts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
snprc_ehr/resources/queries/study/demographicsEarliestHousing.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright (c) 2017-2018 LabKey Corporation | ||
| * | ||
| * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 | ||
| */ | ||
| SELECT | ||
| d.Id AS Id, | ||
| h.date as FirstHousingDate, | ||
| h.room as FirstHousingRoom, | ||
| h.room.area.description as FirstHousingRoomDescription | ||
| FROM study.demographics d | ||
|
|
||
|
|
||
| --date of first housing | ||
| LEFT JOIN study.housing as h on h.id = d.id and h.qcstate.publicdata = true | ||
| and h.date = (select min(c1.date) from study.housing as c1 | ||
| where h.id = c1.id) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
snprc_ehr/src/org/labkey/snprc_ehr/demographics/EarliestHousingDemographicsProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package org.labkey.snprc_ehr.demographics; | ||
|
|
||
| import org.labkey.api.ehr.demographics.AbstractListDemographicsProvider; | ||
| import org.labkey.api.module.Module; | ||
| import org.labkey.api.query.FieldKey; | ||
|
|
||
| import java.util.Collection; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public class EarliestHousingDemographicsProvider extends AbstractListDemographicsProvider | ||
|
|
||
| { | ||
|
|
||
| public EarliestHousingDemographicsProvider(Module owner) | ||
| { | ||
| super(owner, "study", "demographicsEarliestHousing", "earliestHousing"); | ||
| _supportsQCState = false; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() | ||
| { | ||
| return "Earliest Housing"; | ||
| } | ||
|
|
||
| @Override | ||
| protected Collection<FieldKey> getFieldKeys() | ||
| { | ||
| Set<FieldKey> keys = new HashSet<>(); | ||
| keys.add(FieldKey.fromString("FirstHousingDate")); | ||
| keys.add(FieldKey.fromString("FirstHousingRoom")); | ||
| keys.add(FieldKey.fromString("FirstHousingRoomDescription")); | ||
|
|
||
| return keys; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean requiresRecalc(String schema, String query) | ||
| { | ||
| return ("study".equalsIgnoreCase(schema) && "Housing".equalsIgnoreCase(query)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| import org.jetbrains.annotations.Nullable; | ||
| import org.labkey.api.collections.CaseInsensitiveHashSet; | ||
| import org.labkey.api.data.AbstractTableInfo; | ||
| import org.labkey.api.data.BaseColumnInfo; | ||
| import org.labkey.api.data.ColumnInfo; | ||
| import org.labkey.api.data.Container; | ||
| import org.labkey.api.data.ForeignKey; | ||
|
|
@@ -29,6 +30,7 @@ | |
| import org.labkey.api.data.WhitespacePreservingDisplayColumnFactory; | ||
| import org.labkey.api.data.WrappedColumn; | ||
|
|
||
| import org.labkey.api.data.WrappedColumnInfo; | ||
| import org.labkey.api.ehr.EHRService; | ||
| import org.labkey.api.ehr.security.EHRDataEntryPermission; | ||
| import org.labkey.api.exp.api.StorageProvisioner; | ||
|
|
@@ -62,6 +64,8 @@ public class SNPRC_EHRCustomizer extends AbstractTableCustomizer | |
|
|
||
| private Set<CalculatedColumn> calculatedColumns; | ||
|
|
||
| public static final String ID_COL = "Id"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In src/org/labkey/snrpc_ehr/constants/QueryConstants.java we have this string already as constant ID_COLUMN
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I'll make the change. |
||
|
|
||
| public SNPRC_EHRCustomizer() | ||
| { | ||
| _provider = new CustomizerQueryProvider(); | ||
|
|
@@ -161,8 +165,14 @@ public void doTableSpecificCustomizations(AbstractTableInfo ti) | |
| */ | ||
| if (matches(ti, "study", "Animal")) | ||
| { | ||
| UserSchema us = getEHRUserSchema(ti, STUDY_SCHEMA); | ||
| customizeAnimalTable(ti); | ||
| var col42 = getWrappedCol(us, ti, "earliestHousing", "demographicsEarliestHousing",ID_COL,ID_COL); | ||
|
RameshRapa marked this conversation as resolved.
Outdated
|
||
| col42.setLabel("Housing - Earliest"); | ||
| col42.setDescription("The calculates the earliest housing location for each living animal."); | ||
| ti.addColumn(col42); | ||
| } | ||
|
|
||
| if (matches(ti, "study", "Animal Events") || matches(ti, "study", "encounters")) | ||
| { | ||
| customizeEncounterTable(ti); | ||
|
|
@@ -444,35 +454,35 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
| } | ||
| if (ds.getColumn("flags") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "Flags", "demographicsActiveFlags", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "Flags", "demographicsActiveFlags", ID_COL, ID_COL); | ||
| col.setLabel("ActiveFlags"); | ||
| col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=ehr_lookups&queryName=flag_values&query.Id~eq=${Id}", ds.getContainerContext())); | ||
| ds.addColumn(col); | ||
| } | ||
| if (ds.getColumn("parents") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "parents", "demographicsParents", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "parents", "demographicsParents", ID_COL, ID_COL); | ||
| col.setLabel("Parents"); | ||
| ds.addColumn(col); | ||
| } | ||
|
|
||
| if (ds.getColumn("mhcSummary") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "mhcSummary", "mhcSummary", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "mhcSummary", "mhcSummary", ID_COL, ID_COL); | ||
| col.setLabel("mhcSummary"); | ||
| ds.addColumn(col); | ||
| } | ||
| if (ds.getColumn("totalOffspring") == null) | ||
| { | ||
| var col15 = getWrappedCol(us, ds, "totalOffspring", "demographicsTotalOffspring", "Id", "Id"); | ||
| var col15 = getWrappedCol(us, ds, "totalOffspring", "demographicsTotalOffspring", ID_COL, ID_COL); | ||
| col15.setLabel("Number of Offspring"); | ||
| col15.setDescription("Shows the total offspring of each animal"); | ||
| ds.addColumn(col15); | ||
| } | ||
|
|
||
| if (ds.getColumn("labworkHistory") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "labworkHistory", "demographicsLabwork", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "labworkHistory", "demographicsLabwork", ID_COL, ID_COL); | ||
| col.setLabel("Labwork History"); | ||
| col.setDescription("Shows the date of last labwork for a subsets of tests"); | ||
| ds.addColumn(col); | ||
|
|
@@ -481,15 +491,15 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
| //do we have freezer samples? | ||
| if (ds.getColumn("freezerSamples") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "freezerSamples", "demographicsFreezers", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "freezerSamples", "demographicsFreezers", ID_COL, ID_COL); | ||
| col.setLabel("Freezer Samples"); | ||
| col.setDescription("Shows the number of archived freezer samples"); | ||
| col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=study&queryName=freezerWorks&query.Id~eq=${Id}", ds.getContainerContext())); | ||
| ds.addColumn(col); | ||
| } | ||
| if (ds.getColumn("idHistoryList") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "idHistoryList", "demographicsIdHistory", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "idHistoryList", "demographicsIdHistory", ID_COL, ID_COL); | ||
| col.setLabel("Id Hx List"); | ||
| col.setDescription("List of Ids assigned to animal"); | ||
| col.setURL(DetailsURL.fromString("/query/executeQuery.view?schemaName=study&queryName=idHistory&query.Id~eq=${Id}", ds.getContainerContext())); | ||
|
|
@@ -498,46 +508,46 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
|
|
||
| if (ds.getColumn("activeAccounts") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "activeAccounts", "demographicsActiveAccount", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "activeAccounts", "demographicsActiveAccount", ID_COL, ID_COL); | ||
| col.setLabel("Accounts - Active"); | ||
| col.setDescription("Shows all accounts to which the animal is actively assigned on the current date"); | ||
| ds.addColumn(col); | ||
| } | ||
|
|
||
| if (ds.getColumn("packageCategory") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "packageCategory", "demographicsPackageCategories", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "packageCategory", "demographicsPackageCategories", ID_COL, ID_COL); | ||
| col.setLabel("Package Category"); | ||
| col.setDescription("Shows the package category for procedures"); | ||
| ds.addColumn(col); | ||
| } | ||
|
|
||
| if (ds.getColumn("activeAssignments") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "activeAssignments", "demographicsActiveAssignment", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "activeAssignments", "demographicsActiveAssignment", ID_COL, ID_COL); | ||
| col.setLabel("IACUC Assignments - Active"); | ||
| col.setDescription("Shows all protocols to which the animal is actively assigned on the current date"); | ||
| ds.addColumn(col); | ||
| } | ||
|
|
||
| if (ds.getColumn("activeGroups") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "activeGroups", "demographicsAnimalGroups", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "activeGroups", "demographicsAnimalGroups", ID_COL, ID_COL); | ||
| col.setLabel("Animal Groups - Active"); | ||
| col.setDescription("Shows all groups to which the animal is actively assigned on the current date"); | ||
| ds.addColumn(col); | ||
| } | ||
|
|
||
| if (ds.getColumn("MostRecentTBDate") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "MostRecentTBDate", "demographicsMostRecentTBDate", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "MostRecentTBDate", "demographicsMostRecentTBDate", ID_COL, ID_COL); | ||
| col.setLabel("Most Recent TB"); | ||
| col.setDescription("Queries the most recent TB date for the animal."); | ||
| ds.addColumn(col); | ||
| } | ||
| if (ds.getColumn("LastBCS") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "LastBCS", "demographicsLastBCS", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "LastBCS", "demographicsLastBCS", ID_COL, ID_COL); | ||
| col.setLabel("Most Recent BCS"); | ||
| col.setDescription("Queries the most recent BCS value for the animal."); | ||
| ds.addColumn(col); | ||
|
|
@@ -546,7 +556,7 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
| // Change label and description 8/31/2017 tjh | ||
| if (ds.getColumn("MostRecentArrival") != null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "MostRecentArrival", "demographicsArrival", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "MostRecentArrival", "demographicsArrival", ID_COL, ID_COL); | ||
| ds.removeColumn(col); | ||
| col.setLabel("Acquisition"); | ||
| col.setDescription("Calculates the earliest and most recent acquisition per animal."); | ||
|
|
@@ -556,7 +566,7 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
| // Change label and description 8/31/2017 tjh | ||
| if (ds.getColumn("MostRecentDeparture") != null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "MostRecentDeparture", "demographicsMostRecentDeparture", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "MostRecentDeparture", "demographicsMostRecentDeparture", ID_COL, ID_COL); | ||
| ds.removeColumn(col); | ||
| col.setLabel("Disposition"); | ||
| col.setDescription("Calculates the earliest and most recent departure per animal, if applicable, and most recent acquisition."); | ||
|
|
@@ -568,7 +578,7 @@ private void customizeAnimalTable(AbstractTableInfo ds) | |
| { | ||
| if (ds.getColumn("GenDemoCustomizer") == null) | ||
| { | ||
| var col = getWrappedCol(us, ds, "GenDemoCustomizer", "GenDemoCustomizer", "Id", "Id"); | ||
| var col = getWrappedCol(us, ds, "GenDemoCustomizer", "GenDemoCustomizer", ID_COL, ID_COL); | ||
| col.setLabel("Genetic Assays"); | ||
| col.setDescription("Show if genetic assays exist for ID"); | ||
| ds.addColumn(col); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.