Skip to content

Commit

Permalink
Merge 24.7 to 24.11
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Jan 20, 2025
2 parents 01b2ad3 + 8ff1a9e commit 004b577
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 1 deletion.
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

0 comments on commit 004b577

Please sign in to comment.