diff --git a/nbri_ehr/resources/queries/study/animal_group_members.query.xml b/nbri_ehr/resources/queries/study/animal_group_members.query.xml index 09a5157..3f4678e 100644 --- a/nbri_ehr/resources/queries/study/animal_group_members.query.xml +++ b/nbri_ehr/resources/queries/study/animal_group_members.query.xml @@ -7,9 +7,11 @@ Date Added + DateTime Date Removed + DateTime false diff --git a/nbri_ehr/resources/queries/study/arrival.query.xml b/nbri_ehr/resources/queries/study/arrival.query.xml index 84e30cc..eb3af07 100644 --- a/nbri_ehr/resources/queries/study/arrival.query.xml +++ b/nbri_ehr/resources/queries/study/arrival.query.xml @@ -11,6 +11,7 @@ Arrival Date + DateTime Arrival Type diff --git a/nbri_ehr/resources/queries/study/assignment.query.xml b/nbri_ehr/resources/queries/study/assignment.query.xml index df55a2e..6360ef8 100644 --- a/nbri_ehr/resources/queries/study/assignment.query.xml +++ b/nbri_ehr/resources/queries/study/assignment.query.xml @@ -7,7 +7,9 @@ DateTime - + + DateTime + ehr diff --git a/nbri_ehr/resources/queries/study/birth.js b/nbri_ehr/resources/queries/study/birth.js index 6531bc9..2c06b1b 100644 --- a/nbri_ehr/resources/queries/study/birth.js +++ b/nbri_ehr/resources/queries/study/birth.js @@ -43,7 +43,6 @@ function onInit(event, helper){ skipHousingCheck: true, announceAllModifiedParticipants: true, allowDatesInDistantPast: true, - removeTimeFromDate: true, skipAssignmentCheck: true, }); diff --git a/nbri_ehr/resources/queries/study/birth.query.xml b/nbri_ehr/resources/queries/study/birth.query.xml index f424994..fc7174f 100644 --- a/nbri_ehr/resources/queries/study/birth.query.xml +++ b/nbri_ehr/resources/queries/study/birth.query.xml @@ -11,6 +11,7 @@ Birth Date + DateTime Conception Id diff --git a/nbri_ehr/resources/queries/study/deaths.js b/nbri_ehr/resources/queries/study/deaths.js index fc9b3e9..87dd9ec 100644 --- a/nbri_ehr/resources/queries/study/deaths.js +++ b/nbri_ehr/resources/queries/study/deaths.js @@ -10,6 +10,10 @@ var idMap = {}; var deathIdMap = {}; var idsToSync = []; +// QC states that mean a death has been declared. Leaving draft for anything else -- 'Delete Requested', a denied +// request -- is not a declaration, so it must not notify or close out the animal's procedure orders. +var NOTIFY_STATES = ['REQUEST: PENDING', 'REVIEW REQUIRED', 'COMPLETED']; + function onInit(event, helper){ // the script scope can outlive a single save, so never inherit ids from a prior one @@ -185,24 +189,33 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even idsToSync = []; } + // A delete arrives here as the deleted row with a null oldRow, which otherwise reads as a draft leaving draft. + if (event === 'delete') + return; + var rows = helper.getRows() || []; + var idsToComplete = []; for (var i = 0; i < rows.length; i++) { var row = rows[i].row; var oldRow = rows[i].oldRow; - // Notification will get sent when: - // 1) a brand-new row saved directly as 'Request: Pending' (i.e., when a user clicks 'Submit Death'), or - // 2) a draft death record moving from 'In Progress' to 'Request: Pending'. - if (!helper.isETL() && - row && row.Id && - row.QCStateLabel && - row.QCStateLabel.toUpperCase() === 'REQUEST: PENDING' && - (!oldRow || !oldRow.QCStateLabel || oldRow.QCStateLabel.toUpperCase() === 'IN PROGRESS')) { + if (helper.isETL() || !row || !row.Id || !row.QCStateLabel) + continue; + + // Notify once, on the first save that leaves draft: 'Submit Death' lands on 'Request: Pending', but a death entered alongside its necropsy goes straight to 'Review Required' or 'Completed'. + var wasDraft = !oldRow || !oldRow.QCStateLabel || oldRow.QCStateLabel.toUpperCase() === 'IN PROGRESS'; + if (wasDraft && NOTIFY_STATES.indexOf(row.QCStateLabel.toUpperCase()) > -1) { console.log("Sending NBRI Death Notification") triggerHelper.sendDeathNotification(row.Id); - console.log("Updating Procedure Orders to Completed for Animal: " + row.Id + "") - triggerHelper.updateProcedureOrdersToCompleted([row.Id]); + if (idsToComplete.indexOf(row.Id) === -1) + idsToComplete.push(row.Id); } } + + // One pass for the whole save: the helper filters and updates in bulk, so a call per row multiplies round trips. + if (idsToComplete.length) { + console.log("Updating Procedure Orders to Completed for: " + idsToComplete.join(', ')) + triggerHelper.updateProcedureOrdersToCompleted(idsToComplete); + } }); \ No newline at end of file diff --git a/nbri_ehr/resources/queries/study/deaths.query.xml b/nbri_ehr/resources/queries/study/deaths.query.xml index e28e2f0..f66b06d 100644 --- a/nbri_ehr/resources/queries/study/deaths.query.xml +++ b/nbri_ehr/resources/queries/study/deaths.query.xml @@ -6,6 +6,7 @@ Death Date + DateTime Death Type diff --git a/nbri_ehr/resources/queries/study/demographics.query.xml b/nbri_ehr/resources/queries/study/demographics.query.xml index 0323b4a..6e6f2cc 100644 --- a/nbri_ehr/resources/queries/study/demographics.query.xml +++ b/nbri_ehr/resources/queries/study/demographics.query.xml @@ -13,7 +13,7 @@ Species - Date + DateTime Birth /query/executeQuery.view? schemaName=study& @@ -22,7 +22,7 @@ - Date + DateTime Death /query/executeQuery.view? schemaName=study& diff --git a/nbri_ehr/resources/queries/study/housing.query.xml b/nbri_ehr/resources/queries/study/housing.query.xml index e1a21a3..9c8a81f 100644 --- a/nbri_ehr/resources/queries/study/housing.query.xml +++ b/nbri_ehr/resources/queries/study/housing.query.xml @@ -6,6 +6,7 @@ In Date + DateTime true @@ -13,6 +14,7 @@ true true Out Date + DateTime Location diff --git a/nbri_ehr/resources/queries/study/necropsy.query.xml b/nbri_ehr/resources/queries/study/necropsy.query.xml index 35290a8..f8054a1 100644 --- a/nbri_ehr/resources/queries/study/necropsy.query.xml +++ b/nbri_ehr/resources/queries/study/necropsy.query.xml @@ -5,6 +5,7 @@ Exam Date + DateTime Category diff --git a/nbri_ehr/resources/queries/study/protocolAssignment.query.xml b/nbri_ehr/resources/queries/study/protocolAssignment.query.xml index d95eb07..ccd46a8 100644 --- a/nbri_ehr/resources/queries/study/protocolAssignment.query.xml +++ b/nbri_ehr/resources/queries/study/protocolAssignment.query.xml @@ -4,8 +4,12 @@ - - + + DateTime + + + DateTime + true diff --git a/nbri_ehr/resources/scripts/nbri_triggers.js b/nbri_ehr/resources/scripts/nbri_triggers.js index 320c63f..2c806fe 100644 --- a/nbri_ehr/resources/scripts/nbri_triggers.js +++ b/nbri_ehr/resources/scripts/nbri_triggers.js @@ -58,7 +58,9 @@ exports.init = function (EHR) { // group memberships are routinely backdated, so historical dates must not raise a warning helper.setScriptOptions({ requiresStatusRecalc: false, - allowDatesInDistantPast: true + allowDatesInDistantPast: true, + // Overrides the shared animal_group_members script, which sets this true. + removeTimeFromDate: false }); }); diff --git a/nbri_ehr/resources/web/nbri_ehr/buttons/deathNecropsyButtons.js b/nbri_ehr/resources/web/nbri_ehr/buttons/deathNecropsyButtons.js index efee481..b07a7a5 100644 --- a/nbri_ehr/resources/web/nbri_ehr/buttons/deathNecropsyButtons.js +++ b/nbri_ehr/resources/web/nbri_ehr/buttons/deathNecropsyButtons.js @@ -101,7 +101,7 @@ Ext4.define('NBRI_EHR.window.DeathNecropsySubmitForReviewWindow', { text: 'Cancel', scope: this, handler: function(btn){ - btn.up('window').hide(); + btn.up('window').close(); } }], items: [{ @@ -127,8 +127,10 @@ Ext4.define('NBRI_EHR.window.DeathNecropsySubmitForReviewWindow', { value: this.getDefaultRecipient(), displayField: 'DisplayName', valueField: 'UserId', + // No global 'id' here: a reopened window would adopt the previous window's element and render a second combo. itemId: 'assignedTo', - id: 'assignedTo', + // Ext derives the input's name from the component id when 'name' is absent, so set it explicitly rather than leaning on the id. + name: 'assignedTo', anyMatch: true, caseSensitive: false, }]