-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23.11 fb eiacuc to prime end date (#1213)
* Restructure of Feature BRanch for eIACUC to Prime * Upd[atre of Stored Proecure to End Date Protocols * Don't enddate protocols in approved state This code done in a pairing session with Gary and Brent. * Update of Stored Procedure to insure only none approved Protocols are enddated * Created new StoreProcedure of Stored Procedure to insure only none approved Protocols are enddated * Modification the Storedc Proec ure was missing the end statment was erroring out * Update onprc_ehr-24.005-24.006.sql COrrected Misspelled field name at line 44 * Update of EiACUC P{rocessing for enddate * Update onprc_ehr-24.004-24.005.sql Removeed withdrawn from the query where clause * Rename .xml and change descriptions * Updated the Stored Precedure from ALTER to CREATE * UPdate of SQL Script to remove unwanted testing comments and reformt CTEs for Stnadarization --------- Co-authored-by: Brent Logan <gbrentlogan@gmail.com>
- Loading branch information
1 parent
c818022
commit 09c2278
Showing
6 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<etl xmlns="http://labkey.org/etl/xml"> | ||
|
||
<name>Update Protocols in EHR</name> | ||
|
||
<description>Runs stored procedures to update the protocol table in schema ehr.</description> | ||
|
||
<transforms> | ||
|
||
<transform id="UpdateBaseProtocol" type="StoredProcedure"> | ||
<description>Determines and populates BaseProtocol and RevisionNumber data for the protocol table in schema onprc_ehr.</description> | ||
<procedure schemaName="onprc_ehr" procedureName="BaseProtocol"> | ||
</procedure> | ||
</transform> | ||
|
||
<transform id="enddateExpiredProtocolsProtocol" type="StoredProcedure"> | ||
<description>Adds enddate data to the protocol table in ehr.</description> | ||
<procedure schemaName="onprc_ehr" procedureName="ExpiredProtocolUpdate"> | ||
</procedure> | ||
</transform> | ||
|
||
</transforms> | ||
|
||
<!-- | ||
<schedule> | ||
<cron expression="0 50 04 * * "/> | ||
</schedule> | ||
--> | ||
|
||
</etl> | ||
|
||
|
||
|
||
|
7 changes: 7 additions & 0 deletions
7
onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.001-24.002.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--added to allow insert of calculated fields from eIACUC | ||
|
||
--2024-12-13 In development need to use a drop if exists statement for these to run | ||
|
||
ALTER TABLE onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS ADD [BaseProtocol] varchar(100) Null; | ||
ALTER TABLE onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS ADD [RevisionNumber] varchar(100) Null; | ||
ALTER TABLE onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS ADD [NewestRecord] INT Null; |
34 changes: 34 additions & 0 deletions
34
onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.002-24.003.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
CREATE PROCEDURE onprc_ehr.BaseProtocol | ||
AS | ||
BEGIN | ||
-- Create a Common Table Expression (CTE) named BaseProtocol | ||
WITH BaseProtocol AS | ||
( | ||
SELECT | ||
RowID, | ||
Protocol_id, | ||
-- Determine the BaseProtocol based on the length of the Protocol_id | ||
CASE | ||
WHEN LEN(Protocol_id) > 10 THEN SUBSTRING(Protocol_id, 6, 15) | ||
ELSE Protocol_id | ||
END AS BaseProtocol, | ||
-- Determine the RevisionNumber based on the length of the Protocol_id | ||
CASE | ||
WHEN LEN(Protocol_id) > 10 THEN SUBSTRING(Protocol_id,1, 5) | ||
ELSE 'Original' | ||
END AS RevisionNumber, | ||
approval_date, | ||
Three_Year_Expiration, | ||
last_modified, | ||
Protocol_State | ||
FROM onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS | ||
) | ||
|
||
-- Update the onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS table with BaseProtocol and RevisionNumber from the CTE | ||
UPDATE onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS | ||
SET BaseProtocol = BaseProtocol.BaseProtocol, | ||
RevisionNumber = BaseProtocol.RevisionNumber | ||
FROM BaseProtocol | ||
WHERE onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS.RowID = BaseProtocol.RowID; | ||
END | ||
GO |
48 changes: 48 additions & 0 deletions
48
onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-24.004-24.005.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
GO | ||
/****** Object: StoredProcedure [onprc_ehr].[ExpiredProtocolUpdate] Script Date: 12/20/2024 9:09:09 AM ******/ | ||
SET ANSI_NULLS ON | ||
GO | ||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
CREATE PROCEDURE [onprc_ehr].[ExpiredProtocolUpdate] | ||
AS | ||
BEGIN | ||
|
||
WITH ApprovedProtocols AS ( | ||
SELECT | ||
BaseProtocol, | ||
MAX(Approval_Date) AS maxApprovalDate | ||
FROM | ||
onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS | ||
WHERE | ||
Protocol_State IN ('approved','expired', 'terminated') | ||
GROUP BY | ||
BaseProtocol | ||
), | ||
|
||
|
||
DistinctProtocols AS ( | ||
SELECT DISTINCT | ||
p.rowID, | ||
p.BaseProtocol, | ||
p.RevisionNumber, | ||
p.Protocol_State, | ||
p.Approval_Date, | ||
p.Last_Modified, | ||
p.Three_Year_Expiration | ||
FROM | ||
onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p | ||
INNER JOIN ApprovedProtocols ap ON p.BaseProtocol = ap.BaseProtocol | ||
AND p.Approval_Date = ap.maxApprovalDate), | ||
ExpiredProtocol AS ( | ||
Select | ||
d.*, | ||
p.protocol, | ||
p.enddate | ||
from DistinctProtocols d inner join ehr.protocol p on d.BaseProtocol = p.external_ID | ||
where d.Protocol_State != 'Approved' and p.enddate is Null) | ||
|
||
Update p | ||
Set p.enddate = getDate() | ||
from ehr.protocol p inner join expiredProtocol e on p.external_id = e.BaseProtocol | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters