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
@@ -0,0 +1,9 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="vet_assignment_InvalidRule" tableDbType="NOT_IN_DB">
<tableTitle>Invalid Vet Assignment Rules</tableTitle>
</table>
</tables>
</metadata>
</query>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2014-2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

WITH ruleData AS (
SELECT
rowid,
CASE
WHEN (userId IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Project IS NULL AND Protocol IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Project IS NULL AND Protocol IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Protocol IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Protocol IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Protocol IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Protocol IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Area IS NULL AND Room IS NULL AND Protocol IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Project IS NOT NULL AND Area IS NULL AND Room IS NULL AND Protocol IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Project IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Project IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Project IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Project IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Area IS NULL AND Room IS NULL AND Project IS NULL AND Priority = true) THEN 1
WHEN (userId IS NOT NULL AND Protocol.DisplayName IS NOT NULL AND Area IS NULL AND Room IS NULL AND Project IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Room IS NOT NULL AND Area IS NULL AND Protocol IS NULL AND Project IS NULL AND Priority = false) THEN 1
WHEN (userId IS NOT NULL AND Area IS NOT NULL AND Room IS NULL AND Protocol IS NULL AND Project IS NULL AND Priority = false) THEN 1
ELSE 0
END AS valid
FROM onprc_ehr.vet_assignment
)
SELECT
userId,
project,
protocol,
area,
room,
priority
FROM onprc_ehr.vet_assignment
WHERE rowid IN (SELECT rowid FROM ruleData WHERE valid = 0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="observationsLinkedToAnotherAnimalsCase" tableDbType="NOT_IN_DB">
<tableTitle>Observations Linked to Another Animal's Case</tableTitle>
</table>
</tables>
</metadata>
</query>
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
WITH Observations AS (
SELECT
o.Id,
o.caseid,
o.caseid.id.id AS linkid,
o.caseid.caseNo AS linkCaseNo,
o.caseid._key AS linkCaseKey,
o.caseid.date AS linkCaseDate,
o.taskid,
o.performedby,
o.date,
o.created,

NULLIF(o.category, 'Observations') AS category,
NULLIF(o.area, 'N/A') AS area,

CASE
WHEN o.category IS NULL AND o.observation IS NOT NULL
THEN o.observation
WHEN o.category IS NOT NULL AND o.observation IS NULL
THEN o.category
WHEN o.category IS NOT NULL AND o.area IS NULL
THEN (o.category || ': ' || o.observation)
WHEN o.category IS NOT NULL AND o.area IS NOT NULL
THEN (o.category || ': ' || o.area || ', ' || o.observation)
ELSE NULL
END
||
COALESCE(
CASE
WHEN o.remark IS NOT NULL AND o.observation IS NOT NULL
THEN ('. ' || o.remark)
ELSE o.remark
END,
''
) AS observation_string
FROM study.clinical_observations o
WHERE
o.caseid IS NOT NULL
AND o.category NOT IN ('Vet Review', 'Reviewed')
AND o.id <> o.caseid.id.id -- MUCH faster than NOT LIKE
),

AggregatedObservations AS (
SELECT
Id,
caseid,
linkid,
linkCaseNo,
linkCaseKey,
linkCaseDate,
taskid,
performedby,
date,
MIN(created) AS created,
GROUP_CONCAT(
CAST(observation_string AS VARCHAR(1000)),
'; '
) AS observations
FROM Observations
GROUP BY
Id,
caseid,
linkid,
linkCaseNo,
linkCaseKey,
linkCaseDate,
taskid,
performedby,
date
),

AnimalCases AS (
SELECT
ao.*,
c.category,
c.caseNo,
c.objectId AS key
FROM AggregatedObservations ao
LEFT JOIN study.cases c
ON c.Id = ao.Id
AND ao.created >= c.date
AND (ao.created <= c.enddate OR c.enddate IS NULL)
)

SELECT
Id AS ObsAnimalId,
date,
created,
observations,
taskid,
performedby,
linkid AS LinkedCaseAnimalId,
caseid AS linkedCaseCategory,
linkCaseNo,
linkCaseKey,
linkCaseDate,
GROUP_CONCAT(category, ', ') AS openCasesAtObsCreation,
GROUP_CONCAT(caseNo, ', ') AS openCaseNosAtObsCreation,
GROUP_CONCAT(key, ', ') AS openCaseKeysAtObsCreation
FROM AnimalCases
GROUP BY
Id,
date,
created,
observations,
taskid,
performedby,
linkid,
caseid,
linkCaseNo,
linkCaseKey,
linkCaseDate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<query xmlns="http://labkey.org/data/xml/query">
<metadata>
<tables xmlns="http://labkey.org/data/xml">
<table tableName="vetAssignment_multipleVets" tableDbType="NOT_IN_DB">
<tableTitle>NHPs With Multiple Assigned Vets</tableTitle>
</table>
</tables>
</metadata>
</query>
25 changes: 25 additions & 0 deletions onprc_ehr/resources/queries/study/vetAssignment_multipleVets.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2014-2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/

WITH assignmentData AS (
SELECT DISTINCT
Id,
Area,
Room,
CASE
WHEN AssignmentType = 'Open Case' THEN (AssignedVet || ', Open Case: ' || COALESCE(MasterProblems, ''))
ELSE (AssignedVet || ', ' || AssignmentType)
END AS assignment
FROM demographicsAssignedVet
)
SELECT
Id,
Area,
Room,
GROUP_CONCAT(assignment, chr(10)) AS Vets
FROM assignmentData
GROUP BY Id, Area, Room
HAVING COUNT(*) > 1
2 changes: 1 addition & 1 deletion onprc_ehr/resources/queries/study/vetassignment_filter.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023-2026 LabKey Corporation
* Copyright (c) 2014-2026 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
Expand Down
16 changes: 5 additions & 11 deletions onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ exports.init = function(EHR){
Id: row.Id,
birth: row.date,
date: row.date,
calculated_status: 'Fetus'
calculated_status: 'Fetus',
species: row.species,
geographic_origin: row.geographic_origin,
gender: row.gender

};


Expand Down Expand Up @@ -692,16 +696,6 @@ exports.init = function(EHR){
hasUpdates = true;
}

//update death date in demographics if born dead
if (row.Id && row.date && !data.death && !triggerHelper.isBirthAlive(row.birth_condition || null)){
obj.death = row.date;
hasUpdates = true;

//if this is the first time a birth condition was entered, treat this the same as when a death is entered
if (oldRow && !oldRow.birth_condition){
helper.onDeathDeparture(row.Id, row.date);
}
}

if (hasUpdates){
obj.Id = row.Id;
Expand Down
82 changes: 82 additions & 0 deletions onprc_ehr/resources/web/onprc_ehr/data/sources/ONPRCDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,52 @@ EHR.model.DataModelManager.registerMetadata('Default', {
ret.setHours(8);
return ret;
}
},
route: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
},
vol_units: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
},
amount_units: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
}
},
'study.drug': {
route: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
},
vol_units: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
},
amount_units: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
}

},

