From 78a37e23b86e4d665f0ae32398a9a76d1a7c4a7d Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 5 Mar 2026 13:37:35 -0800 Subject: [PATCH 01/18] Modified Surgical Rounds form to now include a "P2" input field. --- .../onprc_ehr/model/sources/SurgicalRounds.js | 46 +++++++++++++++++++ .../dataentry/SurgicalRoundsFormType.java | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js new file mode 100644 index 000000000..5286feef8 --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 + */ +EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { + allQueries: { + Id: { + editable: false, + columnConfig: { + editable: false + } + } + }, + byQuery: { + 'study.clinremarks': { + category: { + defaultValue: 'Surgery', + hidden: true + }, + hx: { + hidden: true + }, + s: { + hidden: true + }, + o: { + hidden: true + }, + a: { + hidden: true + }, + p: { + hidden: true + }, + p2: { + hidden: false + } + }, + 'study.blood': { + reason: { + defaultValue: 'Clinical' + } + } + } +}); \ No newline at end of file diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java index 9dd6206d3..6a6f3f0f4 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java @@ -58,7 +58,7 @@ public SurgicalRoundsFormType(DataEntryFormContext ctx, Module owner) } } - addClientDependency(ClientDependency.supplierFromPath("ehr/model/sources/SurgicalRounds.js")); + addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/model/sources/SurgicalRounds.js")); setDisplayReviewRequired(true); } From 54b6beead9b5a9687be484e985ba30a0e7997205 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 00:54:40 -0700 Subject: [PATCH 02/18] Modified Surgical Rounds so that P2 input loads data as soon as the form opens. --- .../resources/web/onprc_ehr/model/sources/SurgicalRounds.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 5286feef8..6da8ad0c7 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -34,6 +34,10 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, p2: { + formEditorConfig: { + xtype: 'textarea' + }, + height: 100, hidden: false } }, From b8e3c9f4db20f4ab65a542e70677e82537f04657 Mon Sep 17 00:00:00 2001 From: ohsudev Date: Thu, 12 Mar 2026 10:16:41 -0700 Subject: [PATCH 03/18] Modified Surgical Rounds so that P2 input loads data as soon as the form opens. --- .../resources/web/onprc_ehr/model/sources/SurgicalRounds.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 6da8ad0c7..5286feef8 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -34,10 +34,6 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, p2: { - formEditorConfig: { - xtype: 'textarea' - }, - height: 100, hidden: false } }, From f350409a9c6adcd6ee60c361e15327edff49fe84 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 24 Mar 2026 17:01:29 -0700 Subject: [PATCH 04/18] Modified Surgical Rounds to accommodate a new "P2" remarks exclusively for the Surgery module. --- .../form/field/Surgery_PlantextArea.js | 199 ++++++++++++++++++ .../onprc_ehr/model/sources/SurgicalRounds.js | 2 + .../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 4 + 3 files changed, 205 insertions(+) create mode 100644 onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js new file mode 100644 index 000000000..03e3ebe4f --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2014-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 + */ +Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { + extend: 'Ext.form.field.TextArea', + alias: 'widget.onprc_ehr-Surg_plantextarea', + + onAnimalChange: function(){ + this.updateDisplayEl(); + }, + + onRender : function(ct, position){ + this.callParent(arguments); + + this.wrap = this.inputEl.wrap({ + tag: 'div', + cls: 'x4-form-field-wrap' + }); + + this.linkDiv = this.wrap.createChild({ + tag: 'div', + style: 'vertical-align:top;' + }, this.inputEl); + + this.linkEl = this.linkDiv.createChild({ + tag: 'a', + cls: 'labkey-text-link', + html: (this.getValue() ? 'Copy Latest P2' : 'Edit P2') + }); + + var panel = this.up('ehr-formpanel'); + if (panel){ + this.mon(panel, 'bindrecord', this.onAnimalChange, this, {buffer: 100}); + } + else { + LDK.Utils.logToServer({ + message: 'Unable to find ehr-formpanel in Surg_PlantextArea' + }) + } + + var dataEntryPanel = this.up('ehr-dataentrypanel'); + if (dataEntryPanel){ + this.mon(dataEntryPanel, 'animalchange', this.onAnimalChange, this, {buffer: 100}); + } + else { + LDK.Utils.logToServer({ + message: 'Unable to find ehr-dataentrypanel in Surg_PlanTextArea' + }) + } + + this.linkEl.on('click', this.copyMostRecentP2, this); + this.setupMask(); + }, + + setupMask: function(){ + if (this.getValue()){ + this.showTextArea(); + return; + } + + this.inputEl.setVisibilityMode(Ext4.dom.AbstractElement.DISPLAY); + this.inputEl.setVisible(false); + + this.displayEl = this.wrap.createChild({ + tag: 'div', + style: 'vertical-align:top;', + html: '' + }); + + this.displayEl.setWidth(this.width - this.labelWidth); + this.displayEl.setHeight(this.getHeight()); + + this.updateDisplayEl(); + }, + + showTextArea: function(){ + if (!this.rendered){ + return; + } + + if (this.displayEl){ + this.displayEl.remove(); + delete this.displayEl; + } + + if (this.linkEl){ + this.linkEl.update('Copy Latest P2'); + } + + if (this.inputEl) + this.inputEl.setVisible(true); + }, + + updateDisplayEl: function(){ + if (!this.displayEl){ + return; + } + + var rec = EHR.DataEntryUtils.getBoundRecord(this); + if (rec && rec.get('Id')){ + this.getMostRecentP2(rec, function(ret, Id){ + if (!ret || !this.displayEl){ + this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + return; + } + + if (ret.mostRecentP2 && ret.isActive){ + this.displayEl.update(ret.mostRecentP2); + } + else { + this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + } + }); + } + else { + this.displayEl.update('No animal entered'); + } + }, + + copyMostRecentP2: function(){ + var rec = EHR.DataEntryUtils.getBoundRecord(this); + if (!rec || !rec.get('Id')){ + Ext4.Msg.alert('Error', 'No Id Entered'); + return; + } + + Ext4.Msg.wait('Loading...'); + this.showTextArea(); + + this.getMostRecentP2(rec, function(ret){ + Ext4.Msg.hide(); + + if (ret && ret.mostRecentP2){ + this.setValue(ret.mostRecentP2); + this.linkEl.update('Refresh P2'); + } + }, true); + }, + + getMostRecentP2: function(rec, cb, alwaysUseCallback){ + var date = rec.get('date') || new Date(); + var id = rec.get('Id'); + this.pendingIdRequest = id; + + LABKEY.Query.executeSql({ + schemaName: 'study', + sql: 'SELECT c.Id, c.p2 as mostRecentP2, c.caseid, as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Surgery\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + failure: LDK.Utils.getErrorCallback(), + scope: this, + success: function(results){ + if (!alwaysUseCallback && id != this.pendingIdRequest){ + console.log('more recent request, aborting'); + return; + } + + if (results && results.rows && results.rows.length){ + cb.call(this, results.rows[0], results.rows[0].Id); + } + else { + cb.call(this, null, id); + } + } + }); + }, + + onDestroy : function(){ + if (this.linkEl){ + this.linkEl.removeAllListeners(); + this.linkEl.remove(); + } + + if (this.linkDiv){ + this.linkDiv.removeAllListeners(); + this.linkDiv.remove(); + } + + if (this.displayEl){ + //NOTE: no listeners were added + //this.displayEl.removeAllListeners(); + this.displayEl.remove(); + } + + if (this.wrap){ + this.wrap.remove(); + } + + this.callParent(this); + }, + + setValue: function(){ + this.callParent(arguments); + + if (this.getValue()){ + this.showTextArea(); + } + } +}); \ No newline at end of file diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 5286feef8..7a74b4df4 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -34,6 +34,8 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, p2: { + xtype: 'onprc_ehr-Surg_plantextarea', + header: 'S2', hidden: false } }, 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 d18c157d4..81adfe858 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -333,6 +333,10 @@ private void registerEHRResources() //Added: 10-12-2023 R.Blasa EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/EnvironmentalField.js"), this); + //Added: 3-24-2026 R.Blasa References new Xtype + EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/Surgery_PlantextArea.js"), this); + + EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "List Single Housed Animals", this, DetailsURL.fromString("/query/executeQuery.view?schemaName=study&query.queryName=demographicsPaired&query.viewName=Single Housed"), "Commonly Used Queries"); EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "Find Animals Housed In A Given Room/Cage At A Specific Time", this, DetailsURL.fromString("/ehr/housingOverlaps.view?groupById=1"), "Commonly Used Queries"); From 77cd4877a3e18e647ac5f951480da7231556bc8f Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 24 Mar 2026 17:15:11 -0700 Subject: [PATCH 05/18] Modified Surgical Rounds to accommodate a new "P2" remarks exclusively for the Surgery module. --- .../web/onprc_ehr/form/field/PlanTextArea.js | 199 ++++++++++++++++++ .../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 3 +- 2 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js new file mode 100644 index 000000000..3781bb74a --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2014-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 + */ +Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { + extend: 'Ext.form.field.TextArea', + alias: 'widget.onprc_ehr-plantextarea', + + onAnimalChange: function(){ + this.updateDisplayEl(); + }, + + onRender : function(ct, position){ + this.callParent(arguments); + + this.wrap = this.inputEl.wrap({ + tag: 'div', + cls: 'x4-form-field-wrap' + }); + + this.linkDiv = this.wrap.createChild({ + tag: 'div', + style: 'vertical-align:top;' + }, this.inputEl); + + this.linkEl = this.linkDiv.createChild({ + tag: 'a', + cls: 'labkey-text-link', + html: (this.getValue() ? 'Copy Latest P2' : 'Edit P2') + }); + + var panel = this.up('ehr-formpanel'); + if (panel){ + this.mon(panel, 'bindrecord', this.onAnimalChange, this, {buffer: 100}); + } + else { + LDK.Utils.logToServer({ + message: 'Unable to find ehr-formpanel in PlanTextArea' + }) + } + + var dataEntryPanel = this.up('ehr-dataentrypanel'); + if (dataEntryPanel){ + this.mon(dataEntryPanel, 'animalchange', this.onAnimalChange, this, {buffer: 100}); + } + else { + LDK.Utils.logToServer({ + message: 'Unable to find ehr-dataentrypanel in PlanTextArea' + }) + } + + this.linkEl.on('click', this.copyMostRecentP2, this); + this.setupMask(); + }, + + setupMask: function(){ + if (this.getValue()){ + this.showTextArea(); + return; + } + + this.inputEl.setVisibilityMode(Ext4.dom.AbstractElement.DISPLAY); + this.inputEl.setVisible(false); + + this.displayEl = this.wrap.createChild({ + tag: 'div', + style: 'vertical-align:top;', + html: '' + }); + + this.displayEl.setWidth(this.width - this.labelWidth); + this.displayEl.setHeight(this.getHeight()); + + this.updateDisplayEl(); + }, + + showTextArea: function(){ + if (!this.rendered){ + return; + } + + if (this.displayEl){ + this.displayEl.remove(); + delete this.displayEl; + } + + if (this.linkEl){ + this.linkEl.update('Copy Latest P2'); + } + + if (this.inputEl) + this.inputEl.setVisible(true); + }, + + updateDisplayEl: function(){ + if (!this.displayEl){ + return; + } + + var rec = EHR.DataEntryUtils.getBoundRecord(this); + if (rec && rec.get('Id')){ + this.getMostRecentP2(rec, function(ret, Id){ + if (!ret || !this.displayEl){ + this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + return; + } + + if (ret.mostRecentP2 && ret.isActive){ + this.displayEl.update(ret.mostRecentP2); + } + else { + this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + } + }); + } + else { + this.displayEl.update('No animal entered'); + } + }, + + copyMostRecentP2: function(){ + var rec = EHR.DataEntryUtils.getBoundRecord(this); + if (!rec || !rec.get('Id')){ + Ext4.Msg.alert('Error', 'No Id Entered'); + return; + } + + Ext4.Msg.wait('Loading...'); + this.showTextArea(); + + this.getMostRecentP2(rec, function(ret){ + Ext4.Msg.hide(); + + if (ret && ret.mostRecentP2){ + this.setValue(ret.mostRecentP2); + this.linkEl.update('Refresh P2'); + } + }, true); + }, + + getMostRecentP2: function(rec, cb, alwaysUseCallback){ + var date = rec.get('date') || new Date(); + var id = rec.get('Id'); + this.pendingIdRequest = id; + + LABKEY.Query.executeSql({ + schemaName: 'study', + sql: 'SELECT c.Id, c.p2 as mostRecentP2, c.caseid, c.caseid.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Clinical\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + failure: LDK.Utils.getErrorCallback(), + scope: this, + success: function(results){ + if (!alwaysUseCallback && id != this.pendingIdRequest){ + console.log('more recent request, aborting'); + return; + } + + if (results && results.rows && results.rows.length){ + cb.call(this, results.rows[0], results.rows[0].Id); + } + else { + cb.call(this, null, id); + } + } + }); + }, + + onDestroy : function(){ + if (this.linkEl){ + this.linkEl.removeAllListeners(); + this.linkEl.remove(); + } + + if (this.linkDiv){ + this.linkDiv.removeAllListeners(); + this.linkDiv.remove(); + } + + if (this.displayEl){ + //NOTE: no listeners were added + //this.displayEl.removeAllListeners(); + this.displayEl.remove(); + } + + if (this.wrap){ + this.wrap.remove(); + } + + this.callParent(this); + }, + + setValue: function(){ + this.callParent(arguments); + + if (this.getValue()){ + this.showTextArea(); + } + } +}); \ No newline at end of file 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 81adfe858..f4ff09917 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -336,7 +336,8 @@ private void registerEHRResources() //Added: 3-24-2026 R.Blasa References new Xtype EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/Surgery_PlantextArea.js"), this); - + //Added: 3-24-2026 R.Blasa References new Xtype from ehr + EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/PlanTextArea.js"), this); EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "List Single Housed Animals", this, DetailsURL.fromString("/query/executeQuery.view?schemaName=study&query.queryName=demographicsPaired&query.viewName=Single Housed"), "Commonly Used Queries"); EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "Find Animals Housed In A Given Room/Cage At A Specific Time", this, DetailsURL.fromString("/ehr/housingOverlaps.view?groupById=1"), "Commonly Used Queries"); From ce259064bcf621fe6f95cdd48cb3d33a94655778 Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 24 Mar 2026 17:35:43 -0700 Subject: [PATCH 06/18] Modified Surgical Rounds to accommodate a new "P2" remarks exclusively for the Surgery module. --- .../onprc_ehr/panel/ClinicalRemarkPanel.js | 100 ++++++++++++++++++ .../dataentry/RoundsRemarksFormSection.java | 2 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 onprc_ehr/resources/web/onprc_ehr/panel/ClinicalRemarkPanel.js diff --git a/onprc_ehr/resources/web/onprc_ehr/panel/ClinicalRemarkPanel.js b/onprc_ehr/resources/web/onprc_ehr/panel/ClinicalRemarkPanel.js new file mode 100644 index 000000000..6ec997600 --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/panel/ClinicalRemarkPanel.js @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 + */ +/** + * @cfg remarkFormat + */ +Ext4.define('ONPRC_EHR.panel.ClinicalRemarkPanel', { + extend: 'Ext.form.Panel', + alias: 'widget.onprc_ehr-clinicalremarkpanel', + + initComponent: function(){ + Ext4.apply(this, { + bodyStyle: 'padding: 5px;', + defaults: { + labelWidth: 140, + width: 550 + }, + items: [{ + xtype: 'xdatetime', + itemId: 'dateField', + fieldLabel: 'Date', + allowBlank: false, + name: 'date', + value: new Date() + },{ + xtype: 'combo', + fieldLabel: 'Remark Format', + isFormField: false, + itemId: 'remarkFormat', + displayField: 'label', + valueField: 'label', + store: { + type: 'store', + fields: ['label', 'fields', 'fieldLabels'], + data: [ + {label: 'SOAP', fields: ['s', 'o', 'a', 'p'], fieldLabels: ['S', 'O', 'A', 'P']}, + {label: 'S2', fields: ['p2'], fieldLabels: ['S2']}, + {label: 'Hx', fields: ['hx'], fieldLabels: ['Hx']}, + {label: 'Simple Remark', fields: ['remark'], fieldLabels: ['Remark']} + ] + }, + value: this.remarkFormat, + editable: false, + listeners: { + scope: this, + change: function(field){ + var panel = this.down('#remarkPanel'); + panel.removeAll(); + panel.add(this.getItems(field.store.findRecord('label', field.getValue()))); + }, + beforerender: function(field){ + if (field.getValue()){ + field.fireEvent('change', field, field.getValue()); + } + } + } + },{ + xtype: 'container', + itemId: 'remarkPanel' + }] + }); + + this.store = this.getStoreCfg(); + + this.callParent(); + }, + + getItems: function(rec){ + var fields = rec.get('fields'); + var labels = rec.get('fieldLabels'); + + var toAdd = []; + Ext4.each(fields, function(field, idx){ + toAdd.push({ + xtype: 'textarea', + fieldLabel: labels[idx], + labelWidth: 140, + name: field, + width: 550, + height: 60 + }); + }); + + return toAdd; + }, + + getStoreCfg: function(){ + return { + type: 'labkey-store', + schemaName: 'study', + queryName: 'Clinical Remarks', + filterArray: [LABKEY.Filter.create('caseId/category', 'Surgery', LABKEY.Filter.Types.EQUAL)], + columns: 'Id,date,caseid,s,o,a,p,p2,hx,remark', + maxRows: 0, + autoLoad: true + } + } +}); \ No newline at end of file diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java index d46d02bfd..c48594d2e 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java @@ -34,7 +34,7 @@ public RoundsRemarksFormSection(String label, EHRService.FORM_SECTION_LOCATION l { super("study", "Clinical Remarks", label, "ehr-roundsremarksgridpanel", location); addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalObservationsCellEditing.js")); - addClientDependency(ClientDependency.supplierFromPath("ehr/panel/ClinicalRemarkPanel.js")); + addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/panel/ClinicalRemarkPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/grid/RoundsRemarksGridPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/grid/ObservationsRowEditorGridPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalRemarksRowEditor.js")); From 747e76a2d7deebc717f2b1b1f6ab00bb3b6eb682 Mon Sep 17 00:00:00 2001 From: blasar Date: Fri, 3 Apr 2026 00:51:15 -0700 Subject: [PATCH 07/18] Modified Surgical Rounds configurations --- .../form/field/Surgery_PlantextArea.js | 28 +++--- .../onprc_ehr/model/sources/SurgicalRounds.js | 8 +- .../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 5 -- .../dataentry/RoundsRemarksFormSection.java | 2 +- .../SurgeryRoundsRemarksFormSection.java | 87 +++++++++++++++++++ .../dataentry/SurgicalRoundsFormType.java | 5 ++ .../SurgicalRoundsRemarksFormSection.java | 2 +- 7 files changed, 114 insertions(+), 23 deletions(-) create mode 100644 onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgeryRoundsRemarksFormSection.java diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js index 03e3ebe4f..3601f5a38 100644 --- a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js @@ -27,7 +27,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { this.linkEl = this.linkDiv.createChild({ tag: 'a', cls: 'labkey-text-link', - html: (this.getValue() ? 'Copy Latest P2' : 'Edit P2') + html: (this.getValue() ? 'Copy Latest S2' : 'Edit S2') }); var panel = this.up('ehr-formpanel'); @@ -50,7 +50,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { }) } - this.linkEl.on('click', this.copyMostRecentP2, this); + this.linkEl.on('click', this.copyMostRecentS2, this); this.setupMask(); }, @@ -86,7 +86,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { } if (this.linkEl){ - this.linkEl.update('Copy Latest P2'); + this.linkEl.update('Copy Latest S2'); } if (this.inputEl) @@ -100,17 +100,17 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { var rec = EHR.DataEntryUtils.getBoundRecord(this); if (rec && rec.get('Id')){ - this.getMostRecentP2(rec, function(ret, Id){ + this.getMostRecentS2(rec, function(ret, Id){ if (!ret || !this.displayEl){ - this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + this.displayEl.update('Either no active case or no S2 for ' + (Id || rec.get('Id'))); return; } - if (ret.mostRecentP2 && ret.isActive){ - this.displayEl.update(ret.mostRecentP2); + if (ret.mostRecentS2 && ret.isActive){ + this.displayEl.update(ret.mostRecentS2); } else { - this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + this.displayEl.update('Either no active case or no S2 for ' + (Id || rec.get('Id'))); } }); } @@ -129,24 +129,24 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { Ext4.Msg.wait('Loading...'); this.showTextArea(); - this.getMostRecentP2(rec, function(ret){ + this.getMostRecentS2(rec, function(ret){ Ext4.Msg.hide(); - if (ret && ret.mostRecentP2){ - this.setValue(ret.mostRecentP2); - this.linkEl.update('Refresh P2'); + if (ret && ret.mostRecentS2){ + this.setValue(ret.mostRecentS2); + this.linkEl.update('Refresh S2'); } }, true); }, - getMostRecentP2: function(rec, cb, alwaysUseCallback){ + getMostRecentS2: function(rec, cb, alwaysUseCallback){ var date = rec.get('date') || new Date(); var id = rec.get('Id'); this.pendingIdRequest = id; LABKEY.Query.executeSql({ schemaName: 'study', - sql: 'SELECT c.Id, c.p2 as mostRecentP2, c.caseid, as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Surgery\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.caseid.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Surgery\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', failure: LDK.Utils.getErrorCallback(), scope: this, success: function(results){ diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 7a74b4df4..6b334659a 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -34,10 +34,14 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, p2: { - xtype: 'onprc_ehr-Surg_plantextarea', + formEditorConfig: { + xtype: 'onprc_ehr-Surg_plantextarea', + }, header: 'S2', - hidden: false + hidden: false, + height: 75 } + }, 'study.blood': { reason: { 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 f4ff09917..d18c157d4 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -333,11 +333,6 @@ private void registerEHRResources() //Added: 10-12-2023 R.Blasa EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/EnvironmentalField.js"), this); - //Added: 3-24-2026 R.Blasa References new Xtype - EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/Surgery_PlantextArea.js"), this); - - //Added: 3-24-2026 R.Blasa References new Xtype from ehr - EHRService.get().registerClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/PlanTextArea.js"), this); EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "List Single Housed Animals", this, DetailsURL.fromString("/query/executeQuery.view?schemaName=study&query.queryName=demographicsPaired&query.viewName=Single Housed"), "Commonly Used Queries"); EHRService.get().registerReportLink(EHRService.REPORT_LINK_TYPE.housing, "Find Animals Housed In A Given Room/Cage At A Specific Time", this, DetailsURL.fromString("/ehr/housingOverlaps.view?groupById=1"), "Commonly Used Queries"); diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java index c48594d2e..d46d02bfd 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/RoundsRemarksFormSection.java @@ -34,7 +34,7 @@ public RoundsRemarksFormSection(String label, EHRService.FORM_SECTION_LOCATION l { super("study", "Clinical Remarks", label, "ehr-roundsremarksgridpanel", location); addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalObservationsCellEditing.js")); - addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/panel/ClinicalRemarkPanel.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/panel/ClinicalRemarkPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/grid/RoundsRemarksGridPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/grid/ObservationsRowEditorGridPanel.js")); addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalRemarksRowEditor.js")); diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgeryRoundsRemarksFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgeryRoundsRemarksFormSection.java new file mode 100644 index 000000000..5b2b3792a --- /dev/null +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgeryRoundsRemarksFormSection.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2013-2014 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.json.JSONObject; +import org.labkey.api.ehr.EHRService; +import org.labkey.api.ehr.dataentry.DataEntryFormContext; +import org.labkey.api.ehr.dataentry.SimpleFormSection; +import org.labkey.api.view.template.ClientDependency; + +import java.util.List; + + +public class SurgeryRoundsRemarksFormSection extends SimpleFormSection +{ + public SurgeryRoundsRemarksFormSection(String label, EHRService.FORM_SECTION_LOCATION location) + { + super("study", "Clinical Remarks", label, "ehr-roundsremarksgridpanel", location); + addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalObservationsCellEditing.js")); + addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/panel/ClinicalRemarkPanel.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/grid/RoundsRemarksGridPanel.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/grid/ObservationsRowEditorGridPanel.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/plugin/ClinicalRemarksRowEditor.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/data/ClinicalObservationsClientStore.js")); + addClientDependency(ClientDependency.supplierFromPath("ehr/buttons/roundsButtons.js")); + + + + setTemplateMode(TEMPLATE_MODE.NONE); + } + + @Override + public List getTbarButtons() + { + List defaultButtons = super.getTbarButtons(); + defaultButtons.remove("COPYFROMSECTION"); + defaultButtons.remove("ADDRECORD"); + defaultButtons.remove("ADDANIMALS"); + + if (defaultButtons.contains("DELETERECORD")) + { + int idx = defaultButtons.indexOf("DELETERECORD"); + defaultButtons.remove("DELETERECORD"); + defaultButtons.add(idx, "ROUNDSDELETE"); + } + + defaultButtons.add("MARK_ROUNDS_REVIEWED"); + + return defaultButtons; + } + + @Override + public List getTbarMoreActionButtons() + { + List defaultButtons = super.getTbarMoreActionButtons(); + defaultButtons.remove("DUPLICATE"); + + return defaultButtons; + } + + @Override + public JSONObject toJSON(DataEntryFormContext ctx, boolean includeFormElements) + { + JSONObject ret = super.toJSON(ctx, includeFormElements); + + return ret; + } + + @Override + protected String getServerSort() + { + return "Id/curLocation/room,Id/curLocation/cage,Id"; + } +} diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java index 6a6f3f0f4..0c1f87fed 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsFormType.java @@ -59,6 +59,11 @@ public SurgicalRoundsFormType(DataEntryFormContext ctx, Module owner) } addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/model/sources/SurgicalRounds.js")); + + // Added: 4-3-2026 R. Blasa + addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/form/field/Surgery_PlantextArea.js")); + + setDisplayReviewRequired(true); } diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java index 68608d813..7ac93eace 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java @@ -26,7 +26,7 @@ * Date: 7/7/13 * Time: 10:36 AM */ -public class SurgicalRoundsRemarksFormSection extends RoundsRemarksFormSection +public class SurgicalRoundsRemarksFormSection extends SurgeryRoundsRemarksFormSection { public SurgicalRoundsRemarksFormSection() { From d73c8d34536e57c4eb58ac5b6ba67d9bf6ce3ffc Mon Sep 17 00:00:00 2001 From: blasar Date: Fri, 3 Apr 2026 12:52:21 -0700 Subject: [PATCH 08/18] Modified Surgery Rounds report to include P2 surgery exclusive entries. --- .../web/onprc_ehr/form/field/Surgery_PlantextArea.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js index 3601f5a38..d7b351c30 100644 --- a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js @@ -119,7 +119,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { } }, - copyMostRecentP2: function(){ + copyMostRecentS2: function(){ var rec = EHR.DataEntryUtils.getBoundRecord(this); if (!rec || !rec.get('Id')){ Ext4.Msg.alert('Error', 'No Id Entered'); @@ -146,7 +146,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { LABKEY.Query.executeSql({ schemaName: 'study', - sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.caseid.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Surgery\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category = \'Surgery\' OR c.category is null) AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', failure: LDK.Utils.getErrorCallback(), scope: this, success: function(results){ From b8254dc4952f6b726005b5654bb826165182f7b7 Mon Sep 17 00:00:00 2001 From: blasar Date: Fri, 3 Apr 2026 14:31:02 -0700 Subject: [PATCH 09/18] Modified Surgery Rounds report to include P2 surgery exclusive entries. --- .../resources/web/onprc_ehr/model/sources/SurgicalRounds.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 6b334659a..c871145a5 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -33,7 +33,10 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { p: { hidden: true }, - p2: { + CEG_Plan: { + hidden: true + }, + P2: { formEditorConfig: { xtype: 'onprc_ehr-Surg_plantextarea', }, From c8d89e57ed883a84a5326f2549915a9dc5ac66d4 Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 6 Apr 2026 14:34:33 -0700 Subject: [PATCH 10/18] Modified Surgery Rounds report to include P2 surgery exclusive entries. --- .../resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js index d7b351c30..6ce5dd7be 100644 --- a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js @@ -146,7 +146,7 @@ Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { LABKEY.Query.executeSql({ schemaName: 'study', - sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category = \'Surgery\' OR c.category is null) AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category = \'Surgery\' ) AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', failure: LDK.Utils.getErrorCallback(), scope: this, success: function(results){ From f7db15495c229baeb0d14e554a65fe4cf28c151b Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 29 Jun 2026 14:35:26 -0700 Subject: [PATCH 11/18] Modified surgical rounds input form to allow S2 remark's field to load data automatically. --- .../resources/web/onprc_ehr/model/sources/SurgicalRounds.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index c871145a5..95dbe3afb 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -37,9 +37,6 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, P2: { - formEditorConfig: { - xtype: 'onprc_ehr-Surg_plantextarea', - }, header: 'S2', hidden: false, height: 75 From c470d1d5acca526f0165a9b5a57599835caf0d3b Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 29 Jun 2026 18:32:52 -0700 Subject: [PATCH 12/18] Modified Surgical reporting of S2 as part of Full Animal History. --- .../history/ONPRCClinicalRemarksDataSource.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java b/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java index a7a67fffb..5d740a067 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java @@ -15,6 +15,7 @@ */ package org.labkey.onprc_ehr.history; +import com.google.gwt.user.cellview.client.AbstractCellTable; import org.labkey.api.data.Container; import org.labkey.api.data.Results; import org.labkey.api.ehr.history.AbstractDataSource; @@ -91,7 +92,15 @@ protected String getHtml(Container c, Results rs, boolean redacted) throws SQLEx appendNote(rs, "o", "O", sb); appendNote(rs, "a", "A", sb); appendNote(rs, "p", "P", sb); - appendNote(rs, "p2", "P2", sb); + if ("Surgery".equals(category)) + { + appendNote(rs, "p2", "S2", sb); + } + else + { + appendNote(rs, "p2", "P2", sb); + } + appendNote(rs, "CEG_Plan", "CEG Plan", sb); appendNote(rs, "remark", "Other Remark", sb); From adce4f45b3caa0fadefbed444f703b18722c93fa Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 1 Jul 2026 11:17:40 -0700 Subject: [PATCH 13/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- .../window/AddSurgicalCasesWindow.js | 198 ++++++++++++++++++ .../SurgicalRoundsRemarksFormSection.java | 4 +- 2 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js diff --git a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js new file mode 100644 index 000000000..6117d4b9c --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2013-2019 LabKey Corporation + * + * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 + */ +/** + * This window will allow users to query open cases and add records to a task based on them + */ +Ext4.define('EHR.window.AddSurgicalCasesWindow', { + extend: 'EHR.window.AddClinicalCasesWindow', + caseCategory: 'Surgery', + templateName: 'Surgical Rounds', + + allowNoSelection: true, + allowReviewAnimals: false, + showAssignedVetCombo: false, + caseDisplayField: 'remark', + caseEmptyText: 'No description available', + defaultRemark: 'Surgical rounds performed.', + + initComponent: function(){ + this.callParent(arguments); + + this.obsStore = this.targetStore.storeCollection.getClientStoreByName('Clinical Observations'); + LDK.Assert.assertNotEmpty('Unable to find targetStore in AddSurgicalCasesWindow', this.obsStore); + }, + + getCases: function(button){ + Ext4.Msg.wait("Loading..."); + this.hide(); + + var casesFilterArray = this.getCasesFilterArray(); + var obsFilterArray = this.getBaseFilterArray(); + obsFilterArray.push(LABKEY.Filter.create('caseCategory', this.caseCategory, LABKEY.Filter.Types.EQUAL)); + obsFilterArray.push(LABKEY.Filter.create('caseIsActive', true, LABKEY.Filter.Types.EQUAL)); + + //find distinct animals matching criteria + var multi = new LABKEY.MultiRequest(); + + multi.add(LABKEY.Query.selectRows, { + requiredVersion: 9.1, + schemaName: 'study', + queryName: 'latestObservationsForCase', + columns: 'Id,date,category,area,observation,remark,caseid', + filterArray: obsFilterArray, + scope: this, + success: function(results){ + this.obsResults = results; + }, + failure: LDK.Utils.getErrorCallback() + }); + + multi.add(LABKEY.Query.selectRows, { + requiredVersion: 9.1, + schemaName: 'study', + queryName: 'cases', + sort: 'Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue,Id,remark', + columns: 'Id,objectid,remark,mostRecentP2,Id/curLocation/location', + filterArray: casesFilterArray, + scope: this, + success: function(results){ + this.casesResults = results; + }, + failure: LDK.Utils.getErrorCallback() + }); + + multi.send(this.onSuccess, this); + }, + + onSuccess: function(){ + if (!this.casesResults || !this.casesResults.rows || !this.casesResults.rows.length){ + Ext4.Msg.hide(); + Ext4.Msg.alert('', 'No active cases were found' + (this.down('#excludeToday').getValue() ? ', excluding those reviewed today.' : '.')); + return; + } + + LDK.Assert.assertNotEmpty('Unable to find targetStore in AddSurgicalCasesWindow', this.targetStore); + + var records = []; + var idMap = {}; + this.caseRecordMap = {}; + this.recordData = { + performedby: this.down('#performedBy').getValue(), + date: this.down('#date').getValue() + }; + + Ext4.Array.each(this.casesResults.rows, function(sr){ + var row = new LDK.SelectRowsRow(sr); + idMap[row.getValue('Id')] = row; + this.caseRecordMap[row.getValue('objectid')] = row; + + var obj = { + Id: row.getValue('Id'), + date: this.recordData.date, + category: this.caseCategory, + s: null, + o: null, + a: null, + p: null, + p2: row.getValue('mostRecentP2'), + caseid: row.getValue('objectid'), + remark: this.defaultRemark, + performedby: this.recordData.performedby, + 'Id/curLocation/location': row.getValue('Id/curLocation/location') + }; + + records.push(this.targetStore.createModel(obj)); + }, this); + + //check for dupes + this.addRecords(records); + }, + + doAddRecords: function(records){ + var toAdd = this.checkForExistingCases(records); + this.targetStore.add(toAdd); + if (toAdd.length){ + this.processObservations(records); + } + else { + this.onComplete(); + } + }, + + processObservations: function(records){ + var previousObsMap = {}; + if (this.obsResults && this.obsResults.rows && this.obsResults.rows.length){ + Ext4.Array.forEach(this.obsResults.rows, function(sr){ + var row = new LDK.SelectRowsRow(sr); + + var caseId = row.getValue('caseid'); + if (!previousObsMap[caseId]) + previousObsMap[caseId] = []; + + previousObsMap[caseId].push({ + Id: row.getValue('Id'), + date: this.recordData.date, + performedby: this.recordData.performedby, + caseid: row.getValue('caseid'), + category: row.getValue('category'), + area: row.getValue('area'), + p2:row.getValue('p2'), + observation: row.getValue('observation'), + remark: row.getValue('remark') + }); + }, this); + } + + var toAdd = []; + var recordsNeedingTemplate = []; + Ext4.Array.forEach(records, function(rec){ + var caseId = rec.get('caseid'); + if (previousObsMap[caseId]){ + Ext4.Array.forEach(previousObsMap[caseId], function(obsRec){ + toAdd.push(this.obsStore.createModel(obsRec)); + }, this); + } + else { + console.log('no existing obs'); + recordsNeedingTemplate.push(rec) + } + }, this); + + if (toAdd.length){ + this.obsStore.add(toAdd); + } + + if (recordsNeedingTemplate.length){ + this.applyObsTemplate(recordsNeedingTemplate); + } + else { + Ext4.Msg.hide(); + this.close(); + } + } +}); + +EHR.DataEntryUtils.registerGridButton('ADDSURGICALCASES_Amended', function(config){ + return Ext4.Object.merge({ + text: 'Add Open Cases', + tooltip: 'Click to automatically add animals with open cases', + handler: function(btn){ + var grid = btn.up('gridpanel'); + if(!grid.store || !grid.store.hasLoaded()){ + console.log('no store or store hasnt loaded'); + return; + } + + var cellEditing = grid.getPlugin('cellediting'); + if(cellEditing) + cellEditing.completeEdit(); + + Ext4.create('EHR.window.AddSurgicalCasesWindow', { + targetStore: grid.store + }).show(); + } + }, config); +}); diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java index 7ac93eace..b02f31179 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/dataentry/SurgicalRoundsRemarksFormSection.java @@ -39,7 +39,7 @@ public SurgicalRoundsRemarksFormSection(EHRService.FORM_SECTION_LOCATION locatio setConfigSources(Collections.singletonList("Task")); addClientDependency(ClientDependency.supplierFromPath("ehr/window/AddClinicalCasesWindow.js")); - addClientDependency(ClientDependency.supplierFromPath("ehr/window/AddSurgicalCasesWindow.js")); + addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/window/AddSurgicalCasesWindow.js")); addClientDependency(ClientDependency.supplierFromPath("onprc_ehr/window/BulkChangeCasesWindow.js")); _showLocation = true; @@ -49,7 +49,7 @@ public SurgicalRoundsRemarksFormSection(EHRService.FORM_SECTION_LOCATION locatio public List getTbarButtons() { List defaultButtons = super.getTbarButtons(); - defaultButtons.add(0, "ADDSURGICALCASES"); + defaultButtons.add(0, "ADDSURGICALCASES_Amended"); defaultButtons.add("BULK_CHANGE_CASES"); return defaultButtons; From 4fd5bcd4259b53845b606ada1e8ee5654b6ff738 Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 1 Jul 2026 12:06:04 -0700 Subject: [PATCH 14/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- .../resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js | 1 - 1 file changed, 1 deletion(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js index 6117d4b9c..de7aad31f 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js @@ -139,7 +139,6 @@ Ext4.define('EHR.window.AddSurgicalCasesWindow', { caseid: row.getValue('caseid'), category: row.getValue('category'), area: row.getValue('area'), - p2:row.getValue('p2'), observation: row.getValue('observation'), remark: row.getValue('remark') }); From 0c59c359c4e13e0e56b846a8cfcfbe5d7cc65eca Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 1 Jul 2026 17:40:29 -0700 Subject: [PATCH 15/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- .../web/onprc_ehr/window/AddSurgicalCasesWindow.js | 4 ++-- .../labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js index de7aad31f..387092aa5 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js @@ -55,7 +55,7 @@ Ext4.define('EHR.window.AddSurgicalCasesWindow', { schemaName: 'study', queryName: 'cases', sort: 'Id/curLocation/room_sortValue,Id/curLocation/cage_sortValue,Id,remark', - columns: 'Id,objectid,remark,mostRecentP2,Id/curLocation/location', + columns: 'Id,objectid,remark,lastP2,Id/curLocation/location', filterArray: casesFilterArray, scope: this, success: function(results){ @@ -97,7 +97,7 @@ Ext4.define('EHR.window.AddSurgicalCasesWindow', { o: null, a: null, p: null, - p2: row.getValue('mostRecentP2'), + p2: row.getValue('lastP2'), caseid: row.getValue('objectid'), remark: this.defaultRemark, performedby: this.recordData.performedby, diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java b/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java index 7f95381d7..9ed8744a6 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/table/ONPRC_EHRCustomizer.java @@ -1356,6 +1356,17 @@ private void appendLatestHxCol(AbstractTableInfo ti) recentP2.setDisplayWidth("200"); ti.addColumn(recentP2); + //Last recorded p2 specifically designed for Surgery cases + SQLFragment lastp2Sql = new SQLFragment("(SELECT " + prefix + " (" + "r.p2" + ") as _expr FROM " + realTable.getSelectName() + + " r WHERE " + + " r.caseid = " + ExprColumn.STR_TABLE_ALIAS + ".objectid AND " + + " r.participantId = " + ExprColumn.STR_TABLE_ALIAS + ".participantId AND (r.category != ? OR r.category IS NULL) ORDER BY r.date desc " + suffix + ")", ONPRC_EHRManager.REPLACED_SOAP); + ExprColumn lastP2 = new ExprColumn(ti, "lastP2", lastp2Sql, JdbcType.VARCHAR, objectId); + lastP2.setLabel("S2"); + lastP2.setDescription("This column will display the last P2 recorded corresponding to a case for the animal."); + lastP2.setDisplayWidth("200"); + ti.addColumn(lastP2); + //uses caseId. this is a proxy for rounds SQLFragment recentRemarkSql = new SQLFragment("(SELECT " + prefix + " (" + "r.remark" + ") as _expr FROM " + realTable.getSelectName() + " r WHERE " From 5455a7ecadb4eded86c815aa7f57dce3eb4fe242 Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 11:49:53 -0700 Subject: [PATCH 16/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- .../web/onprc_ehr/model/sources/SurgicalRounds.js | 2 +- .../web/onprc_ehr/window/AddSurgicalCasesWindow.js | 2 +- .../history/ONPRCClinicalRemarksDataSource.java | 11 +---------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js index 95dbe3afb..b80a922ca 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -37,7 +37,7 @@ EHR.model.DataModelManager.registerMetadata('SurgicalRounds', { hidden: true }, P2: { - header: 'S2', + header: 'P2', hidden: false, height: 75 } diff --git a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js index 387092aa5..7145bb4eb 100644 --- a/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js +++ b/onprc_ehr/resources/web/onprc_ehr/window/AddSurgicalCasesWindow.js @@ -97,7 +97,7 @@ Ext4.define('EHR.window.AddSurgicalCasesWindow', { o: null, a: null, p: null, - p2: row.getValue('lastP2'), + R2: row.getValue('lastP2'), caseid: row.getValue('objectid'), remark: this.defaultRemark, performedby: this.recordData.performedby, diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java b/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java index 5d740a067..a7a67fffb 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/history/ONPRCClinicalRemarksDataSource.java @@ -15,7 +15,6 @@ */ package org.labkey.onprc_ehr.history; -import com.google.gwt.user.cellview.client.AbstractCellTable; import org.labkey.api.data.Container; import org.labkey.api.data.Results; import org.labkey.api.ehr.history.AbstractDataSource; @@ -92,15 +91,7 @@ protected String getHtml(Container c, Results rs, boolean redacted) throws SQLEx appendNote(rs, "o", "O", sb); appendNote(rs, "a", "A", sb); appendNote(rs, "p", "P", sb); - if ("Surgery".equals(category)) - { - appendNote(rs, "p2", "S2", sb); - } - else - { - appendNote(rs, "p2", "P2", sb); - } - + appendNote(rs, "p2", "P2", sb); appendNote(rs, "CEG_Plan", "CEG Plan", sb); appendNote(rs, "remark", "Other Remark", sb); From 77aaf770dd44dca2a4f7d4753741efe09378f9bc Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 12:22:05 -0700 Subject: [PATCH 17/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- onprc_ehr/resources/queries/study/clinremarks/.qview.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml index 9f5ac339e..1196a662a 100644 --- a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml +++ b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml @@ -10,6 +10,8 @@ + + From 761522d03aa515baaa90c4f3aa058dad245ff0bf Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 12:55:55 -0700 Subject: [PATCH 18/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- .../web/onprc_ehr/form/field/PlanTextArea.js | 40 ++-- .../form/field/Surgery_PlantextArea.js | 199 ------------------ 2 files changed, 21 insertions(+), 218 deletions(-) delete mode 100644 onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js index 3781bb74a..3620e5e9d 100644 --- a/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js +++ b/onprc_ehr/resources/web/onprc_ehr/form/field/PlanTextArea.js @@ -1,11 +1,14 @@ +/** + * Created: R.Blasa on 10/25/2017. + */ /* - * Copyright (c) 2014-2019 LabKey Corporation + * Copyright (c) 2014 LabKey Corporation * * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 */ -Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { +Ext4.define('ONPRC_EHR.form.field.CEG_PlantextArea', { extend: 'Ext.form.field.TextArea', - alias: 'widget.onprc_ehr-plantextarea', + alias: 'widget.onprc_ehr-CEG_Plantextarea', onAnimalChange: function(){ this.updateDisplayEl(); @@ -27,7 +30,7 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { this.linkEl = this.linkDiv.createChild({ tag: 'a', cls: 'labkey-text-link', - html: (this.getValue() ? 'Copy Latest P2' : 'Edit P2') + html: (this.getValue() ? 'Copy Latest CEG_Plan' : 'Edit CEG_Plan') }); var panel = this.up('ehr-formpanel'); @@ -50,7 +53,7 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { }) } - this.linkEl.on('click', this.copyMostRecentP2, this); + this.linkEl.on('click', this.copyMostRecentCEG_Plan, this); this.setupMask(); }, @@ -86,7 +89,7 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { } if (this.linkEl){ - this.linkEl.update('Copy Latest P2'); + this.linkEl.update('Copy Latest CEG_Plan'); } if (this.inputEl) @@ -100,17 +103,16 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { var rec = EHR.DataEntryUtils.getBoundRecord(this); if (rec && rec.get('Id')){ - this.getMostRecentP2(rec, function(ret, Id){ + this.getMostRecentCEG_Plan(rec, function(ret, Id){ if (!ret || !this.displayEl){ - this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); return; } - if (ret.mostRecentP2 && ret.isActive){ - this.displayEl.update(ret.mostRecentP2); + if (ret.mostRecentCeg_Plan && ret.isActive){ + this.displayEl.update(ret.mostRecentCeg_Plan); } else { - this.displayEl.update('Either no active case or no P2 for ' + (Id || rec.get('Id'))); + this.displayEl.update('Either no active case or no CEG_Plan for ' + (Id || rec.get('Id'))); } }); } @@ -119,7 +121,7 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { } }, - copyMostRecentP2: function(){ + copyMostRecentCEG_Plan: function(){ var rec = EHR.DataEntryUtils.getBoundRecord(this); if (!rec || !rec.get('Id')){ Ext4.Msg.alert('Error', 'No Id Entered'); @@ -129,24 +131,24 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { Ext4.Msg.wait('Loading...'); this.showTextArea(); - this.getMostRecentP2(rec, function(ret){ + this.getMostRecentCEG_Plan(rec, function(ret){ Ext4.Msg.hide(); - if (ret && ret.mostRecentP2){ - this.setValue(ret.mostRecentP2); - this.linkEl.update('Refresh P2'); + if (ret){ + this.setValue(ret.mostRecentCeg_Plan); + this.linkEl.update('Refresh CEG Plan'); } }, true); }, - getMostRecentP2: function(rec, cb, alwaysUseCallback){ + getMostRecentCEG_Plan: function(rec, cb, alwaysUseCallback){ var date = rec.get('date') || new Date(); var id = rec.get('Id'); this.pendingIdRequest = id; LABKEY.Query.executeSql({ schemaName: 'study', - sql: 'SELECT c.Id, c.p2 as mostRecentP2, c.caseid, c.caseid.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.caseid.category= \'Clinical\' AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', + sql: 'SELECT c.Id, c.CEG_Plan as mostRecentCeg_Plan, c.caseid, c.caseid.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category != \'Replaced SOAP\' OR c.category IS NULL) AND c.CEG_Plan IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', failure: LDK.Utils.getErrorCallback(), scope: this, success: function(results){ @@ -155,7 +157,7 @@ Ext4.define('ONPRC_EHR.form.field.PlanTextArea', { return; } - if (results && results.rows && results.rows.length){ + if (results && results.rows && results.rows.length && results.rows[0].mostRecentCeg_Plan){ cb.call(this, results.rows[0], results.rows[0].Id); } else { diff --git a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js b/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js deleted file mode 100644 index 6ce5dd7be..000000000 --- a/onprc_ehr/resources/web/onprc_ehr/form/field/Surgery_PlantextArea.js +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) 2014-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ -Ext4.define('ONPRC_EHR.form.field.Surg_PlanTextArea', { - extend: 'Ext.form.field.TextArea', - alias: 'widget.onprc_ehr-Surg_plantextarea', - - onAnimalChange: function(){ - this.updateDisplayEl(); - }, - - onRender : function(ct, position){ - this.callParent(arguments); - - this.wrap = this.inputEl.wrap({ - tag: 'div', - cls: 'x4-form-field-wrap' - }); - - this.linkDiv = this.wrap.createChild({ - tag: 'div', - style: 'vertical-align:top;' - }, this.inputEl); - - this.linkEl = this.linkDiv.createChild({ - tag: 'a', - cls: 'labkey-text-link', - html: (this.getValue() ? 'Copy Latest S2' : 'Edit S2') - }); - - var panel = this.up('ehr-formpanel'); - if (panel){ - this.mon(panel, 'bindrecord', this.onAnimalChange, this, {buffer: 100}); - } - else { - LDK.Utils.logToServer({ - message: 'Unable to find ehr-formpanel in Surg_PlantextArea' - }) - } - - var dataEntryPanel = this.up('ehr-dataentrypanel'); - if (dataEntryPanel){ - this.mon(dataEntryPanel, 'animalchange', this.onAnimalChange, this, {buffer: 100}); - } - else { - LDK.Utils.logToServer({ - message: 'Unable to find ehr-dataentrypanel in Surg_PlanTextArea' - }) - } - - this.linkEl.on('click', this.copyMostRecentS2, this); - this.setupMask(); - }, - - setupMask: function(){ - if (this.getValue()){ - this.showTextArea(); - return; - } - - this.inputEl.setVisibilityMode(Ext4.dom.AbstractElement.DISPLAY); - this.inputEl.setVisible(false); - - this.displayEl = this.wrap.createChild({ - tag: 'div', - style: 'vertical-align:top;', - html: '' - }); - - this.displayEl.setWidth(this.width - this.labelWidth); - this.displayEl.setHeight(this.getHeight()); - - this.updateDisplayEl(); - }, - - showTextArea: function(){ - if (!this.rendered){ - return; - } - - if (this.displayEl){ - this.displayEl.remove(); - delete this.displayEl; - } - - if (this.linkEl){ - this.linkEl.update('Copy Latest S2'); - } - - if (this.inputEl) - this.inputEl.setVisible(true); - }, - - updateDisplayEl: function(){ - if (!this.displayEl){ - return; - } - - var rec = EHR.DataEntryUtils.getBoundRecord(this); - if (rec && rec.get('Id')){ - this.getMostRecentS2(rec, function(ret, Id){ - if (!ret || !this.displayEl){ - this.displayEl.update('Either no active case or no S2 for ' + (Id || rec.get('Id'))); - return; - } - - if (ret.mostRecentS2 && ret.isActive){ - this.displayEl.update(ret.mostRecentS2); - } - else { - this.displayEl.update('Either no active case or no S2 for ' + (Id || rec.get('Id'))); - } - }); - } - else { - this.displayEl.update('No animal entered'); - } - }, - - copyMostRecentS2: function(){ - var rec = EHR.DataEntryUtils.getBoundRecord(this); - if (!rec || !rec.get('Id')){ - Ext4.Msg.alert('Error', 'No Id Entered'); - return; - } - - Ext4.Msg.wait('Loading...'); - this.showTextArea(); - - this.getMostRecentS2(rec, function(ret){ - Ext4.Msg.hide(); - - if (ret && ret.mostRecentS2){ - this.setValue(ret.mostRecentS2); - this.linkEl.update('Refresh S2'); - } - }, true); - }, - - getMostRecentS2: function(rec, cb, alwaysUseCallback){ - var date = rec.get('date') || new Date(); - var id = rec.get('Id'); - this.pendingIdRequest = id; - - LABKEY.Query.executeSql({ - schemaName: 'study', - sql: 'SELECT c.Id, c.p2 as mostRecentS2, c.caseid, c.category as caseCategory, c.caseid.isActive as isActive FROM study.clinRemarks c WHERE (c.category = \'Surgery\' ) AND c.p2 IS NOT NULL AND c.Id = \'' + rec.get('Id') + '\' ORDER BY c.date DESC LIMIT 1', - failure: LDK.Utils.getErrorCallback(), - scope: this, - success: function(results){ - if (!alwaysUseCallback && id != this.pendingIdRequest){ - console.log('more recent request, aborting'); - return; - } - - if (results && results.rows && results.rows.length){ - cb.call(this, results.rows[0], results.rows[0].Id); - } - else { - cb.call(this, null, id); - } - } - }); - }, - - onDestroy : function(){ - if (this.linkEl){ - this.linkEl.removeAllListeners(); - this.linkEl.remove(); - } - - if (this.linkDiv){ - this.linkDiv.removeAllListeners(); - this.linkDiv.remove(); - } - - if (this.displayEl){ - //NOTE: no listeners were added - //this.displayEl.removeAllListeners(); - this.displayEl.remove(); - } - - if (this.wrap){ - this.wrap.remove(); - } - - this.callParent(this); - }, - - setValue: function(){ - this.callParent(arguments); - - if (this.getValue()){ - this.showTextArea(); - } - } -}); \ No newline at end of file