Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

23.11 fb eiacuc to prime end date #1213

Merged
merged 14 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions onprc_ehr/resources/etls/UpdateEhrProtocols.xml
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>




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;
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
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
3 changes: 3 additions & 0 deletions onprc_ehr/resources/schemas/onprc_ehr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@
<column columnName="PROTOCOL_State"/>
<column columnName="PPQ_Numbers"/>
<column columnName="Description"/>
<column columnName="BaseProtocol"/>
<column columnName="RevisionNumber"/>
<column columnName="NewestRecord"/>
</columns>
</table>
<table tableName="PotentialDam_source" tableDbType="TABLE">
Expand Down
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.005;
}

@Override
Expand Down