Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function beforeDelete(row, errors){
var fields = ['categoryname'], fieldName;
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', 'category', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', 'category', row[fieldName], 'employeecategory')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the employees table');
}

if (helper.verifyNotUsed('ehr_compliancedb', 'requirementspercategory', 'category', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'requirementspercategory', 'category', row[fieldName], 'employeecategory')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the requirementspercategory table');
}

if (helper.verifyNotUsed('ehr_compliancedb', 'sopbycategory', 'category', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'sopbycategory', 'category', row[fieldName], 'employeecategory')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the sopbycategory table');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function beforeDelete(row, errors){
var fields = ['location'], fieldName;
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', 'location', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', 'location', row[fieldName], 'employeelocations')){
errors[fieldName] = ['Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the employees table'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ function beforeDelete(row, errors){
query = queries[j];
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', query, 'employeeid', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', query, 'employeeid', row[fieldName], 'employees')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the table ' + query);
}
}
}

//also check trainer
if (helper.verifyNotUsed('ehr_compliancedb', 'completiondates', 'trainer', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'completiondates', 'trainer', row[fieldName], 'employees')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the table completiondates');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function beforeDelete(row, errors){
var fields = ['title'], fieldName;
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', fieldName, row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', fieldName, row[fieldName], 'employeetitles')){
errors[fieldName] = ['Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the employees table'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function beforeDelete(row, errors){
var fields = ['type'], fieldName;
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', fieldName, row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'employees', fieldName, row[fieldName], 'employeetypes')){
errors[fieldName] = ['Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the employees table'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function beforeDelete(row, errors){
query = queries[j];
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', query, 'requirementname', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', query, 'requirementname', row[fieldName], 'requirements')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the table ' + query);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function beforeDelete(row, errors){
var fields = ['type'], fieldName;
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', 'requirements', fieldName, row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', 'requirements', fieldName, row[fieldName], 'requirementtype')){
errors[fieldName] = ['Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the requirements table'];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function beforeDelete(row, errors){
query = queries[j];
for (var i=0;i<fields.length;i++){
fieldName = fields[i];
if (helper.verifyNotUsed('ehr_compliancedb', query, 'unit', row[fieldName])){
if (helper.verifyNotUsed('ehr_compliancedb', query, 'unit', row[fieldName], 'unit_names')){
addError(errors, fieldName, 'Cannot delete row with value: ' + row[fieldName] + ' because it is referenced by the table ' + query);
}
}
Expand Down
12 changes: 7 additions & 5 deletions ehr/resources/queries/ehr_lookups/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

var console = require("console");
var LABKEY = require("labkey");
var triggers = require("ehr/triggers");
triggers.initScript(this);
var EHR = triggers.EHR;

var helper = org.labkey.ldk.query.LookupValidationHelper.create(LABKEY.Security.currentContainer.id, LABKEY.Security.currentUser.id, 'ehr_lookups', 'procedures');
var lookupValidationHelper = org.labkey.ldk.query.LookupValidationHelper.create(LABKEY.Security.currentContainer.id, LABKEY.Security.currentUser.id, 'ehr_lookups', 'procedures');


function beforeDelete(row, errors){
if (helper.verifyNotUsed('study', 'encounters', 'procedureid', row['rowid'])){
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_DELETE, 'ehr_lookups', 'procedures', function(helper, scriptErrors, row, oldRow){
if (lookupValidationHelper.verifyNotUsed('study', 'encounters', 'procedureid', row['rowid'], 'procedures')) {
addError(errors, 'name', 'Cannot delete row with ID: ' + row['rowid'] + ' because it is referenced by the table encounters. You should inactivate this item instead.');
}
}
});

function addError(errors, fieldName, msg){
if (!errors[fieldName])
Expand Down
45 changes: 13 additions & 32 deletions ehr/resources/queries/study/HousingOverlaps.sql
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
/*
* Copyright (c) 2011-2019 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

/**
* This query is designed to find housing records that overlap. In this query, the overlap to calculated based on both date and time
* A record that ends at the same time that a second record begins is not considered an overlap.
*/
PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL)

Modified by Kollil on 7/23/25 - Added Area field to the query and the rooms are filtered by area(s) selected, refer to tkt # 12894
*/
SELECT
h.lsid,
h.id,
h.room,
h.cage,
h.date,
h.enddate,
h.reason,
h.remark,
h.qcstate

h.lsid,
h.id,
h.room.area as area, -- Added by Kollil
h.room,
h.cage,
h.date,
h.enddate,
h.reason,
h.remark,
h.qcstate
FROM study.housing h

WHERE
h.qcstate = 18

(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND
(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND

/* entered startdate must be <= entered enddate */
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now())
and

/* entered startdate must be less than record's enddate */
coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now())
and

/* entered enddate must be greater than record's startdate */
coalesce(ENDDATE, now()) >= coalesce(h.date, now())
31 changes: 0 additions & 31 deletions ehr/resources/queries/study/HousingOverlapsById.sql

This file was deleted.

64 changes: 0 additions & 64 deletions ehr/resources/queries/study/HousingOverlapsById/.qview.xml

This file was deleted.

31 changes: 0 additions & 31 deletions ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql

This file was deleted.

64 changes: 0 additions & 64 deletions ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="HousingOverlapsById" tableDbType="TABLE">
<table tableName="HousingOverlapsReport" tableDbType="TABLE">
<javaCustomizer class="org.labkey.ehr.table.DefaultEHRCustomizer" />
<tableTitle>Housing Overlaps</tableTitle>
<description>This query identifies distinct animal IDs that overlapped with given housing records, accounting for date and time</description>
<description>This query identifies distinct housing records that overlapped with the given housing records, accounting for date and time</description>
<tableUrl />
<columns>
<column columnName="Id">
<column columnName="lsid">
<isKeyField>true</isKeyField>
</column>
<column columnName="date">
<columnTitle>Start Date</columnTitle>
<isHidden>true</isHidden>
</column>
</columns>
<buttonBarOptions position="both" includeStandardButtons="false">
Expand Down
Loading