Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
4493dfa
Migrating changes to water system to 24.3 (#627)
dnicolalde Jul 25, 2024
17d71b7
Fixing problem with binding JSP page
dnicolalde Jul 26, 2024
8307a1e
Fixing title for death animals in Full calendar.
dnicolalde Jul 26, 2024
ffceaa3
Fixing problem with branchName for the gradle build process
dnicolalde Jul 26, 2024
dc2a595
adding a function to remove all the future water amounts that are sch…
dnicolalde Sep 17, 2024
6d74924
Fix to the water total reports in animal history, removing the watera…
dnicolalde Oct 1, 2024
dd4411b
adding new js report for animal history.
dnicolalde Oct 1, 2024
c585e2f
adding close function to expedite closing water orders.
dnicolalde Oct 11, 2024
8495277
Using close water order flag to not checkwaterregulation.
dnicolalde Oct 22, 2024
647f02b
fixing function to switch to lixit animals.
dnicolalde Oct 31, 2024
3df39c3
Deleting water orders that are start in the future, also deleting wat…
dnicolalde Nov 7, 2024
dab6c17
Correcting typo on WaterCalendar.jsp
dnicolalde Nov 8, 2024
0891ac2
Fixing format of error message.
dnicolalde Nov 11, 2024
a9672db
Fixing incomplete water treatments view.
dnicolalde Nov 12, 2024
527b09e
Adding filter to show only regulated animals.
dnicolalde Nov 12, 2024
772b1ef
adding report for water total so it does not request start and end da…
dnicolalde Nov 12, 2024
4a29a06
Removing file after merging husbandry reports to wnprcHusbandry.js fi…
dnicolalde Nov 12, 2024
6b93b1e
Hiding watertotal from the future when a water amount or order is pre…
dnicolalde Nov 14, 2024
3576b87
Removing dependency for wnprcTotalWaterReport.js.
dnicolalde Nov 15, 2024
6aeba07
Fixing problem with water notification, adding parameters to query.
dnicolalde Dec 2, 2024
f3a32f5
Adding water source to treatment form.
dnicolalde Dec 2, 2024
c709d86
Removing on lixit from the water schedule when first order is complet…
dnicolalde Dec 3, 2024
2153d2f
Fixing problem with re-rendering inside the webpart in the animal his…
dnicolalde Dec 4, 2024
23bc065
Moving remarks to follow the order in .qview file
dnicolalde Dec 4, 2024
1b70e8c
Fixing problem with zero when adding lixit into the water treatment f…
dnicolalde Dec 4, 2024
820757c
Removing not used button from DataEntryButtons.js
dnicolalde Dec 4, 2024
0157558
Adding action required to the qview to show first lixit in calendar.
dnicolalde Dec 4, 2024
46991e1
Adding filter to obtain all water schedule in the future.
dnicolalde Dec 4, 2024
75949c7
Multiple changes to WaterCalendar.jsp to fix problems with lixit.
dnicolalde Dec 4, 2024
ed98f26
Button for completing water given to have a pop up message
dnicolalde Dec 5, 2024
ab19acd
Switching text to submit final
dnicolalde Dec 5, 2024
af6c909
Adding validations to the water orders, removing validation from clie…
dnicolalde Dec 6, 2024
abd9233
Adding Submit Water button to the Enter Water Treatment.
dnicolalde Dec 6, 2024
e43bda6
Removing extra code that is no longer used.
dnicolalde Dec 6, 2024
63c2df9
Closing lixit order if one is open.
dnicolalde Dec 18, 2024
e61cc4d
Triggerscript function to check if animal is on lixit
dnicolalde Dec 18, 2024
eb32f70
Improving formatting of WaterCalendar.jsp
dnicolalde Dec 18, 2024
2041ea7
fixing overlap when closing lixit.
dnicolalde Dec 24, 2024
10ecb1a
Removing commented code.
dnicolalde Jan 3, 2025
398d8f6
fixing problem with lixit error and blank volume when adding a new wa…
dnicolalde Jan 4, 2025
4478c13
fix of water calendar not loading on production.
dnicolalde Jan 14, 2025
545bcda
fixing problem with closing water from water calendar UI and when ent…
dnicolalde Jan 15, 2025
09717d5
Fix problem with going back one month in the water calendar.
dnicolalde Jan 15, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SELECT
frequencyMeaning AS frequencyMeaningCoalesced,
timeofday AS timeofday,
displaytimeofday AS displaytimeofday,
actionRequired AS actionRequired,
qcstate AS qcstate,

--(SELECT max(wg.qcstate) as label FROM study.waterGiven wg WHERE WCO.objectid = wg.treatmentid AND WCO.dateOrdered = wg.dateordered ) AS waterStatus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<column name="rawDate"/>
<column name="mlsPerKg"/>
<column name="conditionAtTime"/>
<column name="actionRequired"/>
<column name="qcstate" />
<column name="taskid" />
</columns>
Expand Down
27 changes: 27 additions & 0 deletions WNPRC_EHR/resources/queries/study/deaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,35 @@ function onComplete(event, errors, helper) {
var ids = helper.getRows().map(function (row) {
return row.row.id;
});
var animalDateMap= [];
let clientRows = helper.getRows();

console.log("number of rows "+ clientRows.length);
if (clientRows){

for (var i= 0; i < clientRows.length; i++){
console.log("animalId "+clientRows[i].row.id);

animalDateMap.push({
animalId: clientRows[i].row.id,
endDate : clientRows[i].row.date
});

}

}
/*console.log("array line 37 " + Object.values(animalDateMap).length);

for (var i = 0; i < animalDateMap.length; i++){
console.log("array value " + animalDateMap[i]);
}*/

WNPRC.Utils.getJavaHelper().removeWaterAmounts(animalDateMap);

//Sends notification.
var hostName = 'https://' + LABKEY.serverName;
WNPRC.Utils.getJavaHelper().sendDeathNotification(ids, hostName);



}
25 changes: 1 addition & 24 deletions WNPRC_EHR/resources/queries/study/waterGiven.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,36 +85,19 @@ function onInit(event, helper){
}

function onUpsert(helper, scriptErrors, row, oldRow) {
/*if (row.volume == null){
EHR.Server.Utils.addError(scriptErrors, 'volume', 'This field is required', 'WARN');
console.log ("value of QCState "+ row.QCState)
}*/

if (row.QCStateLabel == 'Scheduled'){
EHR.Server.Validation.verifyDate(row, scriptErrors, helper);
}

if (row.Id && row.date)
{
// volume is handled differently for requestsvs actual draws
var errorQC = 'ERROR';
//if (EHR.Server.Security.getQCStateByLabel(row.QCStateLabel)['isRequest'] && !row.taskid)
// errorQC = 'ERROR';
//else
// errorQC = 'INFO';

var map = helper.getProperty('waterInTransaction');
var waters = [];
if (map && map[row.Id])
{
waters = map[row.Id];
/*for (var i=0;i<map.length; i++ ){
console.log ('value of map '+ map[i]);
waters.push (map[i]);
console.log ("map in JS "+map[i].objectid + " " + map[i].volume);
}*/
//console.log("stablishing map "+ map);
// waters.push(map);
}
if (row.location=='laboratory'){
if (!row.restraint){
Expand All @@ -135,7 +118,7 @@ function onUpsert(helper, scriptErrors, row, oldRow) {


//TODO: Troubleshoot this function to determine if the animal has not gotten enough water for the last three days.
/*if (row.volume)
/* if (row.volume)
{
var msg = WNPRC.Utils.getJavaHelper().waterLastThreeDays(row.Id, row.date, waters);
if (msg != null){
Expand Down Expand Up @@ -164,8 +147,6 @@ function onUpsert(helper, scriptErrors, row, oldRow) {
}

}


}
console.log ('parentid '+ row.parentid + ' lsid: '+row.lsid);
if (row.id && row.date && row.performedby && row.parentid && !row.lsid){
Expand Down Expand Up @@ -195,10 +176,6 @@ function onUpsert(helper, scriptErrors, row, oldRow) {

}
}


//EHR.Server.Validation.checkRestraint(row, scriptErrors);

}
function addWaterGivenDescription(row, waters){
let clientDescription = '';
Expand Down
6 changes: 3 additions & 3 deletions WNPRC_EHR/resources/queries/study/waterGiven.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
<fkTable>husbandry_fruit</fkTable>
<fkColumnName>value</fkColumnName>
</fk>
</column>
<column columnName="remarks">

</column>
<column columnName="waterSource">
<columnTitle>Water Source</columnTitle>
Expand All @@ -59,6 +56,9 @@
<fkColumnName>value</fkColumnName>
<fkDisplayColumnName>title</fkDisplayColumnName>
</fk>
</column>
<column columnName="remarks">

</column>
<column columnName="location">
<columnTitle>Water Location</columnTitle>
Expand Down
135 changes: 87 additions & 48 deletions WNPRC_EHR/resources/queries/study/waterOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ let allowUsersMap = {};
function onInit(event, helper){
helper.setScriptOptions({
allowFutureDates: true,
allowDatesInDistantPast: true
allowDatesInDistantPast: true,
skipWaterRegulationCheck: false
});
LABKEY.Query.selectRows({
requiredVersion: 9.1,
Expand Down Expand Up @@ -35,9 +36,40 @@ function onInit(event, helper){
});
}

function onInsert(helper, scriptErrors, row){
if (row.frequency !== 4 && row.waterSource === 'lixit'){
EHR.Server.Utils.addError(scriptErrors,"frequency", "Frequency should be 'Daily - Any Time' when selecting Lixit/Ad Lib", "ERROR");
}

function onUpsert(helper, scriptErrors, row, oldRow){
if (row.id && row.waterSource === 'regulated' && row.frequency && row.assignedTo && row.provideFruit && row.date){
let lixitOrderMap = WNPRC.Utils.getJavaHelper().checkWaterLixit(row.id, row.date);
let lixitStartDate;
let lixitOrderObjectid;
let latestWaterSource;

if (lixitOrderMap != null){
lixitStartDate = new Date(lixitOrderMap.date);
lixitOrderObjectid = lixitOrderMap.objectid;
latestWaterSource = lixitOrderMap.waterSource;

if(latestWaterSource === "lixit" ) {
let lixitEndDate = new Date(row.date);
console.log(lixitEndDate)
lixitEndDate.setDate(lixitEndDate.getDate()-1);
console.log("startdate " + lixitStartDate + " objectid " + lixitOrderObjectid + "enddate " + lixitEndDate + " watersource " +row.waterSource);
let jsonArray = WNPRC.Utils.getJavaHelper().closeWaterOrder(row.id, lixitStartDate, lixitEndDate, row.project, lixitOrderObjectid, true);
if (jsonArray != null) {
for (var i = 0; i < jsonArray.length; i++) {
var errorObject = jsonArray[i];
EHR.Server.Utils.addError(scriptErrors, errorObject.field, errorObject.message, errorObject.severity);
}
}
}
}
}
}

function onUpsert(helper, scriptErrors, row, oldRow){
if (row.Id){
EHR.Server.Utils.findDemographics({
participant: row.Id,
Expand All @@ -54,13 +86,9 @@ function onUpsert(helper, scriptErrors, row, oldRow){
});
var animalRestricted = {};
animalRestricted = WNPRC.Utils.getJavaHelper().checkIfAnimalInCondition(row.Id, row.date);
//console.log (animalRestricted);
if (!animalRestricted && !row.skipWaterRegulationCheck){
EHR.Server.Utils.addError(scriptErrors,'Id', 'Animal not assigned to water restriction protocol or is already in ' + row.waterSource + ' condition.', 'ERROR');
}



}


Expand All @@ -84,27 +112,31 @@ function onUpsert(helper, scriptErrors, row, oldRow){
if (rowDate.getTime() > endDate.getTime()){
EHR.Server.Utils.addError(scriptErrors,'endDate', 'EndDate cannot be before StartDate', 'ERROR');
}

if (!row.frequency && row.waterSource == 'regulated'){
if (!row.frequency && row.waterSource === 'regulated'){
EHR.Server.Utils.addError(scriptErrors, 'frequency', 'Frequency is required when entering regulated water orders.', 'ERROR');
}
if (!row.volume && row.waterSource == 'regulated'){
if (!row.volume && row.waterSource === 'regulated'){
//console.log ("water vol "+ row.volume);
EHR.Server.Utils.addError(scriptErrors, 'volume', 'Volume is required when entering regulated water orders.', 'ERROR');
}

if (!row.assignedTo && row.waterSource == 'regulated'){
if (!row.assignedTo && row.waterSource === 'regulated'){
EHR.Server.Utils.addError(scriptErrors, 'assignedTo', 'Assigned To is required when entering regulated water orders.', 'ERROR');
}

if (!row.provideFruit && row.waterSource === 'regulated'){
EHR.Server.Utils.addError(scriptErrors, 'provideFruit', 'Provide Fruit is required when entering regulated water orders.', 'INFO');
}
if (!row.waterSource){
EHR.Server.Utils.addError(scriptErrors, 'waterSource', 'Water Source is required when entering new orders.', 'ERROR');
}
if (row.volume !== undefined && row.volume!== null && row.waterSource === 'lixit'){
EHR.Server.Utils.addError(scriptErrors,"volume", "Volume should be blank when selecting Lixit/Ad Lib for Water Source", "ERROR");
}
if (row.frequency !== 4 && row.waterSource === 'lixit'){
EHR.Server.Utils.addError(scriptErrors,"frequency", "Frequency should be 'Daily - Any Time' when selecting Lixit/Ad Lib", "ERROR");
}


//console.log ("value of ObjectId "+oldRow.objectid + " Value of new objectId "+ row.objectid);
//console.log ('skipWaterRegulation '+ row.skipWaterRegulationCheck);
// if (oldRow && row.date && row.Id && row.frequency && (oldRow.objectid != row.objectid)) {
if (row.project && row.objectid && row.Id && row.date && row.frequency && row.assignedTo && row.waterSource != 'lixit' && !row.skipWaterRegulationCheck) {
if (row.project && row.objectid && row.Id && row.date && row.frequency && row.assignedTo && row.waterSource !== 'lixit' && !row.skipWaterRegulationCheck && !row.closingRecord ) {
let jsonArray = WNPRC.Utils.getJavaHelper().checkWaterRegulation(row.id, row.date, row.enddate ? row.enddate : null, row.frequency, row.waterSource, row.objectid, row.project, this.extraContext);
if (jsonArray != null) {
for (var i = 0; i < jsonArray.length; i++) {
Expand All @@ -115,35 +147,19 @@ function onUpsert(helper, scriptErrors, row, oldRow){
row.date = rowDate;
}

//if (oldRow && oldRow.waterSource == 'regulated' && row.waterSource == 'lixit'){
//TODO: by pass water regulation to change water order to lixit and also chnage the water regulated animals data
if ( row.waterSource == 'lixit' && !row.skipWaterRegulationCheck && !oldRow){

let jsonArray = WNPRC.Utils.getJavaHelper().changeWaterScheduled(row.id,row.date,row.waterSource, row.project, row.objectid,this.extraContext);
let jsonExtraContext = this.extraContext.extraContextArray;

if (jsonArray != null){
for (var i=0; i < jsonArray.length; i++){
let errorObject = JSON.parse(jsonArray[i]);
EHR.Server.Utils.addError(scriptErrors,errorObject.field, errorObject.message, errorObject.severity);

}
if (jsonExtraContext != null){
for (var i = 0; i < jsonExtraContext.length; i++){
let extraContextObject = jsonExtraContext[i];
let date = extraContextObject.date;
let dateOnly = new Date(date.getTime());
dateOnly = dateOnly.getFullYear()+ "-" +dateOnly.getMonth()+ "-" + dateOnly.getDate();
let infoMessage = "Water Order for "+ row.Id + " started on " + dateOnly + " with frequency of " + extraContextObject.frequency + " and volume of " + extraContextObject.volume + "ml will close.";
EHR.Server.Utils.addError(scriptErrors,"waterSource",infoMessage,"INFO")

}

if (row.Id && row.date && row.enddate && row.project && row.objectid && row.closingRecord){
let jsonArray = WNPRC.Utils.getJavaHelper().closeWaterOrder(row.id, row.date, row.enddate, row.project, row.objectid, row.closingRecord);
if (jsonArray != null) {
for (var i = 0; i < jsonArray.length; i++) {
var errorObject = jsonArray[i];
EHR.Server.Utils.addError(scriptErrors, errorObject.field, errorObject.message, errorObject.severity);
}

}
}

if ( row.waterSource === 'lixit' && row.volume === undefined && row.project && row.assignedTo && !row.skipWaterRegulationCheck){
changeWaterScheduled(row, scriptErrors);
}
}

function onUpdate(helper, scriptErrors, row, oldRow){
Expand Down Expand Up @@ -211,17 +227,40 @@ function onUpdate(helper, scriptErrors, row, oldRow){
}
}
}
}


if (row.id !== oldRow.id || row.date !== oldRow.date || row.volume !== oldRow.volume)
{
//EHR.Server.Utils.addError(scriptErrors,'date');

}

if ( row.waterSource === 'lixit' && row.project && row.volume === undefined && row.assignedTo && !row.skipWaterRegulationCheck){
changeWaterScheduled(row, scriptErrors);
}
}

function addErrorMessage(key,scriptErrors){
EHR.Server.Utils.addError(scriptErrors, key, 'User does not have permission to modify this field.', 'ERROR');
}

function changeWaterScheduled(row, scriptErrors){

let jsonArray = WNPRC.Utils.getJavaHelper().changeWaterScheduled(row.id,row.date,row.waterSource, row.project, row.objectid,this.extraContext);
let jsonExtraContext = this.extraContext.extraContextArray;

if (jsonArray != null){
for (var i=0; i < jsonArray.length; i++){
let errorObject = jsonArray[i];
EHR.Server.Utils.addError(scriptErrors,errorObject.field, errorObject.message, errorObject.severity);
}
if (jsonExtraContext != null){
for (var j = 0; j < jsonExtraContext.length; j++){
let extraContextObject = jsonExtraContext[j];
let date = extraContextObject.date;
let dateOnly = new Date(date.getTime());
let monthString = dateOnly.getMonth();
monthString++;

dateOnly = dateOnly.getFullYear()+ "-" + monthString + "-" + dateOnly.getDate();
let infoMessage = "Water Order for "+ row.Id + " started on " + dateOnly + " with frequency of " + extraContextObject.frequency + " and volume of " + extraContextObject.volume + "ml will close.";
EHR.Server.Utils.addError(scriptErrors,"waterSource",infoMessage,"INFO");
}
}
}

}
4 changes: 2 additions & 2 deletions WNPRC_EHR/resources/queries/study/waterSchedule.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ d.calculated_status AS calculated_status,
s.*,
s.objectid as treatmentid,
--(SELECT max(d.qcstate) as label FROM study.drug d WHERE s.objectid = d.treatmentid AND s.date = d.timeordered) as treatmentStatus,
COALESCE((SELECT max(wg.qcstate) as label FROM study.waterGiven wg WHERE wg.treatmentid LIKE '%' || s.objectid || '%' AND s.date = wg.dateordered AND wg.volume IS NOT NULL ),10) as waterStatus,
COALESCE((SELECT max(wg.qcstate) as label FROM study.waterGiven wg WHERE wg.treatmentid LIKE '%' || s.objectid || '%' AND s.date = wg.dateordered AND (wg.volume IS NOT NULL OR wg.waterSource = 'lixit') ),10) as waterStatus,
--COALESCE((SELECT max(wg.qcstate) as label FROM study.waterGiven wg WHERE s.objectid IN (wg.treatmentid) AND s.date = wg.dateordered AND wg.volume IS NOT NULL ),10) as waterStatus,
COALESCE((SELECT max(wg.treatmentid) as treatmentIds FROM study.waterGiven wg WHERE s.date = wg.dateordered AND wg.volume IS NOT NULL ),'objectId') as watertreatment
COALESCE((SELECT max(wg.treatmentid) as treatmentIds FROM study.waterGiven wg WHERE s.date = wg.dateordered AND (wg.volume IS NOT NULL OR wg.waterSource = 'lixit') ),'objectId') as watertreatment


FROM study.demographics d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<filters>
<filter column="dateOrdered" operator="dategte" value="-30d"/>
<filter column="timeofday" operator="eq" value="AM"/>
<filter column="waterSource/title" operator="eq" value="Regulated"/>
<filter column="Id/dataset/demographics/calculated_status" operator="eq" value="Alive"/>
</filters>
</customView>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<filters>
<filter column="dateOrdered" operator="dategte" value="-30d"/>
<filter column="timeofday" operator="eq" value="PM"/>
<filter column="waterSource/title" operator="eq" value="Regulated"/>
<filter column="Id/dataset/demographics/calculated_status" operator="eq" value="Alive"/>
</filters>
</customView>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
</sorts>
<filters>
<filter column="dateOrdered" operator="dategte" value="-30d"/>
<filter column="Id/dataset/demographics/calculated_status" operator="eq" value="Alive"/>
<filter column="qcstate" operator="neqornull" value="Completed"/>
<filter column="calculated_status" operator="eq" value="Alive"/>
<filter column="waterSource/title" operator="eq" value="Regulated"/>
<filter column="qcstate/label" operator="neqornull" value="Completed"/>
</filters>
</customView>
1 change: 1 addition & 0 deletions WNPRC_EHR/resources/web/wnprc_ehr/animalWaterCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EHR.reports.animalWaterCalendar = function (panel, tab){
} else if (panel.getFilterArray(tab).nonRemovable.length === 0){
entireColony = true;
panel.resolveSubjectsFromHousing(tab,renderCalendar,this);
calendarRender++;
//renderCalendar('null', tab)
}
else{
Expand Down
Loading