-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modified Environmental assessment form.
- Loading branch information
Showing
3 changed files
with
117 additions
and
33 deletions.
There are no files selected for viewing
113 changes: 81 additions & 32 deletions
113
onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.007-23.008.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,84 @@ | ||
CREATE TABLE onprc_ehr.Environmental_Assessment( | ||
rowid int IDENTITY(100,1) NOT NULL, | ||
date datetime NULL, | ||
service_requested varchar(300) NULL, | ||
charge_unit varchar(300) NULL, | ||
testing_location varchar(300) NULL, | ||
test_type varchar(300) NULL, | ||
test_results varchar(100) NULL, | ||
pass_fail varchar(100) NULL, | ||
biological_Cycle varchar(300) NULL, | ||
biological_BI varchar(300) NULL, | ||
action varchar(300) NULL, | ||
performedby varchar(300) NULL, | ||
remarks varchar(300) NULL, | ||
water_source varchar(300) NULL, | ||
surface_tested varchar(300) NULL, | ||
retest varchar(300) NULL, | ||
colony_count varchar(300) NULL, | ||
test_method varchar(300) NULL, | ||
objectid ENTITYID Not Null, | ||
createdby int NULL, | ||
created datetime NULL, | ||
modifiedby int NULL, | ||
modified datetime NULL, | ||
Container ENTITYID NOT NULL, | ||
taskid entityid, | ||
qcstate int NULL, | ||
formsort int NULL | ||
|
||
|
||
CONSTRAINT PK_assessment PRIMARY KEY (objectid) | ||
-- ================================================================================================= | ||
-- 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', 'onprcitsupport@ohsu.edu', 'Clinical', @taskId, 1003, 1003 | ||
From studyDataset.c6d178_drug | ||
Where code = 'E-85760' And CONVERT(DATE, date) = CONVERT(DATE, GETDATE()) And qcstate = 18 | ||
End | ||
|
||
GO | ||
END | ||
|
||
GO |
35 changes: 35 additions & 0 deletions
35
onprc_ehr/resources/schemas/dbscripts/sqlserver/onprc_ehr-23.009-23.010.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
CREATE TABLE onprc_ehr.Environmental_Assessment( | ||
rowid int IDENTITY(100,1) NOT NULL, | ||
date datetime NULL, | ||
service_requested varchar(300) NULL, | ||
charge_unit varchar(300) NULL, | ||
testing_location varchar(300) NULL, | ||
test_type varchar(300) NULL, | ||
test_results varchar(100) NULL, | ||
pass_fail varchar(100) NULL, | ||
biological_Cycle varchar(300) NULL, | ||
biological_BI varchar(300) NULL, | ||
action varchar(300) NULL, | ||
performedby varchar(300) NULL, | ||
remarks varchar(300) NULL, | ||
water_source varchar(300) NULL, | ||
surface_tested varchar(300) NULL, | ||
retest varchar(300) NULL, | ||
colony_count varchar(300) NULL, | ||
test_method varchar(300) NULL, | ||
objectid ENTITYID Not Null, | ||
createdby int NULL, | ||
created datetime NULL, | ||
modifiedby int NULL, | ||
modified datetime NULL, | ||
Container ENTITYID NOT NULL, | ||
taskid entityid, | ||
qcstate int NULL, | ||
formsort int NULL | ||
|
||
|
||
CONSTRAINT PK_assessment PRIMARY KEY (objectid) | ||
) | ||
|
||
GO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters