Skip to content

Commit f839d3b

Browse files
authored
1. Created demographics provider for BSC data (#258)
2. Added BCS to Animal History Snapshot 3. Added BCS to Browse All Datasets
1 parent 0648b60 commit f839d3b

10 files changed

Lines changed: 182 additions & 7 deletions

File tree

snprc_ehr/resources/data/reports.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ Exposure History Exposures query Exposure History true study ExpExposureHistory
6969
Procedure History Exposures query Procedure History true study ExpProcedureHistory Date false false qcstate/publicdata Exposure procedures data
7070
Research Treatments Exposures query Research Treatments true study ExpResearchTreatments Date false false qcstate/publicdata Research Treatments data
7171
Abnormal Behavior Behavior query Abnormal Behavior true study BehaviorAbnormalSummary Date false false qcstate/publicdata Abnormal behavoir detail data
72-
Vaccines Exposures query Vaccines true study ExpVaccines Date false false qcstate/publicdata Exposure vaccines data
72+
Vaccines Exposures query Vaccines true study ExpVaccines Date false false qcstate/publicdata Exposure vaccines data
73+
Body Condition Score Clinical query Body Condition Score true study BodyConditionScores
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="BodyConditionScores" tableDbType="NOT_IN_DB">
5+
<tableTitle>Body Condition Scores</tableTitle>
6+
<columns>
7+
<column columnName="Id">
8+
<isKeyField>true</isKeyField>
9+
<fk>
10+
<fkDbSchema>study</fkDbSchema>
11+
<fkTable>animal</fkTable>
12+
<fkColumnName>Id</fkColumnName>
13+
</fk>
14+
</column>
15+
<column columnName="BcsDate">
16+
<columnTitle>BCS Date</columnTitle>
17+
</column>
18+
<column columnName="BCS">
19+
<columnTitle>Body Condition Score</columnTitle>
20+
</column>
21+
<column columnName="BCSValue">
22+
<columnTitle>Numeric BCS Value</columnTitle>
23+
</column>
24+
<column columnName="Created">
25+
<isHidden>true</isHidden>
26+
</column>
27+
<column columnName="CreatedBy">
28+
<isHidden>true</isHidden>
29+
<fk>
30+
<fkColumnName>UserId</fkColumnName>
31+
<fkTable>Users</fkTable>
32+
<fkDbSchema>core</fkDbSchema>
33+
</fk>
34+
</column>
35+
<column columnName="Modified">
36+
<isHidden>true</isHidden>
37+
</column>
38+
<column columnName="ModifiedBy">
39+
<isHidden>true</isHidden>
40+
<fk>
41+
<fkColumnName>UserId</fkColumnName>
42+
<fkTable>Users</fkTable>
43+
<fkDbSchema>core</fkDbSchema>
44+
</fk>
45+
</column>
46+
</columns>
47+
</table>
48+
</tables>
49+
</metadata>
50+
</query>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
SELECT
3+
p.id as Id,
4+
p.date as BcsDate,
5+
p.procNarrative as BCS,
6+
case when substring(p.procNarrative, 7, 1) = ' ' then cast(substring (p.procNarrative, 6,1) as float)
7+
else cast( substring (p.procNarrative, 6,3) as float )
8+
end as BCSValue,
9+
p.Created,
10+
p.CreatedBy,
11+
p.Modified,
12+
p.ModifiedBy
13+
14+
FROM study.procedure AS p
15+
WHERE p.qcstate.publicdata = true
16+
AND p.pkgId.categories like '%BCS%'
17+
AND p.procNarrative <> 'BCS: error'

snprc_ehr/resources/queries/study/BrowseDataSets.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,5 @@ UNION
6060
select 'study' as schema, 'Misc' as CategoryId,'Animals with Genetic data' as Label, 'GenDemohasData' as Name, true as ShowByDefault, true as isAnimal
6161
UNION
6262
select 'study' as schema, 'Behavior' as CategoryId,'Abnormal Behavior' as Label, 'BehaviorAbnormalAll' as Name, true as ShowByDefault, true as isAnimal
63+
UNION
64+
select 'study' as schema, 'Clinical' as CategoryId,'Body Condition Scores' as Label, 'BodyConditionScores' as Name, true as ShowByDefault, true as isAnimal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
SELECT
3+
p.id as Id,
4+
p.date as BcsDate,
5+
p.procNarrative as LastBCS,
6+
p.QCState
7+
8+
FROM study.procedure AS p
9+
WHERE p.qcstate.publicdata = true
10+
AND p.pkgId.categories like '%BCS%'
11+
and p.date = (select max(p2.date) from study.procedure as p2
12+
where p2.id = p.id and p2.pkgId.categories like '%BCS%')

snprc_ehr/resources/web/snprc_ehr/DemographicsRecord.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ EHR.DemographicsRecord = function(data){
201201

202202
getSourceRecord: function(){
203203
return data.source;
204-
}
204+
},
205+
206+
getLastBcs: function() {
207+
return data['LastBCS'];
208+
},
205209
}
206-
}
210+
}

