Skip to content
Merged
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
3 changes: 2 additions & 1 deletion snprc_ehr/resources/data/reports.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@ Exposure History Exposures query Exposure History true study ExpExposureHistory
Procedure History Exposures query Procedure History true study ExpProcedureHistory Date false false qcstate/publicdata Exposure procedures data
Research Treatments Exposures query Research Treatments true study ExpResearchTreatments Date false false qcstate/publicdata Research Treatments data
Abnormal Behavior Behavior query Abnormal Behavior true study BehaviorAbnormalSummary Date false false qcstate/publicdata Abnormal behavoir detail data
Vaccines Exposures query Vaccines true study ExpVaccines Date false false qcstate/publicdata Exposure vaccines data
Vaccines Exposures query Vaccines true study ExpVaccines Date false false qcstate/publicdata Exposure vaccines data
Body Condition Score Clinical query Body Condition Score true study BodyConditionScores
50 changes: 50 additions & 0 deletions snprc_ehr/resources/queries/study/BodyConditionScores.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="BodyConditionScores" tableDbType="NOT_IN_DB">
<tableTitle>Body Condition Scores</tableTitle>
<columns>
<column columnName="Id">
<isKeyField>true</isKeyField>
<fk>
<fkDbSchema>study</fkDbSchema>
<fkTable>animal</fkTable>
<fkColumnName>Id</fkColumnName>
</fk>
</column>
<column columnName="BcsDate">
<columnTitle>BCS Date</columnTitle>
</column>
<column columnName="BCS">
<columnTitle>Body Condition Score</columnTitle>
</column>
<column columnName="BCSValue">
<columnTitle>Numeric BCS Value</columnTitle>
</column>
<column columnName="Created">
<isHidden>true</isHidden>
</column>
<column columnName="CreatedBy">
<isHidden>true</isHidden>
<fk>
<fkColumnName>UserId</fkColumnName>
<fkTable>Users</fkTable>
<fkDbSchema>core</fkDbSchema>
</fk>
</column>
<column columnName="Modified">
<isHidden>true</isHidden>
</column>
<column columnName="ModifiedBy">
<isHidden>true</isHidden>
<fk>
<fkColumnName>UserId</fkColumnName>
<fkTable>Users</fkTable>
<fkDbSchema>core</fkDbSchema>
</fk>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
17 changes: 17 additions & 0 deletions snprc_ehr/resources/queries/study/BodyConditionScores.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

SELECT
p.id as Id,
p.date as BcsDate,
p.procNarrative as BCS,
case when substring(p.procNarrative, 7, 1) = ' ' then cast(substring (p.procNarrative, 6,1) as float)
else cast( substring (p.procNarrative, 6,3) as float )
end as BCSValue,
p.Created,
p.CreatedBy,
p.Modified,
p.ModifiedBy

FROM study.procedure AS p
WHERE p.qcstate.publicdata = true
AND p.pkgId.categories like '%BCS%'
AND p.procNarrative <> 'BCS: error'
2 changes: 2 additions & 0 deletions snprc_ehr/resources/queries/study/BrowseDataSets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ UNION
select 'study' as schema, 'Misc' as CategoryId,'Animals with Genetic data' as Label, 'GenDemohasData' as Name, true as ShowByDefault, true as isAnimal
UNION
select 'study' as schema, 'Behavior' as CategoryId,'Abnormal Behavior' as Label, 'BehaviorAbnormalAll' as Name, true as ShowByDefault, true as isAnimal
UNION
select 'study' as schema, 'Clinical' as CategoryId,'Body Condition Scores' as Label, 'BodyConditionScores' as Name, true as ShowByDefault, true as isAnimal
12 changes: 12 additions & 0 deletions snprc_ehr/resources/queries/study/demographicsLastBCS.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

SELECT
p.id as Id,
p.date as BcsDate,
p.procNarrative as LastBCS,
p.QCState

FROM study.procedure AS p
WHERE p.qcstate.publicdata = true
AND p.pkgId.categories like '%BCS%'
and p.date = (select max(p2.date) from study.procedure as p2
where p2.id = p.id and p2.pkgId.categories like '%BCS%')
8 changes: 6 additions & 2 deletions snprc_ehr/resources/web/snprc_ehr/DemographicsRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ EHR.DemographicsRecord = function(data){

getSourceRecord: function(){
return data.source;
}
},

