Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bot] Fast-forward for 24.7.6 #398

Merged
merged 5 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nirc_ehr/resources/data/editable_lookups.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ necropsy_physical_condition Colony Management Necropsy Physical Condition
necropsy_specimen_condition Colony Management Necropsy Specimen Condition
necropsy_tissue Colony Management Necropsy Tissue
neurologic_types Clinical Neurologic Types Clinical observation fixed values.
nhp_training_reason Behavior NHP Training Reason Behavior training reason values
nhp_training_result Behavior NHP Training Result Behavior training result values
nhp_training_type Behavior NHP Training Type Behavior training type values
numeric_unit Colony Management Numeric Unit
observation_types Clinical Clin remarks observation types
observation_areas Clinical Observation Areas Clinical observation areas.
Expand Down
3 changes: 3 additions & 0 deletions nirc_ehr/resources/data/lookup_sets.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ necropsy_physical_condition Physical Condition value title
necropsy_specimen_condition Specimen Condition value title
necropsy_tissue Tissues value title
neurologic_types Neurologic Types value title
nhp_training_reason NHP Training Reason value
nhp_training_result NHP Training Result value
nhp_training_type NHP Training Type value
numeric_unit Numeric Units value title
observation_areas Observation Areas value
ocular_problem Ocular Problem value
Expand Down
3 changes: 3 additions & 0 deletions nirc_ehr/resources/data/lookupsManifest.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ necropsy_physical_condition
necropsy_specimen_condition
necropsy_tissue
neurologic_types
nhp_training_reason
nhp_training_result
nhp_training_type
numeric_unit
observation_areas
ocular_problem
Expand Down
3 changes: 3 additions & 0 deletions nirc_ehr/resources/data/lookupsManifestTest.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ necropsy_physical_condition
necropsy_specimen_condition
necropsy_tissue
neurologic_types
nhp_training_reason
nhp_training_result
nhp_training_type
numeric_unit
observation_areas
ocular_problem
Expand Down
6 changes: 6 additions & 0 deletions nirc_ehr/resources/data/nhp_training_reason.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
value
PI Request
Behavioral Initiated
Clinic
Husbandry
Other
4 changes: 4 additions & 0 deletions nirc_ehr/resources/data/nhp_training_result.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
value
In-Progress
Successful
Unsuccessful
5 changes: 5 additions & 0 deletions nirc_ehr/resources/data/nhp_training_type.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
value
Chair
Present
Physical Therapy
Other
4 changes: 1 addition & 3 deletions nirc_ehr/resources/queries/study/assignment.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
</fk>
</column>
<column columnName="remark"/>
<column columnName="performedBy">
<columnTitle>Performed By</columnTitle>
</column>
<column columnName="performedBy" />
<column columnName="taskid">
<isHidden>true</isHidden>
</column>
Expand Down
26 changes: 26 additions & 0 deletions nirc_ehr/resources/queries/study/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

const console = require("console");
require("ehr/triggers").initScript(this);

var triggerHelper = new org.labkey.nirc_ehr.query.NIRC_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id);
Expand All @@ -15,3 +16,28 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even
}
}
});

EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.COMPLETE, 'study', 'cases', function(event, errors, helper){
if (!helper.isETL()) {
var rows = helper.getRows();
if (helper.getEvent() == 'insert' && rows.length && !helper.isValidateOnly()) {
for (var i = 0; i < rows.length; i++) {
var row = rows[i].row;
var qc;
if (row.QCStateLabel) {
qc = EHR.Server.Security.getQCStateByLabel(row.QCStateLabel);
}
else if (row.QCState) {
qc = EHR.Server.Security.getQCStateByRowId(row.QCState);
}

if (!qc) {
console.error('Unable to find QCState: ' + row.QCState + '/' + row.QCStateLabel);
}
else if (qc.Label != 'COMPLETED' && row.caseid && row.Id && qc) {
triggerHelper.ensureDailyClinicalObservationOrders(row.Id, row.caseid, row.performedby, qc.RowId);
}
}
}
}
});
56 changes: 17 additions & 39 deletions nirc_ehr/resources/queries/study/clinical_observations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,12 @@
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

const console = require("console");
require("ehr/triggers").initScript(this);

var animalIdCasesMap = {};
var triggerHelper = new org.labkey.nirc_ehr.query.NIRC_EHRTriggerHelper(LABKEY.Security.currentUser.id, LABKEY.Security.currentContainer.id);

function onInit(event, helper){

LABKEY.Query.selectRows({
schemaName: 'study',
queryName: 'cases',
columns: ['Id', 'caseid', 'taskid', 'enddate'],
scope: this,
sort: 'Id',
success: function (results) {
if (!results || !results.rows || results.rows.length < 1)
return;

for(var i=0; i < results.rows.length; i++) {

// get all open cases associated with an animal
if (null === results.rows[i]["enddate"]) {
var animal = results.rows[i]["Id"];
if (!animalIdCasesMap[animal]) {
animalIdCasesMap[animal] = [];
}
animalIdCasesMap[animal].push(results.rows[i]);
}
}
// console.log("animalIdCasesMap: " + JSON.stringify(animalIdCasesMap));
},
failure: function (error) {
console.log("error getting death data in death trigger onInit()\n" + error);
}
});
}

