Skip to content
Open
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
16 changes: 16 additions & 0 deletions ONPRC_EHR_ComplianceDB/resources/views/employeeDetailsPublic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script type="text/javascript" nonce="<%=scriptNonce%>">

Ext4.onReady(function (){
if (!LABKEY.ActionURL.getParameter('employeeid')){
alert('Must Provide An Employee Id');
return;
}

var webpart = <%=webpartContext%>;
Ext4.create('EHR_ComplianceDB.panel.EmployeeDetailsPanel', {
employeeId: LABKEY.ActionURL.getParameter('employeeid'),
schemaName: 'EmployeeData'
}).render(webpart.wrapperDivId);
});

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<view xmlns="http://labkey.org/data/xml/view" title="Employee Details" frame="none">
<dependencies>
<dependency path="Ext4"/>
<dependency path="LDK/LDKApi"/>
<dependency path="ehr_complianceDB/panel/EmployeeDetailsPanel.js"/>
</dependencies>
</view>
24 changes: 20 additions & 4 deletions onprc_ehr/resources/queries/ehr_lookups/cageReview.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ SELECT
t.totalWeightExempt,
t.totalHeightExempt


FROM (

SELECT
Expand All @@ -68,6 +69,8 @@ SELECT
sum(CASE WHEN t0.weightExemption IS NULL THEN 0 ELSE 1 END) as totalWeightExempt,
count(t0.heightExemption) as totalHeightExempt



FROM (

SELECT
Expand All @@ -82,11 +85,14 @@ SELECT
group_concat(c1.height) as heights,
f.heightExemption,
CASE
WHEN hf.Id is not null AND c1.height >= pc.cage_type.height THEN 'ERROR: According to the monkeys weight-- it needs a height step taller than required.'
WHEN hf.Id is not null AND c1.height < pc.cage_type.height THEN 'NOTE: According to the monkeys weight-- it needs a height step taller than required.'
WHEN (pc.cage_type.height < c1.height AND f.heightExemption IS NULL) THEN ('ERROR: Insufficient height, ' || h.id ||' needs at least: ' || cast(c1.height AS varchar(50)))
WHEN (pc.cage_type.height < c1.height AND f.heightExemption IS NOT NULL) THEN cast(('NOTE: Height Exemption: ' || h.Id) as varchar(500))
ELSE null
END as heightStatus,
wf.weightExemption
wf.weightExemption,
hf.height_error

FROM ehr_lookups.connectedCages pc

Expand All @@ -98,17 +104,27 @@ LEFT JOIN (
f.id,
min(f.flag.value) as heightExemption
FROM study.flags f
WHERE f.isActive = true AND f.flag.category = 'Caging Note' and f.flag.description like '%exempt%'
WHERE f.isActive = true AND f.flag.category = 'Caging Note' and (f.flag.description like '%height-exempt%' or f.flag.description like '%Medical-exempt%')
GROUP BY f.Id
) f on (f.Id = h.Id)

--weight flags
--height flags
LEFT JOIN (
SELECT
f.id,
min(f.flag.value) as height_error
FROM study.flags f
WHERE f.isActive = true AND f.flag.category = 'Caging Note' and (f.flag.description like '%height-error%')
GROUP BY f.Id
) hf on (hf.Id = h.Id)

---weight flags
LEFT JOIN (
SELECT
f.id,
min(f.flag.value) as weightExemption
FROM study.flags f
WHERE f.isActive = true AND f.flag.category = 'Caging Note' and f.flag.description like '%exempt%'
WHERE f.isActive = true AND f.flag.category = 'Caging Note' and (f.flag.description like '%weight-exempt%' or f.flag.description like '%Medical-exempt%')
GROUP BY f.Id
) wf on (wf.Id = h.Id)

Expand Down
127 changes: 80 additions & 47 deletions onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1256,85 +1256,118 @@ exports.init = function(EHR){
}
}
});

//Added by Kollil, April 2026
function toDateOnly(val) {
if (!val)
return null;

// row.date object
if (typeof val === 'object' && val.time) {
var d = new Date(val.time);
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
}

// date strings like "2026-04-20 00:00:00.000"
var s = String(val).split(' ')[0]; // keep only YYYY-MM-DD
var parts = s.split('-');
if (parts.length !== 3)
return null;

return new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
}

