From b39c1c1045508ca036ed164193182155f140224f Mon Sep 17 00:00:00 2001 From: Ohsudev <76500320+Ohsudev@users.noreply.github.com> Date: Tue, 16 Nov 2021 11:54:11 -0800 Subject: [PATCH 1/2] 21.7 fb compliance entry addendum (#265) * Created a version of BSU age class * Adding files for the Compliance input screens project that have missing files after committing feature branch into default branch. Tested default build on Prime UAT, and it generated errors. * Update EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql * Update EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql Co-authored-by: Josh Eckels --- .../EHR_ComplianceDB-12.40-12.41.sql | 22 +++++ .../EHR_ComplianceDB-12.40-12.41.sql | 24 +++++ .../resources/schemas/ehr_compliancedb.xml | 91 +++++++++++++++++++ .../EHR_ComplianceDBModule.java | 2 +- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-12.40-12.41.sql create mode 100644 EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql diff --git a/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-12.40-12.41.sql b/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-12.40-12.41.sql new file mode 100644 index 000000000..5c3400225 --- /dev/null +++ b/EHR_ComplianceDB/resources/schemas/dbscripts/postgresql/EHR_ComplianceDB-12.40-12.41.sql @@ -0,0 +1,22 @@ +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add COLUMN trackingflag varchar(100); + +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add COLUMN objectid ENTITYID; + +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add COLUMN taskid ENTITYID; + +CREATE TABLE ehr_compliancedb.EmployeePerUnit +( + RowId SERIAL NOT NULL, + EmployeeId varchar(255) not null, + unit varchar(255) null, + category varchar(255) null, + Container ENTITYID NOT NULL, + CreatedBy USERID, + Created timestamp, + ModifiedBy USERID, + Modified timestamp, + taskid entityid, + objectid entityid, + + CONSTRAINT PK_EmployeePerUnits PRIMARY KEY (RowId) +); diff --git a/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql b/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql new file mode 100644 index 000000000..434f06971 --- /dev/null +++ b/EHR_ComplianceDB/resources/schemas/dbscripts/sqlserver/EHR_ComplianceDB-12.40-12.41.sql @@ -0,0 +1,24 @@ + +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add trackingflag nvarchar(100); + +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add objectid ENTITYID; + +ALTER TABLE ehr_compliancedb.RequirementsPerCategory add taskid ENTITYID; + + +CREATE TABLE ehr_compliancedb.EmployeePerUnit +( + RowId INT IDENTITY(1,1) NOT NULL, + EmployeeId nvarchar(255) not null, + unit nvarchar(255) null, + category nvarchar(255) null, + Container ENTITYID NOT NULL, + CreatedBy USERID, + Created datetime, + ModifiedBy USERID, + Modified datetime, + taskid entityid, + objectid entityid + + CONSTRAINT PK_EmployeePerUnits PRIMARY KEY (RowId) +); diff --git a/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml b/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml index a2f83fe82..3b3cfabec 100644 --- a/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml +++ b/EHR_ComplianceDB/resources/schemas/ehr_compliancedb.xml @@ -420,6 +420,21 @@ true true + + true + true + false + + + false + true + true + + + false + true + true + @@ -804,4 +819,80 @@
+ + DETAILED + + Requirements Per Employee + rowid + + + true + true + Key + + + Employee Id + + ehr_compliancedb + employees + employeeid + + + + Unit + + ehr_compliancedb + unit_names + unit + + + + Unit + + ehr_compliancedb + employeecategory + categoryname + + + + false + true + + core + containers + entityid + + + + false + true + true + + + false + true + true + + + false + true + true + + + false + true + true + + + false + true + true + + + false + true + true + + +
\ No newline at end of file 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 ed0734f0c..77df98be7 100644 --- a/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java +++ b/EHR_ComplianceDB/src/org/labkey/ehr_compliancedb/EHR_ComplianceDBModule.java @@ -49,7 +49,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 12.40; + return 12.41; } @Override From 578b633de9f2d173bc3c222be2778fb2862f00d7 Mon Sep 17 00:00:00 2001 From: Josh Eckels Date: Wed, 17 Nov 2021 13:31:06 -0800 Subject: [PATCH 2/2] Issue 44283: Age is not calculated for new animals on snapshot (#264) --- ehr/resources/queries/study/Demographics.js | 3 +-- .../labkey/ehr/demographics/EHRDemographicsServiceImpl.java | 2 +- ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java | 6 +++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ehr/resources/queries/study/Demographics.js b/ehr/resources/queries/study/Demographics.js index eacb7dd51..38df4c5c3 100644 --- a/ehr/resources/queries/study/Demographics.js +++ b/ehr/resources/queries/study/Demographics.js @@ -14,11 +14,10 @@ function onInit(event, helper){ }); } -function onUpsert(helper, scriptErrors, row, oldRow){ +function onUpsert(helper, scriptErrors, row, oldRow) { //NOTE: this should be getting set by the birth, death, arrival & departure tables //ALSO: it should be rare to insert directly into this table. usually this record will be created by inserting into either birth or arrival if (!row.calculated_status && !helper.isETL()){ row.calculated_status = helper.getJavaHelper().getCalculatedStatusValue(row.Id); } - } \ No newline at end of file diff --git a/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java b/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java index e3550f613..c8cc042b3 100644 --- a/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java +++ b/ehr/src/org/labkey/ehr/demographics/EHRDemographicsServiceImpl.java @@ -233,7 +233,7 @@ else if (existing.getProps().isEmpty() && record.getProps().isEmpty()) _cache.put(key, record); } - private void recacheRecords(Container c, List ids) + public void recacheRecords(Container c, List ids) { for (String id : ids) { diff --git a/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java b/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java index df0605eb7..ea07f2515 100644 --- a/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java +++ b/ehr/src/org/labkey/ehr/utils/TriggerScriptHelper.java @@ -826,7 +826,11 @@ public void createDemographicsRecord(String id, Map props) throw if (errors.hasErrors()) throw errors; - EHRDemographicsServiceImpl.get().getAnimal(getContainer(), id); + // The normal (re)caching of demographics providers runs before the study module has done its bookkeeping and + // inserted a row into study.participant, which means that calculated lookup values like the animal's current + // age won't resolve until AFTER the call to insertRows() has completed. Thus, refresh the cache for this new + // animal an extra time. See ticket 44283. + EHRDemographicsServiceImpl.get().recacheRecords(getContainer(), Collections.singletonList(id)); } public void updateDemographicsRecord(List> updatedRows) throws QueryUpdateServiceException, SQLException, BatchValidationException, InvalidKeyException