Skip to content

Commit 94ea7e2

Browse files
Ticket 54467: Correct a death record (#665)
* Allow admins to update Death records Co-authored-by: Marty Pradere <martyp@labkey.com>
1 parent f4bcbea commit 94ea7e2

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

nirc_ehr/resources/queries/study/deaths.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ function onUpsert(helper, scriptErrors, row, oldRow) {
7171

7272
if (!helper.isETL()) {
7373

74-
//only allow death record to be created if animal is in demographics table
74+
//skip other checks so that the admins can update a death record
75+
if (helper.getEvent() === 'update' && LABKEY.Security.currentUser.isAdmin) {
76+
return;
77+
}
78+
79+
//only allow death record to be created if the animal is in the demographics table
7580
if (idMap[row.Id]) {
7681

77-
// check if death record already exists for this animal
78-
if (idMap[row.Id].calculated_status.toUpperCase() === 'DEAD' && row.QCStateLabel.toUpperCase() === 'COMPLETED') {
82+
// check if a death record already exists for this animal
83+
if (idMap[row.Id].calculated_status.toUpperCase() === 'DEAD' && deathIdMap[row.Id].QCStateLabel.toUpperCase() === 'COMPLETED') {
7984
EHR.Server.Utils.addError(scriptErrors, 'Id', 'Death record already exists for this animal.', 'ERROR');
8085
}
8186
// check if the animal is at the center

nirc_ehr/resources/views/datasets.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const config = {displayField: 'Label', headerField: 'categoryId/label', target: webpart.wrapperDivId};
88

9-
const nonFormUpdates = ["Cases", "Procedures", "Drug Administration"];
9+
const nonFormUpdates = ["Treatment Cases", "Procedures", "Drug Administration", "Deaths"];
1010

1111
const hideUpdateRecords = [];
1212

@@ -66,12 +66,22 @@
6666
params.queryUpdateURL = true;
6767

6868
if(EHR.Security.hasPermission('Completed', 'update', {schemaName: 'study', queryName: item.queryName}) && hideUpdateRecords.indexOf(item.queryName) === -1){
69-
cfg.items.push({
69+
70+
if(nonFormUpdates.indexOf(item.queryName) !== -1) {
71+
//adding an item here so that the 'Admin Update Records' link aligns with other links in the same "column"
72+
cfg.items.push({
73+
xtype: 'box',
74+
html: '<span><a class="labkey-text-link" style="cursor: pointer; visibility: hidden;">Update Records</a></span>'
75+
});
76+
}
77+
else {
78+
cfg.items.push({
7079
xtype: 'ldk-linkbutton',
7180
tooltip: item.searchTooltip || 'Click to update records',
7281
href: LABKEY.ActionURL.buildURL('ehr', 'updateQuery', null, params),
7382
text: 'Update Records'
7483
});
84+
}
7585
}
7686

7787
params.queryUpdateURL = true;

0 commit comments

Comments
 (0)