Skip to content

Commit

Permalink
FIles for Phase 1 of eiACUAC to Protocol. Updates the eriCIC Data to …
Browse files Browse the repository at this point in the history
…add Base Prtocol
  • Loading branch information
jonesgaohsu committed Jul 24, 2024
1 parent 41f2c11 commit 65c9542
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
16 changes: 16 additions & 0 deletions onprc_ehr/resources/etls/eIACUCtoPrimeUpdate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<etl xmlns="http://labkey.org/etl/xml">
<name>eiACUCtoPrimeBaseProtocol</name>
<description>Transfers from the eIACUC Import tables to the Prime tables in ONPRC_EHR</description>
<transforms>

<transform id="step1a">
<description>Transfer to Protocols</description>
<source queryName="PRIME_VIEW_PROTOCOLS" schemaName="eIACUC"/>
<destination queryName="eIACUC_PRIME_VIEW_PROTOCOLS" schemaName="ONPRC_EHR" targetOption="truncate"/>
</transform>
<!--//Need a query that has needed fields for BaseProtocol and revisionNumber and then inserts that into eIACUC_Prime_View_Protocols
Also only want latest data-->

</transforms>

</etl>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
Expand All @@ -19,62 +18,56 @@ GO
-- Description: Iniitial Stage of update of eIACUC to protocol processing
-- =============================================

CREATE PROCEDURE onprc_ehr.eIACUCBaseProtocol
ALTER PROCEDURE onprc_ehr.eIACUCBaseProtocol

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
--Drop Temporary Table
DROP TABLE #eIACUCBaseProtocol
--DROP TABLE #eIACUCBaseProtocol
-- Insert statements for procedure here
cREATE tABLE #eIACUCBaseProtocol
(BaseProtocol varchar(50) Not Null,
RevisionNumber varchar(20) Not Null,
RenewalNumber varchar(20) Not Null,
Protocol_Id varchar(50) Not Null,
Last_Modified varchar(30) not null ,
LatestInstance varchar (30) Not Null);
LatestREnewal varchar (30) Not Null);

--Populate the temporary table from query
Insert INTO #eIACUCBaseProtocol(BaseProtocol,RevisionNumber,Protocol_id,Last_Modified,LatestInstance)
Insert INTO #eIACUCBaseProtocol(BaseProtocol,RenewalNumber,Protocol_id,Last_Modified,LatestRenewal)
Select

Case when len(p.protocol_id) > 10 then substring(p.protocol_id, 6,15)
else p.protocol_id
End as BaseProtocol,
Case when len(p.protocol_id) > 10 then substring(p.protocol_id, 1,4)
else 'Original'
End as RevisionNumber,
End as RenewalNumber,
protocol_id,
Last_Modified,
' ' as LatestInstance
' ' as LatestRenewal

from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p

Update p1
Set p1.BaseProtocol = e.BaseProtocol

from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 join #eIACUCUpdate e on p1.protocol_id = e.Protocol_Id
from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 join #eIACUCBaseProtocol e on p1.protocol_id = e.Protocol_Id

Update p1
Set p1.RevisionNumber = e.RevisionNumber
Set p1.ReNewalNumber = e.ReNewalNumber

from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 join #eIACUCUpdate e on p1.protocol_id = e.Protocol_Id
from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 join #eIACUCBaseProtocol e on p1.protocol_id = e.Protocol_Id

Update p1
Set p1.LatestRenewal = e.LatestRenewal


--Now will limit the records to be inserted to most recent record


update p
Set p.updateStatus = 'Update'

from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p
where (p.BaseProtocol is not null and p.last_Modified = (Select Max(p1.Last_Modified) from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 where p1.BaseProtocol = p.BaseProtocol))

from onprc_ehr.eIACUC_PRIME_VIEW_PROTOCOLS p1 join #eIACUCBaseProtocol e on p1.protocol_id = e.Protocol_Id


--Now will limit the records to be inserted to most recent record


END
Expand Down
6 changes: 4 additions & 2 deletions onprc_ehr/resources/schemas/onprc_ehr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,10 @@
<column columnName="PPQ_Numbers"/>
<column columnName="Description"/>
<column columnName="BaseProtocol"/>
<column columnName="RevisionNumber"/>
<column columnName="UpdateStatus"/>
<column columnName="RenewalNumber"/>
<column columnName="LatestRenewal"/>


</columns>
</table>
<table tableName="PotentialDam_source" tableDbType="TABLE">
Expand Down

0 comments on commit 65c9542

Please sign in to comment.