getLastBcs: function() {
return data['LastBCS'];
},
}
}
}
30 changes: 28 additions & 2 deletions snprc_ehr/resources/web/snprc_ehr/snprcOverrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,27 @@ Ext4.override(EHR.panel.SnapshotPanel, {
toSet['idHistories'] = text.length ? '<table>' + text.join('') + '</table>' : null;
},

appendLastBcs: function (toSet, results) {
var text = [];
if (results) {
var rows = [];
Ext4.each(results, function (row) {
var d = LDK.ConvertUtils.parseDate(row['BcsDate'], LABKEY.extDefaultDateFormat);
var newRow = {
BcsDate: d.format(LABKEY.extDefaultDateFormat),
LastBCS: row['LastBCS']
};
rows.push(newRow);
}, this);

Ext4.each(rows, function (r) {
text.push('<tr><td nowrap>' + r.BcsDate + ':' + '</td><td style="padding-left: 5px;" nowrap>' + r.LastBCS + '</td></tr>');
}, this);
}

toSet['LastBCS'] = text.length ? '<table>' + text.join('') + '</table>' : null;
},


appendCurrentAccountsResults: function (toSet, results) {
var text = [];
Expand Down Expand Up @@ -337,7 +358,11 @@ Ext4.override(EHR.panel.SnapshotPanel, {
xtype: 'displayfield',
fieldLabel: 'Id History',
name: 'idHistories'
}]
},{
xtype: 'displayfield',
fieldLabel: 'Last BCS',
name: 'LastBCS'
},]
}]
}]
}];
Expand Down Expand Up @@ -499,6 +524,7 @@ Ext4.override(EHR.panel.SnapshotPanel, {

this.appendFlags(toSet, results.getActiveFlags());
this.appendTBResults(toSet, results.getTBRecord());
this.appendLastBcs(toSet, results.getLastBcs());

if (this.showExtendedInformation) {
this.appendBirthResults(toSet, results.getBirthInfo(), results.getBirth());
Expand Down Expand Up @@ -533,4 +559,4 @@ Ext4.override(EHR.panel.SnapshotPanel, {
// }]
// }]
// }
// });
// });
4 changes: 3 additions & 1 deletion snprc_ehr/src/org/labkey/snprc_ehr/SNPRC_EHRModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.labkey.snprc_ehr.demographics.ActiveFlagsDemographicsProvider;
import org.labkey.snprc_ehr.demographics.BirthDemographicsProvider;
import org.labkey.snprc_ehr.demographics.CurrentAccountsDemographicsProvider;
import org.labkey.snprc_ehr.demographics.LastBcsDemographicsProvider;
import org.labkey.snprc_ehr.demographics.CurrentDietDemographicsProvider;
import org.labkey.snprc_ehr.demographics.CurrentPedigreeDemographicsProvider;
import org.labkey.snprc_ehr.demographics.DeathsDemographicsProvider;
Expand Down Expand Up @@ -199,6 +200,7 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
EHRService.get().registerDemographicsProvider(new ActiveFlagsDemographicsProvider(this));
EHRService.get().registerDemographicsProvider(new MhcSummaryDemographicsProvider(this));
EHRService.get().registerDemographicsProvider(new LastHousingDemographicsProvider(this));
EHRService.get().registerDemographicsProvider(new LastBcsDemographicsProvider(this));

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");
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");
Expand Down Expand Up @@ -370,4 +372,4 @@ public WebPartView getWebPartView(@NotNull ViewContext portalCtx, @NotNull Porta

return webPartFactories;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.labkey.snprc_ehr.demographics;


import org.labkey.api.data.CompareType;
import org.labkey.api.data.SimpleFilter;
import org.labkey.api.data.Sort;
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;

/**
* Created by thawkins on 7/6/2020.
*/

public class LastBcsDemographicsProvider extends AbstractListDemographicsProvider
{

public LastBcsDemographicsProvider(Module owner)
{
super(owner, "study", "demographicsLastBCS", "LastBCS");
_supportsQCState = false;
}

@Override
protected Set<FieldKey> getFieldKeys()
{
Set<FieldKey> keys = new HashSet<>();
keys.add(FieldKey.fromString("Id"));
keys.add(FieldKey.fromString("BcsDate"));
keys.add(FieldKey.fromString("LastBCS"));

return keys;
}

@Override
protected Sort getSort()
{
return new Sort("-Id");
}

@Override
protected SimpleFilter getFilter(Collection<String> ids)
{
SimpleFilter filter = super.getFilter(ids);
filter.addCondition(FieldKey.fromString("qcstate/publicData"), true, CompareType.EQUAL);

return filter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ private void customizeAnimalTable(AbstractTableInfo ds)
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");
col.setLabel("Most Recent BCS");
col.setDescription("Queries the most recent BCS value for the animal.");
ds.addColumn(col);
}

// Change label and description 8/31/2017 tjh
if (ds.getColumn("MostRecentArrival") != null)
Expand All @@ -480,6 +487,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
col.setDescription("Calculates the earliest and most recent departure per animal, if applicable, and most recent acquisition.");
ds.addColumn(col);
}

// Because of performance, changed to study based dataset ETLed from genetics folder 10/14/19 srr
if (genetics != null)
{
Expand Down Expand Up @@ -533,4 +541,4 @@ else if (targetTable.getSchema() != null)
}
return realTable;
}
}
}