function onUpsert(helper, scriptErrors, row, oldRow) {

Expand All @@ -53,14 +24,21 @@ function onUpsert(helper, scriptErrors, row, oldRow) {
EHR.Server.Utils.addError(scriptErrors, 'remark', "You selected 'No' for 'Verified Id?', please enter Remark", "WARN");
}

// if (!helper.isValidateOnly()) {
// if (row.Id) {
// if (animalIdCasesMap[row.Id] && animalIdCasesMap[row.Id].length > 0) {
//
//TODO:
// triggerHelper.addClinicalObsForCases(row, oldRow, animalIdCasesMap[row.Id]); //Add clinical obs for all open cases associated with an animal
// }
// }
// }
if (!helper.isValidateOnly()) {
var qc;
if (row.QCStateLabel) {
qc = EHR.Server.Security.getQCStateByLabel(row.QCStateLabel);
}
else if (row.QCState) {
qc = EHR.Server.Security.getQCStateByRowId(row.QCState);
}

if (!qc) {
console.error('Unable to find QCState: ' + row.QCState + '/' + row.QCStateLabel);
}
else {
triggerHelper.propagateClinicalObs(row, qc.RowId); //Add clinical obs for all open cases associated with an animal
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
<columnTitle>Performed By</columnTitle>
<nullable>false</nullable>
</column>
<column columnName="scheduledDate">
<columnTitle>Scheduled Date</columnTitle>
</column>
<column columnName="type">
<columnTitle>Type</columnTitle>
<isHidden>true</isHidden>
</column>
</columns>
</table>
</tables>
Expand Down
9 changes: 1 addition & 8 deletions nirc_ehr/resources/queries/study/deaths.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@
</fk>
</column>
<column columnName="remark"/>
<column columnName="performedby">
<fk>
<fkDbSchema>core</fkDbSchema>
<fkTable>Users</fkTable>
<fkColumnName>UserId</fkColumnName>
<fkDisplayColumnName>DisplayName</fkDisplayColumnName>
</fk>
</column>
<column columnName="performedby" />
<column columnName="description">
<isHidden>true</isHidden>
</column>
Expand Down
5 changes: 2 additions & 3 deletions nirc_ehr/resources/queries/study/drug.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@
<fkDisplayColumnName useRawValue="true"/>
</fk>
</column>
<column columnName="performedby">
<columnTitle>Ordered By</columnTitle>
</column>
<column columnName="orderedby" />
<column columnName="performedby" />
<column columnName="scheduledDate">
<columnTitle>Scheduled Date</columnTitle>
</column>
Expand Down
1 change: 1 addition & 0 deletions nirc_ehr/resources/queries/study/drug/.qview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<column name="conc_units"/>
<column name="dosage"/>
<column name="dosage_units"/>
<column name="orderedby"/>
<column name="performedBy"/>
<column name="description"/>
<column name="remark"/>
Expand Down
4 changes: 1 addition & 3 deletions nirc_ehr/resources/queries/study/flags.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
<isHidden>true</isHidden>
</column>
<column columnName="remark"/>
<column columnName="performedby">
<columnTitle>Performed By</columnTitle>
</column>
<column columnName="performedby" />
<column columnName="project">
<isHidden>true</isHidden>
</column>
Expand Down
4 changes: 1 addition & 3 deletions nirc_ehr/resources/queries/study/housing.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
</fk>
</column>
<column columnName="remark"/>
<column columnName="performedBy">
<columnTitle>Performed By</columnTitle>
</column>
<column columnName="performedBy" />
</columns>
</table>
</tables>
Expand Down
9 changes: 1 addition & 8 deletions nirc_ehr/resources/queries/study/necropsy.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@
<column columnName="remark">
<isHidden>true</isHidden>
</column>
<column columnName="performedby">
<fk>
<fkDbSchema>core</fkDbSchema>
<fkTable>Users</fkTable>
<fkColumnName>userId</fkColumnName>
<fkDisplayColumnName>DisplayName</fkDisplayColumnName>
</fk>
</column>
<column columnName="performedby" />
<column columnName="taskid">
<isHidden>true</isHidden>
</column>
Expand Down
1 change: 1 addition & 0 deletions nirc_ehr/resources/queries/study/nhpTraining.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require("ehr/triggers").initScript(this);
41 changes: 41 additions & 0 deletions nirc_ehr/resources/queries/study/nhpTraining.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="nhpTraining" tableDbType="TABLE" useColumnOrder="true">
<tableTitle>Animal Training</tableTitle>
<columns>
<column columnName="Id" />
<column columnName="date" />
<column columnName="trainingType">
<columnTitle>Training Type</columnTitle>
<fk>
<fkDbSchema>ehr_lookups</fkDbSchema>
<fkTable>nhp_training_type</fkTable>
<fkColumnName>value</fkColumnName>
</fk>
</column>
<column columnName="reason">
<columnTitle>Reason</columnTitle>
<fk>
<fkDbSchema>ehr_lookups</fkDbSchema>
<fkTable>nhp_training_reason</fkTable>
<fkColumnName>value</fkColumnName>
</fk>
</column>
<column columnName="result">
<columnTitle>Result</columnTitle>
<fk>
<fkDbSchema>ehr_lookups</fkDbSchema>
<fkTable>nhp_training_result</fkTable>
<fkColumnName>value</fkColumnName>
</fk>
</column>
<column columnName="trainingStaff" >
<columnTitle>Training Staff</columnTitle>
</column>

</columns>
</table>
</tables>
</metadata>
</query>
22 changes: 22 additions & 0 deletions nirc_ehr/resources/queries/study/observationSchedule.query.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="observationSchedule" tableDbType="TABLE" useColumnOrder="true">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
<tableTitle>Observation Schedule</tableTitle>
<columns>
<column columnName="Id" />
<column columnName="scheduledDate">
<columnTitle>Scheduled Date/Time</columnTitle>
</column>
<column columnName="observations">
<columnTitle>Observations</columnTitle>
</column>
<column columnName="observationRecord">
<columnTitle></columnTitle>
</column>
</columns>
</table>
</tables>
</metadata>
</query>
Loading
Loading