Skip to content

Commit 84fb7a9

Browse files
Necropsy reporting enhancements (#569)
* Add last project and protocol columns for all animals (alive, dead or departed) * Add printable necropsy report page * Update performedby data entry metadata to not include inactive users
1 parent 1b406cb commit 84fb7a9

13 files changed

Lines changed: 168 additions & 4 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="demographicsLastProject" tableDbType="NOT_IN_DB">
5+
<columns>
6+
<column columnName="project">
7+
<columnTitle>Last Project</columnTitle>
8+
</column>
9+
</columns>
10+
</table>
11+
</tables>
12+
</metadata>
13+
</query>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
SELECT
3+
d2.id,
4+
d2.project,
5+
h.enddate as enddate
6+
7+
FROM study.assignment d2
8+
JOIN (SELECT id, max(date) as maxDate, max(enddate) as enddate FROM study.assignment h GROUP BY id) h
9+
ON (h.id = d2.id and d2.date = h.maxdate)
10+
WHERE d2.qcstate.publicdata = true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<query xmlns="http://labkey.org/data/xml/query">
2+
<metadata>
3+
<tables xmlns="http://labkey.org/data/xml">
4+
<table tableName="demographicsLastProtocol" tableDbType="NOT_IN_DB">
5+
<columns>
6+
<column columnName="protocol">
7+
<columnTitle>Last Protocol</columnTitle>
8+
</column>
9+
</columns>
10+
</table>
11+
</tables>
12+
</metadata>
13+
</query>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
SELECT
3+
d2.id,
4+
d2.protocol,
5+
h.enddate as enddate
6+
7+
FROM study.protocolAssignment d2
8+
JOIN (SELECT id, max(date) as maxDate, max(enddate) as enddate FROM study.protocolAssignment h GROUP BY id) h
9+
ON (h.id = d2.id and d2.date = h.maxdate)
10+
WHERE d2.qcstate.publicdata = true

nirc_ehr/resources/queries/study/tissueDisposition.query.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
<columns>
66
<column columnName="necropsyTissue">
77
<columnTitle>Tissue</columnTitle>
8+
<displayWidth>80</displayWidth>
89
<fk>
910
<fkDbSchema>ehr_lookups</fkDbSchema>
1011
<fkTable>necropsy_tissue</fkTable>
1112
<fkColumnName>value</fkColumnName>
1213
</fk>
1314
</column>
1415
<column columnName="necropsyDispositionCode">
15-
<columnTitle>Tissue Disposition Codes</columnTitle>
16+
<columnTitle>Tissue Disposition Code</columnTitle>
17+
<displayWidth>180</displayWidth>
1618
<fk>
1719
<fkDbSchema>ehr_lookups</fkDbSchema>
1820
<fkTable>necropsy_disposition_codes</fkTable>

nirc_ehr/resources/queries/study/tissueDisposition/.qview.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
<column name="date"/>
88
<column name="necropsyTissue"/>
99
<column name="necropsyDispositionCode"/>
10+
<column name="remark"/>
1011
</columns>
1112
</customView>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
<style>
3+
.page-break {
4+
page-break-before: always; /* Older CSS spec */
5+
break-before: page; /* Newer spec */
6+
}
7+
8+
@media print {
9+
.hide-on-print {
10+
display: none !important;
11+
}
12+
}
13+
14+
/* Top border on panel header when printing */
15+
.panel-heading {
16+
border-top: 1px solid black;
17+
}
18+
</style>
19+
<div class="hide-on-print">
20+
<label for="animalId" style="margin-right: 10px;">Animal Id</label><input id="animalId" type="text" />
21+
<button id="animalIdSubmit" name="animalIdSubmit">Submit</button>
22+
<br>
23+
<div id="animalIdError"></div>
24+
</div>
25+
<br>
26+
27+
<div id="animalDeath"></div>
28+
<div id="animalNecropsy"></div>
29+
<div class="page-break"></div>
30+
<div id="grossPathology"></div>
31+
<div id="tissueDisposition"></div>
32+
33+
<script type="text/javascript" nonce="<%=scriptNonce%>">
34+
document.getElementById('animalIdSubmit')['onclick'] = function(){ submitNecropsyForm(); return false; }
35+
36+
const submitNecropsyForm = function() {
37+
const animalId = document.getElementById('animalId').value;
38+
39+
if (!animalId) {
40+
document.getElementById('animalIdError').innerHTML = 'Please enter an Animal Id';
41+
}
42+
43+
const animalIdError = document.getElementById('animalIdError');
44+
const animalDeath = document.getElementById('animalDeath');
45+
const animalNecropsy = document.getElementById('animalNecropsy');
46+
const grossPathology = document.getElementById('grossPathology');
47+
const tissueDisposition = document.getElementById('tissueDisposition');
48+
49+
animalIdError.innerHTML = '';
50+
animalDeath.innerHTML = '';
51+
animalNecropsy.innerHTML = '';
52+
grossPathology.innerHTML = '';
53+
tissueDisposition.innerHTML = '';
54+
55+
const filterArray = [LABKEY.Filter.create('Id', animalId, LABKEY.Filter.Types.EQUAL)]
56+
57+
Ext4.create('LDK.panel.DetailsPanel', {
58+
store: {
59+
schemaName: 'study',
60+
queryName: 'deaths',
61+
filterArray: filterArray,
62+
columns: 'Id,Id/demographics/species,date,reason,remark,performedby,Id/lastProtocol/protocol,Id/lastProject/project',
63+
},
64+
title: 'Death',
65+
renderTo: 'animalDeath',
66+
showBackBtn: false
67+
});
68+
69+
Ext4.create('LDK.panel.DetailsPanel', {
70+
store: {
71+
schemaName: 'study',
72+
queryName: 'necropsy',
73+
filterArray: filterArray,
74+
},
75+
title: 'Necropsy',
76+
renderTo: 'animalNecropsy',
77+
showBackBtn: false
78+
});
79+
80+
LDK.Utils.getReadOnlyQWP({
81+
title: 'Gross Pathology',
82+
schemaName: 'study',
83+
queryName: 'grossPathology',
84+
filterArray: filterArray,
85+
}).render('grossPathology');
86+
87+
LDK.Utils.getReadOnlyQWP({
88+
title: 'Tissue Disposition',
89+
schemaName: 'study',
90+
queryName: 'tissueDisposition',
91+
filterArray: filterArray,
92+
}).render('tissueDisposition');
93+
}
94+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<view xmlns="http://labkey.org/data/xml/view" template="print" title="Necropsy Report">
2+
<requiresLogin/>
3+
</view>

nirc_ehr/resources/web/nirc_ehr/model/sources/BehaviorDefaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ EHR.model.DataModelManager.registerMetadata('BehaviorDefaults', {
5151
store: {
5252
type: 'labkey-store',
5353
schemaName: 'core',
54-
sql: 'SELECT CAST (UserId AS VARCHAR) AS UserId,DisplayName,FirstName,LastName FROM core.users',
54+
sql: "SELECT CAST (UserId AS VARCHAR) AS UserId,DisplayName,FirstName,LastName FROM core.PrincipalsWithoutAdmin WHERE active = TRUE AND Type = 'u'",
5555
autoLoad: true
5656
}
5757
}

nirc_ehr/resources/web/nirc_ehr/model/sources/ClinicalCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ EHR.model.DataModelManager.registerMetadata('ClinicalCase', {
134134
store: {
135135
type: 'labkey-store',
136136
schemaName: 'core',
137-
sql: 'SELECT CAST (UserId AS VARCHAR) AS UserId,DisplayName,FirstName,LastName FROM core.users',
137+
sql: "SELECT CAST (UserId AS VARCHAR) AS UserId,DisplayName,FirstName,LastName FROM core.PrincipalsWithoutAdmin WHERE active = TRUE AND Type = 'u'",
138138
autoLoad: true
139139
}
140140
}

0 commit comments

Comments
 (0)