defaultButtons = super.getTbarButtons();
+
+ if (defaultButtons.contains("COPYFROMSECTION"))
+ {
+ int idx = defaultButtons.indexOf("COPYFROMSECTION");
+ defaultButtons.remove("COPYFROMSECTION");
+ defaultButtons.add(idx, "IPC_COPYFROMSECTION");
+ }
+
+ return defaultButtons;
+ }
+
+}
\ No newline at end of file
From 5f26b76f6ffeec93e8416b9ed4bad7654fed89d2 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Tue, 15 Feb 2022 13:14:09 -0800
Subject: [PATCH 02/23] Fixed the sql error
---
.../schemas/dbscripts/sqlserver/onprc_ehr-20.418-20.419.sql | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-20.418-20.419.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-20.418-20.419.sql
index 934ce5a85..5889279c9 100644
--- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-20.418-20.419.sql
+++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-20.418-20.419.sql
@@ -1,5 +1,5 @@
-DROP TABLE IF EXISTS [onprc_ehr].[IPC_Reference_Data]
- GO
+EXEC core.fn_dropifexists 'IPC_Reference_Data','onprc_ehr','TABLE';
+GO
/****** Object: Table [onprc_ehr].[IPC_Reference_Data] Script Date: 4/27/2020 ******/
CREATE TABLE [onprc_ehr].[IPC_Reference_Data](
From eca2fa6009c76161cbcfc55cb42f319df80f1a32 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Tue, 15 Feb 2022 14:57:04 -0800
Subject: [PATCH 03/23] Removed the commented out lines from the code.
---
.../web/onprc_ehr/model/sources/IPC_Child.js | 24 +--------------
.../IPC_ServiceRequestDetailsFormSection.java | 29 ++-----------------
2 files changed, 3 insertions(+), 50 deletions(-)
diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Child.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Child.js
index db7065d75..b481aa490 100644
--- a/onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Child.js
+++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/IPC_Child.js
@@ -14,30 +14,8 @@ EHR.model.DataModelManager.registerMetadata('IPC_Child', {
date: {
inheritDateFromParent: true
}
- // project: {
- // inheritFromParent: true
- // }
- // chargetype: {
- // inheritFromParent: true
- // }
+
}
- // byQuery: {
- // 'study.treatment_order': {
- // date: {
- // inheritDateFromParent: false
- // }
- // },
- // 'study.blood': {
- // project: {
- // inheritFromParent: false
- // }
- // },
- // 'onprc_billing.miscCharges': {
- // project: {
- // inheritFromParent: false
- // }
- // }
- // }
});
\ No newline at end of file
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/IPC_ServiceRequestDetailsFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/IPC_ServiceRequestDetailsFormSection.java
index 04022c6ba..c623a20bf 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/IPC_ServiceRequestDetailsFormSection.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/IPC_ServiceRequestDetailsFormSection.java
@@ -1,39 +1,14 @@
-//package org.labkey.onprc_ehr.dataentry;
-//
-//import org.labkey.api.ehr.EHRService;
-//import org.labkey.api.ehr.dataentry.SimpleFormPanelSection;
-//import org.labkey.api.view.template.ClientDependency;
-//
-///**
+/*
// * User: Kolli
// * Date: 4/01/2020
// * Time: 10:36 AM
-// */
-//public class IPC_AnimalDetailsFormSection extends SimpleGridPanel
-//{
-// public IPC_AnimalDetailsFormSection()
-// {
-// this(EHRService.FORM_SECTION_LOCATION.Body);
-// }
-//
-// public IPC_AnimalDetailsFormSection(EHRService.FORM_SECTION_LOCATION location)
-// {
-// super("study", "IPC_AnimalDetails", "Service Request Details", location);
-// addClientDependency(ClientDependency.fromPath("onprc_ehr/model/sources/IPC_AnimalDetails.js"));
-// addConfigSource("AnimalDetails");
-// }
-//}
+ */
package org.labkey.onprc_ehr.dataentry;
import org.labkey.api.ehr.dataentry.SimpleFormPanelSection;
import org.labkey.api.view.template.ClientDependency;
-/**
- * User: Kolli
- * Date: 4/01/2020
- * Time: 10:36 AM
- */
public class IPC_ServiceRequestDetailsFormSection extends SimpleFormPanelSection
{
public IPC_ServiceRequestDetailsFormSection(String label)
From c30bc767f9624001cd1868e5f36c6a53a1645705 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Tue, 15 Feb 2022 17:42:02 -0800
Subject: [PATCH 04/23] Added the IPC service
---
onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
index b5e8f562a..541678ef5 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
@@ -483,7 +483,7 @@ public String toString()
// EHRService.get().registerFormType(new DefaultDataEntryFormFactory(ARTCoreRequestFormType.class, this));
//Added: 8/10/2019 Kolli
-// EHRService.get().registerFormType(new DefaultDataEntryFormFactory(IPCRequestFormType.class, this));
+ EHRService.get().registerFormType(new DefaultDataEntryFormFactory(IPCRequestFormType.class, this));
// Added: 11-21-2017 R.Blasa
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(ProcedureRequestBulkEditFormType.class, this));
From 3ea906878ce02ff85a7816cdec8efbe60b7b6e76 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Thu, 17 Feb 2022 12:25:18 -0800
Subject: [PATCH 05/23] Added the reference data table and xml schema.
---
.../sqlserver/onprc_ehr-22.001-22.002.sql | 17 +++++++++
onprc_ehr/resources/schemas/onprc_ehr.xml | 35 +++++++++++++++++++
.../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 2 +-
3 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-22.001-22.002.sql
diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-22.001-22.002.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-22.001-22.002.sql
new file mode 100644
index 000000000..5889279c9
--- /dev/null
+++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-22.001-22.002.sql
@@ -0,0 +1,17 @@
+EXEC core.fn_dropifexists 'IPC_Reference_Data','onprc_ehr','TABLE';
+GO
+
+/****** Object: Table [onprc_ehr].[IPC_Reference_Data] Script Date: 4/27/2020 ******/
+CREATE TABLE [onprc_ehr].[IPC_Reference_Data](
+ [rowId] INT IDENTITY(1,1)NOT NULL,
+ [value] [nvarchar](1000) NULL,
+ [name] [nvarchar](1000) NULL,
+ [remark] [nvarchar](4000) NULL,
+ [dateDisabled] [datetime] NULL,
+ [created] [datetime] NULL,
+ [createdBy] [int] NULL,
+ [modified] [datetime] NULL,
+ [modifiedBy] [int] NULL
+
+ CONSTRAINT pk_IPC_Reference_Data PRIMARY KEY (rowId)
+ )
\ No newline at end of file
diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml
index 08acd88db..bb0ae2dc3 100644
--- a/onprc_ehr/resources/schemas/onprc_ehr.xml
+++ b/onprc_ehr/resources/schemas/onprc_ehr.xml
@@ -1028,6 +1028,41 @@
+
+
+ IPC_Reference_Data
+
+ DETAILED
+
+
+ true
+
+
+
+ Value
+
+
+
+ Name
+
+
+
+
+ End Date
+
+
+
+ true
+
+
+
+ true
+
+
+
+
+
+
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
index 541678ef5..229cdcb03 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
@@ -121,7 +121,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
- return 22.001;
+ return 22.002;
}
@Override
From 734d7c9088a0012629ad163ad26d89bfb639117b Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Wed, 23 Mar 2022 12:11:35 -0700
Subject: [PATCH 06/23] Updated IPC code
---
onprc_ehr/resources/queries/study/IPC_Stains.sql | 1 +
1 file changed, 1 insertion(+)
diff --git a/onprc_ehr/resources/queries/study/IPC_Stains.sql b/onprc_ehr/resources/queries/study/IPC_Stains.sql
index 52bdaddb0..d2aa3e2e8 100644
--- a/onprc_ehr/resources/queries/study/IPC_Stains.sql
+++ b/onprc_ehr/resources/queries/study/IPC_Stains.sql
@@ -1,2 +1,3 @@
+--Get the stains data
SELECT value, name from Site.{substitutePath moduleProperty('EHR','EHRStudyContainer')}.onprc_ehr.IPC_Reference_Data
Where name like 'IPCStains' and dateDisabled is null
\ No newline at end of file
From d0c5f4fbcefaade1cc791f42790e5fbfda943183 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Wed, 6 Apr 2022 12:50:46 -0700
Subject: [PATCH 07/23] Added th IPC copy section feature
---
.../window/IPC_CopyFromSectionWindow.js | 398 ++++++++++++++++++
1 file changed, 398 insertions(+)
create mode 100644 onprc_ehr/resources/web/onprc_ehr/window/IPC_CopyFromSectionWindow.js
diff --git a/onprc_ehr/resources/web/onprc_ehr/window/IPC_CopyFromSectionWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/IPC_CopyFromSectionWindow.js
new file mode 100644
index 000000000..889a8cbcb
--- /dev/null
+++ b/onprc_ehr/resources/web/onprc_ehr/window/IPC_CopyFromSectionWindow.js
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 2013-2017 LabKey Corporation
+ *
+ * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
+ */
+/**
+ * @cfg targetGrid
+ * @cfg parentStore
+ * @cfg sourceLabel
+ * Created: Kollil, 5/19/2020
+ */
+Ext4.define('ONPRC_EHR.window.IPC_CopyFromSectionWindow', {
+ extend: 'Ext.window.Window',
+
+ initComponent: function(){
+ this.getParentRecords();
+
+ Ext4.applyIf(this, {
+ modal: true,
+ width: 1000,
+ closeAction: 'destroy',
+ title: 'Copy From ' + this.sourceLabel,
+ bodyStyle: 'padding: 5px;',
+ defaults: {
+ border: false
+ },
+ items: [{
+ html: 'This helper allows you to populate 1 row for each animal from the ' + this.sourceLabel + ' section. Choose which IDs to add from the list below.',
+ style: 'margin-bottom: 10px;'
+ },{
+ xtype: 'checkbox',
+ fieldLabel: 'Bulk Edit Values',
+ labelWidth: 150,
+ helpPopup: 'If checked, you will be prompted with a screen that lets you bulk edit the records that will be created. This is often very useful when adding many similar records.',
+ itemId: 'chooseValues',
+ style: 'margin-bottom: 10px;'
+ },{
+ itemId: 'animalIds',
+ items: this.getInitialItems()
+ }],
+ buttons: [{
+ text: 'Submit',
+ itemId: 'submitBtn',
+ scope: this,
+ handler: this.onSubmit
+ },{
+ text: 'Close',
+ handler: function(btn){
+ btn.up('window').close();
+ }
+ }]
+ });
+
+ this.callParent();
+
+ this.on('beforeshow', function(window){
+ if (!this.parentRecords.length){
+ Ext4.Msg.alert('No Records', 'There are no records to copy. Note: only records with an Id/Date can be copied.');
+ return false;
+ }
+ }, this);
+ },
+
+ getParentRecords: function(){
+ var records = [];
+ this.parentStore.each(function(r){
+ if (r.get('Id') && r.get('date')){
+ records.push(r);
+ }
+ }, this);
+
+ this.parentRecords = records;
+
+ return records;
+ },
+
+ getExistingIds: function(keyFields){
+ var map = {};
+ this.targetGrid.store.each(function(r){
+ var key = this.getKeyValue(r, keyFields);
+ if (r.get('Id'))
+ map[key] = true;
+ }, this);
+
+ return map;
+ },
+
+ getKeyValue: function(record, keyFields){
+ var key = [];
+ Ext4.Array.forEach(keyFields, function(kf){
+ if (record.get(kf))
+ key.push(record.get(kf));
+ }, this);
+
+ return key.join ('||');
+ },
+
+ getInitialItems: function(){
+ var items = [{
+ html: 'Animal'
+ },{
+ html: 'Date'
+ },{
+ html: 'Project'
+ }]
+
+ if (this.targetGrid.store.getFields().get('chargetype'))
+ {
+ items.push({
+ html: 'Charge Unit'
+ });
+ }
+
+ if (this.targetGrid.store.getFields().get('tissueType'))
+ {
+ items.push({
+ html: 'Tissue Type'
+ });
+ }
+
+ items = items.concat([{
+ html: 'Performed By'
+ },{
+ html: 'Skip?'
+ }]);
+
+ var keys = {}, key;
+ var keyFields = ['Id', 'date', 'tissueType'];
+// if (this.targetGrid.store.getFields().get('parentid')){
+// keyFields.push('parentid');
+// }
+// if (this.targetGrid.store.getFields().get('runid')){
+// keyFields.push('runid');
+// }
+
+ //console.log(keyFields);
+ var orderedKeys = [];
+ Ext4.Array.forEach(this.parentRecords, function(record){
+ key = this.getKeyValue(record, keyFields);
+ if (orderedKeys.indexOf(key) == -1){
+ orderedKeys.push(key);
+ }
+
+ keys[key] = keys[key] || {
+ Id: record.get('Id'),
+// parentid: keyFields.indexOf('parentid') > -1 ? record.get('parentid') : null,
+// runid: keyFields.indexOf('runid') > -1 ? record.get('runid') : null,
+ performedby: [],
+ projects: [],
+ chargeUnits: [],
+ tissueTypes: [],
+ dates: [],
+ total: 0
+ };
+
+ keys[key].total++;
+ if (record.get('performedby'))
+ keys[key].performedby.push(record.get('performedby'));
+ if (record.get('project'))
+ keys[key].projects.push(record.get('project'));
+ if (record.fields.get('chargetype') && record.get('chargetype'))
+ keys[key].chargeUnits.push(record.get('chargetype'));
+
+ if (record.fields.get('tissueType') && record.get('tissueType'))
+ keys[key].tissueTypes.push(record.get('tissueType'));
+
+ keys[key].dates.push(record.get('date'))
+ }, this);
+
+ var existingIds = this.getExistingIds(keyFields);
+ Ext4.Array.forEach(orderedKeys, function(key){
+ var o = keys[key];
+
+ items.push({
+ xtype: 'displayfield',
+ key: key,
+ value: o.Id,
+ fieldName: 'Id'
+ });
+
+ var dates = [];
+ var minDate;
+ Ext4.Array.forEach(o.dates, function(date){
+ if (!minDate || date < minDate)
+ minDate = date;
+
+ dates.push(date.format(LABKEY.extDefaultDateTimeFormat));
+ }, this);
+
+ o.performedby = Ext4.unique(o.performedby);
+ var performedby = o.performedby.length == 1 ? o.performedby[0] : null;
+
+ o.projects = Ext4.unique(o.projects);
+ var project = o.projects.length == 1 ? o.projects[0] : null;
+
+ o.chargeUnits = Ext4.unique(o.chargeUnits);
+ var chargeUnit = o.chargeUnits.length == 1 ? o.chargeUnits[0] : null;
+
+ o.tissueTypes = Ext4.unique(o.tissueTypes);
+ var tissueType = o.tissueTypes.length == 1 ? o.tissueTypes[0] : null;
+
+
+ items.push({
+ xtype: 'xdatetime',
+ width: 300,
+ format: LABKEY.extDefaultDateTimeFormat,
+ timeFormat: 'H:i',
+ fieldName: 'date',
+ key: key,
+ value: minDate
+ });
+
+ items.push({
+ xtype: 'ehr-projectfield',
+ matchFieldWidth: false,
+ showInactive: true,
+ fieldLabel: null,
+ width: 100,
+ fieldName: 'project',
+ key: key,
+ value: project
+ });
+
+ if (this.targetGrid.store.getFields().get('chargetype')){
+ var cfg = LABKEY.ext4.Util.getDefaultEditorConfig(this.targetGrid.store.getFields().get('chargetype'));
+
+ items.push(Ext4.apply(cfg, {
+ matchFieldWidth: false,
+ showInactive: true,
+ fieldLabel: null,
+ width: 160,
+ fieldName: 'chargetype',
+ key: key,
+ value: chargeUnit
+ }));
+ }
+
+ if (this.targetGrid.store.getFields().get('tissueType')){
+ var cfg = LABKEY.ext4.Util.getDefaultEditorConfig(this.targetGrid.store.getFields().get('tissueType'));
+
+ items.push(Ext4.apply(cfg, {
+ matchFieldWidth: false,
+ showInactive: true,
+ fieldLabel: null,
+ width: 160,
+ fieldName: 'tissueType',
+ key: key,
+ value: tissueType
+ }));
+ }
+
+ items.push({
+ xtype: 'textfield',
+ width: 200,
+ fieldName: 'performedby',
+ key: key,
+ value: performedby
+ });
+
+ items.push({
+ xtype: 'checkbox',
+ key: key,
+ fieldName: 'exclude',
+ checked: existingIds[key]
+ });
+ }, this);
+
+ return [{
+ itemId: 'theTable',
+ border: false,
+ layout: {
+ type: 'table',
+ //columns: this.targetGrid.store.getFields().get('chargetype') ? 6 : 5,
+ columns: this.targetGrid.store.getFields().get('tissueType') ? 6 : 5
+ },
+ defaults: {
+ border: false,
+ style: 'margin: 5px;'
+ },
+ items: items
+ }]
+ },
+
+ getRows: function(){
+ var table = this.down('#theTable');
+ var orderedKeys = [];
+ var rowMap = {};
+ table.items.each(function(item){
+ if (item.fieldName){
+ if (orderedKeys.indexOf(item.key) == -1)
+ orderedKeys.push(item.key);
+
+ rowMap[item.key] = rowMap[item.key] || {};
+ rowMap[item.key][item.fieldName] = item.getValue ? item.getValue() : item.value;
+ }
+ }, this);
+
+ var ret = [];
+ Ext4.Array.forEach(orderedKeys, function(key){
+ ret.push(rowMap[key]);
+ }, this);
+
+ return ret;
+ },
+
+ onSubmit: function(btn){
+ var toAdd = [];
+ Ext4.Array.forEach(this.getRows(), function(data){
+ if (!data.exclude){
+ toAdd.push(this.targetGrid.store.createModel(data));
+ }
+ }, this);
+
+ if (toAdd.length){
+ var choose = this.down('#chooseValues').getValue();
+ if (choose){
+ Ext4.create('EHR.window.BulkEditWindow', {
+ suppressConfirmMsg: true,
+ records: toAdd,
+ targetStore: this.targetGrid.store,
+ formConfig: this.targetGrid.formConfig
+ }).show();
+ this.close();
+ }
+ else {
+ this.targetGrid.store.add(toAdd);
+ }
+ }
+
+ this.close();
+ }
+});
+
+
+EHR.DataEntryUtils.registerGridButton('IPC_COPYFROMSECTION', function(config){
+ return Ext4.Object.merge({
+ text: 'IPC Copy From Section',
+ xtype: 'button',
+ tooltip: 'Click to copy records from one of the other sections',
+ listeners: {
+ beforerender: function(btn){
+ var grid = btn.up('gridpanel');
+ LDK.Assert.assertNotEmpty('Unable to find gridpanel in COPYFROMSECTION button', grid);
+
+ btn.grid = grid;
+
+ btn.appendButtons.call(btn);
+ }
+ },
+ menu: {
+ xtype: 'menu',
+ items: [{
+ text: 'Loading...'
+ }]
+ },
+ appendButtons: function(){
+ this.dataEntryPanel = this.grid.up('ehr-dataentrypanel');
+ LDK.Assert.assertNotEmpty('Unable to find dataEntryPanel in COPYFROMSECTION button', this.dataEntryPanel);
+
+ var toAdd = [];
+ Ext4.Array.forEach(this.dataEntryPanel.formConfig.sections, function(section){
+ if (section.name == this.grid.formConfig.name){
+ return;
+ }
+
+ var store = this.dataEntryPanel.storeCollection.getClientStoreByName(section.name);
+ if (store){
+ //only allow copying from sections with an ID field
+ if (!store.getFields().get('Id')){
+ return;
+ }
+
+ toAdd.push({
+ text: section.label,
+ scope: this,
+ handler: function(menu){
+ Ext4.create('ONPRC_EHR.window.IPC_CopyFromSectionWindow', {
+ targetGrid: this.grid,
+ sourceLabel: section.label,
+ parentStore: store
+ }).show();
+ }
+ });
+ }
+ }, this);
+
+ this.menu.removeAll();
+ if (toAdd.length){
+ this.menu.add(toAdd);
+ }
+ else {
+ this.menu.add({
+ text: 'There are no other sections'
+ })
+ }
+ }
+ });
+});
\ No newline at end of file
From fa4ff954a636bfe0e45cf2526d0579e9515e57ca Mon Sep 17 00:00:00 2001
From: kollil
Date: Mon, 23 Oct 2023 11:55:43 -0700
Subject: [PATCH 08/23] IPC project load. created new sql file.
---
.../sqlserver/onprc_ehr-23.007-23.008.sql | 17 +++++++++++++++++
onprc_ehr/resources/schemas/onprc_ehr.xml | 1 -
.../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 14 +++++---------
3 files changed, 22 insertions(+), 10 deletions(-)
create mode 100644 onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.007-23.008.sql
diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.007-23.008.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.007-23.008.sql
new file mode 100644
index 000000000..ad07d4cfc
--- /dev/null
+++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.007-23.008.sql
@@ -0,0 +1,17 @@
+EXEC core.fn_dropifexists 'IPC_Reference_Data','onprc_ehr','TABLE';
+GO
+
+/****** Object: Table [onprc_ehr].[IPC_Reference_Data] Script Date: 4/27/2020 ******/
+CREATE TABLE [onprc_ehr].[IPC_Reference_Data](
+ [rowId] INT IDENTITY(1,1)NOT NULL,
+ [value] [nvarchar](1000) NULL,
+ [name] [nvarchar](1000) NULL,
+ [remark] [nvarchar](4000) NULL,
+ [dateDisabled] [datetime] NULL,
+ [created] [datetime] NULL,
+ [createdBy] [int] NULL,
+ [modified] [datetime] NULL,
+ [modifiedBy] [int] NULL
+
+ CONSTRAINT pk_IPC_Reference_Data PRIMARY KEY (rowId)
+ )
diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml
index 17a512e8a..8f9f18715 100644
--- a/onprc_ehr/resources/schemas/onprc_ehr.xml
+++ b/onprc_ehr/resources/schemas/onprc_ehr.xml
@@ -898,7 +898,6 @@
true
-
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
index edbb6bde0..0c12e543c 100644
--- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
+++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
@@ -123,7 +123,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
- return 23.007;
+ return 23.008;
}
@Override
@@ -550,13 +550,11 @@ public String toString()
//Added: 7/10/2019 by Kolli
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(PMICDataEntryFormType.class, this));
- //Added: 1/13/2021 Kolli
-// EHRService.get().registerFormType(new DefaultDataEntryFormFactory(ARTCoreRequestFormType.class, this));
-
- //Added: 8/10/2019 Kolli
-// EHRService.get().registerFormType(new DefaultDataEntryFormFactory(IPCRequestFormType.class, this));
+ //Created: 8/10/2019 Kolli
+ //Modified: 10/20/2023 Kolli
+ EHRService.get().registerFormType(new DefaultDataEntryFormFactory(IPCRequestFormType.class, this));
-// Added: 11-21-2017 R.Blasa
+ //Added: 11-21-2017 R.Blasa
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(ProcedureRequestBulkEditFormType.class, this));
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(RecordAmendmentFormType.class, this));
@@ -576,8 +574,6 @@ public String toString()
//Added: 6-6-2022 R.Blasa
EHRService.get().registerFormType(new DefaultDataEntryFormFactory(NecropsyRequestForm.class, this));
-
-
//single section forms
EHRService.get().registerSingleFormOverride(new SingleQueryFormProvider(this, "study", "treatment_order", new MedicationsQueryFormSection("study", "Treatment Orders", "Medication/Treatment Orders")));
EHRService.get().registerSingleFormOverride(new SingleQueryFormProvider(this, "study", "drug", new MedicationsQueryFormSection("study", "Drug Administration", "Medication/Treatments Given")));
From a422097b04472f31b65d183845168063a04b679f Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:01:20 -0700
Subject: [PATCH 09/23] Delete
onprc_ehr/resources/queries/study/Notes_WithLocation.query.xml
not related to this PR
---
.../queries/study/Notes_WithLocation.query.xml | 10 ----------
1 file changed, 10 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/Notes_WithLocation.query.xml
diff --git a/onprc_ehr/resources/queries/study/Notes_WithLocation.query.xml b/onprc_ehr/resources/queries/study/Notes_WithLocation.query.xml
deleted file mode 100644
index 948863812..000000000
--- a/onprc_ehr/resources/queries/study/Notes_WithLocation.query.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
From c76266271a502fe80a2d922cc315d277584fb990 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:02:05 -0700
Subject: [PATCH 10/23] Delete
onprc_ehr/src/org/labkey/onprc_ehr/notification/TreatmentAlertsMPANotification.java
not related to this PR
---
.../TreatmentAlertsMPANotification.java | 272 ------------------
1 file changed, 272 deletions(-)
delete mode 100644 onprc_ehr/src/org/labkey/onprc_ehr/notification/TreatmentAlertsMPANotification.java
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/TreatmentAlertsMPANotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/TreatmentAlertsMPANotification.java
deleted file mode 100644
index 07e75a87d..000000000
--- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/TreatmentAlertsMPANotification.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (c) 2015-2018 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.onprc_ehr.notification;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.labkey.api.data.ColumnInfo;
-import org.labkey.api.data.CompareType;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.Results;
-import org.labkey.api.data.ResultsImpl;
-import org.labkey.api.data.Selector;
-import org.labkey.api.data.SimpleFilter;
-import org.labkey.api.data.Sort;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.data.TableSelector;
-import org.labkey.api.module.Module;
-import org.labkey.api.query.FieldKey;
-import org.labkey.api.query.QueryService;
-import org.labkey.api.security.User;
-import org.labkey.api.ehr.notification.AbstractEHRNotification;
-import org.labkey.api.util.PageFlowUtil;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-//Added by Kollil 9/25/23 Post Op MPA injections scheduled at 2Pm on Wednesdays starting from Sep 13th, 2023
-//Tkt #9939
-public class TreatmentAlertsMPANotification extends AbstractEHRNotification
-{
- public TreatmentAlertsMPANotification(Module owner)
- {
- super(owner);
- }
-
- @Override
- public String getName()
- {
- return "MPA Injection Alerts";
- }
-
- @Override
- public String getDescription()
- {
- return "This runs every Wednesday at 2PM if there are MPA injections scheduled that have not yet been marked complete";
- }
-
- @Override
- public String getEmailSubject(Container c)
- {
- return "MPA Injection Alert: " + getDateTimeFormat(c).format(new Date());
- }
-
- @Override
- public String getCronString() { return "0 0 14 ? * WED * ";}
-
- @Override
- public String getScheduleDescription()
- {
- return "Every Wednesday at 2PM";
- }
-
- @Override
- public String getMessageBodyHTML(Container c, User u)
- {
- StringBuilder msg = new StringBuilder();
-
- //Find today's date
- Date now = new Date();
- msg.append("This email contains any treatments not marked as completed. It was run on: " + getDateFormat(c).format(now) + " at " + _timeFormat.format(now) + "
" +
- "Please use the following contacts if the medication has not been completed.
" +
- "Email: cmumedicationrequests@ohsu.edu
" +
- "DCM Commons: 503 - 346 - 5074
" +
- "Colony tech office: 503 - 346 - 5152
" +
- "Colony hospital: 503 - 346 - 5424 " + "");
-
- processMPATreatments(c, u, msg, new Date());
- return msg.toString();
- }
-
- private void processMPATreatments(Container c, User u, final StringBuilder msg, final Date maxDate)
- {
- Date curDate = new Date();
- Date roundedMax = new Date();
- roundedMax.setTime(maxDate.getTime());
- roundedMax = DateUtils.truncate(roundedMax, Calendar.DATE);
-
- TableInfo ti = QueryService.get().getUserSchema(u, c, "study").getTable("treatmentScheduleMPA");
-
- SimpleFilter filter = new SimpleFilter(FieldKey.fromString("date"), roundedMax, CompareType.DATE_EQUAL);
- filter.addCondition(FieldKey.fromString("date"), maxDate, CompareType.LTE);
- filter.addCondition(FieldKey.fromString("Id/DataSet/Demographics/calculated_status"), "Alive");
-
- Set columns = new HashSet<>();
- columns.add(FieldKey.fromString("Id"));
- columns.add(FieldKey.fromString("Id/curLocation/area"));
- columns.add(FieldKey.fromString("Id/curLocation/room"));
- columns.add(FieldKey.fromString("Id/curLoation/cage"));
- columns.add(FieldKey.fromString("projectStatus"));
- columns.add(FieldKey.fromString("treatmentStatus"));
- columns.add(FieldKey.fromString("treatmentStatus/Label"));
- columns.add(FieldKey.fromString("code"));
- columns.add(FieldKey.fromString("code/meaning"));
-
- Map params = new HashMap<>();
- params.put("StartDate", roundedMax);
- params.put("NumDays", 1);
-
- final Map colMap = QueryService.get().getColumns(ti, columns);
- TableSelector ts = new TableSelector(ti, colMap.values(), filter, new Sort("Id/curLocation/area,Id/curLocation/room"));
- ts.setNamedParameters(params);
-
- String url = getExecuteQueryUrl(c, "study", "treatmentScheduleMPA", null) + "&" + filter.toQueryString("query") + getParameterUrlString(c, params);
- long total = ts.getRowCount();
- if (total == 0) {
- msg.append("There are no MPA injections scheduled on " + getDateFormat(c).format(maxDate) + " on or before " + _timeFormat.format(maxDate) + ". Treatments could be added after this email was sent, so please click here to check online closer to the time.
\n");
- }
- else {
- final String completed = "completed";
- final String incomplete = "incomplete";
- final Map totals = new HashMap<>();
- totals.put(completed, 0);
- totals.put(incomplete, 0);
-
- final Map totalByArea = new TreeMap<>();
- ts.forEach(new Selector.ForEachBlock()
- {
- @Override
- public void exec(ResultSet object) throws SQLException {
- Results rs = new ResultsImpl(object, colMap);
- if ("Completed".equals(rs.getString(FieldKey.fromString("treatmentStatus")))) {
- totals.put(completed, totals.get(completed) + 1);
- }
- else {
- totals.put(incomplete, totals.get(incomplete) + 1);
-
- String area = rs.getString(FieldKey.fromString("Id/curLocation/area"));
- Integer areaVal = totalByArea.containsKey(area) ? totalByArea.get(area) : 0;
- areaVal++;
-
- totalByArea.put(area, areaVal);
- }
- }
- });
- msg.append("Treatments:");
- msg.append("There are " + (totals.get(completed) + totals.get(incomplete)) + " scheduled treatments on or before " + _timeFormat.format(maxDate) + ". Click here to view them. Of these, " + totals.get(completed) + " have been marked completed.
\n");
-
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //Add code to display report, by Kollil
-
- TableInfo ti1 = QueryService.get().getUserSchema(u, c, "study").getTable("treatmentScheduleMPA");
-
- //All fields
- Set columns1 = new HashSet<>();
- columns1.add(FieldKey.fromString("id"));
- columns1.add(FieldKey.fromString("calculated_status"));
- columns1.add(FieldKey.fromString("treatmentStatus"));
- columns1.add(FieldKey.fromString("room"));
- columns1.add(FieldKey.fromString("cage"));
- columns1.add(FieldKey.fromString("date"));
- columns1.add(FieldKey.fromString("startDate"));
- columns1.add(FieldKey.fromString("endDate"));
- columns1.add(FieldKey.fromString("dayselapsed"));
- columns1.add(FieldKey.fromString("category"));
- columns1.add(FieldKey.fromString("medication"));
- columns1.add(FieldKey.fromString("volume"));
- columns1.add(FieldKey.fromString("vol_units"));
- columns1.add(FieldKey.fromString("concentration"));
- columns1.add(FieldKey.fromString("conc_units"));
- columns1.add(FieldKey.fromString("amountWithUnits"));
- columns1.add(FieldKey.fromString("amountAndVolume"));
- columns1.add(FieldKey.fromString("dosage"));
- columns1.add(FieldKey.fromString("dosage_units"));
- columns1.add(FieldKey.fromString("frequency"));
- columns1.add(FieldKey.fromString("route"));
- columns1.add(FieldKey.fromString("reason"));
- columns1.add(FieldKey.fromString("remark"));
- columns1.add(FieldKey.fromString("performedby"));
-
- final Map colMap1 = QueryService.get().getColumns(ti1, columns1);
- TableSelector ts1 = new TableSelector(ti1, colMap1.values(), filter, new Sort("id"));
- ts1.setNamedParameters(params);
- total = ts1.getRowCount();
-
- if (total == 0) {
- msg.append("There are no MPA injections.");
- }
- else {
- msg.append("
MPA Injections:
\n");
- msg.append("");
- msg.append("| Id | Status | Treatment Status | Room | Cage | Treatment Date | Treatment Start Date | Treatment End Date | Days Elapsed | Category | Treatment | Volume | Volume Units | Drug Conc | Conc Units | Amount | Amount And Volume | Dosage | Dosage Units | Frequency | Route | Reason | Remark | Ordered By |
");
-
- ts1.forEach(new Selector.ForEachBlock()
- {
- @Override
- public void exec(ResultSet object) throws SQLException
- {
- Results rs = new ResultsImpl(object, colMap1);
- String status = rs.getString("TreatmentStatus");
- if ("completed".equalsIgnoreCase(status)) {
- msg.append("");
- }
- else {
- //If not "completed", highlight the record with yellow color
- msg.append("
");
- }
- msg.append("| " + PageFlowUtil.filter(rs.getString("id")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("calculated_status")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("TreatmentStatus")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("room")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("cage")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("date")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("startDate")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("endDate")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("dayselapsed")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("category")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("medication")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("volume")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("vol_units")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("concentration")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("conc_units")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("amountWithUnits")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("amountAndVolume")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("dosage")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("dosage_units")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("frequency")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("route")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("reason")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("remark")) + " | ");
- msg.append("" + PageFlowUtil.filter(rs.getString("performedby")) + " | ");
- msg.append("
");
- }
- });
-
- msg.append("
");
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- if (totals.get(incomplete) == 0) {
- msg.append("All MPA medications scheduled prior to " + _timeFormat.format(maxDate) + " have been marked complete as of " + getDateTimeFormat(c).format(curDate) + ".\n");
- }
- else {
- msg.append("There are " + totals.get(incomplete) + " treatments that have not been marked complete:
\n");
- msg.append("
\n");
- }
- msg.append("
\n");
- }
- }
-}
\ No newline at end of file
From 21087bdaa4e36d12356305a782612012a1e2d6bd Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:02:33 -0700
Subject: [PATCH 11/23] Delete
onprc_ehr/resources/queries/study/demographicsAssignedVet.query.xml
not related to this PR
---
.../study/demographicsAssignedVet.query.xml | 15 ---------------
1 file changed, 15 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/demographicsAssignedVet.query.xml
diff --git a/onprc_ehr/resources/queries/study/demographicsAssignedVet.query.xml b/onprc_ehr/resources/queries/study/demographicsAssignedVet.query.xml
deleted file mode 100644
index 16a065547..000000000
--- a/onprc_ehr/resources/queries/study/demographicsAssignedVet.query.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- Assigned Vets
-
-
- true
-
-
-
-
-
-
-
From 947cbd69d03795938a92f53cdfb6df3e9be0359f Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:02:58 -0700
Subject: [PATCH 12/23] Delete
onprc_ehr/resources/queries/study/treatmentScheduleMPA.query.xml
not related to this PR
---
.../queries/study/treatmentScheduleMPA.query.xml | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/treatmentScheduleMPA.query.xml
diff --git a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.query.xml b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.query.xml
deleted file mode 100644
index 830f79524..000000000
--- a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.query.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
- MPA Injections
-
-
- Status
-
-
-
-
-
-
From 0da347df67a2ef71e027e5c89c6cc162d2a6e367 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:03:16 -0700
Subject: [PATCH 13/23] Delete
onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql
not related to this PR
---
.../queries/study/treatmentScheduleMPA.sql | 98 -------------------
1 file changed, 98 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql
diff --git a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql b/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql
deleted file mode 100644
index 13defec33..000000000
--- a/onprc_ehr/resources/queries/study/treatmentScheduleMPA.sql
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2015 LabKey Corporation
- * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
-
- -- Created by Kollil on 9/25/2023
- Tkt# 9939
- Creating a new alert for this medication. This MPA injection is a post op med category but scheduled once a month.
-
- */
-SELECT
- h.id,
- h.calculated_status,
- --s.TreatmentStatus,
- (SELECT max(d.qcstate.label) as label FROM study.drug d WHERE s.objectid = d.treatmentid and s.date = d.timeordered) as TreatmentStatus,
- h.Id.curLocation.room as room,
- h.Id.curLocation.cage as cage,
- s.date,
- s.startDate,
- s.endDate,
- s.dayselapsed,
- s.category,
- s.code,
- s.code.meaning as medication,
- s.volume,
- s.vol_units,
- s.concentration,
- s.conc_units,
- s.amountWithUnits,
- s.amountAndVolume,
- s.dosage,
- s.dosage_units,
- s.frequency,
- s.route,
- s.reason,
- s.remark,
- s.performedby
-FROM study.demographics h JOIN (
-
- SELECT
- s.animalid, s.TreatmentStatus, timestampadd('SQL_TSI_MINUTE', ((s.hours * 60) + s.minutes), s.origDate) as date, s.objectid,
- s.startdate, s.enddate, s.dayselapsed, s.category, s.code, s.volume, s.vol_units, s.concentration, s.conc_units,
- s.amountWithUnits, s.amountAndVolume, s.dosage, s.dosage_units, s.frequency, s.route, s.reason, s.remark, s.performedby
- FROM (
-
- SELECT
- t1.objectid,
- t1.id as animalid,
- (coalesce(tt.time, ft.hourofday, (hour(t1.date) * 100)) / 100) as hours,
-
- CASE
- WHEN (tt.time IS NOT NULL OR ft.hourofday IS NOT NULL) THEN (((coalesce(tt.time, ft.hourofday) / 100.0) - floor(coalesce(tt.time, ft.hourofday) / 100)) * 100)
- ELSE minute(t1.date)
- END as minutes,
- dr.date as origDate,
-
- CASE
- WHEN snomed.code IS NOT NULL THEN 'Post Op Meds'
- ELSE t1.category
- END as category,
-
- t1.date as startDate,
- timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed,
- t1.enddate, t1.code, t1.volume, t1.vol_units, t1.concentration, t1.conc_units, t1.amountWithUnits,
- t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning + ' (' + t1.frequency.times + ')' as frequency, t1.route,
- t1.reason, t1.performedby, t1.remark, t1.qcstate.label as TreatmentStatus
-
- FROM ehr_lookups.dateRange dr
-
- Join study."Treatment Orders" t1
- ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND
- mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0
- )
-
- LEFT JOIN ehr.treatment_times tt ON (tt.treatmentid = t1.objectid)
- LEFT JOIN ehr_lookups.treatment_frequency_times ft ON (ft.frequency = t1.frequency.meaning AND tt.rowid IS NULL)
-
- INNER JOIN (
- SELECT
- sc.code
- FROM ehr_lookups.snomed_subset_codes sc
- WHERE sc.primaryCategory = 'Post Op Meds'
- /* Added this clause by Kollil on 10/4/2023 to exclude the MPA injection from the list.
- This change is made according to the new request by Cassie Tkt# 9939. The MPA med is part of the post op meds category
- so, excluding the other post op meds from this alert list. This list produces only the MPA injection entires.
- */
- AND sc.code IN ('E-85760')
- GROUP BY sc.code
- ) snomed ON snomed.code = t1.code
-
---NOTE: if we run this report on a future interval, we want to include those treatments
- WHERE t1.date is not null
---NOTE: they have decided to include non-public data
- ) s
-
-) s ON (s.animalid = h.id)
-WHERE h.calculated_status = 'Alive'
- --account for date/time in schedule
- and s.date >= s.startDate and s.date <= s.enddate
\ No newline at end of file
From 9943ea6c81dceda2e551c6ec23b9a041d440167b Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:04:00 -0700
Subject: [PATCH 14/23] Delete
onprc_ehr/src/org/labkey/onprc_ehr/dataentry/MedSignoffFormType.java
not related to this PR
---
.../dataentry/MedSignoffFormType.java | 86 -------------------
1 file changed, 86 deletions(-)
delete mode 100644 onprc_ehr/src/org/labkey/onprc_ehr/dataentry/MedSignoffFormType.java
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/MedSignoffFormType.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/MedSignoffFormType.java
deleted file mode 100644
index a9c8fbfef..000000000
--- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/MedSignoffFormType.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2013-2018 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.onprc_ehr.dataentry;
-
-import org.labkey.api.ehr.EHRService;
-import org.labkey.api.ehr.dataentry.AnimalDetailsFormSection;
-import org.labkey.api.ehr.dataentry.DataEntryFormContext;
-import org.labkey.api.ehr.dataentry.NonStoreFormSection;
-import org.labkey.api.ehr.dataentry.TaskForm;
-import org.labkey.api.ehr.dataentry.TaskFormSection;
-import org.labkey.api.ehr.dataentry.DrugAdministrationFormSection;
-import org.labkey.api.ehr.security.EHRClinicalEntryPermission;
-import org.labkey.api.module.Module;
-import org.labkey.api.module.ModuleLoader;
-import org.labkey.api.security.Group;
-import org.labkey.api.security.GroupManager;
-import org.labkey.api.security.permissions.AdminPermission;
-import org.labkey.api.view.template.ClientDependency;
-import org.labkey.security.xml.GroupEnumType;
-
-import java.util.Arrays;
-
-/**
- * User: bimber
- * Date: 7/29/13
- * Time: 5:03 PM
- */
-public class MedSignoffFormType extends TaskForm
-{
- public static final String NAME = "medsignoff";
- public static final String LABEL = "Post-administration Med Verification"; //Changed by Kollil on 10/11/23, Refer to tkt #9939
-
- public MedSignoffFormType(DataEntryFormContext ctx, Module owner)
- {
- super(ctx, owner, NAME, LABEL, "Clinical", Arrays.asList(
- new TaskFormSection(),
- //Added 2-19-2016 Blasa
- new NonStoreFormSection("Treatment Template Helper", "Treatment Template Helper", "onprc_AddScheduledTreatmentPanel", Arrays.asList(ClientDependency.supplierFromPath("/onprc_ehr/panel/AddScheduledTreatmentPanel.js"))),
-
- new AnimalDetailsFormSection(),
- new DrugAdministrationFormSection(ClientDependency.supplierFromPath("onprc_ehr/window/ONPRC_AddScheduledTreatmentWindow.js"))
- /* new TreatmentOrdersFormSection()*/
- ));
-
- if (ctx.getContainer().getActiveModules().contains(ModuleLoader.getInstance().getModule("onprc_billing")))
- {
- addSection(new MiscChargesFormSection(EHRService.FORM_SECTION_LOCATION.Body));
- }
-
- }
-
- @Override
- protected boolean canInsert()
- {
- if (!getCtx().getContainer().hasPermission(getCtx().getUser(), EHRClinicalEntryPermission.class))
- return false;
-
- return super.canInsert();
- }
-
- //Modified: 12-5-2019 R.Blasa
- @Override
- public boolean isVisible()
- {
- Group g = GroupManager.getGroup(getCtx().getContainer(), "ASB Support", GroupEnumType.SITE);
- if (g != null && getCtx().getUser().isInGroup(g.getUserId()) && !getCtx().getContainer().hasPermission(getCtx().getUser(), AdminPermission.class))
- {
- return false;
- }
-
- return super.isVisible();
- }
-}
From 34ca2460304d3844d928ac42478fdcd819eac702 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:04:47 -0700
Subject: [PATCH 15/23] Delete
onprc_ehr/resources/queries/study/Notes_WithLocation.sql
not related to this PR
---
.../queries/study/Notes_WithLocation.sql | 15 ---------------
1 file changed, 15 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/Notes_WithLocation.sql
diff --git a/onprc_ehr/resources/queries/study/Notes_WithLocation.sql b/onprc_ehr/resources/queries/study/Notes_WithLocation.sql
deleted file mode 100644
index 68b54fa60..000000000
--- a/onprc_ehr/resources/queries/study/Notes_WithLocation.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-Select
- Id,
- CASE
- WHEN id.curLocation.cage is null then id.curLocation.room
- ELSE (id.curLocation.room || '-' || id.curLocation.cage)
- END AS Location,
- date,
- actiondate,
- enddate,
- category,
- value,
- remark,
- qcstate,
- taskid
-From study.notes
\ No newline at end of file
From e54689c213560b6e30d6c586b268971437c33abb Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:05:06 -0700
Subject: [PATCH 16/23] Delete
onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql
not related to this PR
---
.../study/TreatmentSchedulePostOps.sql | 214 ------------------
1 file changed, 214 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql
diff --git a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql b/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql
deleted file mode 100644
index ece5f0b8e..000000000
--- a/onprc_ehr/resources/queries/study/TreatmentSchedulePostOps.sql
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2015 LabKey Corporation
- * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
-
- -- Modified by Kolli on 9/10/2019
-*/
-SELECT
- h.id,
- h.calculated_status,
- --s.TreatmentStatus,
- (SELECT max(d.qcstate.label) as label FROM study.drug d WHERE s.objectid = d.treatmentid and s.date = d.timeordered) as TreatmentStatus,
- h.Id.curLocation.room as room,
- h.Id.curLocation.cage as cage,
- s.date,
- s.startDate,
- s.endDate,
- s.dayselapsed,
- s.category,
- s.code,
- s.code.meaning as medication,
- s.volume,
- s.vol_units,
- s.concentration,
- s.conc_units,
- s.amountWithUnits,
- s.amountAndVolume,
- s.dosage,
- s.dosage_units,
- s.frequency,
- s.route,
- s.reason,
- s.remark,
- s.performedby
-FROM study.demographics h JOIN (
-
-SELECT
- s.animalid, s.TreatmentStatus, timestampadd('SQL_TSI_MINUTE', ((s.hours * 60) + s.minutes), s.origDate) as date, s.objectid,
- s.startdate, s.enddate, s.dayselapsed, s.category, s.code, s.volume, s.vol_units, s.concentration, s.conc_units,
- s.amountWithUnits, s.amountAndVolume, s.dosage, s.dosage_units, s.frequency, s.route, s.reason, s.remark, s.performedby
-FROM (
-
- SELECT
- t1.objectid,
- t1.id as animalid,
- (coalesce(tt.time, ft.hourofday, (hour(t1.date) * 100)) / 100) as hours,
-
- CASE
- WHEN (tt.time IS NOT NULL OR ft.hourofday IS NOT NULL) THEN (((coalesce(tt.time, ft.hourofday) / 100.0) - floor(coalesce(tt.time, ft.hourofday) / 100)) * 100)
- ELSE minute(t1.date)
- END as minutes,
- dr.date as origDate,
-
- CASE
- WHEN snomed.code IS NOT NULL THEN 'Post Op Meds'
- ELSE t1.category
- END as category,
-
- t1.date as startDate,
- timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed,
- t1.enddate, t1.code, t1.volume, t1.vol_units, t1.concentration, t1.conc_units, t1.amountWithUnits,
- t1.amountAndVolume, t1.dosage, t1.dosage_units, t1.frequency.meaning + ' (' + t1.frequency.times + ')' as frequency, t1.route,
- t1.reason, t1.performedby, t1.remark, t1.qcstate.label as TreatmentStatus
-
- FROM ehr_lookups.dateRange dr
-
-Join study."Treatment Orders" t1
- ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND
- mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0
- )
-
-LEFT JOIN ehr.treatment_times tt ON (tt.treatmentid = t1.objectid)
-LEFT JOIN ehr_lookups.treatment_frequency_times ft ON (ft.frequency = t1.frequency.meaning AND tt.rowid IS NULL)
-
-INNER JOIN (
- SELECT
- sc.code
- FROM ehr_lookups.snomed_subset_codes sc
- WHERE sc.primaryCategory = 'Post Op Meds'
- /* Added this clause by Kollil on 10/4/2023 to exclude the MPA injection from the list.
- This change is made according to the new request by Cassie Tkt# 9939. The MPA med is part of the post op meds category
- but a separate alert is created so, excluding this med from this alert list.
- */
- AND sc.code NOT IN ('E-85760')
- GROUP BY sc.code
-) snomed ON snomed.code = t1.code
-
---NOTE: if we run this report on a future interval, we want to include those treatments
-WHERE t1.date is not null
---NOTE: they have decided to include non-public data
-
-) s
-
-) s ON (s.animalid = h.id)
- WHERE h.calculated_status = 'Alive'
- --account for date/time in schedule
- and s.date >= s.startDate and s.date <= s.enddate
-
-
--- /*
--- * Copyright (c) 2015 LabKey Corporation
--- *
--- * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
--- */
---
--- SELECT
--- h.id,
--- h.calculated_status,
--- s.*,
--- s.objectid as treatmentid,
--- ---Modified 7-2-2015 Blasa from d.qcstate to d.qcstate.label
--- (SELECT max(d.qcstate.label) as label FROM study.drug d WHERE s.objectid = d.treatmentid AND s.date = d.timeordered) as treatmentStatus
---
---
--- FROM study.demographics h JOIN (
---
--- SELECT
--- s.*,
--- timestampadd('SQL_TSI_MINUTE', ((s.hours * 60) + s.minutes), s.origDate) as date,
--- CASE
--- WHEN (hours >= 6 AND hours < 20) THEN 'AM'
--- WHEN (hours < 6 OR hours >= 20) THEN 'PM'
--- ELSE 'Other'
--- END as timeOfDay,
---
--- ((s.hours * 60) + s.minutes) as timeOffset
---
--- FROM (
---
--- SELECT
--- t1.lsid,
--- t1.objectid,
--- t1.dataset,
--- t1.id as animalid,
---
--- coalesce(tt.time, ft.hourofday, ((hour(t1.date) * 100) + minute(t1.date))) as time,
--- (coalesce(tt.time, ft.hourofday, (hour(t1.date) * 100)) / 100) as hours,
--- CASE
--- WHEN (tt.time IS NOT NULL OR ft.hourofday IS NOT NULL) THEN (((coalesce(tt.time, ft.hourofday) / 100.0) - floor(coalesce(tt.time, ft.hourofday) / 100)) * 100)
--- ELSE minute(t1.date)
--- END as minutes,
--- dr.date as origDate,
--- --ft.timedescription as timeOfDay,
--- CASE
--- WHEN (tt.time IS NULL) THEN 'Default'
--- ELSE 'Custom'
--- END as timeType,
---
--- CASE
--- WHEN snomed.code IS NOT NULL THEN 'Post Op Meds'
--- ELSE t1.category
--- END as category,
--- --t1.category,
---
--- t1.frequency.meaning as frequency,
--- t1.date as startDate,
--- timestampdiff('SQL_TSI_DAY', cast(t1.dateOnly as timestamp), dr.dateOnly) + 1 as daysElapsed,
--- t1.enddate,
--- --t1.duration,
--- t1.project,
--- t1.code,
---
--- t1.volume,
--- t1.vol_units,
--- t1.concentration,
--- t1.conc_units,
--- t1.amount,
--- t1.amount_units,
--- t1.amountWithUnits,
--- t1.amountAndVolume,
--- t1.dosage,
--- t1.dosage_units,
--- t1.qualifier,
---
--- t1.route,
--- t1.reason,
--- t1.performedby,
--- t1.remark,
--- --t1.description,
---
--- t1.qcstate
---
--- FROM ehr_lookups.dateRange dr
---
--- JOIN study."Treatment Orders" t1
--- --NOTE: should the enddate consider date/time?
--- ON (dr.dateOnly >= t1.dateOnly and dr.dateOnly <= t1.enddateCoalesced AND
--- --technically the first day of the treatment is day 1, not day 0
--- mod(CAST(timestampdiff('SQL_TSI_DAY', CAST(t1.dateOnly as timestamp), dr.dateOnly) as integer), t1.frequency.intervalindays) = 0
--- )
---
--- LEFT JOIN ehr.treatment_times tt ON (tt.treatmentid = t1.objectid)
--- LEFT JOIN ehr_lookups.treatment_frequency_times ft ON (ft.frequency = t1.frequency.meaning AND tt.rowid IS NULL)
---
--- INNER JOIN (
--- SELECT
--- sc.code
--- from ehr_lookups.snomed_subset_codes sc
--- WHERE sc.primaryCategory = 'Post Op Meds'
--- GROUP BY sc.code
--- ) snomed ON snomed.code = t1.code
---
--- --NOTE: if we run this report on a future interval, we want to include those treatments
--- WHERE t1.date is not null
--- --NOTE: they have decided to include non-public data
--- --AND t1.qcstate.publicdata = true --and t1.dateOnly <= curdate()
---
--- ) s
---
--- ) s ON (s.animalid = h.id)
---
--- WHERE h.calculated_status = 'Alive'
---
--- --account for date/time in schedule
--- and s.date >= s.startDate and s.date <= s.enddate
\ No newline at end of file
From 78ca599c1bfd815d26849187292b4c0ebd2de8be Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:05:27 -0700
Subject: [PATCH 17/23] Delete
onprc_ehr/resources/queries/study/demographicsAssignedVet.sql
not related to this PR
---
.../queries/study/demographicsAssignedVet.sql | 58 -------------------
1 file changed, 58 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/demographicsAssignedVet.sql
diff --git a/onprc_ehr/resources/queries/study/demographicsAssignedVet.sql b/onprc_ehr/resources/queries/study/demographicsAssignedVet.sql
deleted file mode 100644
index 3a7ba2602..000000000
--- a/onprc_ehr/resources/queries/study/demographicsAssignedVet.sql
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-study.demographicsAssignedVet
-
-Returns one or more assigned vets per animal ID
- * When there is an open case, it returns one record for each vet having an open
- case for that animal
- * When there is not an open case, it returns one record for the lowest-numbered
- matched rule
- * VAF2 determines the lowest matched rule for each animal. Doing an inner join
- with VAF1 results in only those records matching the lowest matched rule per
- animal. The select distinct limits it to a single record.
-
-Future enhancements
- * Add ProjectType to select statement and hide in XML
- * Add Protocol_PI to study.vet_assignmentFilter and to onprc_ehr.vet_assignment
- * Add species to study.vet_assignmentFilter and to onprc_ehr.vet_assignment
- * Add validation to onprc_ehr.vet_assignment to prevent creating a rule that has
- * no match in the filter
- */
-
-SELECT DISTINCT VAF1.Id
- , VAF1.AssignedVet
- , VAF1.AssignmentType
- , VAF1.Room
- , VAF1.Area
- , VAF1.Calculated_Status
- , VAF1.MatchedRule
-FROM vetAssignment_filter AS VAF1
- INNER JOIN (
- SELECT VAF2.Id
- , MIN(VAF2.matchedRule) AS minRule
- FROM vetAssignment_filter AS VAF2
- GROUP BY VAF2.id
-) AS VAF3
- ON VAF1.id = VAF3.id
- AND VAF1.matchedRule = VAF3.minRule
-
-
--- SELECT VAF1.Id
--- , VAF1.AssignedVet
--- , VAF1.AssignmentType
--- /* , VAF1.AssignmentType AS codeAssignmentType*/
--- , VAF1.Room
--- , VAF1.Area
--- , VAF1.Project
--- , VAF1.Protocol
--- , VAF1.ProtocolPI
--- , VAF1.Calculated_Status
--- , VAF1.MatchedRule
--- , VAF1.history
--- FROM vetAssignment_filter AS VAF1
--- INNER JOIN (
--- SELECT VAF2.Id
--- , MIN(VAF2.matchedRule) AS minRule
--- FROM vetAssignment_filter AS VAF2
--- GROUP BY VAF2.id
--- ) AS VAF3 ON VAF1.id = VAF3.id
--- AND VAF1.matchedRule = VAF3.minRule
From a5053d35a06607aed554d148f1c0a114f78721bd Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:05:46 -0700
Subject: [PATCH 18/23] Delete
onprc_ehr/resources/queries/study/vetAssignment_demographics.sql
not related to this PR
---
.../study/vetAssignment_demographics.sql | 92 -------------------
1 file changed, 92 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/vetAssignment_demographics.sql
diff --git a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql b/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql
deleted file mode 100644
index 0adf50eb4..000000000
--- a/onprc_ehr/resources/queries/study/vetAssignment_demographics.sql
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-study.vetAssignment_demographics
-
-Replaces: study.vetAssignmentDemographics
-
-Returns at least one record for all living NHPs at the center.
-Notes:
- * Multiple open cases and multiple assignments for a single animal
- result in open cases * assignments for that animal
- * Left joins are needed for CMUcases and assignedProject as those tables
- might not have records for an animal ID. Left joins are used for all
- other joins to be resiliant against missing data.
- * enddate.TimeCoalesced is never in the future
-
-Future modifications:
- * Limit open cases to those that are not inactive after confirming w/ Heather
- */
-
-SELECT demographics.id
- , CMUcases.assignedVet.displayName AS caseVet
- , CMUcases.date AS caseDate
- , housing.room
- , housing.room.area
- , assignedProject.project AS project
- , assignedProject.Protocol AS protocol
- , assignedProject.PI AS protocolPI
- , assignedProject.projectType AS assignmentType
- , demographics.calculated_status
- , demographics.gender
- , demographics.species
- , demographics.history
-FROM Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.animal AS nhp
-LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.ClinicalCases_Open AS CMUcases
-ON CMUcases.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.housing AS housing
- ON housing.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.demographics AS demographics
- ON demographics.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.vetAssignment_projects AS assignedProject
- ON assignedProject.id = nhp.id
-WHERE demographics.Calculated_Status = 'Alive'
- AND nhp.id NOT LIKE '[A-Z]%'
- AND housing.enddate IS NULL
-
-
-/*
-study.vetAssignment_demographics.sql
-
-Replaces: study.vetAssignmentDemographics
-
-Returns at least one record for all living NHPs at the center.
-Notes:
- * Multiple open cases and multiple assignments for a single animal
- result in open cases * assignments for that animal
- * Left joins are needed for CMUcases and assignedProject as those tables
- might not have records for an animal ID. Left joins are used for all
- other joins to be resiliant against missing data.
-
-Future modifications:
- * Limit open cases to those that are not inactive
- */
-/*
-SELECT demographics.id
- , CMUcases.assignedVet.displayName AS caseVet
- , CMUcases.DATE AS caseDate
- , housing.room
- , housing.room.area
- , assignedProject.project AS project
- , assignedProject.Protocol AS protocol
- , assignedProject.PI AS protocolPI
- , assignedProject.projectType AS assignmentType
- , demographics.calculated_status
- , demographics.gender
- , demographics.species
- , demographics.history
-FROM Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.animal AS nhp
-LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.ClinicalCases_Open AS CMUcases
-ON CMUcases.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.housing AS housing
- ON housing.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.demographics AS demographics
- ON demographics.id = nhp.id
- LEFT JOIN Site.{ substitutePath moduleProperty('EHR', 'EHRStudyContainer') }.study.vetAssignment_projects AS assignedProject
- ON assignedProject.id = nhp.id
-WHERE demographics.Calculated_Status = 'Alive'
- AND nhp.id NOT LIKE '[A-Z]%'
- AND (
- housing.enddateTimeCoalesced >= Curdate()
- OR housing.enddateTimeCoalesced IS NULL
- )
-
-*/
From ea436f21ba0f8a207daaf298bcc2b854561616fe Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:06:08 -0700
Subject: [PATCH 19/23] Delete
onprc_ehr/resources/queries/study/vetAssignment_projects.sql
not related to this PR
---
.../queries/study/vetAssignment_projects.sql | 70 -------------------
1 file changed, 70 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/vetAssignment_projects.sql
diff --git a/onprc_ehr/resources/queries/study/vetAssignment_projects.sql b/onprc_ehr/resources/queries/study/vetAssignment_projects.sql
deleted file mode 100644
index e03256a34..000000000
--- a/onprc_ehr/resources/queries/study/vetAssignment_projects.sql
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-study.vetAssignment_projects
-
-Replaces:
- * study.vetAssignedResearch
- * study.vetAssignedResearch_project
- * study.vetAssignedResource
- * study.vetAssignedResource_project
-
-Returns a record for each active assignment of an animal ID to a project.
-Notes:
- * Animals assigned to multiple projects results in multiple records
- * Animals solely on the P51 are not considered "assigned" in PRIMe
- and won't have records returned by this query
- * Uses Curdate() to avoid issues where an assignment ends on the day this
- query is run
- * Returns the actual use category instead of "Project Resource Assigned"
- or "Project Research Assigned"
- */
-
-SELECT Id
- , project
- , project.protocol.external_id AS Protocol
- , project.protocol.investigatorID.lastname AS PI
- , date
- , enddate
- , project.use_category AS projectType
-FROM study.assignment
-WHERE date <= Curdate()
- AND (
- enddate IS NULL
- OR enddate >= Curdate()
- )
-
-/*
-study.vetAssignment_projects.sql
-
-Replaces:
- * study.vetAssignedResearch
- * study.vetAssignedResearch_project
- * study.vetAssignedResource
- * study.vetAssignedResource_project
-
-Returns a record for each active assignment of an animal ID to a project.
-Notes:
- * Animals assigned to multiple projects results in multiple records
- * Animals solely on the P51 are not considered "assigned" in PRIMe
- and won't have records returned by this query
- * Uses Curdate() to avoid issues where an assignment ends on the day this
- query is run
- * Returns the actual use category instead of "Project Resource Assigned"
- or "Project Research Assigned"
- */
-
-/*
-SELECT Id
- , project
- , project.protocol.external_id AS Protocol
- , project.protocol.investigatorID.lastname AS PI
- , date
- , enddate
- , project.use_category AS projectType
-FROM study.assignment
-WHERE date <= Curdate()
- AND (
- enddate IS NULL
- OR enddate >= Curdate()
- )
-
- */
\ No newline at end of file
From 3755e12a9ec185aa1f9392577102bb22f65dc182 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:06:29 -0700
Subject: [PATCH 20/23] Delete
onprc_ehr/resources/queries/study/vetassignment_filter.sql
not related to this PR
---
.../queries/study/vetassignment_filter.sql | 144 ------------------
1 file changed, 144 deletions(-)
delete mode 100644 onprc_ehr/resources/queries/study/vetassignment_filter.sql
diff --git a/onprc_ehr/resources/queries/study/vetassignment_filter.sql b/onprc_ehr/resources/queries/study/vetassignment_filter.sql
deleted file mode 100644
index b0d1ce126..000000000
--- a/onprc_ehr/resources/queries/study/vetassignment_filter.sql
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-study.vetAssignment_filter
-
-Partially replaces: study.demographicsAssignedVet, which still exists
-
-Returns a record for each input record from study.vetAssignment_demographics
-using vet assignment rules defined in onprc_ehr.vet_assignment
-
-Notes:
- * This can result in multiple assignments per animal
- * Comparisons against rules check for both matches against rule requirements and
- no additional rule requirements to ensure no false positives
- * Comparisons rely on empty data to be NULL, not ""
- * The code prioritizes research projects over non-research projects *for
- the same rule*
- * Unassigned animals can be found by filtering for "unassigned" in
- the AssignedVet column
- */
-
-SELECT *
-FROM (
- SELECT d.Id
- , CASE
- WHEN d.CaseVet IS NOT NULL THEN d.CaseVet
- WHEN R01.UserID IS NOT NULL THEN R01.UserID.DisplayName
- WHEN R02.UserID IS NOT NULL THEN R02.UserID.DisplayName
- WHEN R03.UserID IS NOT NULL THEN R03.UserID.DisplayName
- WHEN R04.UserID IS NOT NULL THEN R04.UserID.DisplayName
- WHEN R05.UserID IS NOT NULL THEN R05.UserID.DisplayName
- WHEN R06.UserID IS NOT NULL THEN R06.UserID.DisplayName
- WHEN R07.UserID IS NOT NULL THEN R07.UserID.DisplayName
- WHEN R08.UserID IS NOT NULL THEN R08.UserID.DisplayName
- WHEN R09.UserID IS NOT NULL THEN R09.UserID.DisplayName
- WHEN R10.UserID IS NOT NULL THEN R10.UserID.DisplayName
- WHEN R11.UserID IS NOT NULL THEN R11.UserID.DisplayName
- WHEN R12.UserID IS NOT NULL THEN R12.UserID.DisplayName
- WHEN R13.UserID IS NOT NULL THEN R13.UserID.DisplayName
- WHEN R14.UserID IS NOT NULL THEN R14.UserID.DisplayName
- WHEN R15.UserID IS NOT NULL THEN R15.UserID.DisplayName
- WHEN R16.UserID IS NOT NULL THEN R16.UserID.DisplayName
- WHEN R17.UserID IS NOT NULL THEN R17.UserID.DisplayName
- WHEN R18.UserID IS NOT NULL THEN R18.UserID.DisplayName
- WHEN R19.UserID IS NOT NULL THEN R19.UserID.DisplayName
- WHEN R20.UserID IS NOT NULL THEN R20.UserID.DisplayName
- WHEN R21.UserID IS NOT NULL THEN R21.UserID.DisplayName
- WHEN R22.UserID IS NOT NULL THEN R22.UserID.DisplayName
- ELSE 'Unassigned'
- END AS AssignedVet
- , CASE
- WHEN d.CaseVet IS NOT NULL THEN 'Open Case'
- WHEN R01.UserID IS NOT NULL THEN 'Room Priority'
- WHEN R02.UserID IS NOT NULL THEN 'Area Priority'
- WHEN R03.UserID IS NOT NULL THEN 'Project Room Research Priority'
- WHEN R04.UserID IS NOT NULL THEN 'Project Room Resource Priority'
- WHEN R05.UserID IS NOT NULL THEN 'Project Room Research'
- WHEN R06.UserID IS NOT NULL THEN 'Project Room Resource'
- WHEN R07.UserID IS NOT NULL THEN 'Project Area Research Priority'
- WHEN R08.UserID IS NOT NULL THEN 'Project Area Resource Priority'
- WHEN R09.UserID IS NOT NULL THEN 'Project Area Research'
- WHEN R10.UserID IS NOT NULL THEN 'Project Area Resource'
- WHEN R11.UserID IS NOT NULL THEN 'Project Research Priority'
- WHEN R12.UserID IS NOT NULL THEN 'Project Resource Priority'
- WHEN R13.UserID IS NOT NULL THEN 'Project Research'
- WHEN R14.UserID IS NOT NULL THEN 'Project Resource'
- WHEN R15.UserID IS NOT NULL THEN 'Protocol Room Priority'
- WHEN R16.UserID IS NOT NULL THEN 'Protocol Area Priority'
- WHEN R17.UserID IS NOT NULL THEN 'Protocol Room'
- WHEN R18.UserID IS NOT NULL THEN 'Protocol Area'
- WHEN R19.UserID IS NOT NULL THEN 'Protocol Priority'
- WHEN R20.UserID IS NOT NULL THEN 'Protocol'
- WHEN R21.UserID IS NOT NULL THEN 'Room'
- WHEN R22.UserID IS NOT NULL THEN 'Area'
- ELSE 'No Matching Rule'
- END AS AssignmentType
- , d.CaseVet
- , d.CaseDate
- , d.Project
- , d.AssignmentType AS ProjectType
- , d.Protocol
- , d.ProtocolPI
- , d.Room
- , d.Area
- , d.Calculated_status
- , CASE
- WHEN d.CaseVet IS NOT NULL THEN 0
- WHEN R01.UserID IS NOT NULL THEN 1
- WHEN R02.UserID IS NOT NULL THEN 2
- WHEN R03.UserID IS NOT NULL THEN 3
- WHEN R04.UserID IS NOT NULL THEN 4
- WHEN R05.UserID IS NOT NULL THEN 5
- WHEN R06.UserID IS NOT NULL THEN 6
- WHEN R07.UserID IS NOT NULL THEN 7
- WHEN R08.UserID IS NOT NULL THEN 8
- WHEN R09.UserID IS NOT NULL THEN 9
- WHEN R10.UserID IS NOT NULL THEN 10
- WHEN R11.UserID IS NOT NULL THEN 11
- WHEN R12.UserID IS NOT NULL THEN 12
- WHEN R13.UserID IS NOT NULL THEN 13
- WHEN R14.UserID IS NOT NULL THEN 14
- WHEN R15.UserID IS NOT NULL THEN 15
- WHEN R16.UserID IS NOT NULL THEN 16
- WHEN R17.UserID IS NOT NULL THEN 17
- WHEN R18.UserID IS NOT NULL THEN 18
- WHEN R19.UserID IS NOT NULL THEN 19
- WHEN R20.UserID IS NOT NULL THEN 20
- WHEN R21.UserID IS NOT NULL THEN 21
- WHEN R22.UserID IS NOT NULL THEN 22
- ELSE 99
- END AS MatchedRule
- FROM study.vetAssignment_demographics AS d
-/* R01 Room Priority */ LEFT JOIN onprc_ehr.vet_assignment R01 ON (R01.Room = d.Room AND R01.Area IS NULL AND R01.Project IS NULL AND R01.Protocol IS NULL AND R01.Priority = true)
-/* R02 Area Priority */ LEFT JOIN onprc_ehr.vet_assignment R02 ON (R02.Area = d.Area AND R02.Room IS NULL AND R02.Project IS NULL AND R02.Protocol IS NULL AND R02.Priority = true)
-
-/* R03 Project Room Research Priority */ LEFT JOIN onprc_ehr.vet_assignment R03 ON (R03.Project = d.Project AND R03.Room = d.Room AND R03.Area IS NULL AND R03.Protocol IS NULL AND R03.Priority = true AND d.AssignmentType = 'Research')
-/* R04 Project Room Resource Priority */ LEFT JOIN onprc_ehr.vet_assignment R04 ON (R04.Project = d.Project AND R04.Room = d.Room AND R04.Area IS NULL AND R04.Protocol IS NULL AND R04.Priority = true AND d.AssignmentType <> 'Research')
-
-/* R05 Project Room Research */ LEFT JOIN onprc_ehr.vet_assignment R05 ON (R05.Project = d.Project AND R05.Room = d.Room AND R05.Area IS NULL AND R05.Protocol IS NULL AND R05.Priority = false AND d.AssignmentType = 'Research')
-/* R06 Project Room Resource */ LEFT JOIN onprc_ehr.vet_assignment R06 ON (R06.Project = d.Project AND R06.Room = d.Room AND R06.Area IS NULL AND R06.Protocol IS NULL AND R06.Priority = false AND d.AssignmentType <> 'Research')
-
-/* R07 Project Area Research Priority */ LEFT JOIN onprc_ehr.vet_assignment R07 ON (R07.Project = d.Project AND R07.Area = d.Area AND R07.Room IS NULL AND R07.Protocol IS NULL AND R07.Priority = true AND d.AssignmentType = 'Research')
-/* R08 Project Area Resource Priority */ LEFT JOIN onprc_ehr.vet_assignment R08 ON (R08.Project = d.Project AND R08.Area = d.Area AND R08.Room IS NULL AND R08.Protocol IS NULL AND R08.Priority = true AND d.AssignmentType <> 'Research')
-
-/* R09 Project Area Research */ LEFT JOIN onprc_ehr.vet_assignment R09 ON (R09.Project = d.Project AND R09.Area = d.Area AND R09.Room IS NULL AND R09.Protocol IS NULL AND R09.Priority = false AND d.AssignmentType = 'Research')
-/* R10 Project Area Resource */ LEFT JOIN onprc_ehr.vet_assignment R10 ON (R10.Project = d.Project AND R10.Area = d.Area AND R10.Room IS NULL AND R10.Protocol IS NULL AND R10.Priority = false AND d.AssignmentType <> 'Research')
-
-/* R11 Project Research Priority */ LEFT JOIN onprc_ehr.vet_assignment R11 ON (R11.Project = d.Project AND R11.Area IS NULL AND R11.Room IS NULL AND R11.Protocol IS NULL AND R11.Priority = true AND d.AssignmentType = 'Research')
-/* R12 Project Resource Priority */ LEFT JOIN onprc_ehr.vet_assignment R12 ON (R12.Project = d.Project AND R12.Area IS NULL AND R12.Room IS NULL AND R12.Protocol IS NULL AND R12.Priority = true AND d.AssignmentType <> 'Research')
-
-/* R13 Project Research */ LEFT JOIN onprc_ehr.vet_assignment R13 ON (R13.Project = d.Project AND R13.Area IS NULL AND R13.Room IS NULL AND R13.Protocol IS NULL AND R13.Priority = false AND d.AssignmentType = 'Research')
-/* R14 Project Resource */ LEFT JOIN onprc_ehr.vet_assignment R14 ON (R14.Project = d.Project AND R14.Area IS NULL AND R14.Room IS NULL AND R14.Protocol IS NULL AND R14.Priority = false AND d.AssignmentType <> 'Research')
-
-/* R15 Protocol Room Priority */ LEFT JOIN onprc_ehr.vet_assignment R15 ON (R15.Protocol.DisplayName = d.Protocol AND R15.Room = d.Room AND R15.Area IS NULL AND R15.Project IS NULL AND R15.Priority = true)
-/* R16 Protocol Area Priority */ LEFT JOIN onprc_ehr.vet_assignment R16 ON (R16.Protocol.DisplayName = d.Protocol AND R16.Area = d.Area AND R16.Room IS NULL AND R16.Project IS NULL AND R16.Priority = true)
-
-/* R17 Protocol Room */ LEFT JOIN onprc_ehr.vet_assignment R17 ON (R17.Protocol.DisplayName = d.Protocol AND R17.Room = d.Room AND R17.Area IS NULL AND R17.Project IS NULL AND R17.Priority = false)
-/* R18 Protocol Area */ LEFT JOIN onprc_ehr.vet_assignment R18 ON (R18.Protocol.DisplayName = d.Protocol AND R18.Area = d.Area AND R18.Room IS NULL AND R18.Project IS NULL AND R18.Priority = false)
-
-/* R19 Protocol Priority */ LEFT JOIN onprc_ehr.vet_assignment R19 ON (R19.Protocol.DisplayName = d.Protocol AND R19.Area IS NULL AND R19.Room IS NULL AND R19.Project IS NULL AND R19.Priority = true)
-/* R20 Protocol */ LEFT JOIN onprc_ehr.vet_assignment R20 ON (R20.Protocol.DisplayName = d.Protocol AND R20.Area IS NULL AND R20.Room IS NULL AND R20.Project IS NULL AND R20.Priority = false)
-
-/* R21 Room */ LEFT JOIN onprc_ehr.vet_assignment R21 ON (R21.Room = d.Room AND R21.Area IS NULL AND R21.Protocol IS NULL AND R21.Project IS NULL AND R21.Priority = false)
-/* R22 Area */ LEFT JOIN onprc_ehr.vet_assignment R22 ON (R22.Area = d.Area AND R22.Room IS NULL AND R22.Protocol IS NULL AND R22.Project IS NULL AND R22.Priority = false)
- ) placeholderAlias
-
From 8e9d133ed050c2ec5f84bcbe15cbb7b796740840 Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:06:58 -0700
Subject: [PATCH 21/23] Delete
onprc_ehr/resources/web/onprc_ehr/data/sources/TreatmentOrdersClientStore.js
not related to this PR
---
.../sources/TreatmentOrdersClientStore.js | 91 -------------------
1 file changed, 91 deletions(-)
delete mode 100644 onprc_ehr/resources/web/onprc_ehr/data/sources/TreatmentOrdersClientStore.js
diff --git a/onprc_ehr/resources/web/onprc_ehr/data/sources/TreatmentOrdersClientStore.js b/onprc_ehr/resources/web/onprc_ehr/data/sources/TreatmentOrdersClientStore.js
deleted file mode 100644
index 67d973567..000000000
--- a/onprc_ehr/resources/web/onprc_ehr/data/sources/TreatmentOrdersClientStore.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2013-2015 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
- */
-//Created: 7-29-2020 R.Blasa
-
-Ext4.define('ONPRC_EHR.data.TreatmentOrdersClientStore', {
- extend: 'EHR.data.DrugAdministrationRunsClientStore',
-
- constructor: function(){
- this.callParent(arguments);
-
- this.on('add', this.onAddRecord, this);
- },
-
- onAddRecord: function(store, records){
- Ext4.each(records, function(record){
- this.onRecordUpdate(record, ['objectid', 'code']);
- }, this);
- },
-
- afterEdit: function(record, modifiedFieldNames){
- this.onRecordUpdate(record, modifiedFieldNames);
-
- this.callParent(arguments);
- },
-
- onRecordUpdate: function(record, modifiedFieldNames){
- if (record.get('code')){
- modifiedFieldNames = modifiedFieldNames || [];
-
- if (modifiedFieldNames.indexOf('code') == -1){
- return;
- }
-
- /* Changed by Kollil on 10/11/2023,
- Requested by Cassie to remove the verbiage in the remark field for the MPA medication. Refer to tkt # 9939
- The default setting for this medication in DB schema browser is updated too.
- */
- if (record.get('code') == 'E-85760'){
- record.beginEdit();
- record.set('remark', '');
- record.endEdit(true);
- }
- // if (record.get('code') == 'E-85760' && record.get('remark') == null){
- // record.beginEdit();
- // record.set('remark', 'Please make a clinical prime entry at each administration once the administration is complete.');
- // record.endEdit(true);
- // }
-
- if (!this.formularyStore){
- LDK.Utils.logToServer({
- message: 'Unable to find formulary store in DrugAdministrationRunsClientStore'
- });
- console.error('Unable to find formulary store in DrugAdministrationRunsClientStore');
-
- return;
- }
-
- var values = this.formularyStore.getFormularyValues(record.get('code'));
- if (!Ext4.Object.isEmpty(values)){
- var params = {};
-
- for (var fieldName in this.fieldMap){
- if (!this.getFields().get(fieldName)){
- continue;
- }
-
- if (modifiedFieldNames.indexOf(this.fieldMap[fieldName]) != -1){
- //console.log('field already set: ' + fieldName);
- continue;
- }
-
- var def = values[fieldName];
- if (Ext4.isDefined(def)){
- params[this.fieldMap[fieldName]] = def;
- }
- }
-
- if (!LABKEY.Utils.isEmptyObj(params)){
- record.beginEdit();
- record.set(params);
- record.endEdit(true);
- }
- }
- }
- }
-
-
-});
From f5b6e2270cd5f00b76a7ca6cf888fea3a950fd9a Mon Sep 17 00:00:00 2001
From: Lakshmi Kolli <69940873+kollil@users.noreply.github.com>
Date: Mon, 23 Oct 2023 12:07:54 -0700
Subject: [PATCH 22/23] Delete
onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
not related to this PR
---
.../notification/BehaviorNotification.java | 385 ------------------
1 file changed, 385 deletions(-)
delete mode 100644 onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
deleted file mode 100644
index fe06dda55..000000000
--- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/BehaviorNotification.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (c) 2013-2016 LabKey Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.labkey.onprc_ehr.notification;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.json.JSONObject;
-import org.labkey.api.data.CompareType;
-import org.labkey.api.data.Container;
-import org.labkey.api.data.ContainerFilter;
-import org.labkey.api.data.SQLFragment;
-import org.labkey.api.data.SimpleFilter;
-import org.labkey.api.data.Sort;
-import org.labkey.api.data.SqlSelector;
-import org.labkey.api.data.TableInfo;
-import org.labkey.api.data.TableSelector;
-import org.labkey.api.module.Module;
-import org.labkey.api.query.FieldKey;
-import org.labkey.api.query.QueryDefinition;
-import org.labkey.api.query.QueryException;
-import org.labkey.api.query.QueryService;
-import org.labkey.api.query.UserSchema;
-import org.labkey.api.security.User;
-import org.labkey.api.util.PageFlowUtil;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * User: bimber
- * Date: 4/5/13
- * Time: 2:25 PM
- */
-public class BehaviorNotification extends ColonyAlertsNotification
-{
- public BehaviorNotification(Module owner)
- {
- super(owner);
- }
-
- @Override
- public String getName()
- {
- return "Behavior Notification";
- }
-
- @Override
- public String getEmailSubject(Container c)
- {
- return "Behavior Alerts: " + getDateTimeFormat(c).format(new Date());
- }
-
- @Override
- public String getCronString()
- {
- return "0 0 5 * * ?";
- }
-
- @Override
- public String getScheduleDescription()
- {
- return "every day at 5:00AM";
- }
-
- @Override
- public String getDescription()
- {
- return "The report is designed to provide a daily summary of issues related to behavior management, such as housing, pairing, and behavior cases";
- }
-
- @Override
- public String getMessageBodyHTML(Container c, User u)
- {
- Map saved = getSavedValues(c);
- Map toSave = new HashMap();
-
- StringBuilder msg = new StringBuilder();
-
- msg.append(getDescription()).append("
");
-
- colonyHousingSummary(c, u, msg, saved, toSave);
- behaviorCaseSummary(c, u, msg);
- getFlaggedPairs(c, u, msg);
- changedPairs(c, u, msg);
- singleHousedAnimals(c, u, msg);
- transfersYesterday(c, u, msg);
- surgeryCasesRecentlyClosed(c, u, msg);
- pairIdConflicts(c, u , msg);
- NHPTraining_BehaviorAlert(c, u , msg);
- dcmNotesAlert(c, u , msg);
-
- notesEndingToday(c, u, msg, Arrays.asList("BSU Notes"), null);
- saveValues(c, toSave);
-
- return msg.toString();
- }
-
- // Added by Kollil 11/04/2020
- private void NHPTraining_BehaviorAlert(final Container c, User u, final StringBuilder msg)
- {
- if (QueryService.get().getUserSchema(u, c, "onprc_ehr") == null) {
- msg.append("Warning: The onprc_ehr schema has not been enabled in this folder, so the alert cannot run!
");
- return;
- }
- TableInfo ti = QueryService.get().getUserSchema(u, c, "onprc_ehr").getTable("NHP_Training_BehaviorAlert",ContainerFilter.Type.AllFolders.create(c, u));
-// ((ContainerFilterable) ti).setContainerFilter(ContainerFilter.Type.AllFolders.create(u);
- TableSelector ts = new TableSelector(ti, null, null);
-
- long total = ts.getRowCount();
- msg.append("NHP_Training entries where \"Training Result = In-Progress\" for over 60 days:");
- if (total > 0)
- {
- msg.append("There are " + total + " entries found. ");
- msg.append("
Click here to view them
\n");
- msg.append("
\n\n");
- }
- else
- {
- msg.append("WARNING: There are no NHP_Training entries where \"Training Result = In Progress\" for over 60 days!
\n");
- }
-
- }
-
- /*
- Kollil, Created: 11/18/20, Modified: 04/07/2021
- 1. New alert for DCM notes (category = notes pertaining to DAR) added the previous day.
- 2. New alert for DCM notes (category = notes pertaining to DAR) removed the previous day.
- 3. New alert for Flags added the previous day.
- 4. New alert for Flags removed the previous day.
- */
- /**
- * Modified: 12-9-2021 R.Blasa using Lakshmi's original code
- */
- protected void dcmNotesAlert(final Container c, User u, final StringBuilder msg)
- {
- SimpleFilter filter = new SimpleFilter(FieldKey.fromString("actiondate"), new Date(), CompareType.DATE_EQUAL);
- filter.addCondition(FieldKey.fromString("category"), "Notes Pertaining to DAR", CompareType.EQUAL);
- TableSelector ts = new TableSelector(getStudySchema(c, u).getTable("Notes_WithLocation"), filter, null);
- long count = ts.getRowCount();
- if (count > 0)
- {
- msg.append("WARNING: There are " + count + " DCM action items.
\n");
- msg.append("Click here to view them
\n\n");
- msg.append("
");
- }
- else
- {
- msg.append("WARNING: There are no DCM action items!
");
- }
-
- //Added by Kollil on 11/04/2020
- //New alert for DCM notes (category = notes pertaining to DAR) added the previous day.
-
- //Get yesterday date
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
- cal.add(Calendar.DATE, -1);
- String formatted = getDateFormat(c).format(cal.getTime());
-
- SimpleFilter filter1 = new SimpleFilter(FieldKey.fromString("date"), cal.getTime(), CompareType.DATE_EQUAL);
- filter1.addCondition(FieldKey.fromString("category"), "Notes Pertaining to DAR", CompareType.EQUAL);
- TableSelector ts1 = new TableSelector(getStudySchema(c, u).getTable("Notes_WithLocation"), filter1, null);
- long count1 = ts1.getRowCount();
- msg.append("DCM Alerts:
");
- if (count1 > 0) {
- msg.append("" + count1 + " DCM notes entries added yesterday where \"Category = Notes pertaining to DAR\".
\n");
- msg.append("Click here to view them
\n\n");
- msg.append("
\n\n");
- }
- else
- {
- msg.append("WARNING: No DCM notes added yesterday where \"Category = Notes pertaining to DAR\"!
");
- }
-
- /* Added by Kollil on 10/12/2023
- New alert for DCM notes (category = notes pertaining to DAR) removed the previous day.
- Refer to tkt #9977
- */
- SimpleFilter filter4 = new SimpleFilter(FieldKey.fromString("enddate"), cal.getTime(), CompareType.DATE_EQUAL);
- TableSelector ts4 = new TableSelector(getStudySchema(c, u).getTable("Notes_WithLocation"), filter4, null);
- long count4 = ts4.getRowCount();
-
- if (count4 > 0) {
- msg.append("" + count4 + " DCM notes entries removed yesterday where \"Category = Notes pertaining to DAR\".
\n");
- msg.append("Click here to view them
\n\n");
- msg.append("
\n\n");
- }
- else {
- msg.append("WARNING: No DCM notes ended yesterday where \"Category = Notes pertaining to DAR\"!
");
- }
-
- //Added by Kollil on 11/04/2020
- //New alert for Flags added the previous day.
- SimpleFilter filter2 = new SimpleFilter(FieldKey.fromString("date"), cal.getTime(), CompareType.DATE_EQUAL);
- TableSelector ts2 = new TableSelector(getStudySchema(c, u).getTable("Flags_WithLocation"), filter2, null);
- long count2 = ts2.getRowCount();
- if (count2 > 0)
- {
- msg.append("There are " + count2 + " flag(s) added yesterday.
\n");
- msg.append("Click here to view them
\n\n");
- msg.append("
");
- }
- else
- {
- msg.append("WARNING: There are no flags added yesterday!
");
- }
-
- //Added by Kollil on 1/04/2021
- //New alert for Flags removed the previous day.
- SimpleFilter filter3 = new SimpleFilter(FieldKey.fromString("enddate"), cal.getTime(), CompareType.DATE_EQUAL);
- TableSelector ts3 = new TableSelector(getStudySchema(c, u).getTable("Flags_WithLocation"), filter3, null);
- long count3 = ts3.getRowCount();
- if (count3 > 0) {
- msg.append("" + count3 + " flag(s) removed yesterday.
\n");
- msg.append("Click here to view them
\n\n");
- msg.append("
");
- }
- else {
- msg.append("WARNING: There are no flags removed yesterday!
");
- }
-
- }
-
- // Modified: 9-7-2018 R.Blasa
- private void behaviorCaseSummary(Container c, User u, final StringBuilder msg)
- {
- TableInfo ti = getStudySchema(c, u).getTable("mostRecentObservationsBehavior");
- SimpleFilter filter = new SimpleFilter(FieldKey.fromString("isActive"), true);
-
- TableSelector ts = new TableSelector(ti, PageFlowUtil.set("Id"), filter, null);
- long total = ts.getRowCount();
- msg.append("Behavior Cases:");
- msg.append("There are " + total + " active behavior cases (this does not include cases closed for review). ");
- String url = getExecuteQueryUrl(c, "study", "mostRecentObservationsBehavior", "Open Behavior Case") + "&query.isActive~eq=true";
- msg.append("Click here to view them");
- msg.append("
");
- }
-
- private void pairIdConflicts(Container c, User u, final StringBuilder msg)
- {
- TableInfo ti = getStudySchema(c, u).getTable("pairingIdConflicts");
- TableSelector ts = new TableSelector(ti);
- long total = ts.getRowCount();
- if (total > 0)
- {
- msg.append("Conflicting Pair IDs:");
- msg.append("There are " + total + " pairing records with conflicting pairIds. If this occurs, there is a bug in data entry which could cause unusual results when viewing the data. If you see this, please contact the site administrator. ");
- String url = getExecuteQueryUrl(c, "study", "pairingIdConflicts", null);
- msg.append("Click here to view them");
- msg.append("
");
- }
- }
-
- private void singleHousedAnimals(Container c, User u, final StringBuilder msg)
- {
- TableInfo ti = getStudySchema(c, u).getTable("demographicsDaysAlone");
- SimpleFilter filter = new SimpleFilter(FieldKey.fromString("cagemates"), 0, CompareType.EQUAL);
- filter.addCondition(FieldKey.fromString("daysAlone"), 30, CompareType.GT);
-
- TableSelector ts = new TableSelector(ti, PageFlowUtil.set("Id"), filter, null);
- long total = ts.getRowCount();
- msg.append("Single Housed Animals:");
- msg.append("There are " + total + " animals that have been single housed for at least 30 days. ");
- String url = getExecuteQueryUrl(c, "study", "demographicsDaysAlone", null, filter) + "&query.sort=-DaysAlone";
- msg.append("Click here to view them");
- msg.append("
");
- }
-
- private void getFlaggedPairs(Container c, User u, final StringBuilder msg)
- {
- TableInfo ti = getStudySchema(c, u).getTable("pairingSeparations");
- TableSelector ts = new TableSelector(ti, PageFlowUtil.set("Id"));
- long total = ts.getRowCount();
- if (total > 0)
- {
- msg.append("There are " + total + " animals with temporary separations, but there is no subsequent pairing observation to indicate a reunite, permanent separation, new pair formation, etc. These may need attention.");
- String url = getExecuteQueryUrl(c, "study", "pairingSeparations", null);
- msg.append("Click here to view them");
- msg.append("
");
- }
- }
-
- private void changedPairs(Container c, User u, final StringBuilder msg)
- {
- Calendar date1 = Calendar.getInstance();
- date1.setTime(new Date());
- date1 = DateUtils.truncate(date1, Calendar.DATE);
-
- Calendar date2 = Calendar.getInstance();
- date2.setTime(new Date());
- date2 = DateUtils.truncate(date2, Calendar.DATE);
- date2.add(Calendar.DATE, -1);
-
- UserSchema us = getStudySchema(c, u);
- QueryDefinition qd = us.getQueryDefForTable("pairDifferences");
- List errors = new ArrayList<>();
- TableInfo ti = qd.getTable(us, errors, true);
- Map params = new HashMap<>();
- params.put("Date1", date1.getTime());
- params.put("Date2", date2.getTime());
-
- SQLFragment sql = ti.getFromSQL("t");
- QueryService.get().bindNamedParameters(sql, params);
-
- sql = new SQLFragment("SELECT * FROM " + sql.getSQL() + " WHERE (t.changeType IS NOT NULL AND t.changeType != 'Group Members Changed') ORDER BY ldk.naturalize(t.room1), ldk.naturalize(t.cage1)", sql.getParams());
- QueryService.get().bindNamedParameters(sql, params);
- SqlSelector ss = new SqlSelector(ti.getSchema(), sql);
- Collection