diff --git a/nirc_ehr/resources/queries/dbo/q_clinremarks.sql b/nirc_ehr/resources/queries/dbo/q_clinremarks.sql index 3a2a452d..9442286b 100644 --- a/nirc_ehr/resources/queries/dbo/q_clinremarks.sql +++ b/nirc_ehr/resources/queries/dbo/q_clinremarks.sql @@ -5,7 +5,6 @@ SELECT anmEvt.ANIMAL_EVENT_ID WHEN (trim(anmEvt.STAFF_ID.STAFF_FIRST_NAME) IS NULL OR trim(anmEvt.STAFF_ID.STAFF_LAST_NAME) IS NULL) THEN 'unknown' ELSE (trim(anmEvt.STAFF_ID.STAFF_FIRST_NAME) || '|' || trim(anmEvt.STAFF_ID.STAFF_LAST_NAME)) END) AS performedby, - anmEvt.EVENT_ID.EVENT_ID AS category, anmEvt.DIAGNOSIS AS vetreview, anmCmt.TEXT AS remark, 'Clinical' AS category, diff --git a/nirc_ehr/resources/queries/ehr/activeProtocols.sql b/nirc_ehr/resources/queries/ehr/activeProtocols.sql new file mode 100644 index 00000000..04ffcc1c --- /dev/null +++ b/nirc_ehr/resources/queries/ehr/activeProtocols.sql @@ -0,0 +1,2 @@ +SELECT protocol, title FROM ehr.protocol pr +WHERE pr.inactiveDate IS NULL OR pr.inactiveDate > now() \ No newline at end of file diff --git a/nirc_ehr/resources/queries/ehr/project.query.xml b/nirc_ehr/resources/queries/ehr/project.query.xml index 3d414995..598eeb5e 100644 --- a/nirc_ehr/resources/queries/ehr/project.query.xml +++ b/nirc_ehr/resources/queries/ehr/project.query.xml @@ -2,6 +2,7 @@ + /EHR/projectDetails.view?project=${project} @@ -67,12 +68,6 @@ true - - true - - - true -
diff --git a/nirc_ehr/resources/queries/ehr/project/.qview.xml b/nirc_ehr/resources/queries/ehr/project/.qview.xml index 889dd5a4..2022e605 100644 --- a/nirc_ehr/resources/queries/ehr/project/.qview.xml +++ b/nirc_ehr/resources/queries/ehr/project/.qview.xml @@ -1,5 +1,8 @@ + + + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/ehr/protocol.query.xml b/nirc_ehr/resources/queries/ehr/protocol.query.xml index 3a211823..4e082112 100644 --- a/nirc_ehr/resources/queries/ehr/protocol.query.xml +++ b/nirc_ehr/resources/queries/ehr/protocol.query.xml @@ -2,6 +2,7 @@ + Protocol diff --git a/nirc_ehr/resources/queries/ehr/protocol/.qview.xml b/nirc_ehr/resources/queries/ehr/protocol/.qview.xml index e19bec57..e2e125f6 100644 --- a/nirc_ehr/resources/queries/ehr/protocol/.qview.xml +++ b/nirc_ehr/resources/queries/ehr/protocol/.qview.xml @@ -36,5 +36,6 @@ + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/BehaviorClinRemarks.sql b/nirc_ehr/resources/queries/study/BehaviorClinRemarks.sql new file mode 100644 index 00000000..fe224a37 --- /dev/null +++ b/nirc_ehr/resources/queries/study/BehaviorClinRemarks.sql @@ -0,0 +1,2 @@ +SELECT * FROM study.clinremarks +WHERE category = 'Behavior' \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/BehaviorClinRemarks/.qview.xml b/nirc_ehr/resources/queries/study/BehaviorClinRemarks/.qview.xml new file mode 100644 index 00000000..4e381e42 --- /dev/null +++ b/nirc_ehr/resources/queries/study/BehaviorClinRemarks/.qview.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/ClinicalClinRemarks.sql b/nirc_ehr/resources/queries/study/ClinicalClinRemarks.sql new file mode 100644 index 00000000..225b0922 --- /dev/null +++ b/nirc_ehr/resources/queries/study/ClinicalClinRemarks.sql @@ -0,0 +1,2 @@ +SELECT * FROM study.clinremarks +WHERE category = 'Clinical' \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/ClinicalClinRemarks/.qview.xml b/nirc_ehr/resources/queries/study/ClinicalClinRemarks/.qview.xml new file mode 100644 index 00000000..c3ca1eaa --- /dev/null +++ b/nirc_ehr/resources/queries/study/ClinicalClinRemarks/.qview.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/reports/additionalReports.tsv b/nirc_ehr/resources/reports/additionalReports.tsv index 61aecdea..052af9ce 100644 --- a/nirc_ehr/resources/reports/additionalReports.tsv +++ b/nirc_ehr/resources/reports/additionalReports.tsv @@ -44,6 +44,6 @@ surgicalCases surgMedicationSchedule surgMedicationScheduleDaily pairings -behaviorRemarks Behavior query Behavior Remarks true study Clinical Remarks Behavior date false false qcstate/publicdata This report contains the behavior remarks entered about each animal +behaviorRemarks Behavior query Behavior Remarks true study BehaviorClinRemarks date false false qcstate/publicdata This report contains the behavior remarks entered about each animal clinObsBehavior Behavior query Observations true study behaviorObservations date false false qcstate/publicdata This report contains one record for each encounter with each animal, including surergies, exams, procedures, etc. -clinremarks Clinical query Clinical Remarks true study Clinical Remarks Clinical date false false qcstate/publicdata This report contains the clinical remarks entered about each animal +clinremarks Clinical query Clinical Remarks true study ClinicalClinRemarks date false false qcstate/publicdata This report contains the clinical remarks entered about each animal diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js index e6594ea0..4fbabbe7 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Arrival.js @@ -55,7 +55,10 @@ EHR.model.DataModelManager.registerMetadata('Arrival', { schemaName: 'ehr', queryName: 'project', keyColumn: 'project', - columns: 'project,name' + columns: 'project,name', + filterArray: [ + LABKEY.Filter.create('isActive', true, LABKEY.Filter.Types.EQUAL), + ] }, allowBlank: false }, @@ -63,7 +66,13 @@ EHR.model.DataModelManager.registerMetadata('Arrival', { allowBlank: false, columnConfig: { width: 200 - } + }, + lookup: { + schemaName: 'ehr', + queryName: 'activeProtocols', + keyColumn: 'protocol', + columns: 'protocol,title' + }, }, performedby: { hidden: true, diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Assignment.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Assignment.js index 32c47e2d..237b1703 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Assignment.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Assignment.js @@ -14,7 +14,10 @@ EHR.model.DataModelManager.registerMetadata('Assignment', { schemaName: 'ehr', queryName: 'project', keyColumn: 'project', - columns: 'project,name' + columns: 'project,name', + filterArray: [ + LABKEY.Filter.create('isActive', true, LABKEY.Filter.Types.EQUAL), + ] } } }, @@ -29,6 +32,12 @@ EHR.model.DataModelManager.registerMetadata('Assignment', { fixed: true, width: 150 }, + lookup: { + schemaName: 'ehr', + queryName: 'activeProtocols', + keyColumn: 'protocol', + columns: 'protocol,title' + }, } } } diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/Birth.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/Birth.js index b6600b6e..de878383 100644 --- a/nirc_ehr/resources/web/nirc_ehr/model/sources/Birth.js +++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/Birth.js @@ -43,14 +43,23 @@ EHR.model.DataModelManager.registerMetadata('Birth', { schemaName: 'ehr', queryName: 'project', keyColumn: 'project', - columns: 'project,name' + columns: 'project,name', + filterArray: [ + LABKEY.Filter.create('isActive', true, LABKEY.Filter.Types.EQUAL), + ] } }, birthProtocol: { columnConfig: { width: 200 }, - allowBlank: false + allowBlank: false, + lookup: { + schemaName: 'ehr', + queryName: 'activeProtocols', + keyColumn: 'protocol', + columns: 'protocol,title' + }, }, 'Id/demographics/birth': { allowBlank: false diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCDeathNecropsyFormType.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCDeathNecropsyFormType.java index 613420ed..8ab094f6 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCDeathNecropsyFormType.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCDeathNecropsyFormType.java @@ -55,6 +55,7 @@ protected List getButtonConfigs() if (isVet) { defaultButtons.add("SUBMIT"); //submit final + defaultButtons.add("DEATH_NECROPSY_VET_REVIEW"); //submit for review } else if (isVetTech) { diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRCustomizer.java b/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRCustomizer.java index f0fdf8bb..1113aa08 100644 --- a/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRCustomizer.java +++ b/nirc_ehr/src/org/labkey/nirc_ehr/table/NIRC_EHRCustomizer.java @@ -683,6 +683,10 @@ public void doTableSpecificCustomizations(AbstractTableInfo ti) { customizeProtocolTable(ti); } + if (matches(ti, "ehr", "project")) + { + addIsActiveForProject(ti, EHRService.EndingOption.activeAfterMidnightTonight); + } if (matches(ti, "study", "protocolAssignment")) { EHRService.get().addIsActiveCol(ti, false, EHRService.EndingOption.activeAfterMidnightTonight, EHRService.EndingOption.activeAfterMidnightTonight); @@ -701,6 +705,29 @@ public void doTableSpecificCustomizations(AbstractTableInfo ti) } } + private void addIsActiveForProject(AbstractTableInfo ti, EHRService.EndingOption... endOptions) + { + String name = "isActive"; + if (ti.getColumn(name) == null) + { + SQLFragment sql = new SQLFragment("(CASE " + + // when enddate is null, it is active + " WHEN (" + ExprColumn.STR_TABLE_ALIAS + ".enddate IS NULL) THEN " + ti.getSqlDialect().getBooleanTRUE()); + for (EHRService.EndingOption endOption : endOptions) + { + sql.append(endOption.getSql()); + } + sql.append( + " WHEN (CAST(" + ExprColumn.STR_TABLE_ALIAS + ".enddate AS DATE) > {fn curdate()}) THEN " + ti.getSqlDialect().getBooleanTRUE() + + " ELSE " + ti.getSqlDialect().getBooleanFALSE() + + " END)"); + + ExprColumn col = new ExprColumn(ti, name, sql, JdbcType.BOOLEAN, ti.getColumn("enddate")); + col.setLabel("Is Active?"); + ti.addColumn(col); + } + } + public void doSharedCustomization(AbstractTableInfo ti) { for (var col : ti.getMutableColumns())