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

[bot] Fast-forward for 24.2.0 #922

Merged
merged 5 commits into from
Feb 14, 2024
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
31 changes: 31 additions & 0 deletions onprc_ehr/resources/etls/MPA_ClnRemarkAddition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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 onprc_ehr.Temp_ClnRemarks table</description>
<procedure schemaName="onprc_ehr" procedureName="MPA_ClnRemarkAddition"> </procedure>
</transform>

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

<schedule>
<!-- Runs daily at 10pm -->
<cron expression="0 0 22 * * ?"/>
</schedule>

</etl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
-- =================================================================================================
-- Add MPA Clinical remarks: By, Lakshmi Kolli
-- Created on: 1/25/2024
/* Description: 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.
*/
-- =================================================================================================

--Drop table if exists
EXEC core.fn_dropifexists 'Temp_ClnRemarks','onprc_ehr','TABLE';
--Drop Stored proc if exists
EXEC core.fn_dropifexists '[onprc_ehr].[MPA_ClnRemarkAddition]', 'onprc_ehr', 'PROCEDURE';
GO

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

GO

-- Create the stored proc
/****** Object: StoredProcedure [onprc_ehr].[MPA_ClnRemarkAddition] Script Date: 1/25/2024 *****/
-- =================================================================================
-- Author: Lakshmi Kolli
-- Create date: 1/25/2024
-- 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 nvarchar(4000)

BEGIN
--Delete all rows from the temp_Drug table
Delete From 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 remarks now
If @MPACount > 0
Begin
-- Create a Task entry in ehr.tasks table
Set @taskid = NEWID() -- creating taskid
Insert Into ehr.tasks
(taskid, category, title, formtype, qcstate, assignedto, duedate, createdby, created,
container, modifiedby, modified, description, datecompleted)
Values
(@taskid, '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())

--Insert the clinical remark into the temp clinical remarks table.
/* Get all the Animals who had MPA injection today from studyDataset.c6d178_drug
and INSERT the data into the studyDataset.c6d185_clinremarks table */
Insert Into onprc_ehr.Temp_ClnRemarks (
date, qcstate, participantid, project, remark, p, performedby, category, taskid, createdby, modifiedby
)
Select GETDATE(), 18, participantid, project, 'Remark entered by the ETL process', 'MPA injection administered', '[email protected]', 'Clinical', @taskId, 1003, 1003
From studyDataset.c6d178_drug
Where code = 'E-85760' And CONVERT(DATE, date) = CONVERT(DATE, GETDATE()) And qcstate = 18
End

END

GO
18 changes: 18 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,22 @@
</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="p" />
<column columnName="performedby" />
<column columnName="category" />
<column columnName="taskId" />
<column columnName="createdby" />
<column columnName="modifiedby" />

</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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.labkey.api.security.Group;
import org.labkey.api.security.SecurityManager;
import org.labkey.api.security.User;
import org.labkey.api.security.UserManager;
import org.labkey.api.security.ValidEmail;
import org.labkey.api.util.Pair;

Expand Down Expand Up @@ -114,6 +115,11 @@ public boolean hasPermission(User user, @NotNull Issue issue, List<Issue> relate

private boolean checkAccess(User user, @NotNull Issue issue, @Nullable Group groupWithAccess)
{
// Creators have access to their own issues
User createdBy = UserManager.getUser(issue.getCreatedBy());
if (createdBy != null && createdBy.equals(user))
return true;

// Assigned to users have access
if (Objects.equals(issue.getAssignedTo(), user.getUserId()))
return true;
Expand Down
Loading