Skip to content

Commit

Permalink
New Stored Preocduere to Identify Protocol recorfds in Prime to Enddate
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesgaohsu committed Nov 19, 2024
1 parent ec49906 commit ecee5a1
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: jonesga
-- Create date: 2024-11-18
-- Description: This Stored Preocduer is deigned to
----Compare current Prime Protocols to eiACUC Protocols
----and end Date the Protocols in Prime that have a
----Protocol State of expired, terminated or withdrawn
-- =============================================
CREATE PROCEDURE onprc_ehr.eIACUCtoPRIMEProtocolProcessing
-- No Parameters are used
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
--Step One
--Determine the Base Protocol and Revision Number in eIACUC Protocols
--Creates temp Table #PRIMEProtocolstoEndDate

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,4)
ELSE 'Original'
END as RevisionNumber,
Protocol_Title,
Template_OID,
Approval_Date,
last_modified,
Three_year_Expiration,
Protocol_State
INTO #PRIMEProtocolstoEndDate
from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS
-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--Step Two
--Using Values in Step 1 limits tghe records returned to newest record for a base protocol
--Vtrsrd tempt Table #DistincteIACUCProtocolv
SELECT
rowid,
BaseProtocol,
RevisionNumber,
Protocol_Title,
Template_OID,
Approval_Date,
last_modified,
Three_year_Expiration,
Protocol_State
INTO #DistincteIACUCProtocol
from #PRIMEProtocolstoEndDate
where rowID =
(Select Max(rowID) from #PRIMEProtocolstoEndDate p1 where p1.BaseProtocol = #PRIMEProtocolstoEndDate.BaseProtocol)
-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--Step Three
-- Determine what records in ehr.prtotocol (##TestingProtocol) here need to be enddated
--we will use the three year renewal date as the end date of the protocol
--Creates Temp Table #PRIMEProtocolstoEndDate
--DROP TABLE #PRIMEProtocolstoEndDate
Select
p.protocol,
p.external_id,
p.approve,
p.enddate,
d.BaseProtocol,
d.RevisionNumber,
d.PROTOCOL_State,
d.Three_year_Expiration
into #endDatePrimeProtocols
From ehr.protocol p join #DistincteIACUCProtocol d on p.external_Id = d.baseProtocol
--Select * from #PRIMEProtocolstoEndDate
-- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--Step Four
-- Update of Records Identified in Step 3
--we will use the three year renewal date as the end date of the protocol
--
Update p
Set p.enddate = e.Three_year_Expiration,p.contacts = 'Protocol enddate based on eIACUC Record PROTOCOL STATE = ' + e.Protocol_State
--Select p.*
from ehr.protocol p join #endDatePrimeProtocols e on p.protocol = e.protocol


END
GO
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 23.016;
return 24.002;
}

@Override
Expand Down

0 comments on commit ecee5a1

Please sign in to comment.