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/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..6ce5dd7be --- /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 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 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..c871145a5 --- /dev/null +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/SurgicalRounds.js @@ -0,0 +1,55 @@ +/* + * 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 + }, + CEG_Plan: { + hidden: true + }, + P2: { + formEditorConfig: { + xtype: 'onprc_ehr-Surg_plantextarea', + }, + header: 'S2', + hidden: false, + height: 75 + } + + }, + 'study.blood': { + reason: { + defaultValue: 'Clinical' + } + } + } +}); \ No newline at end of file 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/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 9dd6206d3..0c1f87fed 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,12 @@ public SurgicalRoundsFormType(DataEntryFormContext ctx, Module owner) } } - addClientDependency(ClientDependency.supplierFromPath("ehr/model/sources/SurgicalRounds.js")); + 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() {