snprc_ehr/resources/web/snprc_ehr/snprcOverrides.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ Ext4.override(EHR.panel.SnapshotPanel, {
110110
toSet['idHistories'] = text.length ? '<table>' + text.join('') + '</table>' : null;
111111
},
112112

113+
appendLastBcs: function (toSet, results) {
114+
var text = [];
115+
if (results) {
116+
var rows = [];
117+
Ext4.each(results, function (row) {
118+
var d = LDK.ConvertUtils.parseDate(row['BcsDate'], LABKEY.extDefaultDateFormat);
119+
var newRow = {
120+
BcsDate: d.format(LABKEY.extDefaultDateFormat),
121+
LastBCS: row['LastBCS']
122+
};
123+
rows.push(newRow);
124+
}, this);
125+
126+
Ext4.each(rows, function (r) {
127+
text.push('<tr><td nowrap>' + r.BcsDate + ':' + '</td><td style="padding-left: 5px;" nowrap>' + r.LastBCS + '</td></tr>');
128+
}, this);
129+
}
130+
131+
toSet['LastBCS'] = text.length ? '<table>' + text.join('') + '</table>' : null;
132+
},
133+
113134

114135
appendCurrentAccountsResults: function (toSet, results) {
115136
var text = [];
@@ -337,7 +358,11 @@ Ext4.override(EHR.panel.SnapshotPanel, {
337358
xtype: 'displayfield',
338359
fieldLabel: 'Id History',
339360
name: 'idHistories'
340-
}]
361+
},{
362+
xtype: 'displayfield',
363+
fieldLabel: 'Last BCS',
364+
name: 'LastBCS'
365+
},]
341366
}]
342367
}]
343368
}];
@@ -499,6 +524,7 @@ Ext4.override(EHR.panel.SnapshotPanel, {
499524

500525
this.appendFlags(toSet, results.getActiveFlags());
501526
this.appendTBResults(toSet, results.getTBRecord());
527+
this.appendLastBcs(toSet, results.getLastBcs());
502528

503529
if (this.showExtendedInformation) {
504530
this.appendBirthResults(toSet, results.getBirthInfo(), results.getBirth());
@@ -533,4 +559,4 @@ Ext4.override(EHR.panel.SnapshotPanel, {
533559
// }]
534560
// }]
535561
// }
536-
// });
562+
// });

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import org.labkey.snprc_ehr.demographics.ActiveFlagsDemographicsProvider;
6565
import org.labkey.snprc_ehr.demographics.BirthDemographicsProvider;
6666
import org.labkey.snprc_ehr.demographics.CurrentAccountsDemographicsProvider;
67+
import org.labkey.snprc_ehr.demographics.LastBcsDemographicsProvider;
6768
import org.labkey.snprc_ehr.demographics.CurrentDietDemographicsProvider;
6869
import org.labkey.snprc_ehr.demographics.CurrentPedigreeDemographicsProvider;
6970
import org.labkey.snprc_ehr.demographics.DeathsDemographicsProvider;
@@ -199,6 +200,7 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
199200
EHRService.get().registerDemographicsProvider(new ActiveFlagsDemographicsProvider(this));
200201
EHRService.get().registerDemographicsProvider(new MhcSummaryDemographicsProvider(this));
201202
EHRService.get().registerDemographicsProvider(new LastHousingDemographicsProvider(this));
203+
EHRService.get().registerDemographicsProvider(new LastBcsDemographicsProvider(this));
202204

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

371373
return webPartFactories;
372374
}
373-
}
375+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.labkey.snprc_ehr.demographics;
2+
3+
4+
import org.labkey.api.data.CompareType;
5+
import org.labkey.api.data.SimpleFilter;
6+
import org.labkey.api.data.Sort;
7+
import org.labkey.api.ehr.demographics.AbstractListDemographicsProvider;
8+
import org.labkey.api.module.Module;
9+
import org.labkey.api.query.FieldKey;
10+
11+
import java.util.Collection;
12+
import java.util.HashSet;
13+
import java.util.Set;
14+
15+
/**
16+
* Created by thawkins on 7/6/2020.
17+
*/
18+
19+
public class LastBcsDemographicsProvider extends AbstractListDemographicsProvider
20+
{
21+
22+
public LastBcsDemographicsProvider(Module owner)
23+
{
24+
super(owner, "study", "demographicsLastBCS", "LastBCS");
25+
_supportsQCState = false;
26+
}
27+
28+
@Override
29+
protected Set<FieldKey> getFieldKeys()
30+
{
31+
Set<FieldKey> keys = new HashSet<>();
32+
keys.add(FieldKey.fromString("Id"));
33+
keys.add(FieldKey.fromString("BcsDate"));
34+
keys.add(FieldKey.fromString("LastBCS"));
35+
36+
return keys;
37+
}
38+
39+
@Override
40+
protected Sort getSort()
41+
{
42+
return new Sort("-Id");
43+
}
44+
45+
@Override
46+
protected SimpleFilter getFilter(Collection<String> ids)
47+
{
48+
SimpleFilter filter = super.getFilter(ids);
49+
filter.addCondition(FieldKey.fromString("qcstate/publicData"), true, CompareType.EQUAL);
50+
51+
return filter;
52+
}
53+
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ private void customizeAnimalTable(AbstractTableInfo ds)
460460
col.setDescription("Queries the most recent TB date for the animal.");
461461
ds.addColumn(col);
462462
}
463+
if (ds.getColumn("LastBCS") == null)
464+
{
465+
var col = getWrappedCol(us, ds, "LastBCS", "demographicsLastBCS", "Id", "Id");
466+
col.setLabel("Most Recent BCS");
467+
col.setDescription("Queries the most recent BCS value for the animal.");
468+
ds.addColumn(col);
469+
}
463470

464471
// Change label and description 8/31/2017 tjh
465472
if (ds.getColumn("MostRecentArrival") != null)
@@ -480,6 +487,7 @@ private void customizeAnimalTable(AbstractTableInfo ds)
480487
col.setDescription("Calculates the earliest and most recent departure per animal, if applicable, and most recent acquisition.");
481488
ds.addColumn(col);
482489
}
490+
483491
// Because of performance, changed to study based dataset ETLed from genetics folder 10/14/19 srr
484492
if (genetics != null)
485493
{
@@ -533,4 +541,4 @@ else if (targetTable.getSchema() != null)
533541
}
534542
return realTable;
535543
}
536-
}
544+
}

0 commit comments

Comments
 (0)