diff --git a/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-25.000-25.001.sql b/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-25.000-25.001.sql new file mode 100644 index 000000000..52811f63a --- /dev/null +++ b/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-25.000-25.001.sql @@ -0,0 +1 @@ +ALTER TABLE ehr_compliancedb.requirementsperemployee ADD COLUMN LSID LSIDtype; \ No newline at end of file diff --git a/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-25.000-25.001.sql b/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-25.000-25.001.sql new file mode 100644 index 000000000..df2cbf19e --- /dev/null +++ b/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-25.000-25.001.sql @@ -0,0 +1 @@ +ALTER TABLE ehr_compliancedb.requirementsperemployee ADD Lsid LsidType null; \ No newline at end of file diff --git a/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml b/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml index 824de80e8..7ea7baa14 100644 --- a/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml +++ b/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml @@ -453,6 +453,17 @@ true Key + + lsidtype + true + true + false + + ObjectUri + Object + exp + + Employee Id diff --git a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java index b4616010b..c17ff3540 100644 --- a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java +++ b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java @@ -19,9 +19,11 @@ import org.jetbrains.annotations.Nullable; import org.labkey.api.data.DbSchema; import org.labkey.api.data.DbSchemaType; +import org.labkey.api.exp.property.PropertyService; import org.labkey.api.ldk.ExtendedSimpleModule; import org.labkey.api.ldk.LDKService; import org.labkey.api.ldk.notification.NotificationService; +import org.labkey.ehr_compliancedb.model.EHRComplianceDBDomainKind; import org.labkey.ehr_compliancedb.notification.EmployeeComplianceNotification; import org.labkey.api.module.ModuleContext; import org.labkey.ehr_compliancedb.api.EHR_ComplianceService; @@ -49,7 +51,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 12.44; + return 25.001; } @Override @@ -64,6 +66,7 @@ protected void init() addController(CONTROLLER_NAME, EHR_ComplianceDBController.class); EHR_ComplianceService.setInstance(new EHR_ComplianceServiceImpl()); + PropertyService.get().registerDomainKind(new EHRComplianceDBDomainKind()); } @Override diff --git a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBUserSchema.java b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBUserSchema.java index 82af20161..370843787 100644 --- a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBUserSchema.java +++ b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBUserSchema.java @@ -25,8 +25,10 @@ import org.labkey.api.module.Module; import org.labkey.api.query.DefaultSchema; import org.labkey.api.query.QuerySchema; +import org.labkey.api.query.SimpleTableDomainKind; import org.labkey.api.query.SimpleUserSchema; import org.labkey.api.security.User; +import org.labkey.ehr_compliancedb.model.EHRComplianceDBDomainKind; /** * User: bimber @@ -36,6 +38,7 @@ public class EHR_ComplianceDBUserSchema extends SimpleUserSchema { public static final String TABLE_REQUIREMENTS = "requirements"; + private static final String TABLE_REQUIREMENTSPEREMPLOYEE = "requirementsperemployee"; public EHR_ComplianceDBUserSchema(User user, Container container, DbSchema dbschema) { @@ -50,6 +53,23 @@ public TableInfo createTable(String name, ContainerFilter cf) SchemaTableInfo table = _dbSchema.getTable(name); return new ContainerScopedTable<>(this, table, cf, "requirementname").init(); } + else if (TABLE_REQUIREMENTSPEREMPLOYEE.equalsIgnoreCase(name)) + { + SchemaTableInfo table = _dbSchema.getTable(name); + return new SimpleTable<>(this, table, cf) + { + // There are issues with the '_' in the name of this module and creating template domains. This addresses + // the domain URI by normalizing with the domain kind. + @Override + public String getDomainURI() + { + if (_objectUriCol == null) + return null; + + return SimpleTableDomainKind.getDomainURI(EHRComplianceDBDomainKind.KIND_NAME, getName(), getDomainContainer(), _userSchema.getUser()); + } + }.init(); + } return super.createTable(name, cf); } diff --git a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java new file mode 100644 index 000000000..e99f4860c --- /dev/null +++ b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/model/EHRComplianceDBDomainKind.java @@ -0,0 +1,57 @@ +package org.labkey.ehr_compliancedb.model; + +import org.labkey.api.data.Container; +import org.labkey.api.exp.property.Domain; +import org.labkey.api.gwt.client.model.GWTPropertyDescriptor; +import org.labkey.api.query.ExtendedTableDomainKind; +import org.labkey.api.security.User; +import org.labkey.api.security.permissions.AdminPermission; +import org.labkey.data.xml.domainTemplate.DomainTemplateType; +import org.labkey.data.xml.domainTemplate.EHRComplianceDBTemplateType; + + +import java.util.List; +import java.util.Set; + +public class EHRComplianceDBDomainKind extends ExtendedTableDomainKind +{ + public static final String KIND_NAME = "EHRComplianceDB"; + + @Override + public boolean canCreateDefinition(User user, Container container) + { + return container.hasPermission("EHRComplianceDBDomainKind.canCreateDefinition", user, AdminPermission.class); + } + + @Override + protected String getSchemaName() + { + return KIND_NAME.toLowerCase(); + } + + @Override + protected String getNamespacePrefix() + { + return KIND_NAME.toLowerCase(); + } + + @Override + public String getKindName() + { + return KIND_NAME; + } + + @Override + public Set getReservedPropertyNames(Domain domain, User user) + { + return super.getReservedPropertyNames(domain, user); + } + + @Override + public boolean matchesTemplateXML(String templateName, DomainTemplateType template, List properties) + { + return template instanceof EHRComplianceDBTemplateType; + } +} + + diff --git a/ehr/resources/queries/study/HousingOverlaps.sql b/ehr/resources/queries/study/HousingOverlaps.sql index a4efd7d90..2889b8eca 100644 --- a/ehr/resources/queries/study/HousingOverlaps.sql +++ b/ehr/resources/queries/study/HousingOverlaps.sql @@ -1,40 +1,21 @@ -/* - * Copyright (c) 2011-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - /** * This query is designed to find housing records that overlap. In this query, the overlap to calculated based on both date and time * A record that ends at the same time that a second record begins is not considered an overlap. - */ -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) + Modified by Kollil on 7/23/25 - Added Area field to the query and the rooms are filtered by area(s) selected, refer to tkt # 12894 + */ SELECT -h.lsid, -h.id, -h.room, -h.cage, -h.date, -h.enddate, -h.reason, -h.remark, -h.qcstate - + h.lsid, + h.id, + h.room.area as area, -- Added by Kollil + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate FROM study.housing h - WHERE + h.qcstate = 18 -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= entered enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) -and - -/* entered startdate must be less than record's enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) -and - -/* entered enddate must be greater than record's startdate */ -coalesce(ENDDATE, now()) >= coalesce(h.date, now()) \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById.sql b/ehr/resources/queries/study/HousingOverlapsById.sql deleted file mode 100644 index 6296f7ef7..000000000 --- a/ehr/resources/queries/study/HousingOverlapsById.sql +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) - -SELECT -h.Id, -cast(StartDate as timestamp) as date - -FROM study.housing h - -WHERE - -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) -and - -/* entered startdate must be less than record's enddate */ -coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) -and - -/* entered enddate must be greater than record's startdate */ -coalesce(ENDDATE, now()) >= coalesce(h.date, now()) - -GROUP BY h.Id \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById/.qview.xml b/ehr/resources/queries/study/HousingOverlapsById/.qview.xml deleted file mode 100644 index 603b1f172..000000000 --- a/ehr/resources/queries/study/HousingOverlapsById/.qview.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql b/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql deleted file mode 100644 index a6fa7185e..000000000 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.sql +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2012-2019 LabKey Corporation - * - * Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 - */ - -PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Room CHAR DEFAULT NULL, Cage CHAR DEFAULT NULL) - -SELECT -h.Id, -cast(StartDate as timestamp) as date - -FROM study.housing h - -WHERE - -(h.room = ROOM OR ROOM IS NULL or ROOM = '') AND -(h.cage = CAGE OR CAGE IS NULL OR CAGE = '') AND - -/* entered startdate must be <= enddate */ -cast(coalesce(STARTDATE , cast('1900-01-01' as DATE)) as DATE) <= cast(coalesce(ENDDATE, now()) as DATE) -and - -/* entered startdate must be less than record's enddate */ -cast(coalesce(STARTDATE , cast('1900-01-01' as DATE)) as DATE) < cast(coalesce(h.enddate, now()) as DATE) -and - -/* entered enddate must be greater than record's startdate */ -cast(coalesce(ENDDATE, now()) as DATE) >= cast(coalesce(h.date, now()) as DATE) - -GROUP BY h.Id \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml b/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml deleted file mode 100644 index 32b8acce5..000000000 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly/.qview.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsById.query.xml b/ehr/resources/queries/study/HousingOverlapsReport.query.xml similarity index 82% rename from ehr/resources/queries/study/HousingOverlapsById.query.xml rename to ehr/resources/queries/study/HousingOverlapsReport.query.xml index 1f1321218..1256b36ac 100644 --- a/ehr/resources/queries/study/HousingOverlapsById.query.xml +++ b/ehr/resources/queries/study/HousingOverlapsReport.query.xml @@ -1,17 +1,15 @@ - +
Housing Overlaps - This query identifies distinct animal IDs that overlapped with given housing records, accounting for date and time + This query identifies distinct housing records that overlapped with the given housing records, accounting for date and time - + true - - - Start Date + true diff --git a/ehr/resources/queries/study/HousingOverlapsReport.sql b/ehr/resources/queries/study/HousingOverlapsReport.sql new file mode 100644 index 000000000..f2cb68596 --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReport.sql @@ -0,0 +1,27 @@ +PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP) + +SELECT + h.lsid, + h.id, + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate + +FROM study.housing h + +WHERE + +/* entered startdate must be <= entered enddate */ + coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) <= coalesce(ENDDATE, now()) + and + +/* entered startdate must be less than record's enddate */ + coalesce( STARTDATE , cast('1900-01-01 00:00:00.0' as timestamp)) < coalesce(h.enddate, now()) + and + +/* entered enddate must be greater than record's startdate */ + coalesce(ENDDATE, now()) >= coalesce(h.date, now()) \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml b/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml new file mode 100644 index 000000000..7edf3755c --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReport/.qview.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml similarity index 79% rename from ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml rename to ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml index 967758d1c..ae23c19fe 100644 --- a/ehr/resources/queries/study/HousingOverlapsByIdDateOnly.query.xml +++ b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.query.xml @@ -1,17 +1,15 @@ -
+
- Housing Overlaps - This query identifies all distinct animal IDs that overlapped with housing records, accounting for date only, not date/time + Housing Overlaps (Date Only) + This query identifies overlapping housing records, accounting for date only, not date/time - + true - - - Start Date + true diff --git a/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql new file mode 100644 index 000000000..65847cacd --- /dev/null +++ b/ehr/resources/queries/study/HousingOverlapsReportDateOnly.sql @@ -0,0 +1,24 @@ +PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP) + +SELECT + h.lsid, + h.id, + h.room, + h.cage, + h.date, + h.enddate, + h.reason, + h.remark, + h.qcstate + +FROM study.housing h + +WHERE + + ( + (cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) >= cast(h.date AS DATE) AND cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) < cast(COALESCE(h.enddate, now()) AS DATE)) + OR + (cast(COALESCE(ENDDATE, now()) AS DATE) > cast(h.date AS DATE) AND cast(COALESCE(ENDDATE, now()) AS DATE) <= cast(COALESCE(h.enddate, now()) AS DATE)) + OR + (cast(COALESCE(STARTDATE, '1900-01-01') AS DATE) <= cast(h.date AS DATE) AND cast(COALESCE(ENDDATE, now()) AS DATE) >= cast(COALESCE(h.enddate, now()) AS DATE)) + ) \ No newline at end of file diff --git a/ehr/resources/views/ehrTemplates.html b/ehr/resources/views/ehrTemplates.html index a759d4d35..85e8be151 100644 --- a/ehr/resources/views/ehrTemplates.html +++ b/ehr/resources/views/ehrTemplates.html @@ -54,19 +54,52 @@ }); } + createEHRComplianceDomainHandler = function () { + var ctx = EHR.Utils.getEHRContext(); + var container = document.getElementById("ehrcompliance_container").value; + if (!container) { + LABKEY.Utils.alert("Error", "Must enter the container path of the compliance folder."); + } + else { + LABKEY.Domain.create({ + module: ctx ? ctx['EHRCustomModule'] : null, + domainKind: "EHRComplianceDB", + domainGroup: "ehrcompliancedb", + importData: false, + containerPath: container, + success: function () { + LABKEY.Utils.alert("Success", "EHR_ComplianceDB tables updated successfully."); + }, + failure: function (e) { + LABKEY.Utils.alert("Error", e.exception); + } + }); + } + } + LABKEY.Utils.onReady(function(){ document.getElementById('createEHRDomainHandler')['onclick'] = function(){ createEHRDomainHandler(); return false; } document.getElementById('createEHRLookupsDomainHandler')['onclick'] = function(){ createEHRLookupsDomainHandler(); return false; } document.getElementById('createEHRBillingDomainHandler')['onclick'] = function(){ createEHRBillingDomainHandler(); return false; } + document.getElementById('createEHRComplianceDomainHandler')['onclick'] = function(){ createEHRComplianceDomainHandler(); return false; } }); \ No newline at end of file diff --git a/ehr/resources/views/housingOverlaps.html b/ehr/resources/views/housingOverlaps.html index 9736656cc..48f211317 100644 --- a/ehr/resources/views/housingOverlaps.html +++ b/ehr/resources/views/housingOverlaps.html @@ -1,210 +1,278 @@ + + \ No newline at end of file diff --git a/ehr/resources/web/ehr/data/EncounterStoreCollection.js b/ehr/resources/web/ehr/data/EncounterStoreCollection.js index 8239cbda5..a669ecef2 100644 --- a/ehr/resources/web/ehr/data/EncounterStoreCollection.js +++ b/ehr/resources/web/ehr/data/EncounterStoreCollection.js @@ -64,7 +64,7 @@ Ext4.define('EHR.data.EncounterStoreCollection', { model.set('Id', parentRec.get('Id')); } - if (model.fields.get('date') && !model.get('date') && parentRec.get('date')){ + if (model.fields.get('date')?.inheritDefaultDateFromParent && !model.get('date') && parentRec.get('date')){ model.set('date', parentRec.get('date')); } diff --git a/ehr/resources/web/ehr/ehr_api.lib.xml b/ehr/resources/web/ehr/ehr_api.lib.xml index 59f74effe..ead5f3356 100644 --- a/ehr/resources/web/ehr/ehr_api.lib.xml +++ b/ehr/resources/web/ehr/ehr_api.lib.xml @@ -63,6 +63,7 @@