Skip to content

Commit

Permalink
MPA clinical remarks project files are added.
Browse files Browse the repository at this point in the history
  • Loading branch information
kollil committed Jan 30, 2024
1 parent 5fefd60 commit 897ca0b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 1 deletion.
34 changes: 34 additions & 0 deletions onprc_ehr/resources/etls/MPA_ClnRemarkAddition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Created By: Kollil, 1/29/2024.
The ETL adds a P1 clinical remark into the animal record if the MPA injection ('E-85760' - Medroxyprogesterone acetate)
is marked as completed on the current day.
Refer to ticket # 10208 for more details.
-->
<etl xmlns="http://labkey.org/etl/xml">

<name>MPA_ClnRemarkAddition</name>

<description>Executes stored procedure to populate the clinical remarks into a temp table.</description>

<transforms>
<transform id="Stored_Proc" type="StoredProcedure">
<description>Runs the stored procedure to update Labkey_public.onprc_ehr.Temp_ClnRemarks table</description>
<procedure schemaName="onprc_ehr" procedureName="MPA_ClnRemarkAddition">
</procedure>
</transform>

<transform id="AddMPAClnRemark">
<description>Import the remarks data from Labkey_public.onprc_ehr.Temp_ClnRemarks table to study.ClnRemarks
table in Prime
</description>
<source schemaName="LabkeyPublic" queryName="Temp_ClnRemarks"/>
<destination schemaName="study" queryName="clinremarks"/>
</transform>
</transforms>

<schedule>
<!-- Runs daily at 11pm -->
<cron expression="0 23 * * *"/>
</schedule>

</etl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/****** Add MPA Clinical remarks: By Kolli******/
/*
Created 1 temp table to store the clinical remarks records.
The stored proc manages the addition and deleting clinical remarks data from the temp table
at the time of execution via ETL process.
*/
EXEC core.fn_dropifexists 'Temp_ClnRemarks','onprc_ehr','TABLE';
GO

-- Create the temp table
CREATE TABLE onprc_ehr.Temp_ClnRemarks
(
date datetime,
qcstate int,
participantid nvarchar(32),
project int,
remark nvarchar(4000) ,
description nvarchar(4000) ,
performedby nvarchar(4000) ,
category nvarchar(4000) ,
taskid nvarchar(4000)
)
;

GO


-- Create the stored proc here
/****** Object: StoredProcedure [onprc_ehr].[MPA_ClnRemarkAddition] Script Date: 1/25/2024 *****/

-- =============================================
-- Author: Lakshmi Kolli
-- Create date: 1/25/2023
-- Description: This procedure identifies if an animal received an MPA injection
-- and inserts a clinical remark into animal's record.
-- =============================================

CREATE PROCEDURE [onprc_ehr].[MPA_ClnRemarkAddition]
AS

DECLARE
@MPACount Int,
@taskId Int

BEGIN
--Delete all rows from the temp_Drug table
Delete From Labkey_public.onprc_ehr.Temp_ClnRemarks

--Check if the MPA injection, E-85760 was administered today
Select @MPACount = COUNT(*) From studyDataset.c6d178_drug
Where code = 'E-85760' And CONVERT(DATE, date) = CONVERT(DATE, GETDATE()) And qcstate = 18

--Found entries, so, enter the clinical remark for that
If @MPACount > 0
Begin

-- Create a TaskId
-- Get the rowId which is the taskId
Insert Into [ehr].[tasks]
(taskid, category, title, formtype, qcstate, assignedto, duedate, createdby, created,
container, modifiedby, modified, description, datecompleted)
Values
(NEWID(), 'Task', 'Bulk Clinical Entry', 'Bulk Clinical Entry', 18, 1003, GETDATE(), 1003, GETDATE(),
'CD17027B-C55F-102F-9907-5107380A54BE', 1003, GETDATE(), 'Created by the ETL process', GETDATE())

--Get the latest taskId
Select Top 1 @taskId = rowId From ehr.tasks
Where formType = 'Bulk Clinical Entry' And qcstate = 18 And createdby = 1003
And CONVERT(DATE, created) = CONVERT(DATE, GETDATE()) Order by rowId desc

--Insert the clinical remark into the clinical remarks
-- Get all the Animals who had MPA injection today in studyDataset.c6d178_drug
-- and INSERT the data into the studyDataset.c6d185_clinremarks table
Insert Into labkey_LK_public.onprc_ehr.Temp_ClnRemarks (
date, qcstate, participantid, project, remark, description, performedby, category, taskid
)
Select
GETDATE(), 18, participantid, project, 'Remark entered by the ETL process',
'P1: MPA injection administered', 1003, 'Clinical', '662095'
From studyDataset.c6d178_drug
Where code = 'E-85760' And CONVERT(DATE, date) = CONVERT(DATE, GETDATE()) And qcstate = 18

End

END

GO
15 changes: 15 additions & 0 deletions onprc_ehr/resources/schemas/onprc_ehr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1309,4 +1309,19 @@
</columns>
</table>

<!--Created by: Kollil, 1/29/24. Created a temp table to store the clinical remarks -->
<table tableName="Temp_ClnRemarks" tableDbType="TABLE">
<columns>
<column columnName="date" />
<column columnName="qcstate" />
<column columnName="participantid" />
<column columnName="project" />
<column columnName="remark" />
<column columnName="description" />
<column columnName="performedby" />
<column columnName="category" />
<column columnName="taskId" />
</columns>
</table>

</tables>
3 changes: 2 additions & 1 deletion onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ public String getName()
@Override
public @Nullable Double getSchemaVersion()
{
return 23.007;
// 1/29/24 by Kollil
return 23.008;
}

@Override
Expand Down

0 comments on commit 897ca0b

Please sign in to comment.