diff --git a/onprc_ehr/resources/etls/AvailableBlood.xml b/onprc_ehr/resources/etls/AvailableBlood.xml index 7b7445389..3f31cab19 100644 --- a/onprc_ehr/resources/etls/AvailableBlood.xml +++ b/onprc_ehr/resources/etls/AvailableBlood.xml @@ -10,6 +10,6 @@ - + diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.013-24.014.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.013-24.014.sql new file mode 100644 index 000000000..cb3c9c4a9 --- /dev/null +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.013-24.014.sql @@ -0,0 +1,74 @@ + + +/* +** +** Created by +** Blasa 10/8/2025 Process to update birth record;s geogrphic origin data. The "Genetic Ancestry" +** geographic_origin information must override the birth's geographic origin values. +** + +** +** +** +** +*/ + +CREATE Procedure onprc_ehr.p_BirthGeographicOriginUpdates + + as + + +BEGIN + + ----- Process data + + IF exists (select * From studydataset.c6d202_birth bir, studydataset.c6d512_geneticancestry b where bir.participantid = b.participantid + And b.enddate is null + and bir.qcstate = 18 + and b.qcstate = 18 + And bir.geographic_origin <> b.result + And b.result is not null + ) + + + + BEGIN + + ---- Update birth geographic origin + + Update bir + set bir.geographic_origin = b.result, + bir.modified = getdate(), + bir.modifiedby = b.modifiedby ---- ancestry staff + + From studydataset.c6d202_birth bir, studydataset.c6d512_geneticancestry b + where bir.participantid = b.participantid + And b.enddate is null + And bir.qcstate = 18 + And b.qcstate = 18 + And bir.geographic_origin <> b.result + And b.result is not null + + + If @@Error <> 0 + GoTo Err_Proc + +END ---- if + + + + + +RETURN 0 + + + Err_Proc: + -------Error Generated, process stopped + RETURN 1 + + +END + +GO + + diff --git a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js index a9bf2573a..ff0d25cfe 100644 --- a/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js +++ b/onprc_ehr/resources/scripts/onprc_ehr/onprc_triggers.js @@ -1348,12 +1348,6 @@ exports.init = function(EHR){ } }); }); - EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'demographics', function (helper, scriptErrors, row, oldRow) { - if (row.Id && row.geographic_origin) { - //update birth records - triggerHelper.updateBirthGeographics(row.Id, row.geographic_origin); - } - }); //Added: 10-4-2022 R.Blasa EHR.Server.TriggerManager.registerHandler(EHR.Server.TriggerManager.Events.COMPLETE, function(event, errors, helper){ diff --git a/onprc_ehr/resources/views/BSU_BulkEdit.html b/onprc_ehr/resources/views/BSU_BulkEdit.html new file mode 100644 index 000000000..37c9f1ad3 --- /dev/null +++ b/onprc_ehr/resources/views/BSU_BulkEdit.html @@ -0,0 +1,42 @@ + + + + +
+ + + + diff --git a/onprc_ehr/resources/views/BSU_BulkEdit.view.xml b/onprc_ehr/resources/views/BSU_BulkEdit.view.xml new file mode 100644 index 000000000..ef18febee --- /dev/null +++ b/onprc_ehr/resources/views/BSU_BulkEdit.view.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/onprc_ehr/resources/web/onprc_ehr/model/sources/ASB_Services.js b/onprc_ehr/resources/web/onprc_ehr/model/sources/ASB_Services.js index a89c3edfd..45ff89712 100644 --- a/onprc_ehr/resources/web/onprc_ehr/model/sources/ASB_Services.js +++ b/onprc_ehr/resources/web/onprc_ehr/model/sources/ASB_Services.js @@ -54,8 +54,9 @@ EHR.model.DataModelManager.registerMetadata('ASB_Services', { schemaName: 'onprc_ehr', queryName: 'ASB_SpecialInstructions', displayColumn: 'value', - // columns: 'value' - keyColumn: 'value' + keyColumn: 'value', + filterArray: [ + LABKEY.Filter.create('dateDisabled', null, LABKEY.Filter.Types.ISBLANK)] }, columnConfig: { width: 300 diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java index ef99b9f4c..87ec2d89b 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -129,7 +129,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 24.013; + return 24.014; } @Override diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/notification/AvailableBloodVolumeNotification.java b/onprc_ehr/src/org/labkey/onprc_ehr/notification/AvailableBloodVolumeNotification.java index b2b1625cb..0623164f9 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/notification/AvailableBloodVolumeNotification.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/notification/AvailableBloodVolumeNotification.java @@ -11,6 +11,7 @@ import org.labkey.api.query.QueryService; import org.labkey.api.security.User; +import java.util.Calendar; import java.util.Date; @@ -32,9 +33,14 @@ public String getEmailSubject(Container c) { return "Available Blood Volume Alert: " + getDateTimeFormat(c).format(new Date()); } - /* From Hugh Crank: + + /* Mathematica push: * Server mkt7: Runs at :55 from 4:55am to 7:55pm * Server mkt8: Runs at :25 from 4:25am to 7:25pm + * + * ABV ETL: + * :05 and :35 after the hour for hours between 05:00 and 20:00 + * 0 1,31 5-20 ? * * * */ @Override public String getCronString() @@ -45,44 +51,52 @@ public String getCronString() @Override public String getScheduleDescription() { - return "15 minutes after every hour between 06:15 and 19:15."; + return "15 min past every hour from 06:15 to 19:15."; } @Override public String getDescription() { - return "Sends an alert on status of Available Blood Volume data from Mathematica."; + return "Sends status of available blood volume data from Mathematica."; } @Override public String getMessageBodyHTML(Container c, User u) { StringBuilder msg = new StringBuilder(); - - AvailableBloodCheck(c, u, msg); - + availableBloodCheck(c, u, msg); return msg.toString(); } - /* jonesga 5/8/2024 labkeyPublic.labkeyPublic.ValidateAvailableBloodProcess - */ - protected void AvailableBloodCheck(final Container c, User u, final StringBuilder msg) + + protected void availableBloodCheck(final Container c, User u, final StringBuilder msg) { - SimpleFilter filter = new SimpleFilter(FieldKey.fromString("date"), new Date(), CompareType.DATE_GTE); - TableInfo ti = QueryService.get().getUserSchema(u, c, "onprc_ehr").getTable("ValidateAvailableBloodProcess", ContainerFilter.Type.AllFolders.create(c, u)); -// ((ContainerFilterable) ti).setContainerFilter(ContainerFilter.Type.AllFolders.create(u); - TableSelector ts = new TableSelector(ti, null, null); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.HOUR, -1); + Date staleTime = cal.getTime(); + + TableInfo ti = QueryService.get().getUserSchema(u, c, "onprc_ehr").getTable("AvailableBloodVolume", ContainerFilter.Type.AllFolders.create(c, u)); + if (ti == null) + { + msg.append("ERROR: Unable to access onprc_ehr.AvailableBloodVolume table.
\n"); + return; + } + + SimpleFilter filter = new SimpleFilter(FieldKey.fromString("datecreated"), staleTime, CompareType.LTE); + TableSelector ts = new TableSelector(ti, filter, null); long count = ts.getRowCount(); + if (count > 0) { - msg.append("The available blood volume data from Mathematica is stale.
\n"); - msg.append("

Click here to view labkeyPublic.AvailableBloodVolume.
\n\n"); - msg.append("



"); + msg.append("WARNING: The available blood volume data from Mathematica is stale (last updated more than 1 hour ago).
\n"); + msg.append("

View onprc_ehr.AvailableBloodVolume.

\n"); + msg.append("
"); } else { - msg.append("The available blood volume data from Mathematica is current.

"); - msg.append("

Click here to view labkeyPublic.AvailableBloodVolume.
\n\n"); - msg.append("



"); + msg.append("OK: The available blood volume data from Mathematica is current (updated within the last hour).
\n"); + msg.append("

View onprc_ehr.AvailableBloodVolume.

\n"); + msg.append("
"); } - }} + } +} \ No newline at end of file diff --git a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java index 3a89b057c..b7d72a105 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/query/ONPRC_EHRTriggerHelper.java @@ -2634,54 +2634,6 @@ public void exec(ResultSet object) throws SQLException } - public void updateBirthGeographics(String id, String geographic_origin) throws Exception - { - TableInfo ti = getTableInfo("study", "birth"); - if (ti == null) - { - return; - } - - Set keys = new HashSet<>(); - keys.add(FieldKey.fromString("Id")); - keys.add(FieldKey.fromString("geographic_origin")); - keys.add(FieldKey.fromString("lsid")); - final Map colMap = QueryService.get().getColumns(ti, keys); - - - final List> toUpdate = new ArrayList<>(); - final List> oldKeys = new ArrayList<>(); - TableSelector ts = new TableSelector(ti, colMap.values(), new SimpleFilter(FieldKey.fromString("Id"), id, CompareType.IN), null); - ts.forEach(new Selector.ForEachBlock<>() - { - @Override - public void exec(ResultSet object) throws SQLException - { - ResultsImpl rs = new ResultsImpl(object, colMap); - String animalid = rs.getString(FieldKey.fromString("Id")); - String origin = rs.getString(FieldKey.fromString("geographic_origin")); - String lsid = rs.getString(FieldKey.fromString("lsid")); - if (origin != geographic_origin) - { - Map row = new CaseInsensitiveHashMap<>(); - row.put("lsid", lsid); - row.put("geographic_origin", geographic_origin); - Map keyRow = new CaseInsensitiveHashMap<>(); - keyRow.put("lsid", lsid); - - oldKeys.add(keyRow); - toUpdate.add(row); - - } - } - }); - - if (!toUpdate.isEmpty()) - { - TableInfo demographics = getTableInfo("study", "birth"); - demographics.getUpdateService().updateRows(_user, _container, toUpdate, oldKeys, null, getExtraContext()); - } - } //Added 9-30-2025 public String retrieveGeographic_Origin(String Id) diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/AbstractGenericONPRC_EHRTest.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/AbstractGenericONPRC_EHRTest.java index f7ab9afe7..171787cc7 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/AbstractGenericONPRC_EHRTest.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/AbstractGenericONPRC_EHRTest.java @@ -80,6 +80,7 @@ public abstract class AbstractGenericONPRC_EHRTest extends AbstractGenericEHRTes protected static String[] ROOMS = {"Room1", "Room2", "Room3"}; protected static String[] CAGES = {"A1", "B2", "A3"}; protected static String[] CATEGORY = {"Divider Change", "Event", "STP_Beh"}; + protected static String[] TINFANT = {"35160", "24456", "36451"}; @Override public List getAssociatedModules() diff --git a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java index 88f982ca3..5aab368ec 100644 --- a/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java +++ b/onprc_ehr/test/src/org/labkey/test/tests/onprc_ehr/ONPRC_EHRTest2.java @@ -818,6 +818,7 @@ public void testPairingObservations() throws Exception grid.setGridCell(1, "cage", "A1"); grid.setGridCellJS(1, "date", TIME_FORMAT.format(today)); grid.setGridCell(1, "category", CATEGORY[0]); + grid.setGridCell(1, "other_infant", TINFANT[0]); _helper.addRecordToGrid(grid); sleep(200); @@ -827,6 +828,7 @@ public void testPairingObservations() throws Exception grid.setGridCell(2, "cage", "A1"); grid.setGridCellJS(2, "date", TIME_FORMAT.format(today)); grid.setGridCell(2, "category", CATEGORY[0]); + grid.setGridCell(2, "other_infant", TINFANT[0]); Assert.assertEquals(grid.getFieldValue(1, "pairid"), grid.getFieldValue(2, "pairid")); @@ -843,6 +845,7 @@ public void testPairingObservations() throws Exception grid.setGridCell(3, "cage", "A2"); grid.setGridCellJS(3, "date", TIME_FORMAT.format(today)); grid.setGridCell(3, "category", CATEGORY[0]); + grid.setGridCell(3, "other_infant", TINFANT[0]); grid.setGridCell(3, "lowestcage", "A1"); sleep(100);