'study.blood' : {
Expand Down Expand Up @@ -96,6 +141,13 @@ EHR.model.DataModelManager.registerMetadata('Default', {
width: 150
}
},
source: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
},
//Added: 5-3-2018 R.Blasa
acquisitionType: {
hidden: false,
Expand Down Expand Up @@ -210,7 +262,37 @@ EHR.model.DataModelManager.registerMetadata('Default', {
height: 52
}
},
//Modified: 9-10-2026 R. Blasa affects both Necropsy and Surgery
'ehr.encounter_participants': {
username: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
}
},
//Modified: 9-10-2026 R. Blasa
'study.housing': {
room: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
}
},

//Modified: 9-10-2026 R. Blasa
'study.Departure': {
destination: {
editorConfig: {
plugins: [Ext4.create('LDK.plugin.UserEditableCombo', {
allowChooseOther: false
})]
}
}
},
//Added: 12-27-2017 R.blasa

'study.flags': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,8 +1244,8 @@ public void createBirthRecord_ONPRC(String id, Map<String, Object> props) throws
// Added: 6-27-2017 F.Blasa Process when transitioning from Prenatal - Fetus to Live
public void doBirthConditionAfterPrenatal(String id, Date date, String dam, Date Arrival_Date, String birthCondition, boolean isBecomingPublic) throws Exception
{
//is the infant is dead, terminate the assignments
Date enddate = isBirthAlive(birthCondition) ? null : date;

Date enddate = null ;

String nonRestrictedFlag = getFlag("Condition", NONRESTRICTED, null, true);
if (nonRestrictedFlag != null)
Expand Down Expand Up @@ -1273,16 +1273,9 @@ public void doBirthConditionAfterPrenatal(String id, Date date, String dam, Date
//Modified: 10-13-2016 R.Blasa to include assign Arrival date
public void doBirthTriggers(String id, Date date, String dam, Date Arrival_Date, String birthCondition, String species, boolean isBecomingPublic) throws Exception
{
//is the infant is dead, terminate the assignments
Date enddate = isBirthAlive(birthCondition) ? null : date;

Date enddate = null ;

//also check for a pre-existing death record:
Date deathDate = new TableSelector(getTableInfo("study", "deaths"), Collections.singleton("date"), new SimpleFilter(FieldKey.fromString("Id"), id), null).getObject(Date.class);
if (deathDate != null)
{
enddate = deathDate;
}

//note: we only want this to run the first time this record becomes public, not on subsequent updates
if (isBecomingPublic)
Expand Down
Loading
Loading