From 3b8d55368a0ff9dbb1892dc3a864ceec2253584c Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Tue, 27 Jan 2026 08:55:35 -0800 Subject: [PATCH 1/4] Alopecia report fix (#648) * Update .qview.xml files --- .../resources/queries/study/clinical_observations/.qview.xml | 1 + .../study/clinical_observations/Alopecia Scores.qview.xml | 4 ++++ .../queries/study/clinical_observations/Behavior.qview.xml | 1 + .../queries/study/clinical_observations/Clinical.qview.xml | 1 + 4 files changed, 7 insertions(+) diff --git a/nirc_ehr/resources/queries/study/clinical_observations/.qview.xml b/nirc_ehr/resources/queries/study/clinical_observations/.qview.xml index 7b1fc1ad..a48d5a51 100644 --- a/nirc_ehr/resources/queries/study/clinical_observations/.qview.xml +++ b/nirc_ehr/resources/queries/study/clinical_observations/.qview.xml @@ -8,6 +8,7 @@ + diff --git a/nirc_ehr/resources/queries/study/clinical_observations/Alopecia Scores.qview.xml b/nirc_ehr/resources/queries/study/clinical_observations/Alopecia Scores.qview.xml index 7b1fc1ad..0a05b825 100644 --- a/nirc_ehr/resources/queries/study/clinical_observations/Alopecia Scores.qview.xml +++ b/nirc_ehr/resources/queries/study/clinical_observations/Alopecia Scores.qview.xml @@ -8,10 +8,14 @@ + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/clinical_observations/Behavior.qview.xml b/nirc_ehr/resources/queries/study/clinical_observations/Behavior.qview.xml index 7b010377..f7566f32 100644 --- a/nirc_ehr/resources/queries/study/clinical_observations/Behavior.qview.xml +++ b/nirc_ehr/resources/queries/study/clinical_observations/Behavior.qview.xml @@ -8,6 +8,7 @@ + diff --git a/nirc_ehr/resources/queries/study/clinical_observations/Clinical.qview.xml b/nirc_ehr/resources/queries/study/clinical_observations/Clinical.qview.xml index 6cf94811..adf8cf8f 100644 --- a/nirc_ehr/resources/queries/study/clinical_observations/Clinical.qview.xml +++ b/nirc_ehr/resources/queries/study/clinical_observations/Clinical.qview.xml @@ -8,6 +8,7 @@ + From 79b25246798b370333e85c1e31ed9f5c4dbce7f4 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Mon, 9 Feb 2026 08:40:20 -0800 Subject: [PATCH 2/4] Post go-live fixes (#651) * Cases trigger fixes * Snapshot parentage link fix * Necropsy form updates * Necropsy and death dataset updates --- nirc_ehr/resources/data/editable_lookups.tsv | 3 +- nirc_ehr/resources/data/lookup_sets.tsv | 1 - nirc_ehr/resources/data/lookupsManifest.tsv | 1 - .../resources/data/lookupsManifestTest.tsv | 1 - nirc_ehr/resources/queries/study/cases.js | 4 +- nirc_ehr/resources/queries/study/deaths.js | 15 +++++++ .../resources/queries/study/deaths.query.xml | 4 +- .../resources/queries/study/deaths/.qview.xml | 1 + nirc_ehr/resources/queries/study/necropsy.js | 21 ++------- .../queries/study/necropsy.query.xml | 11 ----- .../queries/study/necropsy/.qview.xml | 2 - .../study/datasets/datasets_metadata.xml | 43 ++++++++++++++++--- nirc_ehr/resources/views/necropsy.html | 2 +- .../nirc_ehr/model/sources/DeathNecropsy.js | 12 ++++-- .../web/nirc_ehr/panel/SnapshotPanel.js | 42 +++++++++++++++++- .../tests.nirc_ehr/NIRC_EHRTest.java | 21 ++++++--- 16 files changed, 129 insertions(+), 55 deletions(-) diff --git a/nirc_ehr/resources/data/editable_lookups.tsv b/nirc_ehr/resources/data/editable_lookups.tsv index 23c7d2ac..7f3ba907 100644 --- a/nirc_ehr/resources/data/editable_lookups.tsv +++ b/nirc_ehr/resources/data/editable_lookups.tsv @@ -73,8 +73,7 @@ ehr_lookups mens_score Clinical Menses Types Clinical observation fixed values. ehr_lookups mucous_membranes Clinical Mucous Membranes Used in clinical observations. ehr_lookups musculoskeletal_observations Clinical Musculoskeletal Observations Used in clinical observations. ehr_lookups necropsy_disposition_codes Colony Management Necropsy Disposition Codes -ehr_lookups necropsy_exam_reason Colony Management Necropsy Exam Reason -ehr_lookups necropsy_organ_appearance Colony Management Necropsy Organ Appearance +ehr_lookups necropsy_organ_appearance Colony Management Necropsy Organ Appearance ehr_lookups necropsy_organ_systems Colony Management Necropsy Organ Systems ehr_lookups necropsy_physical_condition Colony Management Necropsy Physical Condition ehr_lookups necropsy_specimen_condition Colony Management Necropsy Specimen Condition diff --git a/nirc_ehr/resources/data/lookup_sets.tsv b/nirc_ehr/resources/data/lookup_sets.tsv index 749d16c0..cea86af6 100644 --- a/nirc_ehr/resources/data/lookup_sets.tsv +++ b/nirc_ehr/resources/data/lookup_sets.tsv @@ -61,7 +61,6 @@ mens_score Menses value mucous_membranes Mucous Membranes value musculoskeletal_observations Musculoskeletal Observations value necropsy_disposition_codes Tissue Disposition Codes value title -necropsy_exam_reason Necropsy Reason value title necropsy_organ_appearance Appearance value title necropsy_organ_systems Organ Systems value title necropsy_physical_condition Physical Condition value title diff --git a/nirc_ehr/resources/data/lookupsManifest.tsv b/nirc_ehr/resources/data/lookupsManifest.tsv index ebf0d0c3..936ec52a 100644 --- a/nirc_ehr/resources/data/lookupsManifest.tsv +++ b/nirc_ehr/resources/data/lookupsManifest.tsv @@ -68,7 +68,6 @@ mens_score mucous_membranes musculoskeletal_observations necropsy_disposition_codes -necropsy_exam_reason necropsy_organ_appearance necropsy_organ_systems necropsy_physical_condition diff --git a/nirc_ehr/resources/data/lookupsManifestTest.tsv b/nirc_ehr/resources/data/lookupsManifestTest.tsv index 8784b08b..fde39961 100644 --- a/nirc_ehr/resources/data/lookupsManifestTest.tsv +++ b/nirc_ehr/resources/data/lookupsManifestTest.tsv @@ -67,7 +67,6 @@ mens_score mucous_membranes musculoskeletal_observations necropsy_disposition_codes -necropsy_exam_reason necropsy_organ_appearance necropsy_organ_systems necropsy_physical_condition diff --git a/nirc_ehr/resources/queries/study/cases.js b/nirc_ehr/resources/queries/study/cases.js index 02dc3b8b..a8e3b6c3 100644 --- a/nirc_ehr/resources/queries/study/cases.js +++ b/nirc_ehr/resources/queries/study/cases.js @@ -33,7 +33,7 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even error = true; } - if (!helper.isValidateOnly() && row.caseid && row.enddate && (row.enddate != oldRow.enddate)) { + if (!helper.isValidateOnly() && row.caseid && row.enddate && oldRow && (row.enddate != oldRow.enddate)) { triggerHelper.closeDailyClinicalObs(row.caseid, row.enddate); } @@ -57,7 +57,7 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even if (oldQc.Label != 'In Progress') { EHR.Server.Utils.addError(errors, null, 'Cannot save a draft copy of a case already opened or in review.', 'ERROR'); } - } else if (row.category == 'Clinical' && (qc.Label == 'Completed' || qc.Label == 'Review Required') && row.caseid && row.Id && row.performedby && row.taskid) { + } else if (row.category == 'Clinical' && (qc.Label == 'Completed' || qc.Label == 'Review Required') && row.caseid && row.Id && row.performedby && row.taskid && !row.enddate) { var ordersInTransaction = helper.getProperty('ordersInTransaction'); var oit = []; if (ordersInTransaction && ordersInTransaction.length) { diff --git a/nirc_ehr/resources/queries/study/deaths.js b/nirc_ehr/resources/queries/study/deaths.js index c6a89eea..03b9d2df 100644 --- a/nirc_ehr/resources/queries/study/deaths.js +++ b/nirc_ehr/resources/queries/study/deaths.js @@ -122,6 +122,21 @@ function onUpsert(helper, scriptErrors, row, oldRow) { console.log(row.id + " is not a valid animal id"); } } + + if(row.QCStateLabel && EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData) { + var qcstate = helper.getJavaHelper().getQCStateForLabel(row.QCStateLabel).getRowId(); + + //add/update weight record + var weightRecord = { + Id: row.Id, + date: row.date, + weight: row.deathWeight, + taskid: row.taskid, + qcstate: qcstate, + performedby: row.performedby + }; + triggerHelper.upsertWeightRecord(weightRecord); + } } } } diff --git a/nirc_ehr/resources/queries/study/deaths.query.xml b/nirc_ehr/resources/queries/study/deaths.query.xml index f16eebcd..35c2e6ae 100644 --- a/nirc_ehr/resources/queries/study/deaths.query.xml +++ b/nirc_ehr/resources/queries/study/deaths.query.xml @@ -7,7 +7,6 @@ Death Date - Disposition @@ -17,6 +16,9 @@ title + + Death Weight (kg) + diff --git a/nirc_ehr/resources/queries/study/deaths/.qview.xml b/nirc_ehr/resources/queries/study/deaths/.qview.xml index d04d768b..fdc063c2 100644 --- a/nirc_ehr/resources/queries/study/deaths/.qview.xml +++ b/nirc_ehr/resources/queries/study/deaths/.qview.xml @@ -7,6 +7,7 @@ + diff --git a/nirc_ehr/resources/queries/study/necropsy.js b/nirc_ehr/resources/queries/study/necropsy.js index 05522f36..bbfa3878 100644 --- a/nirc_ehr/resources/queries/study/necropsy.js +++ b/nirc_ehr/resources/queries/study/necropsy.js @@ -35,29 +35,16 @@ function onUpsert(helper, scriptErrors, row, oldRow) { (deathIdMap[row.Id].QCStateLabel.toUpperCase() === 'REQUEST: PENDING' || deathIdMap[row.Id].QCStateLabel.toUpperCase() === 'REVIEW REQUIRED')) { - if (!row.examReason) - EHR.Server.Utils.addError(scriptErrors, 'examReason', "'Reason for Examination' is required", 'ERROR'); if (!row.specimenCondition) EHR.Server.Utils.addError(scriptErrors, 'specimenCondition', "'Condition of Specimen' is required", 'ERROR'); if (!row.physicalCondition) EHR.Server.Utils.addError(scriptErrors, 'physicalCondition', "'Physical Condition' is required", 'ERROR'); if (!row.diagnosis) EHR.Server.Utils.addError(scriptErrors, 'diagnosis', "'Diagnosis' is required", 'ERROR'); - } - - if(row.QCStateLabel && EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData) { - var qcstate = helper.getJavaHelper().getQCStateForLabel(row.QCStateLabel).getRowId(); - - //add/update weight record - var weightRecord = { - Id: row.Id, - date: row.date, - weight: row.necropsyWeight, - taskid: row.taskid, - qcstate: qcstate, - performedby: row.performedby - }; - triggerHelper.upsertWeightRecord(weightRecord); + if (!row.grossAbnormalities) + EHR.Server.Utils.addError(scriptErrors, 'grossAbnormalities', "'Gross Abnormalities' is required", 'ERROR'); + if (!row.accessionNumber) + EHR.Server.Utils.addError(scriptErrors, 'accessionNumber', "'Accession Number' is required", 'ERROR'); } } } diff --git a/nirc_ehr/resources/queries/study/necropsy.query.xml b/nirc_ehr/resources/queries/study/necropsy.query.xml index 73cd38fd..35290a87 100644 --- a/nirc_ehr/resources/queries/study/necropsy.query.xml +++ b/nirc_ehr/resources/queries/study/necropsy.query.xml @@ -6,20 +6,12 @@ Exam Date - Category Diagnosis - - - ehr_lookups - necropsy_exam_reason - value - - ehr_lookups @@ -34,9 +26,6 @@ value - - Weight - true diff --git a/nirc_ehr/resources/queries/study/necropsy/.qview.xml b/nirc_ehr/resources/queries/study/necropsy/.qview.xml index b1af3175..2a4be61a 100644 --- a/nirc_ehr/resources/queries/study/necropsy/.qview.xml +++ b/nirc_ehr/resources/queries/study/necropsy/.qview.xml @@ -7,10 +7,8 @@ - - diff --git a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml index 91ac8907..bc4e8f73 100644 --- a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml +++ b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml @@ -33,6 +33,7 @@ Alias + Records alternative identifiers and aliases assigned to individual primates within the facility. varchar @@ -59,6 +60,7 @@
Arrival + Tracks the arrival of primates into the research facility, including source, acquisition type, and associated documentation. entityid @@ -110,6 +112,7 @@
Project Assignments + Records project assignments for individual primates, linking animals to specific research projects with start and end dates. varchar @@ -134,6 +137,7 @@
Biopsy + Documents biopsy procedures performed on primates, including tissue type and associated pathology reports. varchar @@ -160,6 +164,7 @@
Protocol Assignments + Tracks the assignment of primates to IACUC-approved research protocols with effective date ranges. varchar @@ -183,6 +188,7 @@
Birth + Records birth events for primates born within the facility, including location and associated protocols. entityid @@ -216,6 +222,7 @@
Blood Draws + Tracks blood draw procedures performed on primates, including volume, sample type, tube type, and purpose. varchar @@ -262,6 +269,7 @@
Breeder + Records breeding evaluations and reproductive assessments for primates in the colony breeding program. varchar @@ -292,6 +300,7 @@
Clinical/Behavior Observations + Documents clinical and behavioral observations recorded during routine monitoring and veterinary assessments of primates. varchar @@ -332,6 +341,7 @@
Clinical Remarks + Stores veterinary clinical remarks and SOAP notes associated with primate health assessments and case management. varchar @@ -388,6 +398,7 @@
Demographics + Contains core demographic information for each primate, including species, sex, parentage, birth and death dates, and colony status. entityid @@ -462,6 +473,7 @@
Departure + Records the departure of primates from the research facility, including destination information. entityid @@ -487,6 +499,7 @@
Deaths + Documents primate deaths, including date, cause of death, and terminal body weight. entityid @@ -508,10 +521,14 @@ varchar + + double +
Exemptions + Tracks approved exemptions from standard care or procedural requirements for individual primates. varchar @@ -560,9 +577,11 @@ Animal Record Flags + Stores active record flags and status indicators applied to individual primates for colony management purposes.
Histopathology + Records histopathology findings from tissue examinations performed on primates, including diagnoses and associated reports. varchar @@ -614,9 +633,11 @@ Historical Other + Captures miscellaneous historical health and research records for primates that do not fit other specific categories.
Housing + Tracks housing assignments and location transfers for primates within the research facility. varchar @@ -677,9 +698,11 @@ Inbreeding Coefficients + Records calculated inbreeding coefficients for primates to support genetic management of the colony.
Necropsy + Documents necropsy (postmortem) examination findings for primates, including gross and histological observations, diagnoses, and reports. varchar @@ -693,9 +716,6 @@ http://cpas.labkey.com/Study#VisitDate http://cpas.labkey.com/Study#VisitDate - - double - Category varchar @@ -704,10 +724,6 @@ Accession Number varchar - - Reason for Examination - varchar - Condition of Specimen varchar @@ -744,6 +760,7 @@
Gross Pathology + Records gross pathology findings observed during necropsy examinations of primates. varchar @@ -768,6 +785,7 @@
Tissue Disposition + Tracks the disposition of tissue samples collected during necropsy of primates. varchar @@ -791,6 +809,7 @@
Pairings + Records social pairing and group housing arrangements for primates, including formation type, compatibility observations, and separation details. varchar @@ -843,6 +862,7 @@
Physical Exam + Documents physical examination findings and measurements recorded during veterinary assessments of primates. varchar @@ -878,6 +898,7 @@
Procedures + Records research and veterinary procedures performed on primates, including procedure type, category, and associated case information. varchar @@ -918,6 +939,7 @@
Procedure Orders + Tracks scheduled procedure orders for primates, including ordering veterinarian and scheduling windows. varchar @@ -957,6 +979,7 @@
Serology + Records serological test results for primates, used for infectious disease screening and colony health monitoring. varchar @@ -980,6 +1003,7 @@
Problem List + Maintains the active and historical problem list for individual primates, supporting ongoing veterinary case management. varchar @@ -1006,6 +1030,7 @@
Drug Administration + Records drug and medication administrations for primates, including dosage, route, concentration, and ordering clinician. varchar @@ -1080,6 +1105,7 @@
Treatment Cases + Tracks veterinary treatment cases for primates, supporting clinical case management from opening through resolution. varchar @@ -1145,6 +1171,7 @@
Treatment Orders + Stores standing treatment orders for primates, including medication details, dosing frequency, and prescribing veterinarian. varchar @@ -1268,9 +1295,11 @@ Vital Signs + Records vital sign measurements for primates, including temperature, heart rate, respiration rate, blood pressure, and pulse oximetry.
Weight + Tracks body weight measurements for primates, used for health monitoring and drug dosage calculations. varchar diff --git a/nirc_ehr/resources/views/necropsy.html b/nirc_ehr/resources/views/necropsy.html index 5b51a70d..2d62d51b 100644 --- a/nirc_ehr/resources/views/necropsy.html +++ b/nirc_ehr/resources/views/necropsy.html @@ -59,7 +59,7 @@ schemaName: 'study', queryName: 'deaths', filterArray: filterArray, - columns: 'Id,Id/demographics/species,date,reason,Id/lastProtocol/protocol,Id/lastProject/project', + columns: 'Id,Id/demographics/species,date,reason,deathWeight,Id/lastProtocol/protocol,Id/lastProject/project', }, title: 'Death', renderTo: 'animalDeath', diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/DeathNecropsy.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/DeathNecropsy.js index 4be79f4c..1db8b70c 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/DeathNecropsy.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/DeathNecropsy.js @@ -12,12 +12,18 @@ EHR.model.DataModelManager.registerMetadata('DeathNecropsy', { dateFormat: 'Y-m-d', timeFormat: 'H:i' }, + }, + deathWeight: { + label: 'Weight (kg)', + allowBlank: false, + nullable: false, + }, + reason: { + allowBlank: false, + nullable: false, } }, 'study.necropsy': { - necropsyWeight: { - label: 'Weight (kg)' - }, date: { label: 'Exam Date', xtype: 'xdatetime', diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/SnapshotPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/SnapshotPanel.js index 708d6b57..16bc553c 100644 --- a/nirc_ehr/resources/web/nirc_ehr/panel/SnapshotPanel.js +++ b/nirc_ehr/resources/web/nirc_ehr/panel/SnapshotPanel.js @@ -291,7 +291,7 @@ Ext4.define('NIRC_EHR.panel.SnapshotPanel', { var html = ''; var sep = ''; Ext4.each(animals, function(id) { - html += sep + '' + LABKEY.Utils.encodeHtml(id) + ''; + html += sep + '' + encodeURIComponent(id) + ''; sep = ', '; }); toSet['cagemates'] = html; @@ -346,4 +346,44 @@ Ext4.define('NIRC_EHR.panel.SnapshotPanel', { } }]); }, + + appendParentageResults: function(toSet, results){ + if (results){ + var parentMap = {}; + Ext4.each(results, function(row){ + var parent = row.parent; + var relationship = row.relationship; + + if (parent && relationship){ + var text = LABKEY.Utils.encodeHtml(relationship + ' - ' + parent); + + if (!parentMap[text]) + parentMap[text] = []; + + var method = row.method; + if (method){ + parentMap[text].push(LABKEY.Utils.encodeHtml(method)); + } + } + }, this); + + var values = []; + Ext4.Array.forEach(Ext4.Object.getKeys(parentMap).sort(), function(text){ + parentMap[text] = Ext4.unique(parentMap[text]); + var subject = text; + var textParts = text.split(' - '); + if (textParts.length > 1){ + subject = textParts[1]; + } + + values.push('' + encodeURIComponent(subject) + ''); + }, this); + + if (values.length) + toSet['parents'] = values.join('
'); + } + else { + toSet['parents'] = 'No data'; + } + }, }); \ No newline at end of file diff --git a/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java b/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java index 8e57226e..bf824464 100644 --- a/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java +++ b/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java @@ -158,7 +158,7 @@ public void importFolderByPath(File path, String containerPath, int finishedJobs { setPipelineRoot(path.getPath(), false); - beginAt(WebTestHelper.getBaseURL() + "/pipeline-status/" + containerPath + "/begin.view"); + beginAt(WebTestHelper.getBaseURL() + "/" + containerPath + "/pipeline-status-begin.view"); clickButton("Process and Import Data", defaultWaitForPage); _fileBrowserHelper.expandFileBrowserRootNode(); _fileBrowserHelper.checkFileBrowserFileCheckbox("folder.xml"); @@ -356,6 +356,18 @@ private void addNIRCEhrLinks() (new PortalHelper(this)).addWebPart("NIRC EHR Links"); } + @Override + protected String getMale() + { + return "3"; + } + + @Override + protected String getFemale() + { + return "2"; + } + @Test public void testSetup() { @@ -837,7 +849,8 @@ public void testDeathNecropsyForm() throws IOException, CommandException setFormElement(Locator.name("Id"), aliveAnimalId); _ext4Helper.selectComboBoxItem("Disposition:", "Euthaniasia (project)"); - + waitForElement(Locator.name("deathWeight")); + setFormElement(Locator.name("deathWeight"), "23"); Assert.assertFalse(isElementPresent(Locator.linkWithText("Submit Necropsy for Review"))); Assert.assertFalse(isElementPresent(Locator.linkWithText("Submit Final"))); submitForm("Submit Death", "Confirm"); @@ -861,12 +874,10 @@ public void testDeathNecropsyForm() throws IOException, CommandException beginAt(url); Ext4GridRef necropsy = _helper.getExt4GridForFormSection("Necropsy"); necropsy.expand(); - waitForElement(Locator.name("necropsyWeight")); - setFormElement(Locator.name("necropsyWeight"), "23"); scrollIntoView(Locator.linkContainingText("More Actions")); _ext4Helper.selectComboBoxItem("Physical Condition:", "Excellent"); - _ext4Helper.selectComboBoxItem("Reason for Examination:", "Natural Death"); _ext4Helper.selectComboBoxItem("Condition of Specimen:", "Fresh"); + _helper.setDataEntryField("accessionNumber", "123"); scrollIntoView(Locator.name("diagnosis")); _helper.setDataEntryField("identification", "Extra information"); _helper.setDataEntryField("grossAbnormalities", "Extra leg"); From a886812b32257da512272855b6312d4360bc133c Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Mon, 9 Feb 2026 09:35:59 -0800 Subject: [PATCH 3/4] Clinical history tweaks (#656) * Custom clinical history and snapshot panels * Drug report for behavior * Update performedby initialization --- .../resources/queries/study/drug/.qview.xml | 4 +- .../queries/study/drug/Behavior.qview.xml | 28 ++++ .../resources/reports/additionalReports.tsv | 3 +- .../views/clinicalHistoryExport.html | 82 ++++++++++ .../views/clinicalHistoryExport.view.xml | 5 + .../web/nirc_ehr/model/sources/NIRCDefault.js | 8 + .../resources/web/nirc_ehr/nircReports.js | 2 +- .../web/nirc_ehr/panel/CaseHistoryPanel.js | 19 +++ .../nirc_ehr/panel/ClinicalHistoryPanel.js | 144 ++++++++++++++++++ .../web/nirc_ehr/panel/NarrowSnapshotPanel.js | 37 +++++ .../nirc_ehr/window/NIRCCaseHistoryWindow.js | 2 +- .../window/NIRCClinicalHistoryWindow.js | 2 +- .../org/labkey/nirc_ehr/NIRC_EHRModule.java | 4 + 13 files changed, 333 insertions(+), 7 deletions(-) create mode 100644 nirc_ehr/resources/queries/study/drug/Behavior.qview.xml create mode 100644 nirc_ehr/resources/views/clinicalHistoryExport.html create mode 100644 nirc_ehr/resources/views/clinicalHistoryExport.view.xml create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js diff --git a/nirc_ehr/resources/queries/study/drug/.qview.xml b/nirc_ehr/resources/queries/study/drug/.qview.xml index 032e214c..3b722685 100644 --- a/nirc_ehr/resources/queries/study/drug/.qview.xml +++ b/nirc_ehr/resources/queries/study/drug/.qview.xml @@ -8,9 +8,7 @@ - - @@ -22,7 +20,7 @@ - +
\ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml b/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml new file mode 100644 index 00000000..a9769cb8 --- /dev/null +++ b/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/reports/additionalReports.tsv b/nirc_ehr/resources/reports/additionalReports.tsv index af1b5ab5..98acfbe0 100644 --- a/nirc_ehr/resources/reports/additionalReports.tsv +++ b/nirc_ehr/resources/reports/additionalReports.tsv @@ -13,7 +13,8 @@ notes Colony Management query Notes true study notes false false qcstate/pu activeClinTreatmentOrders Clinical query Active Clinical Medication Orders true study treatment_order Clinical Active Treatment Orders date false false qcstate/publicdata This report contains the treatment orders entered for each animal activeBehaviorTreatmentOrders Behavior query Active Behavior Medication Orders true study treatment_order Behavior Active Treatment Orders date false false qcstate/publicdata This report contains the treatment orders entered for each animal allTreatments Clinical query All Treatment Orders true study treatment_order false false qcstate/publicdata This report shows all treatment orders -behTreatments Behavior query All Behavior Medication Orders true study treatment_order behavior false false qcstate/publicdata This report shows all treatment orders +behTreatments Behavior query All Behavior Medication Orders true study treatment_order behavior false false qcstate/publicdata This report shows all behavior treatment orders +behDrug Behavior query Behavior Drug Administration true study drug Behavior false false qcstate/publicdata This report shows all behavior drug administrations FileRepository General js File Repository true study FileRepository false false qcstate/publicdata File Repository for uploading and viewing animal related files observationSchedule Daily Reports js Today's Observation Schedule true study observationSchedule date false false qcstate/publicdata This report contains a list of today's treatments to be administered activeClinicalObservationOrders Clinical query Active Clinical Observation Orders true study observation_order Active Clinical Orders date false false qcstate/publicdata This report contains a list of today's treatments to be administered diff --git a/nirc_ehr/resources/views/clinicalHistoryExport.html b/nirc_ehr/resources/views/clinicalHistoryExport.html new file mode 100644 index 00000000..8e15e246 --- /dev/null +++ b/nirc_ehr/resources/views/clinicalHistoryExport.html @@ -0,0 +1,82 @@ + \ No newline at end of file diff --git a/nirc_ehr/resources/views/clinicalHistoryExport.view.xml b/nirc_ehr/resources/views/clinicalHistoryExport.view.xml new file mode 100644 index 00000000..35f09e39 --- /dev/null +++ b/nirc_ehr/resources/views/clinicalHistoryExport.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js index 15cdd8bd..eee4923b 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js @@ -14,6 +14,10 @@ EHR.model.DataModelManager.registerMetadata('Default', { allowBlank: true, defaultValue: LABKEY.Security.currentUser.id, getInitialValue: function (v, rec) { + if (Number.isInteger(v)){ + return v; + } + return LABKEY.Security.currentUser.id; }, editorConfig: { @@ -136,6 +140,10 @@ EHR.model.DataModelManager.registerMetadata('Default', { sort: 'Type,DisplayName' }, getInitialValue: function (v, rec) { + if (Number.isInteger(v)){ + return v; + } + return LABKEY.Security.currentUser.id; }, editorConfig: { diff --git a/nirc_ehr/resources/web/nirc_ehr/nircReports.js b/nirc_ehr/resources/web/nirc_ehr/nircReports.js index ad3f1e12..9a7aab31 100644 --- a/nirc_ehr/resources/web/nirc_ehr/nircReports.js +++ b/nirc_ehr/resources/web/nirc_ehr/nircReports.js @@ -181,7 +181,7 @@ EHR.reports.clinicalHistory = function(panel, tab, showActionsBtn, includeAll){ }); toAdd.push({ - xtype: 'ehr-clinicalhistorypanel', + xtype: 'nirc_ehr-clinicalhistorypanel', border: true, subjectId: s, autoLoadRecords: true, diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js new file mode 100644 index 00000000..517352c6 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js @@ -0,0 +1,19 @@ + +/** + * @cfg caseId + * @cfg maxGridHeight + * @cfg autoLoadRecords + */ +Ext4.define('NIRC_EHR.panel.CaseHistoryPanel', { + extend: 'NIRC_EHR.panel.ClinicalHistoryPanel', + alias: 'widget.nirc_ehr-casehistorypanel', + + getStoreConfig: function(){ + return { + type: 'ehr-clinicalhistorystore', + containerPath: this.containerPath, + actionName: 'getCaseHistory', + sorters: [{property: 'group'}, {property: 'timeString'}] + }; + } +}); diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js new file mode 100644 index 00000000..50f151d9 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js @@ -0,0 +1,144 @@ + +/** + * @cfg subjectId + * @cfg minDate + * @cfg maxDate + * @cfg maxGridHeight + * @cfg autoLoadRecords + * @cfg hideExportBtn + * @cfg sortMode + * @cfg checkedItems + * @cfg showMaxDate + * @cfg redacted + * @cfg printMode + */ +Ext4.define('NIRC_EHR.panel.ClinicalHistoryPanel', { + extend: 'EHR.panel.ClinicalHistoryPanel', + alias: 'widget.nirc_ehr-clinicalhistorypanel', + + showMaxDate: false, + + getGridConfig: function(){ + return { + xtype: 'grid', + border: this.printMode ? false : true, + minHeight: 100, + minWidth: this.width - 50, + cls: 'ldk-grid', + maxHeight: this.maxGridHeight, + height: this.gridHeight, + hideHeaders: true, + deferEmptyText: true, + viewConfig : { + emptyText: this.minDate ? 'No records found since: ' + Ext4.util.Format.date(this.minDate, LABKEY.extDefaultDateFormat): 'There are no records to display', + deferEmptyText: true, + enableTextSelection: true, + border: false, + stripeRows : true + }, + columns: this.getColumnConfig(), + features: [this.getGroupingFeature()], + store: this.getStoreConfig(), + itemId: 'gridPanel', + width: this.width, + subjectId: this.subjectId, + caseId: this.caseId, + minDate: this.minDate, + maxDate: this.maxDate, + tbar: this.hideGridButtons ? null : { + border: true, + items: [{ + xtype: 'datefield', + fieldLabel: 'Min Date', + itemId: 'minDate', + labelWidth: 80, + width: 200, + value: this.minDate + },{ + xtype: 'datefield', + fieldLabel: 'Max Date', + itemId: 'maxDate', + labelWidth: 80, + width: 200, + hidden: this.showMaxDate, + value: this.maxDate + },{ + xtype: 'button', + text: 'Reload', + handler: function(btn){ + var panel = btn.up('ehr-clinicalhistorypanel'); + panel.doReload(); + } + },{ + text: 'Show/Hide Types', + scope: this, + handler: function(btn){ + this.showFilterPanel(); + } + },{ + text: 'Collapse All', + hidden: this.printMode, + collapsed: false, + handler: function(btn){ + var grid = btn.up('grid'); + var feature = grid.getView().getFeature('historyGrouping'); + + if (btn.collapsed){ + feature.expandAll(); + btn.setText('Collapse All'); + } + else { + feature.collapseAll(); + btn.setText('Expand All') + } + + btn.collapsed = !btn.collapsed; + } + },{ + hidden: this.printMode, + text: (this.sortMode == 'type' ? 'Group By Date' : 'Group By Type'), + sortMode: this.sortMode == 'type' ? 'date' : 'type', + scope: this, + handler: function(btn){ + //toggle the button + if (btn.sortMode == 'type'){ + btn.setText('Group By Date'); + btn.sortMode = 'date'; + this.changeMode('type'); + } + else { + btn.setText('Group By Type'); + btn.sortMode = 'type'; + this.changeMode('date'); + } + } + },{ + text: 'Print Version', + hidden: this.hideExportBtn || this.printMode, + scope: this, + handler: function(btn){ + var params = { + hideGridButtons: true + }; + if (this.subjectId) + params.subjectId = [this.subjectId]; + if (this.caseId) + params.caseId = this.caseId; + if (this.minDate) + params.minDate = Ext4.util.Format.date(this.minDate, LABKEY.extDefaultDateFormat); + if (this.maxDate) + params.maxDate = Ext4.util.Format.date(this.maxDate, LABKEY.extDefaultDateFormat); + if (this.sortMode) + params.sortMode = this.sortMode; + if (this.checkedItems && this.checkedItems.length) + params.checkedItems = this.checkedItems.join(';'); + + var url = LABKEY.ActionURL.buildURL('nirc_ehr', 'clinicalHistoryExport', null, params); + window.open(url, '_blank'); + } + }] + } + }; + } +}); + diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js new file mode 100644 index 00000000..15d1f4c3 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js @@ -0,0 +1,37 @@ + +Ext4.define('NIRC_EHR.panel.NarrowSnapshotPanel', { + extend: 'NIRC_EHR.panel.SnapshotPanel', + alias: 'widget.nirc_ehr-narrowsnapshotpanel', + + showLocationDuration: false, + showExtendedInformation: true, + + minWidth: 800, + + initComponent: function(){ + + this.defaultLabelWidth = 120; + this.callParent(); + }, + + getItems: function() { + var items = this.getBaseItems(); + + //combine the first and second columns + var secondCol = items[0].items[1].items[1]; + var extended = this.getExtendedItems(); + + var index = items[0].items[1].items.indexOf(secondCol); + if (index !== -1) { + items[0].items[1].items = items[0].items[1].items.splice(index, 1); + } + + items[0].items[1].items = items[0].items[1].items.concat(extended[0].items[1].items[0]); + items[0].items[1].items[1].items = items[0].items[1].items[1].items.concat(extended[0].items[1].items[1].items[0]); + + items[0].items[1].items[0].columnWidth = 0.45; + items[0].items[1].items[1].columnWidth = 0.55; + + return items; + } +}); \ No newline at end of file diff --git a/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js b/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js index 16e82a21..b95e5db7 100644 --- a/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js +++ b/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js @@ -30,7 +30,7 @@ Ext4.define('NIRC_EHR.window.CaseHistoryWindow', { items[1].items[0].title = 'Entire History'; items[1].items.splice(1, 0, { title: 'Case History', - xtype: 'ehr-casehistorypanel', + xtype: 'nirc_ehr-casehistorypanel', containerPath: this.containerPath, border: true, width: 1180, diff --git a/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js b/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js index e2974882..76c53870 100644 --- a/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js +++ b/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js @@ -45,7 +45,7 @@ Ext4.define('NIRC_EHR.window.ClinicalHistoryWindow', { },{ xtype: 'tabpanel', items: [{ - xtype: 'ehr-clinicalhistorypanel', + xtype: 'nirc_ehr-clinicalhistorypanel', title: 'History', border: true, width: 1230, diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java index badf9d5a..f2413357 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java @@ -101,10 +101,14 @@ protected void init() ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCRecentRemarksWindow.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("ehr/sharedReports.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/SnapshotPanel.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/NarrowSnapshotPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/BloodSummaryPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/AnimalDetailsPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCClinicalHistoryWindow.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCCaseHistoryWindow.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/ClinicalHistoryPanel.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/CaseHistoryPanel.js"), this); + } @Override From f4bcbeabf910dfd5e26f5e759c9ccbeeeb818c4d Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Sun, 15 Feb 2026 08:15:27 -0800 Subject: [PATCH 4/4] Handle rearrivals (#660) * Fix data type issue on performedby default values * Add rearrival form. * Update triggers to prevent reusing Id on arrival but not rearrival * Update assignment triggers --- nirc_ehr/resources/queries/study/arrival.js | 17 ++---- .../resources/queries/study/arrival.query.xml | 3 + .../queries/study/arrival/.qview.xml | 5 +- .../queries/study/protocolAssignment.js | 8 +-- .../study/datasets/datasets_metadata.xml | 3 + nirc_ehr/resources/scripts/nirc_triggers.js | 19 ++++++- .../web/nirc_ehr/model/sources/Arrival.js | 5 ++ .../web/nirc_ehr/model/sources/NIRCDefault.js | 4 +- .../web/nirc_ehr/model/sources/Rearrival.js | 57 +++++++++++++++++++ .../org/labkey/nirc_ehr/NIRC_EHRModule.java | 1 + .../dataentry/form/NIRCRearrivalFormType.java | 43 ++++++++++++++ .../section/NIRCRearrivalFormSection.java | 20 +++++++ .../tests.nirc_ehr/NIRC_EHRTest.java | 26 ++++++--- 13 files changed, 179 insertions(+), 32 deletions(-) create mode 100644 nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js create mode 100644 nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCRearrivalFormType.java create mode 100644 nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java diff --git a/nirc_ehr/resources/queries/study/arrival.js b/nirc_ehr/resources/queries/study/arrival.js index 3eccf2fd..5bf0b91b 100644 --- a/nirc_ehr/resources/queries/study/arrival.js +++ b/nirc_ehr/resources/queries/study/arrival.js @@ -2,19 +2,14 @@ require("ehr/triggers").initScript(this); var triggerHelper = new org.labkey.nirc_ehr.query.NIRC_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id); -function onInit(event, helper){ - helper.setScriptOptions({ - allowAnyId: true, - requiresStatusRecalc: true, - allowDatesInDistantPast: true, - skipAssignmentCheck: true, - }); -} - EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'Arrival', function(helper, scriptErrors, row, oldRow) { + if(!row.rearrival){ + helper.setScriptOptions({requiresStatusRecalc: true}); + } + // Due to order of operation, this needs to be done in upsert instead of insert - if (helper.getEvent() == 'insert' && row.Id && triggerHelper.animalIdExists(row.Id)) { + if (!row.rearrival && helper.getEvent() == 'insert' && row.Id && triggerHelper.animalIdExists(row.Id)) { EHR.Server.Utils.addError(scriptErrors, 'Id', 'Animal Id ' + row.Id + ' is already in use. Please use a different Id.', 'ERROR'); } @@ -25,7 +20,7 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even helper.registerArrival(row.Id, row.date); //Insert or update demographic and birth records - if (!helper.isETL() && !helper.isGeneratedByServer() && !helper.isValidateOnly()) { + if (!row.rearrival && !helper.isETL() && !helper.isGeneratedByServer() && !helper.isValidateOnly()) { // this allows demographic records in qcstates other than completed var extraDemographicsFieldMappings = { diff --git a/nirc_ehr/resources/queries/study/arrival.query.xml b/nirc_ehr/resources/queries/study/arrival.query.xml index 1d70cffe..ffe21086 100644 --- a/nirc_ehr/resources/queries/study/arrival.query.xml +++ b/nirc_ehr/resources/queries/study/arrival.query.xml @@ -69,6 +69,9 @@ meaning + + Rearrival +
diff --git a/nirc_ehr/resources/queries/study/arrival/.qview.xml b/nirc_ehr/resources/queries/study/arrival/.qview.xml index 81c4e233..9aa2dd42 100644 --- a/nirc_ehr/resources/queries/study/arrival/.qview.xml +++ b/nirc_ehr/resources/queries/study/arrival/.qview.xml @@ -5,15 +5,14 @@ - - + + - \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/protocolAssignment.js b/nirc_ehr/resources/queries/study/protocolAssignment.js index 6f505272..c0429b50 100644 --- a/nirc_ehr/resources/queries/study/protocolAssignment.js +++ b/nirc_ehr/resources/queries/study/protocolAssignment.js @@ -6,7 +6,6 @@ var prevDate; var missing = []; var count = 0; -let animalIds = []; var triggerHelper = new org.labkey.nirc_ehr.query.NIRC_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id); @@ -31,12 +30,7 @@ function getLastAssignment(id){ } function onInit(event, helper){ - - helper.setScriptOptions({ - allowAnyId: false, - requiresStatusRecalc: true, - allowDatesInDistantPast: true - }); + if (helper.isETL()) { LABKEY.Query.selectRows({ schemaName: 'ehr', diff --git a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml index bc4e8f73..f8d49b0e 100644 --- a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml +++ b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml @@ -108,6 +108,9 @@ varchar + + boolean + diff --git a/nirc_ehr/resources/scripts/nirc_triggers.js b/nirc_ehr/resources/scripts/nirc_triggers.js index 3e90d1ea..ca94b556 100644 --- a/nirc_ehr/resources/scripts/nirc_triggers.js +++ b/nirc_ehr/resources/scripts/nirc_triggers.js @@ -26,10 +26,27 @@ exports.init = function (EHR) { }); }); + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'arrival', function(event, helper) { + helper.setScriptOptions({ + allowAnyId: true, + requiresStatusRecalc: false, // set in upsert to handle rearrival + allowDatesInDistantPast: true, + skipAssignmentCheck: true, + }); + }); + + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'protocolAssignment', function(event, helper) { + helper.setScriptOptions({ + allowAnyId: false, + requiresStatusRecalc: false, + allowDatesInDistantPast: true + }); + }); + EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.INIT, 'study', 'assignment', function(event, helper) { helper.setScriptOptions({ allowAnyId: false, - requiresStatusRecalc: true, + requiresStatusRecalc: false, allowDatesInDistantPast: true, skipAssignmentCheck: true, removeTimeFromDate: false, diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js index 4fbabbe7..4586e7fe 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js @@ -97,6 +97,11 @@ EHR.model.DataModelManager.registerMetadata('Arrival', { columnConfig: { width: 200 } + }, + rearrival: { + allowBlank: true, + hidden: true, + showInGrid: false } } } diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js index eee4923b..87ff22d8 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js @@ -14,7 +14,7 @@ EHR.model.DataModelManager.registerMetadata('Default', { allowBlank: true, defaultValue: LABKEY.Security.currentUser.id, getInitialValue: function (v, rec) { - if (Number.isInteger(v)){ + if (Number.isInteger(Number(v))){ return v; } @@ -140,7 +140,7 @@ EHR.model.DataModelManager.registerMetadata('Default', { sort: 'Type,DisplayName' }, getInitialValue: function (v, rec) { - if (Number.isInteger(v)){ + if (Number.isInteger(Number(v))){ return v; } diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js new file mode 100644 index 00000000..99600f02 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Rearrival.js @@ -0,0 +1,57 @@ + +EHR.model.DataModelManager.registerMetadata('Rearrival', { + + byQuery: { + 'study.arrival': { + rearrival: { + getInitialValue: function (v, rec) { + return true + }, + editable: false, + hidden: true, + columnConfig: { + editable: false + } + }, + performedby: { + hidden: true, + showInGrid: false + }, + sourceFacility: { + allowBlank: false, + columnConfig: { + fixed: true, + width: 150 + }, + }, + acquisitionType: { + allowBlank: false, + columnConfig: { + fixed: true, + width: 150 + }, + }, + arrivalType: { + allowBlank: false, + columnConfig: { + width: 200 + } + }, + 'cage': { + allowBlank: true, + hidden: true, + showInGrid: false + }, + project: { + allowBlank: true, + hidden: true, + showInGrid: false + }, + arrivalProtocol: { + allowBlank: true, + hidden: true, + showInGrid: false + }, + } + } +}); \ No newline at end of file diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java index f2413357..59dac4c5 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java @@ -236,6 +236,7 @@ private void registerDataEntry() EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCBehaviorRoundsFormType.class, this)); EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCChemistryImportFormType.class, this)); EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCSerologyImportFormType.class, this)); + EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NIRCRearrivalFormType.class, this)); } @Override diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCRearrivalFormType.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCRearrivalFormType.java new file mode 100644 index 00000000..4b9bd840 --- /dev/null +++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCRearrivalFormType.java @@ -0,0 +1,43 @@ +package org.labkey.nirc_ehr.dataentry.form; + +import org.labkey.api.ehr.dataentry.DataEntryFormContext; +import org.labkey.api.ehr.dataentry.FormSection; +import org.labkey.api.ehr.dataentry.forms.LockAnimalsFormSection; +import org.labkey.api.module.Module; +import org.labkey.api.security.permissions.AdminPermission; +import org.labkey.api.view.template.ClientDependency; +import org.labkey.nirc_ehr.dataentry.section.NIRCAnimalDetailsFormSection; +import org.labkey.nirc_ehr.dataentry.section.NIRCArrivalInstructionsFormSection; +import org.labkey.nirc_ehr.dataentry.section.NIRCRearrivalFormSection; +import org.labkey.nirc_ehr.dataentry.section.NIRCTaskFormSection; + +import java.util.Arrays; + +public class NIRCRearrivalFormType extends NIRCBaseTaskFormType +{ + public static final String NAME = "Rearrival"; + + public NIRCRearrivalFormType(DataEntryFormContext ctx, Module owner) + { + super(ctx, owner, NAME, "Rearrivals", "Colony Management", Arrays.asList( + new LockAnimalsFormSection(), + new NIRCArrivalInstructionsFormSection(), + new NIRCTaskFormSection(), + new NIRCAnimalDetailsFormSection(), + new NIRCRearrivalFormSection() + )); + + addClientDependency(ClientDependency.supplierFromPath("nirc_ehr/model/sources/Rearrival.js")); + + for (FormSection s : getFormSections()) + { + s.addConfigSource("Rearrival"); + } + } + + @Override + public boolean isAvailable() + { + return super.isAvailable() && getCtx().getContainer().hasPermission(getCtx().getUser(), AdminPermission.class); + } +} diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java new file mode 100644 index 00000000..17c7eed4 --- /dev/null +++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/section/NIRCRearrivalFormSection.java @@ -0,0 +1,20 @@ +package org.labkey.nirc_ehr.dataentry.section; + +import org.json.JSONObject; +import org.labkey.api.ehr.dataentry.DataEntryFormContext; + +public class NIRCRearrivalFormSection extends BaseFormSection +{ + public NIRCRearrivalFormSection() + { + super("study", "arrival", "Rearrivals", "ehr-gridpanel", true, true, true); + } + + @Override + public JSONObject toJSON(DataEntryFormContext ctx, boolean includeFormElements) + { + JSONObject json = super.toJSON(ctx, includeFormElements); + json.put("dataDependentCollapseHeader", true); + return json; + } +} diff --git a/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java b/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java index bf824464..e27875fc 100644 --- a/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java +++ b/nirc_ehr/test/src/org.labkey.test/tests.nirc_ehr/NIRC_EHRTest.java @@ -872,16 +872,26 @@ public void testDeathNecropsyForm() throws IOException, CommandException log("Entering Necropsy"); impersonate(NIRC_BASIC_SUBMITTER_VET_TECH); beginAt(url); - Ext4GridRef necropsy = _helper.getExt4GridForFormSection("Necropsy"); - necropsy.expand(); - scrollIntoView(Locator.linkContainingText("More Actions")); + _helper.getExt4GridForFormSection("Necropsy"); + waitForElement(Ext4Helper.Locators.ext4Button("Submit Necropsy for Review"), WAIT_FOR_PAGE); + waitForElement(Ext4Helper.Locators.formItemWithLabel("Performed By:"), WAIT_FOR_PAGE); + scrollIntoView(Locator.name("accessionNumber")); _ext4Helper.selectComboBoxItem("Physical Condition:", "Excellent"); _ext4Helper.selectComboBoxItem("Condition of Specimen:", "Fresh"); - _helper.setDataEntryField("accessionNumber", "123"); + sleep(1000); + Ext4FieldRef accessionNumber = _helper.getExt4FieldForFormSection("Necropsy", "Accession Number"); + accessionNumber.setValue("123"); + waitFor(() -> "123".equals(accessionNumber.getValue()), WAIT_FOR_JAVASCRIPT); scrollIntoView(Locator.name("diagnosis")); - _helper.setDataEntryField("identification", "Extra information"); - _helper.setDataEntryField("grossAbnormalities", "Extra leg"); - _helper.setDataEntryField("diagnosis", "Dead"); + Ext4FieldRef identification = _helper.getExt4FieldForFormSection("Necropsy", "Name/State/License no. (quarantine only)"); + identification.setValue("Extra information"); + waitFor(() -> "Extra information".equals(identification.getValue()), WAIT_FOR_JAVASCRIPT); + Ext4FieldRef grossAbnormalities = _helper.getExt4FieldForFormSection("Necropsy", "Gross Abnormalities"); + grossAbnormalities.setValue("Extra leg"); + waitFor(() -> "Extra leg".equals(grossAbnormalities.getValue()), WAIT_FOR_JAVASCRIPT); + Ext4FieldRef diagnosis = _helper.getExt4FieldForFormSection("Necropsy", "Diagnosis"); + diagnosis.setValue("Dead"); + waitFor(() -> "Dead".equals(diagnosis.getValue()), WAIT_FOR_JAVASCRIPT); _ext4Helper.selectComboBoxItem("Performed By:", NIRC_BASIC_SUBMITTER_NAME); log("Entering Tissue Disposition"); @@ -1357,4 +1367,4 @@ private void lockForm() log("Form is already unlocked"); } } -} \ No newline at end of file +}