// Added 10-17-2025 R. Blasa
EHR.Server.TriggerManager.unregisterAllHandlersForQueryNameAndEvent('study', 'assignment', EHR.Server.TriggerManager.Events.BEFORE_UPSERT);
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'assignment', function(helper, scriptErrors, row, oldRow){
if (!helper.isETL()){
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'assignment', function(helper, scriptErrors, row, oldRow) {
if (!helper.isETL()) {
//note: the the date field is handled above by removeTimeFromDate
EHR.Server.Utils.removeTimeFromDate(row, scriptErrors, 'enddate');
EHR.Server.Utils.removeTimeFromDate(row, scriptErrors, 'projectedRelease');
}


//check number of allowed animals at assign/approve time
if (!helper.isETL() && !helper.isQuickValidation() && helper.doStandardProtocolCountValidation() &&
//this is designed to always perform the check on imports, but also updates where the Id was changed
!(oldRow && oldRow.Id && oldRow.Id==row.Id) &&
!(oldRow && oldRow.Id && oldRow.Id == row.Id) &&
row.Id && row.project && row.date
){
) {
var assignmentsInTransaction = helper.getProperty('assignmentsInTransaction');
assignmentsInTransaction = assignmentsInTransaction || [];

var msgs = helper.getJavaHelper().verifyProtocolCounts(row.Id, row.project, assignmentsInTransaction);
if (msgs){
if (msgs) {
msgs = msgs.split("<>");
for (var i=0;i<msgs.length;i++){
for (var i = 0; i < msgs.length; i++) {
EHR.Server.Utils.addError(scriptErrors, 'project', msgs[i], 'WARN');
}
}
}

// note: if this is automatically generated from death/departure, allow an incomplete record
// alerts will flag these
if (row.enddate && !row.releaseCondition && !helper.isGeneratedByServer()){
EHR.Server.Utils.addError(scriptErrors, 'releaseCondition', 'Must provide the release condition when the release date is set', 'WARN');
}
// note: if this is automatically generated from death/departure, allow an incomplete record
// alerts will flag these
if (row.enddate && !row.releaseCondition && !helper.isGeneratedByServer()) {
EHR.Server.Utils.addError(scriptErrors, 'releaseCondition', 'Lakshmi, Must provide the release condition when the release date is set', 'WARN');
}

if (row.enddate && !row.releaseType && !helper.isGeneratedByServer()){
EHR.Server.Utils.addError(scriptErrors, 'releaseType', 'Must provide the release type when the release date is set', 'WARN');
}
if (row.enddate && !row.releaseType && !helper.isGeneratedByServer()) {
EHR.Server.Utils.addError(scriptErrors, 'releaseType', 'Must provide the release type when the release date is set', 'WARN');
}

//update condition on release
//Modified: 5-13-2019 R.Blasa
if (!helper.isETL() && helper.getEvent() == 'update' && oldRow){
if (EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData && EHR.Server.Security.getQCStateByLabel(oldRow.QCStateLabel).PublicData){
if (row.releaseCondition && row.enddate && row.releaseCondition != 206){
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.enddate, row.releaseCondition);
if (msg){
EHR.Server.Utils.addError(scriptErrors, 'releaseCondition', msg, 'INFO');
}
else {
triggerHelper.updateAnimalCondition(row.Id, row.enddate, row.releaseCondition);
}
//update condition on release
//Modified: 5-13-2019 R.Blasa
if (!helper.isETL() && helper.getEvent() == 'update' && oldRow) {
if (EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData && EHR.Server.Security.getQCStateByLabel(oldRow.QCStateLabel).PublicData) {
if (row.releaseCondition && row.enddate && row.releaseCondition != 206) {
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.enddate, row.releaseCondition);
if (msg) {
EHR.Server.Utils.addError(scriptErrors, 'releaseCondition', msg, 'INFO');
} else {
triggerHelper.updateAnimalCondition(row.Id, row.enddate, row.releaseCondition);
}
}
}
}

// we want to record the date a record was marked endded, in addition to the actual end itself
// NOTE: we only do this when both enddate and releaseType are entered
if (!row.enddatefinalized && row.enddate && row.releaseCondition && EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData){
//note: if ended in the future, defer to that date
row.enddatefinalized = new Date();
if (row.enddate.getTime() > row.enddatefinalized.getTime()){
row.enddatefinalized = row.enddate;
}
// we want to record the date a record was marked endded, in addition to the actual end itself
// NOTE: we only do this when both enddate and releaseType are entered
if (!row.enddatefinalized && row.enddate && row.releaseCondition && EHR.Server.Security.getQCStateByLabel(row.QCStateLabel).PublicData) {
//note: if ended in the future, defer to that date
row.enddatefinalized = new Date();
if (row.enddate.getTime() > row.enddatefinalized.getTime()) {
row.enddatefinalized = row.enddate;
}
}

//check for condition downgrade for assign condition
if (!helper.isETL() && row.Id && row.assignCondition){
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.date, row.assignCondition);
if (msg){
EHR.Server.Utils.addError(scriptErrors, 'assignCondition', msg, 'INFO');
}
//check for condition downgrade for assign condition
if (!helper.isETL() && row.Id && row.assignCondition) {
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.date, row.assignCondition);
if (msg) {
EHR.Server.Utils.addError(scriptErrors, 'assignCondition', msg, 'INFO');
}
}

//check for condition downgrade for assign condition
if (!helper.isETL() && row.Id && row.date && row.assignCondition){
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.date, row.assignCondition);
if (msg){
EHR.Server.Utils.addError(scriptErrors, 'assignCondition', msg, 'INFO');
}
//check for condition downgrade for assign condition
if (!helper.isETL() && row.Id && row.date && row.assignCondition) {
var msg = triggerHelper.checkForConditionDowngrade(row.Id, row.date, row.assignCondition);
if (msg) {
EHR.Server.Utils.addError(scriptErrors, 'assignCondition', msg, 'INFO');
}
}

//Added by Kollil, April 2026. Refer to ticket # 13807
if (row.project && row.date) {
var projectEndDate = triggerHelper.getProjectEndDate(row.project); //helper.getJavaHelper().getProjectEndDate(row.project);
var assignmentDate = toDateOnly(row.date);
var endDate = toDateOnly(projectEndDate);

if (assignmentDate && endDate && assignmentDate.getTime() > endDate.getTime()) {
// console.log('4.5 DEBUG assignmentDate=' + assignmentDate);
EHR.Server.Utils.addError(scriptErrors, 'project', 'The assignment start date occurs after the end date of the selected center project. Please review the assignment date and confirm!', 'WARN');

}
}

});

//Added 10-5-2022 R.Blasa
Expand Down
3 changes: 2 additions & 1 deletion onprc_ehr/resources/views/printRoom.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
foundCages = true;
Ext4.create('Ext.panel.Panel', {
border: false,
width: 1450,
defaults: {
border: false
},
Expand All @@ -63,7 +64,7 @@
}
else {
// Hack to improve printing in Chrome
if (Ext4.isChrome) { Ext4.get(webpart.wrapperDivId).setStyle({zoom: '150%'}); };
if (Ext4.isChrome) { Ext4.get(webpart.wrapperDivId).setStyle({zoom: '110%'}); };
}

}, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ EHR.model.DataModelManager.registerMetadata('BehaviorDefaults', {
},
category: {
lookup: {
filterArray: [LABKEY.Filter.create('category', 'Behavior')]
filterArray: [LABKEY.Filter.create('category', 'Behavior'),
LABKEY.Filter.create('value', 'Behaviors',LABKEY.Filter.Types.NEQ)]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,33 @@ public boolean requiresAssistingStaff(Integer procedureId)
return "Surgery".equals(category);
}

//Added by Kollil
//Date: Apr 2026
public Date getProjectEndDate(Object projectId)
{
if (projectId == null)
return null;

int pid;
if (projectId instanceof Number)
pid = ((Number) projectId).intValue();
else
pid = Integer.parseInt(projectId.toString());

UserSchema ehrSchema = QueryService.get().getUserSchema(_user, _container, "ehr");
if (ehrSchema == null)
return null;

TableInfo ti = ehrSchema.getTable("project");
if (ti == null)
return null;

SimpleFilter filter = new SimpleFilter(FieldKey.fromString("project"), pid);
TableSelector ts = new TableSelector(ti, Collections.singleton("enddate"), filter, null);

return ts.getObject(Date.class);
}

public String getSpeciesForDam(String dam)
{
return new TableSelector(getTableInfo("study", "demographics"), PageFlowUtil.set("species"), new SimpleFilter(FieldKey.fromString("Id"), dam), null).getObject(String.class);
Expand Down