From 88894834181b2cec361fb997c7736dfea1fef677 Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 19:56:45 -0700 Subject: [PATCH 01/18] Created an etl to process Clinical Observation Test scores. --- .../etls/ClinicalObservation_TestScores.xml | 53 +++ .../sqlserver/onprc_ehr-25.005-25.006.sql | 332 ++++++++++++++++++ 2 files changed, 385 insertions(+) create mode 100644 onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml create mode 100644 onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql diff --git a/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml b/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml new file mode 100644 index 000000000..5881a9649 --- /dev/null +++ b/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml @@ -0,0 +1,53 @@ + + + + + Clinical_Observation_TestScores_Process + + Create new sets of Clinical Observation Test Scores + + + + + + Runs a stored procedure that generates Clinical Observation Test Scores + + + + + + + + Transfer ehr_task temp to EHR Tasks + + + + + + + + + + Transfer to Study Clinical Observations + + + + + + + + + + + + + + + + + + + + + + diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql new file mode 100644 index 000000000..013db12b8 --- /dev/null +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql @@ -0,0 +1,332 @@ + +EXEC core.fn_dropifexists 'TB_TestTemp', 'onprc_ehr', 'TABLE', NULL; +GO +EXEC core.fn_dropifexists 'Temp_Clinical_Observations', 'onprc_ehr', 'TABLE', NULL; +GO +EXEC core.fn_dropifexists 'Temp_Clinical_Observations_Master', 'onprc_ehr', 'TABLE', NULL; + +EXEC core.fn_dropifexists 'onprc_ehr.Observation_EHRTasks', 'onprc_ehr', 'TABLE', NULL; +GO + + + + + +CREATE TABLE [onprc_ehr].[TB_TestTemp]( + [rowid] [int] IDENTITY(100,1) NOT NULL, + animalid varchar(200) NULL, + date datetime NULL, + objectid ENTITYID NOT NULL, + created datetime NULL, + createdby integer NULL, + performedby varchar(200) NULL, + modifiedby integer NULL + + +) +GO + + +CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations]( + [rowid] [int] IDENTITY(100,1) NOT NULL, + Id varchar(200) NULL, + date smalldatetime NULL, + category varchar(500) NULL, + area varchar(500) NULL, + observation varchar(500) NULL, + createdby integer NULL, + performedby varchar(500) NULL, + taskid varchar(4000) NULL, + qcstate integer NULL, + modifiedby integer NULL, + +) +GO + +CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations_Master]( + [rowid] [int] IDENTITY(100,1) NOT NULL, + rowid integer NULL, + Id varchar(200) NULL, + date smalldatetime NULL, + category varchar(500) NULL, + area varchar(500) NULL, + observation varchar(500) NULL, + createdby integer NULL, + performedby varchar(500) NULL, + taskid varchar(4000) NULL, + qcstate smallint NULL, + modifiedby smalldatetime NULL, + Posted_date smalldatetime + +) +GO + +CREATE TABLE [onprc_ehr].[onprc_ehr.Observation_EHRTasks]( + [rowid] [int] IDENTITY(100,1) NOT NULL, + taskid varchar(4000) NULL, + description varchar(500)NULL, + qcstate smallint NULL, + formtype varchar(500) NULL, + category varchar(500) NULL, + assignedto smallint NULL, + createdby smallint NULL, + modifiedby smallint NULL + + +) +GO + + +EXEC core.fn_dropifexists 'p_Create_TB_Observationrecords', 'onprc_ehr', 'PROCEDURE', NULL; +GO + + +/* +** +** Created by +** R. Blasa 6-5-2024 A Program Process that reviews all TB Test entries on a given date, and creates a +** new TB Test Clinical Observation record based on +** having the same monkey id, date, and to be assigned to a Data Admin for reviews. +** +** R. Blasa Modified program so that each Clinical Observation entries generated by the program is assigned +** only a single task id when the program executes daily. +** +** +*/ + +ALTER Procedure onprc_ehr.p_Create_TB_Observationrecords + + + +AS + + + +DECLARE + @SearchKey Int, + @TempsearchKey Int, + @TaskId varchar(4000), + @AnimalID varchar(100), + @date datetime, + @createdby integer, + @performedby varchar(200), + @modifiedby integer, + @RunID varchar(4000) + + + + +BEGIN + + + + ---- Reset temp table + + Truncate table onprc_ehr.TB_TestTemp + + + If @@Error <> 0 + GoTo Err_Proc + + + --- Generate a list TB test monkeys ) + + Insert into onprc_ehr.TB_TestTemp + + select + a.participantid, + a.date, + a.objectid, + a.created, + a.createdBy, + a.performedby, + a.modifiedby + + + + + from studydataset.c6d214_encounters a + Where a.participantid not in (select b.participantid from studydataset.c6d171_clinical_observations b + where a.participantid = b.participantid + And cast(b.date as date) = dateadd(day,3,cast(a.date as date)) + And b.category = 'TB TST Score (72 hr)' + And a.modified >= cast(getdate() as date) + And a.type = 'Procedure' And a.qcstate = 18 And a.procedureid = 802 ) + + And a.type = 'Procedure' And a.qcstate = 18 And a.procedureid = 802 -----'TB Test Intradermal' + And a.modified >= cast(getdate() as date) + And a.participantid in ( select k.participantid from studydataset.c6d203_demographics k + where k.calculated_status = 'alive') + + order by a.participantid, a.date desc + + + If @@Error <> 0 + GoTo Err_Proc + + ---- When there are no records to process, exit immediately from the program. + + If (Select count(*) from onprc_ehr.TB_TestTemp) = 0 + BEGIN + GOTO No_Records + END + + + ---- Reset temp variables + + Set @SearchKey = 0 + Set @TempSearchKey = 0 + Set @Date = NULL + Set @modifiedby = NULL + Set @createdby =NULL + Set @performedby = NULL + Set @TaskID = NULL + Set @Animalid = Null + Set @RunID = Null + + + + ----- extract initial row id + + Select Top 1 @Searchkey = rowid from onprc_ehr.TB_TestTemp + Order by rowid + + + Set @TaskID = NEWID() ----- Task Record Object ID + + ----Create a single task for each daily process + + + Insert into onprc_ehr.Observation_EHRTasks + ( + taskid, + description, + title, + qcstate, + formType, + category, + assignedto, + createdby, + modifiedby + + ) + + Values ( + + @TaskID, + 'TB TST Scores ' + cast(@Date as varchar(50)) , ------ Title consist of animal id and Clinical procedure date + 'TB TST Scores', + 20, --- Qc State (In Progress) + 'TB TST Scores', ------ FormType + 'task', ----- category, + 1822, ------- Assigned To Data Admins + 1042, -------- Created By IS + 1042 ----- Modified by IS + + ) + + If @@Error <> 0 + GoTo Err_Proc + + + + While @TempSearchKey < @SearchKey + BEGIN + + -----Begin entry Tb observation process + + Select @Animalid =animalid, @date = date, @modifiedby=modifiedby, @createdby =createdby,@performedby= performedby from onprc_ehr.TB_TestTemp Where rowid = @Searchkey + + + ----- Initialize data entries + Set @date = dateadd(day, 3,@date) ----- Add three days from TB Test date + + + + --- Create a Clinical Observation Record + + Insert into Temp_Clinical_Observations + ( + Id, + date, + category, + area, + observation, + createdby, + performedby, + taskid, + qcstate, + modifiedby + + + ) + values ( + @animalid, + @date, + 'TB TST Score (72 hr)', + 'Right Eyelid', + 'Grade: Negative', + @createdby, + @performedby, + @TaskID, + 20 , ---- In Progress QCState + @modifiedby -----modified + + + ) + + If @@Error <> 0 + GoTo Err_Proc + + + + END + + + ----- Proceed and fetch the next record + + Set @TempSearchKey = @SearchKey + + Select Top 1 @SearchKey = rowid from onprc_ehr.TB_TestTemp + Where rowid > @TempSearchKey + Order by rowid + + + END ---- While @TempSearchKey + + + ----- Create a master copy of the completed transaction + + Insert into onprc_ehr.Temp_Clinical_Observations_Master + Select *, getdate() + from onprc_ehr.Temp_Clinical_Observations + + If @@Error <> 0 + GoTo Err_Proc + + + + No_Records: + + RETURN 0 + + + Err_Proc: + -------Error Generated, program processed stopped + RETURN 1 + + +END + +GO + + + + + + + + + + + From 66be5ef12d45ae323c96acb9cb27af066fee2bab Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 20:00:29 -0700 Subject: [PATCH 02/18] Created an etl to process Clinical Observation Test scores. --- onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6e766bdc6..05f769120 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -124,7 +124,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 25.005; + return 25.006; } @Override From e114d911e76bdf67ab56af25efae0df5e4f0c5ff Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 20:34:18 -0700 Subject: [PATCH 03/18] Created an etl to process Clinical Observation Test scores. --- .../schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql index 013db12b8..9bb960709 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql @@ -45,7 +45,7 @@ GO CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations_Master]( [rowid] [int] IDENTITY(100,1) NOT NULL, - rowid integer NULL, + searchid integer NULL, Id varchar(200) NULL, date smalldatetime NULL, category varchar(500) NULL, From 50a669344eb2bd5c00fd7addeebb99a8b7b4fc34 Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 20:39:02 -0700 Subject: [PATCH 04/18] Created an etl to process Clinical Observation Test scores. --- .../schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql index 9bb960709..90da6d75c 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql @@ -38,7 +38,7 @@ CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations]( performedby varchar(500) NULL, taskid varchar(4000) NULL, qcstate integer NULL, - modifiedby integer NULL, + modifiedby integer NULL ) GO @@ -280,9 +280,6 @@ BEGIN - END - - ----- Proceed and fetch the next record Set @TempSearchKey = @SearchKey From fe951b5d9cd53651a999c523b5fbb4900636117a Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 20:43:33 -0700 Subject: [PATCH 05/18] Created an etl to process Clinical Observation Test scores. --- .../schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql index 90da6d75c..fc87fe640 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql @@ -94,7 +94,7 @@ GO ** */ -ALTER Procedure onprc_ehr.p_Create_TB_Observationrecords +CREATE Procedure onprc_ehr.p_Create_TB_Observationrecords From edb570ee60fcce39771ea55ecc863bd5799c070c Mon Sep 17 00:00:00 2001 From: blasar Date: Mon, 18 May 2026 22:55:49 -0700 Subject: [PATCH 06/18] Created an etl to process Clinical Observation Test scores. --- onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml | 2 +- .../schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml b/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml index 5881a9649..528ef8f98 100644 --- a/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml +++ b/onprc_ehr/resources/etls/ClinicalObservation_TestScores.xml @@ -28,7 +28,7 @@ - Transfer to Study Clinical Observations + Transfer temp data to Study Clinical Observations diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql index fc87fe640..b8bee4f72 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql @@ -5,7 +5,7 @@ EXEC core.fn_dropifexists 'Temp_Clinical_Observations', 'onprc_ehr', 'TABLE', NU GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations_Master', 'onprc_ehr', 'TABLE', NULL; -EXEC core.fn_dropifexists 'onprc_ehr.Observation_EHRTasks', 'onprc_ehr', 'TABLE', NULL; +EXEC core.fn_dropifexists 'Observation_EHRTasks', 'onprc_ehr', 'TABLE', NULL; GO @@ -61,7 +61,7 @@ CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations_Master]( ) GO -CREATE TABLE [onprc_ehr].[onprc_ehr.Observation_EHRTasks]( +CREATE TABLE [onprc_ehr].[Observation_EHRTasks]( [rowid] [int] IDENTITY(100,1) NOT NULL, taskid varchar(4000) NULL, description varchar(500)NULL, From 0a47d0d6e8974f7bd097ae8add172c23aeb93f45 Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 24 Jun 2026 09:30:41 -0700 Subject: [PATCH 07/18] Modified the process that generates automatic entries of Clinical Observation when there are current day's Encounter entries for TB Test Intradermal. --- ...25.006.sql => onprc_ehr-26.000-26.001.sql} | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) rename onprc_ehr/resources/schemas/dbscripts/sqlserver/{onprc_ehr-25.005-25.006.sql => onprc_ehr-26.000-26.001.sql} (77%) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql similarity index 77% rename from onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql rename to onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index b8bee4f72..6462a6520 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-25.005-25.006.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -84,7 +84,7 @@ GO /* ** ** Created by -** R. Blasa 6-5-2024 A Program Process that reviews all TB Test entries on a given date, and creates a +** R. Blasa 6-24-2026 A Program Process that reviews all TB Test entries on a given date, and creates a ** new TB Test Clinical Observation record based on ** having the same monkey id, date, and to be assigned to a Data Admin for reviews. ** @@ -143,17 +143,10 @@ BEGIN a.modifiedby - - from studydataset.c6d214_encounters a - Where a.participantid not in (select b.participantid from studydataset.c6d171_clinical_observations b - where a.participantid = b.participantid - And cast(b.date as date) = dateadd(day,3,cast(a.date as date)) - And b.category = 'TB TST Score (72 hr)' - And a.modified >= cast(getdate() as date) - And a.type = 'Procedure' And a.qcstate = 18 And a.procedureid = 802 ) - - And a.type = 'Procedure' And a.qcstate = 18 And a.procedureid = 802 -----'TB Test Intradermal' + Where a.type = 'Procedure' + And a.qcstate = 18 + And a.procedureid = 802 -----'TB Test Intradermal' And a.modified >= cast(getdate() as date) And a.participantid in ( select k.participantid from studydataset.c6d203_demographics k where k.calculated_status = 'alive') @@ -197,45 +190,58 @@ BEGIN ----Create a single task for each daily process - Insert into onprc_ehr.Observation_EHRTasks - ( - taskid, - description, - title, - qcstate, - formType, - category, - assignedto, - createdby, - modifiedby - ) - Values ( - @TaskID, - 'TB TST Scores ' + cast(@Date as varchar(50)) , ------ Title consist of animal id and Clinical procedure date - 'TB TST Scores', - 20, --- Qc State (In Progress) - 'TB TST Scores', ------ FormType - 'task', ----- category, - 1822, ------- Assigned To Data Admins - 1042, -------- Created By IS - 1042 ----- Modified by IS + While @TempSearchKey < @SearchKey + BEGIN - ) + -----Begin entry Tb observation process - If @@Error <> 0 - GoTo Err_Proc + Select @Animalid =animalid, @date = date, @modifiedby=modifiedby, @createdby =createdby,@performedby= performedby + from onprc_ehr.TB_TestTemp Where rowid = @Searchkey - While @TempSearchKey < @SearchKey - BEGIN - -----Begin entry Tb observation process + If not exists (select * from studydataset.c6d171_clinical_observations j Where j.participantid = @AnimalID + And cast(j.date as date) = dateadd(day,3,cast(@date as date)) + And j.category = 'TB TST Score (72 hr)' + And j.qcstate = 18 ) + + BEGIN + + + Insert into onprc_ehr.Observation_EHRTasks + ( + taskid, + description, + title, + qcstate, + formType, + category, + assignedto, + createdby, + modifiedby + + ) + + Values ( + + @TaskID, + 'TB TST Scores ' + cast(@Date as varchar(50)) , ------ Title consist of animal id and Clinical procedure date + 'TB TST Scores', + 20, --- Qc State (In Progress) + 'TB TST Scores', ------ FormType + 'task', ----- category, + 1822, ------- Assigned To Data Admins + 1042, -------- Created By IS + 1042 ----- Modified by IS + + ) - Select @Animalid =animalid, @date = date, @modifiedby=modifiedby, @createdby =createdby,@performedby= performedby from onprc_ehr.TB_TestTemp Where rowid = @Searchkey + If @@Error <> 0 + GoTo Err_Proc ----- Initialize data entries From 30375c6b9511ee00166f9c1ddcb647d8b60abce9 Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 24 Jun 2026 21:05:49 -0700 Subject: [PATCH 08/18] Modified TB Test SCores programs. --- .../sqlserver/onprc_ehr-26.000-26.001.sql | 21 ++++++++++--------- .../org/labkey/onprc_ehr/ONPRC_EHRModule.java | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index 6462a6520..fc0903e87 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -267,16 +267,16 @@ BEGIN ) values ( - @animalid, - @date, - 'TB TST Score (72 hr)', - 'Right Eyelid', - 'Grade: Negative', - @createdby, - @performedby, - @TaskID, - 20 , ---- In Progress QCState - @modifiedby -----modified + @animalid, + @date, + 'TB TST Score (72 hr)', + 'Right Eyelid', + 'Grade: Negative', + @createdby, + @performedby, + @TaskID, + 20 , ---- In Progress QCState + @modifiedby -----modified ) @@ -285,6 +285,7 @@ BEGIN GoTo Err_Proc + END --(If not exist) ----- Proceed and fetch the next record 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 05f769120..1e5ce0399 100644 --- a/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java +++ b/onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java @@ -124,7 +124,7 @@ public String getName() @Override public @Nullable Double getSchemaVersion() { - return 25.006; + return 26.001; } @Override From 77aaf770dd44dca2a4f7d4753741efe09378f9bc Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 12:22:05 -0700 Subject: [PATCH 09/18] Modified Surgical Rounds process to allow displaying of S2 on the Rounds input form --- onprc_ehr/resources/queries/study/clinremarks/.qview.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml index 9f5ac339e..1196a662a 100644 --- a/onprc_ehr/resources/queries/study/clinremarks/.qview.xml +++ b/onprc_ehr/resources/queries/study/clinremarks/.qview.xml @@ -10,6 +10,8 @@ + + From 274360c1b319a27441d6e2f8f45a7cb560dd7d13 Mon Sep 17 00:00:00 2001 From: blasar Date: Thu, 2 Jul 2026 13:50:13 -0700 Subject: [PATCH 10/18] Modified TB Test Scores program to process daily Clinical Encounters TB Test Intradermal entries. --- .../dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index fc0903e87..8ddb6b910 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -111,7 +111,8 @@ DECLARE @createdby integer, @performedby varchar(200), @modifiedby integer, - @RunID varchar(4000) + @RunID varchar(4000), + @FirstFlag integer @@ -176,6 +177,7 @@ BEGIN Set @TaskID = NULL Set @Animalid = Null Set @RunID = Null + Set @FirstFlag = 0 @@ -211,7 +213,8 @@ BEGIN BEGIN - + If @FirstFlag != 1 + BEGIN Insert into onprc_ehr.Observation_EHRTasks ( taskid, @@ -243,6 +246,11 @@ BEGIN If @@Error <> 0 GoTo Err_Proc + ---Set Task insert process only once per single process + Set @FirsFlag = 1 + + END ---(@FirstFlag) + ----- Initialize data entries Set @date = dateadd(day, 3,@date) ----- Add three days from TB Test date From a81ddab674d10d7e1b3b4071c531144adad57528 Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 8 Jul 2026 09:41:48 -0700 Subject: [PATCH 11/18] Modified TB Test Scores program to process daily Clinical Encounters TB Test Intradermal entries. --- .../sqlserver/onprc_ehr-26.000-26.001.sql | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index 8ddb6b910..a474a6bfc 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -20,7 +20,8 @@ CREATE TABLE [onprc_ehr].[TB_TestTemp]( created datetime NULL, createdby integer NULL, performedby varchar(200) NULL, - modifiedby integer NULL + modifiedby integer NULL, + date_posted smalldatetime ) @@ -40,6 +41,7 @@ CREATE TABLE [onprc_ehr].[Temp_Clinical_Observations]( qcstate integer NULL, modifiedby integer NULL + ) GO @@ -84,9 +86,9 @@ GO /* ** ** Created by -** R. Blasa 6-24-2026 A Program Process that reviews all TB Test entries on a given date, and creates a -** new TB Test Clinical Observation record based on -** having the same monkey id, date, and to be assigned to a Data Admin for reviews. +** R. Blasa 6-24-2026 A Program Process that reviews all TB Test Encounter entries on a current date, and creates a +** new TB Test Clinical Observation record based on +** having the same monkey id, date, and then to be assigned to a Data Admin for reviews. ** ** R. Blasa Modified program so that each Clinical Observation entries generated by the program is assigned ** only a single task id when the program executes daily. @@ -104,22 +106,24 @@ AS DECLARE @SearchKey Int, - @TempsearchKey Int, - @TaskId varchar(4000), + @TempsearchKey Int, + @TaskId varchar(4000), @AnimalID varchar(100), - @date datetime, + @date smalldatetime, @createdby integer, - @performedby varchar(200), + @performedby varchar(500), @modifiedby integer, - @RunID varchar(4000), - @FirstFlag integer + @RunID varchar(4000), + @FirstFlag integer, + @TestDate smalldatetime BEGIN - + ----- Set Test Date + Set @TestDate = '7/1/2026' ---- Reset temp table @@ -141,14 +145,16 @@ BEGIN a.created, a.createdBy, a.performedby, - a.modifiedby + a.modifiedby, + getdate() -----date processed from studydataset.c6d214_encounters a Where a.type = 'Procedure' And a.qcstate = 18 And a.procedureid = 802 -----'TB Test Intradermal' - And a.modified >= cast(getdate() as date) + ----And a.modified >= cast(getdate() as date) + And a.modified >= @TestDate And a.participantid in ( select k.participantid from studydataset.c6d203_demographics k where k.calculated_status = 'alive') @@ -192,9 +198,6 @@ BEGIN ----Create a single task for each daily process - - - While @TempSearchKey < @SearchKey BEGIN @@ -231,15 +234,15 @@ BEGIN Values ( - @TaskID, - 'TB TST Scores ' + cast(@Date as varchar(50)) , ------ Title consist of animal id and Clinical procedure date - 'TB TST Scores', - 20, --- Qc State (In Progress) - 'TB TST Scores', ------ FormType - 'task', ----- category, - 1822, ------- Assigned To Data Admins - 1042, -------- Created By IS - 1042 ----- Modified by IS + @TaskID, + 'TB TST Scores ' + cast(@Date as varchar(50)) , ------ Title consist of animal id and Clinical procedure date + 'TB TST Scores', + 20, --- Qc State (In Progress) + 'TB TST Scores', ------ FormType + 'task', ----- category, + 1822, ------- Assigned To Data Admins + 1042, -------- Created By IS + 1042 ----- Modified by IS ) @@ -280,11 +283,11 @@ BEGIN 'TB TST Score (72 hr)', 'Right Eyelid', 'Grade: Negative', - @createdby, + 1842, -----created by IS @performedby, @TaskID, 20 , ---- In Progress QCState - @modifiedby -----modified + 1842 -----modified by IS ) From f69f28610c18cce1c6e8e7af774a9358675dc8a4 Mon Sep 17 00:00:00 2001 From: blasar Date: Fri, 10 Jul 2026 00:02:33 -0700 Subject: [PATCH 12/18] Modified a storedprocedure program to create a process of generating Clinical Observation records based on Clinical Encounters "TB Test Intradermal" entries. --- .../sqlserver/onprc_ehr-26.000-26.001.sql | 3 ++ onprc_ehr/resources/schemas/onprc_ehr.xml | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index a474a6bfc..55ca5b5eb 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -1,6 +1,9 @@ EXEC core.fn_dropifexists 'TB_TestTemp', 'onprc_ehr', 'TABLE', NULL; GO + +EXEC core.fn_dropifexists 'TB_TestTempMaster', 'onprc_ehr', 'TABLE', NULL; +GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations', 'onprc_ehr', 'TABLE', NULL; GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations_Master', 'onprc_ehr', 'TABLE', NULL; diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml index 9b4e8a75e..67849155c 100644 --- a/onprc_ehr/resources/schemas/onprc_ehr.xml +++ b/onprc_ehr/resources/schemas/onprc_ehr.xml @@ -1322,6 +1322,7 @@ + @@ -1338,6 +1339,53 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ DETAILED From 164b2461597f6b595eab1e0482f7cbdf44fee404 Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 12:27:49 -0700 Subject: [PATCH 13/18] Modified program to update the temp tables necessary to execute storedprocedure. --- .../schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index 55ca5b5eb..78916a31c 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -93,7 +93,7 @@ GO ** new TB Test Clinical Observation record based on ** having the same monkey id, date, and then to be assigned to a Data Admin for reviews. ** -** R. Blasa Modified program so that each Clinical Observation entries generated by the program is assigned +** Modified program so that each Clinical Observation entries generated by the program is assigned ** only a single task id when the program executes daily. ** ** @@ -253,7 +253,7 @@ BEGIN GoTo Err_Proc ---Set Task insert process only once per single process - Set @FirsFlag = 1 + Set @FirstFlag = 1 END ---(@FirstFlag) From 4f977114785776708f464e2d94273bd5f23df3ca Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 13:35:11 -0700 Subject: [PATCH 14/18] Modified program to update the temp tables necessary to execute storedprocedure. --- .../sqlserver/onprc_ehr-26.000-26.001.sql | 25 +++++++++++++------ onprc_ehr/resources/schemas/onprc_ehr.xml | 13 +--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index 78916a31c..cec9ca3e2 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -1,9 +1,6 @@ EXEC core.fn_dropifexists 'TB_TestTemp', 'onprc_ehr', 'TABLE', NULL; GO - -EXEC core.fn_dropifexists 'TB_TestTempMaster', 'onprc_ehr', 'TABLE', NULL; -GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations', 'onprc_ehr', 'TABLE', NULL; GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations_Master', 'onprc_ehr', 'TABLE', NULL; @@ -70,6 +67,7 @@ CREATE TABLE [onprc_ehr].[Observation_EHRTasks]( [rowid] [int] IDENTITY(100,1) NOT NULL, taskid varchar(4000) NULL, description varchar(500)NULL, + title varchar(500)NULL, qcstate smallint NULL, formtype varchar(500) NULL, category varchar(500) NULL, @@ -132,10 +130,18 @@ BEGIN Truncate table onprc_ehr.TB_TestTemp - If @@Error <> 0 GoTo Err_Proc + Truncate table [onprc_ehr].[Temp_Clinical_Observations] + + If @@Error <> 0 + GoTo Err_Proc + + Truncate table [onprc_ehr].[Observation_EHRTasks] + + If @@Error <> 0 + GoTo Err_Proc --- Generate a list TB test monkeys ) @@ -160,6 +166,11 @@ BEGIN And a.modified >= @TestDate And a.participantid in ( select k.participantid from studydataset.c6d203_demographics k where k.calculated_status = 'alive') + AND a.participantid not in (select j.participantid from studydataset.c6d171_clinical_observations j + Where j.participantid = a.participantid + And j.date = dateadd(day,3,a.date) + And j.category = 'TB TST Score (72 hr)' + And j.qcstate = 18 ) order by a.participantid, a.date desc @@ -213,7 +224,7 @@ BEGIN If not exists (select * from studydataset.c6d171_clinical_observations j Where j.participantid = @AnimalID - And cast(j.date as date) = dateadd(day,3,cast(@date as date)) + And j.date = dateadd(day,3,@date) And j.category = 'TB TST Score (72 hr)' And j.qcstate = 18 ) @@ -286,11 +297,11 @@ BEGIN 'TB TST Score (72 hr)', 'Right Eyelid', 'Grade: Negative', - 1842, -----created by IS + 1042, -----created by IS @performedby, @TaskID, 20 , ---- In Progress QCState - 1842 -----modified by IS + 1042 -----modified by IS ) diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml index 67849155c..9e43a10fe 100644 --- a/onprc_ehr/resources/schemas/onprc_ehr.xml +++ b/onprc_ehr/resources/schemas/onprc_ehr.xml @@ -1327,18 +1327,6 @@
- - - - - - - - - - - -
@@ -1377,6 +1365,7 @@ + From 9f37b9923fd7d67cd1b18abcc77d8bcc591a7a94 Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 14:03:48 -0700 Subject: [PATCH 15/18] Modified program to update the temp tables necessary to execute storedprocedure. --- .../dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index cec9ca3e2..0ba3b06d3 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -123,8 +123,6 @@ DECLARE BEGIN - ----- Set Test Date - Set @TestDate = '7/1/2026' ---- Reset temp table @@ -159,11 +157,10 @@ BEGIN from studydataset.c6d214_encounters a - Where a.type = 'Procedure' + Where a.type in ('Procedure','Surgery') And a.qcstate = 18 And a.procedureid = 802 -----'TB Test Intradermal' - ----And a.modified >= cast(getdate() as date) - And a.modified >= @TestDate + And a.modified >= cast(getdate() as date) And a.participantid in ( select k.participantid from studydataset.c6d203_demographics k where k.calculated_status = 'alive') AND a.participantid not in (select j.participantid from studydataset.c6d171_clinical_observations j @@ -207,7 +204,6 @@ BEGIN Order by rowid - Set @TaskID = NEWID() ----- Task Record Object ID ----Create a single task for each daily process @@ -232,6 +228,10 @@ BEGIN If @FirstFlag != 1 BEGIN + ---- created a new task id + Set @TaskID = NEWID() + + ---- Create Clinical Observation entries Insert into onprc_ehr.Observation_EHRTasks ( taskid, From a50ff189776f9947353fca9092ce3da9d9d2b483 Mon Sep 17 00:00:00 2001 From: blasar Date: Tue, 14 Jul 2026 23:28:01 -0700 Subject: [PATCH 16/18] Modified Tb Test to include xml column fields. --- onprc_ehr/resources/schemas/onprc_ehr.xml | 33 +++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml index 9e43a10fe..f18b1ae9c 100644 --- a/onprc_ehr/resources/schemas/onprc_ehr.xml +++ b/onprc_ehr/resources/schemas/onprc_ehr.xml @@ -1315,43 +1315,42 @@
- - - - - - - - - + + + + + + + +
- - - - + + + - - - + + +
+ - + From a27bceaef1aa9644ee18229a57550fcf552e5ca1 Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 15 Jul 2026 16:24:04 -0700 Subject: [PATCH 17/18] Modified Tb Test to include xml column fields. --- onprc_ehr/resources/schemas/onprc_ehr.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/onprc_ehr/resources/schemas/onprc_ehr.xml b/onprc_ehr/resources/schemas/onprc_ehr.xml index f18b1ae9c..fc32decdf 100644 --- a/onprc_ehr/resources/schemas/onprc_ehr.xml +++ b/onprc_ehr/resources/schemas/onprc_ehr.xml @@ -1321,6 +1321,7 @@ + From bb6d85140e32bb5b55fb72e921e99384910f797d Mon Sep 17 00:00:00 2001 From: blasar Date: Wed, 15 Jul 2026 16:26:00 -0700 Subject: [PATCH 18/18] Modified Tb Test to include xml column fields. --- .../schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql index 0ba3b06d3..8fcff018a 100644 --- a/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql +++ b/onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-26.000-26.001.sql @@ -1,6 +1,9 @@ EXEC core.fn_dropifexists 'TB_TestTemp', 'onprc_ehr', 'TABLE', NULL; GO + +EXEC core.fn_dropifexists 'TB_TestTempMaster', 'onprc_ehr', 'TABLE', NULL; +GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations', 'onprc_ehr', 'TABLE', NULL; GO EXEC core.fn_dropifexists 'Temp_Clinical_Observations_Master', 'onprc_ehr', 'TABLE', NULL;