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

Merge 24.11 to 25.1 #1238

Merged
merged 9 commits into from
Jan 28, 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
28 changes: 28 additions & 0 deletions onprc_ehr/resources/etls/SLAWeaning.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Created By: Kollil, 9/25/2024.
Create an ETL process for SLA weaning data: Based on the alive pups DOB, create an ETL process that runs daily and checks if there are any pups
that’s 21 days old, load them into SLA purchase & purchase details datasets as pending orders (Confirmation num is null & dateCanceled is null).
Once the data is moved, the “dateofTransfer” field will be set marking the pups are moved into SLA purchase datasets and will be excluded
from the future daily checks.
Refer to ticket # 11233 for more details.
-->
<etl xmlns="http://labkey.org/etl/xml">

<name>SLAWeaning</name>

<description>Executes stored procedure to populate the SLA purchase datasets</description>

<transforms>
<transform id="Stored_Proc" type="StoredProcedure">
<description>Runs the stored procedure to process and update the weaning data from sla.TempWeaning table to sla.purchase and sla.purchasedetails tables in prime</description>
<procedure schemaName="onprc_ehr" procedureName="SLAWeaningDataTransfer"> </procedure>
</transform>
</transforms>

<schedule>
<!-- Runs daily at 11pm -->
<cron expression="0 0 23 * * ?"/>
<!-- <poll interval="15m" />&lt;!&ndash; For testing only - runs every 15 mins &ndash;&gt;-->
</schedule>

</etl>
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<columnTitle>Species</columnTitle>
</column>
<column columnName="Gender">
<columnTitle>Gender</columnTitle>
<columnTitle>Sex</columnTitle>
</column>
<column columnName="Strain">
<columnTitle>Strain</columnTitle>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SELECT
a.title As Title,
i.LastName || ', ' || i.FirstName As PIName,
aa.Species,
aa.Gender,
aa.Gender as Sex,
aa.Strain,
aa.Allowed As NumAllowed,
aa.StartDate,
Expand Down
2 changes: 1 addition & 1 deletion sla/resources/queries/sla/ProtocolProjectsUsage.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<columnTitle>Species</columnTitle>
</column>
<column columnName="Gender">
<columnTitle>Gender</columnTitle>
<columnTitle>Sex</columnTitle>
</column>
<column columnName="Strain">
<columnTitle>Strain</columnTitle>
Expand Down
2 changes: 1 addition & 1 deletion sla/resources/queries/sla/ProtocolProjectsUsage.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SELECT
y.grantNumber as OGAGrantNumber,
y.fiscalAuthorityName As FiscalAuthorityName,
aa.Species,
aa.Gender,
aa.Gender as Sex,
aa.Strain,
aa.Allowed AS NumAllowed,
calc.NumUsed,
Expand Down
2 changes: 1 addition & 1 deletion sla/resources/queries/sla/allowableSLA.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SELECT a.protocol,
c.protocol_id as eIACUC_protocol_name,
a.species,
a.gender,
a.gender as Sex,
a.strain,
a.age,
a.allowed,
Expand Down
18 changes: 18 additions & 0 deletions sla/resources/queries/sla/weaning/.qview.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<customView xmlns="http://labkey.org/data/xml/queryCustomView">
<columns>
<column name="rowid"/>
<column name="investigator"/>
<column name="date"/>
<column name="project"/>
<column name="vendorlocation"/>
<column name="DOB"/>
<column name="DOM"/>
<column name="species"/>
<column name="sex"/>
<column name="strain"/>
<column name="numAlive"/>
<column name="numDead"/>
<column name="totalPups"/>
<column name="dateofTransfer"/>
</columns>
</customView>
2 changes: 1 addition & 1 deletion sla/resources/queries/sla_public/PurchaseOrderDetails.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ p.requestorid,
p.requestor,
p.vendor,
pd.species,
pd.gender,
pd.gender as Sex,
pd.strain,
pd.weight,
pd.gestation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ p.requestorid,
p.requestor,
p.vendor,
pd.species,
pd.gender,
pd.gender As Sex,
pd.strain,
pd.weight,
pd.gestation,
Expand Down
Loading
Loading