From 674dac20b81304911d634eb79a78916631500a40 Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Mon, 9 Feb 2026 05:44:30 -0800 Subject: [PATCH 1/2] fixes --- .../resources/queries/study/drug/.qview.xml | 4 +- .../queries/study/drug/Behavior.qview.xml | 28 ++ .../resources/reports/additionalReports.tsv | 3 +- .../views/clinicalHistoryExport.html | 82 ++++ .../views/clinicalHistoryExport.view.xml | 5 + .../web/nirc_ehr/model/sources/NIRCDefault.js | 8 + .../resources/web/nirc_ehr/nircReports.js | 2 +- .../web/nirc_ehr/panel/CaseHistoryPanel.js | 19 + .../nirc_ehr/panel/ClinicalHistoryPanel.js | 461 ++++++++++++++++++ .../web/nirc_ehr/panel/NarrowSnapshotPanel.js | 37 ++ .../nirc_ehr/window/NIRCCaseHistoryWindow.js | 2 +- .../window/NIRCClinicalHistoryWindow.js | 2 +- .../org/labkey/nirc_ehr/NIRC_EHRModule.java | 4 + 13 files changed, 650 insertions(+), 7 deletions(-) create mode 100644 nirc_ehr/resources/queries/study/drug/Behavior.qview.xml create mode 100644 nirc_ehr/resources/views/clinicalHistoryExport.html create mode 100644 nirc_ehr/resources/views/clinicalHistoryExport.view.xml create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js create mode 100644 nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js diff --git a/nirc_ehr/resources/queries/study/drug/.qview.xml b/nirc_ehr/resources/queries/study/drug/.qview.xml index 032e214c..3b722685 100644 --- a/nirc_ehr/resources/queries/study/drug/.qview.xml +++ b/nirc_ehr/resources/queries/study/drug/.qview.xml @@ -8,9 +8,7 @@ - - @@ -22,7 +20,7 @@ - + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml b/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml new file mode 100644 index 00000000..a9769cb8 --- /dev/null +++ b/nirc_ehr/resources/queries/study/drug/Behavior.qview.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/reports/additionalReports.tsv b/nirc_ehr/resources/reports/additionalReports.tsv index af1b5ab5..98acfbe0 100644 --- a/nirc_ehr/resources/reports/additionalReports.tsv +++ b/nirc_ehr/resources/reports/additionalReports.tsv @@ -13,7 +13,8 @@ notes Colony Management query Notes true study notes false false qcstate/pu activeClinTreatmentOrders Clinical query Active Clinical Medication Orders true study treatment_order Clinical Active Treatment Orders date false false qcstate/publicdata This report contains the treatment orders entered for each animal activeBehaviorTreatmentOrders Behavior query Active Behavior Medication Orders true study treatment_order Behavior Active Treatment Orders date false false qcstate/publicdata This report contains the treatment orders entered for each animal allTreatments Clinical query All Treatment Orders true study treatment_order false false qcstate/publicdata This report shows all treatment orders -behTreatments Behavior query All Behavior Medication Orders true study treatment_order behavior false false qcstate/publicdata This report shows all treatment orders +behTreatments Behavior query All Behavior Medication Orders true study treatment_order behavior false false qcstate/publicdata This report shows all behavior treatment orders +behDrug Behavior query Behavior Drug Administration true study drug Behavior false false qcstate/publicdata This report shows all behavior drug administrations FileRepository General js File Repository true study FileRepository false false qcstate/publicdata File Repository for uploading and viewing animal related files observationSchedule Daily Reports js Today's Observation Schedule true study observationSchedule date false false qcstate/publicdata This report contains a list of today's treatments to be administered activeClinicalObservationOrders Clinical query Active Clinical Observation Orders true study observation_order Active Clinical Orders date false false qcstate/publicdata This report contains a list of today's treatments to be administered diff --git a/nirc_ehr/resources/views/clinicalHistoryExport.html b/nirc_ehr/resources/views/clinicalHistoryExport.html new file mode 100644 index 00000000..8e15e246 --- /dev/null +++ b/nirc_ehr/resources/views/clinicalHistoryExport.html @@ -0,0 +1,82 @@ + \ No newline at end of file diff --git a/nirc_ehr/resources/views/clinicalHistoryExport.view.xml b/nirc_ehr/resources/views/clinicalHistoryExport.view.xml new file mode 100644 index 00000000..35f09e39 --- /dev/null +++ b/nirc_ehr/resources/views/clinicalHistoryExport.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js index 15cdd8bd..eee4923b 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/NIRCDefault.js @@ -14,6 +14,10 @@ EHR.model.DataModelManager.registerMetadata('Default', { allowBlank: true, defaultValue: LABKEY.Security.currentUser.id, getInitialValue: function (v, rec) { + if (Number.isInteger(v)){ + return v; + } + return LABKEY.Security.currentUser.id; }, editorConfig: { @@ -136,6 +140,10 @@ EHR.model.DataModelManager.registerMetadata('Default', { sort: 'Type,DisplayName' }, getInitialValue: function (v, rec) { + if (Number.isInteger(v)){ + return v; + } + return LABKEY.Security.currentUser.id; }, editorConfig: { diff --git a/nirc_ehr/resources/web/nirc_ehr/nircReports.js b/nirc_ehr/resources/web/nirc_ehr/nircReports.js index ad3f1e12..9a7aab31 100644 --- a/nirc_ehr/resources/web/nirc_ehr/nircReports.js +++ b/nirc_ehr/resources/web/nirc_ehr/nircReports.js @@ -181,7 +181,7 @@ EHR.reports.clinicalHistory = function(panel, tab, showActionsBtn, includeAll){ }); toAdd.push({ - xtype: 'ehr-clinicalhistorypanel', + xtype: 'nirc_ehr-clinicalhistorypanel', border: true, subjectId: s, autoLoadRecords: true, diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js new file mode 100644 index 00000000..517352c6 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/CaseHistoryPanel.js @@ -0,0 +1,19 @@ + +/** + * @cfg caseId + * @cfg maxGridHeight + * @cfg autoLoadRecords + */ +Ext4.define('NIRC_EHR.panel.CaseHistoryPanel', { + extend: 'NIRC_EHR.panel.ClinicalHistoryPanel', + alias: 'widget.nirc_ehr-casehistorypanel', + + getStoreConfig: function(){ + return { + type: 'ehr-clinicalhistorystore', + containerPath: this.containerPath, + actionName: 'getCaseHistory', + sorters: [{property: 'group'}, {property: 'timeString'}] + }; + } +}); diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js new file mode 100644 index 00000000..97ba69dc --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js @@ -0,0 +1,461 @@ + +/** + * @cfg subjectId + * @cfg minDate + * @cfg maxDate + * @cfg maxGridHeight + * @cfg autoLoadRecords + * @cfg hideExportBtn + * @cfg sortMode + * @cfg checkedItems + * @cfg showMaxDate + * @cfg redacted + * @cfg printMode + */ +Ext4.define('NIRC_EHR.panel.ClinicalHistoryPanel', { + extend: 'Ext.panel.Panel', + alias: 'widget.nirc_ehr-clinicalhistorypanel', + + showMaxDate: false, + + initComponent: function(){ + this.sortMode = this.sortMode || 'date'; + + if (this.minDate && !Ext4.isDate(this.minDate)) + this.minDate = LDK.ConvertUtils.parseDate(this.minDate, LABKEY.extDefaultDateFormat); + if (this.maxDate && !Ext4.isDate(this.maxDate)) + this.maxDate = LDK.ConvertUtils.parseDate(this.maxDate, LABKEY.extDefaultDateFormat); + + Ext4.apply(this, { + border: false, + items: [ + this.getGridConfig() + ], + listeners: { + scope: this, + render: function(){ + //defer loading of data + if (Ext4.isDefined(store) && this.autoLoadRecords){ + store.reloadData({ + subjectIds: [this.subjectId], + caseId: this.caseId, + minDate: this.minDate, + maxDate: this.maxDate, + checkedItems: this.checkedItems + }); + } + } + } + }); + + this.callParent(); + + var grid = this.down('grid'); + if (grid.rendered){ + grid.setLoading(true); + } + else { + grid.on('afterrender', function(grid){ + if (grid.store.loading){ + grid.setLoading(true); + } + }, this, {delay: 120, single: true}); + } + + if(this.subjectId || this.caseId){ + var store = this.down('#gridPanel').store; + store.on('datachanged', function(){ + if (!store.loading){ + var grid = this.down('grid'); + if (grid){ + grid.setLoading(false); + grid.getView().refresh(); + } + } + }, this); + + store.on('exception', function(store){ + this.down('grid').setLoading(false); + }, this); + } + else { + Ext4.Msg.alert('Error', 'Must supply at least 1 subject Id or a caseId') + } + }, + + getGridConfig: function(){ + return { + xtype: 'grid', + border: this.printMode ? false : true, + minHeight: 100, + minWidth: this.width - 50, + cls: 'ldk-grid', + maxHeight: this.maxGridHeight, + height: this.gridHeight, + hideHeaders: true, + deferEmptyText: true, + viewConfig : { + emptyText: this.minDate ? 'No records found since: ' + Ext4.util.Format.date(this.minDate, LABKEY.extDefaultDateFormat): 'There are no records to display', + deferEmptyText: true, + enableTextSelection: true, + border: false, + stripeRows : true + }, + columns: this.getColumnConfig(), + features: [this.getGroupingFeature()], + store: this.getStoreConfig(), + itemId: 'gridPanel', + width: this.width, + subjectId: this.subjectId, + caseId: this.caseId, + minDate: this.minDate, + maxDate: this.maxDate, + tbar: this.hideGridButtons ? null : { + border: true, + items: [{ + xtype: 'datefield', + fieldLabel: 'Min Date', + itemId: 'minDate', + labelWidth: 80, + width: 200, + value: this.minDate + },{ + xtype: 'datefield', + fieldLabel: 'Max Date', + itemId: 'maxDate', + labelWidth: 80, + width: 200, + hidden: this.showMaxDate, + value: this.maxDate + },{ + xtype: 'button', + text: 'Reload', + handler: function(btn){ + var panel = btn.up('ehr-clinicalhistorypanel'); + panel.doReload(); + } + },{ + text: 'Show/Hide Types', + scope: this, + handler: function(btn){ + this.showFilterPanel(); + } + },{ + text: 'Collapse All', + hidden: this.printMode, + collapsed: false, + handler: function(btn){ + var grid = btn.up('grid'); + var feature = grid.getView().getFeature('historyGrouping'); + + if (btn.collapsed){ + feature.expandAll(); + btn.setText('Collapse All'); + } + else { + feature.collapseAll(); + btn.setText('Expand All') + } + + btn.collapsed = !btn.collapsed; + } + },{ + hidden: this.printMode, + text: (this.sortMode == 'type' ? 'Group By Date' : 'Group By Type'), + sortMode: this.sortMode == 'type' ? 'date' : 'type', + scope: this, + handler: function(btn){ + //toggle the button + if (btn.sortMode == 'type'){ + btn.setText('Group By Date'); + btn.sortMode = 'date'; + this.changeMode('type'); + } + else { + btn.setText('Group By Type'); + btn.sortMode = 'type'; + this.changeMode('date'); + } + } + },{ + text: 'Print Version', + hidden: this.hideExportBtn || this.printMode, + scope: this, + handler: function(btn){ + var params = { + hideGridButtons: true + }; + if (this.subjectId) + params.subjectId = [this.subjectId]; + if (this.caseId) + params.caseId = this.caseId; + if (this.minDate) + params.minDate = Ext4.util.Format.date(this.minDate, LABKEY.extDefaultDateFormat); + if (this.maxDate) + params.maxDate = Ext4.util.Format.date(this.maxDate, LABKEY.extDefaultDateFormat); + if (this.sortMode) + params.sortMode = this.sortMode; + if (this.checkedItems && this.checkedItems.length) + params.checkedItems = this.checkedItems.join(';'); + + var url = LABKEY.ActionURL.buildURL('nirc_ehr', 'clinicalHistoryExport', null, params); + window.open(url, '_blank'); + } + }] + } + }; + }, + + reloadData: function(config){ + var grid = this.down('grid'); + + grid.setLoading(true); + grid.store.reloadData({ + minDate: config.minDate, + maxDate: config.maxDate, + subjectIds: [this.subjectId], + caseId: this.caseId, + sortMode: this.sortMode, + checkedItems: this.checkedItems + }); + }, + + doReload: function(){ + var minDateField = this.down('#minDate'); + var maxDateField = this.down('#maxDate'); + if (!minDateField.isValid()){ + Ext4.Msg.alert('Error', 'Invalid value for min date'); + return; + } + if (!maxDateField.isValid()){ + Ext4.Msg.alert('Error', 'Invalid value for max date'); + return; + } + + this.minDate = minDateField.getValue(); + this.maxDate = maxDateField.getValue(); + + this.reloadData({ + minDate: this.minDate, + maxDate: this.maxDate + }); + }, + + getStoreConfig: function(){ + var me = this; + return { + type: 'ehr-clinicalhistorystore', + containerPath: this.containerPath, + redacted: this.redacted, + sortMode: this.sortMode + }; + }, + + getColumnConfig: function(){ + return [{ + text: 'Category', + dataIndex: 'category', + tdCls: 'ldk-wrap-text', + width: 180, + renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ + if (record.get('categoryColor')){ + cellMetaData.style = cellMetaData.style ? cellMetaData.style + ';' : ''; + cellMetaData.style += 'background-color: ' + record.get('categoryColor') + ';'; + } + + return value; + } + },{ + text: 'Date', + xtype: 'datecolumn', + dataIndex: 'date', + format: LABKEY.extDefaultDateTimeFormat, + hidden: (this.sortMode == 'date'), + width: 180 + },{ + text: '', + dataIndex: 'timeString', + hidden: (this.sortMode != 'date'), + width: 80 + },{ + text: 'Description', + dataIndex: 'html', + minWidth: 300, + tdCls: 'ldk-wrap-text', + flex: 10 + },{ + text: 'Status', + dataIndex: 'qcStateLabel', + tdCls: 'ldk-wrap-text', + width: 120, + renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ + if (record.get('publicData') === false){ + cellMetaData.style = cellMetaData.style ? cellMetaData.style + ';' : ''; + cellMetaData.style += 'background-color: yellow;'; + } + + return value == EHR.QCStates.COMPLETED ? '' : value; + } + },{ + text: '', + dataIndex: 'taskId', + width: 60, + renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ + if (record.get('taskId')){ + return '' + record.get('taskRowId') + ''; + } + + return ''; + } + }]; + }, + + getGroupingFeature: function(){ + return Ext4.create('Ext.grid.feature.Grouping', { + groupHeaderTpl: [ + '
{name:this.formatName}
', { + formatName: function(name) { + name = name.split('_'); + var id = name.shift(); + var date = name[0].split("-"); + var date2 = new Date(date[0], date[1]-1, date[2], 0, 0, 0); + return id + ' (' + Ext4.util.Format.date(date2, LABKEY.extDefaultDateFormat) + ')'; + } + } + ], + hideGroupedHeader: true, + startCollapsed: false, + id: 'historyGrouping' + }); + }, + + changeMode: function(mode){ + this.sortMode = mode; + var grid = this.down('grid'); + + var columns = this.getColumnConfig(); + Ext4.Array.forEach(columns, function(col){ + if (col.dataIndex == 'date'){ + col.hidden = (mode == 'date'); + } + else if (col.dataIndex == 'timeString'){ + col.hidden = (mode == 'type'); + } + }, this); + + grid.on('reconfigure', function(){ + grid.store.changeMode(mode); + }, this, {single: true}); + grid.reconfigure(null, columns); + }, + + showFilterPanel: function(){ + Ext4.create('EHR.window.ClinicalHistoryFilterWindow', { + clinicalHistoryPanel: this + }).show(); + }, + + applyFilter: function(types){ + this.checkedItems = types; + this.getStore().applyFilter(types); + }, + + getStore: function(){ + return this.down('grid').store; + } +}); + +/** + * @cfg clinicalHistoryPanel + */ +Ext4.define('EHR.window.ClinicalHistoryFilterWindow', { + extend: 'Ext.window.Window', + + initComponent: function(){ + Ext4.apply(this, { + bodyStyle: 'padding: 5px;', + title: 'Show/Hide Types', + closeAction: 'destroy', + modal: true, + defaults: { + border: false + }, + items: [{ + html: 'Use the checkboxes below to toggle which types of information are shown', + style: 'padding-bottom: 10px;' + },{ + layout: 'hbox', + style: 'padding-bottom: 5px;', + items: [{ + xtype: 'ldk-linkbutton', + text: '[Select None]', + style: 'padding: 5px;', + itemId: 'selectNone', + handler: function(field){ + field.up('window').down('checkboxgroup').items.each(function(cb){ + cb.setValue(false); + }, this); + } + },{ + xtype: 'ldk-linkbutton', + text: '[Select All]', + style: 'padding: 5px;', + itemId: 'selectAll', + handler: function(field){ + field.up('window').down('checkboxgroup').items.each(function(cb){ + cb.setValue(true); + }, this); + } + }] + },{ + xtype: 'checkboxgroup', + columns: 2, + itemId: 'types', + defaults: { + name: 'type', + xtype: 'checkbox', + width: 220 + }, + items: this.getCheckboxes() + }], + buttons: [{ + text: 'Submit', + scope: this, + handler: this.onSubmit + },{ + text: 'Cancel', + handler: function(btn){ + btn.up('window').close(); + } + }] + }); + + this.callParent(); + }, + + getCheckboxes: function(){ + var store = this.clinicalHistoryPanel.getStore(); + + + var items = []; + Ext4.Array.each(store.getDistinctTypes(), function(type) { + if (type && type != "null") { + items.push({ + boxLabel: type, + inputValue: type, + checked: (!this.clinicalHistoryPanel.checkedItems || Ext4.Array.indexOf(this.clinicalHistoryPanel.checkedItems, type) > -1) + }); + } + }, this); + + return items; + }, + + onSubmit: function(){ + var types = this.down('#types').getValue().type; + types = Ext4.isArray(types) || !types ? types : [types]; + this.clinicalHistoryPanel.applyFilter(types); + this.close(); + } +}); + diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js new file mode 100644 index 00000000..15d1f4c3 --- /dev/null +++ b/nirc_ehr/resources/web/nirc_ehr/panel/NarrowSnapshotPanel.js @@ -0,0 +1,37 @@ + +Ext4.define('NIRC_EHR.panel.NarrowSnapshotPanel', { + extend: 'NIRC_EHR.panel.SnapshotPanel', + alias: 'widget.nirc_ehr-narrowsnapshotpanel', + + showLocationDuration: false, + showExtendedInformation: true, + + minWidth: 800, + + initComponent: function(){ + + this.defaultLabelWidth = 120; + this.callParent(); + }, + + getItems: function() { + var items = this.getBaseItems(); + + //combine the first and second columns + var secondCol = items[0].items[1].items[1]; + var extended = this.getExtendedItems(); + + var index = items[0].items[1].items.indexOf(secondCol); + if (index !== -1) { + items[0].items[1].items = items[0].items[1].items.splice(index, 1); + } + + items[0].items[1].items = items[0].items[1].items.concat(extended[0].items[1].items[0]); + items[0].items[1].items[1].items = items[0].items[1].items[1].items.concat(extended[0].items[1].items[1].items[0]); + + items[0].items[1].items[0].columnWidth = 0.45; + items[0].items[1].items[1].columnWidth = 0.55; + + return items; + } +}); \ No newline at end of file diff --git a/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js b/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js index 16e82a21..b95e5db7 100644 --- a/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js +++ b/nirc_ehr/resources/web/nirc_ehr/window/NIRCCaseHistoryWindow.js @@ -30,7 +30,7 @@ Ext4.define('NIRC_EHR.window.CaseHistoryWindow', { items[1].items[0].title = 'Entire History'; items[1].items.splice(1, 0, { title: 'Case History', - xtype: 'ehr-casehistorypanel', + xtype: 'nirc_ehr-casehistorypanel', containerPath: this.containerPath, border: true, width: 1180, diff --git a/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js b/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js index e2974882..76c53870 100644 --- a/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js +++ b/nirc_ehr/resources/web/nirc_ehr/window/NIRCClinicalHistoryWindow.js @@ -45,7 +45,7 @@ Ext4.define('NIRC_EHR.window.ClinicalHistoryWindow', { },{ xtype: 'tabpanel', items: [{ - xtype: 'ehr-clinicalhistorypanel', + xtype: 'nirc_ehr-clinicalhistorypanel', title: 'History', border: true, width: 1230, diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java index badf9d5a..f2413357 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java @@ -101,10 +101,14 @@ protected void init() ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCRecentRemarksWindow.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("ehr/sharedReports.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/SnapshotPanel.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/NarrowSnapshotPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/BloodSummaryPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/AnimalDetailsPanel.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCClinicalHistoryWindow.js"), this); ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/window/NIRCCaseHistoryWindow.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/ClinicalHistoryPanel.js"), this); + ehrService.registerClientDependency(ClientDependency.supplierFromPath("nirc_ehr/panel/CaseHistoryPanel.js"), this); + } @Override From 176c82eaffd2dadb39e72af5c542ee902f0c028a Mon Sep 17 00:00:00 2001 From: Marty Pradere Date: Mon, 9 Feb 2026 09:31:41 -0800 Subject: [PATCH 2/2] CR cleanup --- .../nirc_ehr/panel/ClinicalHistoryPanel.js | 319 +----------------- 1 file changed, 1 insertion(+), 318 deletions(-) diff --git a/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js index 97ba69dc..50f151d9 100644 --- a/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js +++ b/nirc_ehr/resources/web/nirc_ehr/panel/ClinicalHistoryPanel.js @@ -13,76 +13,11 @@ * @cfg printMode */ Ext4.define('NIRC_EHR.panel.ClinicalHistoryPanel', { - extend: 'Ext.panel.Panel', + extend: 'EHR.panel.ClinicalHistoryPanel', alias: 'widget.nirc_ehr-clinicalhistorypanel', showMaxDate: false, - initComponent: function(){ - this.sortMode = this.sortMode || 'date'; - - if (this.minDate && !Ext4.isDate(this.minDate)) - this.minDate = LDK.ConvertUtils.parseDate(this.minDate, LABKEY.extDefaultDateFormat); - if (this.maxDate && !Ext4.isDate(this.maxDate)) - this.maxDate = LDK.ConvertUtils.parseDate(this.maxDate, LABKEY.extDefaultDateFormat); - - Ext4.apply(this, { - border: false, - items: [ - this.getGridConfig() - ], - listeners: { - scope: this, - render: function(){ - //defer loading of data - if (Ext4.isDefined(store) && this.autoLoadRecords){ - store.reloadData({ - subjectIds: [this.subjectId], - caseId: this.caseId, - minDate: this.minDate, - maxDate: this.maxDate, - checkedItems: this.checkedItems - }); - } - } - } - }); - - this.callParent(); - - var grid = this.down('grid'); - if (grid.rendered){ - grid.setLoading(true); - } - else { - grid.on('afterrender', function(grid){ - if (grid.store.loading){ - grid.setLoading(true); - } - }, this, {delay: 120, single: true}); - } - - if(this.subjectId || this.caseId){ - var store = this.down('#gridPanel').store; - store.on('datachanged', function(){ - if (!store.loading){ - var grid = this.down('grid'); - if (grid){ - grid.setLoading(false); - grid.getView().refresh(); - } - } - }, this); - - store.on('exception', function(store){ - this.down('grid').setLoading(false); - }, this); - } - else { - Ext4.Msg.alert('Error', 'Must supply at least 1 subject Id or a caseId') - } - }, - getGridConfig: function(){ return { xtype: 'grid', @@ -204,258 +139,6 @@ Ext4.define('NIRC_EHR.panel.ClinicalHistoryPanel', { }] } }; - }, - - reloadData: function(config){ - var grid = this.down('grid'); - - grid.setLoading(true); - grid.store.reloadData({ - minDate: config.minDate, - maxDate: config.maxDate, - subjectIds: [this.subjectId], - caseId: this.caseId, - sortMode: this.sortMode, - checkedItems: this.checkedItems - }); - }, - - doReload: function(){ - var minDateField = this.down('#minDate'); - var maxDateField = this.down('#maxDate'); - if (!minDateField.isValid()){ - Ext4.Msg.alert('Error', 'Invalid value for min date'); - return; - } - if (!maxDateField.isValid()){ - Ext4.Msg.alert('Error', 'Invalid value for max date'); - return; - } - - this.minDate = minDateField.getValue(); - this.maxDate = maxDateField.getValue(); - - this.reloadData({ - minDate: this.minDate, - maxDate: this.maxDate - }); - }, - - getStoreConfig: function(){ - var me = this; - return { - type: 'ehr-clinicalhistorystore', - containerPath: this.containerPath, - redacted: this.redacted, - sortMode: this.sortMode - }; - }, - - getColumnConfig: function(){ - return [{ - text: 'Category', - dataIndex: 'category', - tdCls: 'ldk-wrap-text', - width: 180, - renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ - if (record.get('categoryColor')){ - cellMetaData.style = cellMetaData.style ? cellMetaData.style + ';' : ''; - cellMetaData.style += 'background-color: ' + record.get('categoryColor') + ';'; - } - - return value; - } - },{ - text: 'Date', - xtype: 'datecolumn', - dataIndex: 'date', - format: LABKEY.extDefaultDateTimeFormat, - hidden: (this.sortMode == 'date'), - width: 180 - },{ - text: '', - dataIndex: 'timeString', - hidden: (this.sortMode != 'date'), - width: 80 - },{ - text: 'Description', - dataIndex: 'html', - minWidth: 300, - tdCls: 'ldk-wrap-text', - flex: 10 - },{ - text: 'Status', - dataIndex: 'qcStateLabel', - tdCls: 'ldk-wrap-text', - width: 120, - renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ - if (record.get('publicData') === false){ - cellMetaData.style = cellMetaData.style ? cellMetaData.style + ';' : ''; - cellMetaData.style += 'background-color: yellow;'; - } - - return value == EHR.QCStates.COMPLETED ? '' : value; - } - },{ - text: '', - dataIndex: 'taskId', - width: 60, - renderer: function(value, cellMetaData, record, rowIndex, colIndex, store){ - if (record.get('taskId')){ - return '' + record.get('taskRowId') + ''; - } - - return ''; - } - }]; - }, - - getGroupingFeature: function(){ - return Ext4.create('Ext.grid.feature.Grouping', { - groupHeaderTpl: [ - '
{name:this.formatName}
', { - formatName: function(name) { - name = name.split('_'); - var id = name.shift(); - var date = name[0].split("-"); - var date2 = new Date(date[0], date[1]-1, date[2], 0, 0, 0); - return id + ' (' + Ext4.util.Format.date(date2, LABKEY.extDefaultDateFormat) + ')'; - } - } - ], - hideGroupedHeader: true, - startCollapsed: false, - id: 'historyGrouping' - }); - }, - - changeMode: function(mode){ - this.sortMode = mode; - var grid = this.down('grid'); - - var columns = this.getColumnConfig(); - Ext4.Array.forEach(columns, function(col){ - if (col.dataIndex == 'date'){ - col.hidden = (mode == 'date'); - } - else if (col.dataIndex == 'timeString'){ - col.hidden = (mode == 'type'); - } - }, this); - - grid.on('reconfigure', function(){ - grid.store.changeMode(mode); - }, this, {single: true}); - grid.reconfigure(null, columns); - }, - - showFilterPanel: function(){ - Ext4.create('EHR.window.ClinicalHistoryFilterWindow', { - clinicalHistoryPanel: this - }).show(); - }, - - applyFilter: function(types){ - this.checkedItems = types; - this.getStore().applyFilter(types); - }, - - getStore: function(){ - return this.down('grid').store; - } -}); - -/** - * @cfg clinicalHistoryPanel - */ -Ext4.define('EHR.window.ClinicalHistoryFilterWindow', { - extend: 'Ext.window.Window', - - initComponent: function(){ - Ext4.apply(this, { - bodyStyle: 'padding: 5px;', - title: 'Show/Hide Types', - closeAction: 'destroy', - modal: true, - defaults: { - border: false - }, - items: [{ - html: 'Use the checkboxes below to toggle which types of information are shown', - style: 'padding-bottom: 10px;' - },{ - layout: 'hbox', - style: 'padding-bottom: 5px;', - items: [{ - xtype: 'ldk-linkbutton', - text: '[Select None]', - style: 'padding: 5px;', - itemId: 'selectNone', - handler: function(field){ - field.up('window').down('checkboxgroup').items.each(function(cb){ - cb.setValue(false); - }, this); - } - },{ - xtype: 'ldk-linkbutton', - text: '[Select All]', - style: 'padding: 5px;', - itemId: 'selectAll', - handler: function(field){ - field.up('window').down('checkboxgroup').items.each(function(cb){ - cb.setValue(true); - }, this); - } - }] - },{ - xtype: 'checkboxgroup', - columns: 2, - itemId: 'types', - defaults: { - name: 'type', - xtype: 'checkbox', - width: 220 - }, - items: this.getCheckboxes() - }], - buttons: [{ - text: 'Submit', - scope: this, - handler: this.onSubmit - },{ - text: 'Cancel', - handler: function(btn){ - btn.up('window').close(); - } - }] - }); - - this.callParent(); - }, - - getCheckboxes: function(){ - var store = this.clinicalHistoryPanel.getStore(); - - - var items = []; - Ext4.Array.each(store.getDistinctTypes(), function(type) { - if (type && type != "null") { - items.push({ - boxLabel: type, - inputValue: type, - checked: (!this.clinicalHistoryPanel.checkedItems || Ext4.Array.indexOf(this.clinicalHistoryPanel.checkedItems, type) > -1) - }); - } - }, this); - - return items; - }, - - onSubmit: function(){ - var types = this.down('#types').getValue().type; - types = Ext4.isArray(types) || !types ? types : [types]; - this.clinicalHistoryPanel.applyFilter(types); - this.close(); } });