Skip to content

Commit

Permalink
Update of EiACUC P{rocessing for enddate
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesgaohsu committed Dec 26, 2024
1 parent 52d2a69 commit d8f50eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
--This build is a stored preoccured that uses a temp table and then updates onprc_ehronprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS
ALTER Procedure onprc_ehr.BaseProtocol

AS
--Create a Temp Table that creates Base Protocol and Revision Number
WITH BaseProtocol AS (
SELECT
RowID,
Protocol_id,
CASE
WHEN LEN(protocol_id) > 10 THEN SUBSTRING(protocol_id, 6, 15)
ELSE protocol_id
END AS BaseProtocol,
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
)
--This will update the onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS inserting the BaseProtocol and RevisionNumber
Update e
Set e.BaseProtocol = p.BaseProtocol, e.RevisionNumber = p.revisionNumber
--
from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS e, BaseProtocol p
where e.rowID = p.rowID
ALTER 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
USE [Labkey_GJ]
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
ALTER PROCEDURE [onprc_ehr].[ExpiredProtocolUpdate]
CREATE PROCEDURE [onprc_ehr].[ExpiredProtocolUpdate]
AS
BEGIN

Expand Down Expand Up @@ -44,4 +43,5 @@ WITH ApprovedProtocols AS (
Update p
Set p.enddate = getDate() , p.contacts = 'EndDated based on Protocol_State ' + e.PROTOCOL_State

from ehr.protocol p inner join expiredProtocol e on p.external_id = e.BaseProtocol
from ehr.protocol p inner join expiredProtocol e on p.external_id = e.BaseProtocol
END

This file was deleted.

2 changes: 1 addition & 1 deletion onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 24.006;
return 24.005;
}

@Override
Expand Down

0 comments on commit d8f50eb

Please sign in to comment.