Skip to content

Commit 627107b

Browse files
authored
24.11 fb tissue distribution historical updates (#1353)
* Created a new program that will process all past historical Tissue Distribution records so that they will have a taskid recorded in their records. * Created a program that updates Tissue Distribution records so that they can be viewed on Prime. * Modified Tissue Distribution historical program * Modified program to include versioin njumberfor th scripts. * Modified program to include version number of the file scripts and xml declarations
1 parent 1ddf338 commit 627107b

3 files changed

Lines changed: 232 additions & 1 deletion

File tree

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
2+
CREATE TABLE onprc_ehr.Rpt_AnimalIDTissues(
3+
[Searchkey] [int] IDENTITY(1,1) NOT NULL,
4+
[animalID] varchar(100) NULL,
5+
[date] smalldatetime NULL
6+
7+
8+
) ON [PRIMARY]
9+
GO
10+
11+
CREATE TABLE onprc_ehr.Rpt_AnimalIDTissues_Master(
12+
[rowid] [int] IDENTITY(1,1) NOT NULL,
13+
[SearchID] int NULL,
14+
[animalID] varchar(100) NULL,
15+
[date] smalldatetime NULL,
16+
[actual_Created] smalldatetime NUll,
17+
[remarks] varchar(500)
18+
19+
20+
) ON [PRIMARY]
21+
GO
22+
23+
24+
25+
/*
26+
**
27+
** Created by Date
28+
**
29+
** Blasa 4/4/2025 Process to attached Tissues Distribution records to Patholody Tissue records
30+
**
31+
**
32+
33+
**
34+
**
35+
**
36+
**
37+
**
38+
39+
**
40+
**
41+
**
42+
*/
43+
44+
45+
CREATE Procedure [onprc_ehr].[sp_RptNecropsyTissueDistributionUpdates]
46+
@StartDate SmallDateTime,
47+
@EndDate SmallDateTime
48+
49+
50+
51+
52+
AS
53+
54+
55+
56+
DECLARE @ReturnValue Int,
57+
@SearchKey Int,
58+
@TempsearchKey Int,
59+
@TaskId varchar(4000),
60+
@ObjectId Varchar(4000),
61+
@AnimalID varchar(100),
62+
@Date smalldatetime,
63+
@Created smalldatetime,
64+
@Createdby smallint,
65+
@modified smalldatetime,
66+
@modifiedby smallint ,
67+
@RunID varchar(4000)
68+
69+
Begin
70+
71+
72+
----- Reset Temp Table
73+
74+
Set @Returnvalue = 0
75+
76+
77+
78+
Delete onprc_ehr.Rpt_AnimalIDTissues
79+
80+
81+
If @@Error <> 0
82+
GoTo Err_Proc
83+
84+
85+
----Create the set of records to process
86+
87+
Insert into onprc_ehr.Rpt_AnimalIDTissues
88+
select distinct
89+
e.participantid,
90+
e.date
91+
92+
93+
from studydataset.c6d265_tissuedistributions e
94+
95+
Where (e.date >= @StartDate And e.date < Dateadd(day,1,@EndDate) )
96+
And e.qcstate = 18
97+
order by e.participantid, e.date
98+
99+
100+
101+
If @@Error <> 0
102+
GoTo Err_Proc
103+
104+
105+
106+
Set @TempsearchKey = 0
107+
Set @SearchKey = 0
108+
Set @TaskID = null
109+
110+
Select Top 1 @Searchkey = Searchkey from onprc_ehr.Rpt_AnimalIDTissues
111+
Order by Searchkey
112+
113+
114+
While @TempSearchKey < @SearchKey
115+
Begin
116+
117+
------ Create a task record
118+
119+
Set @TaskID = NEWID()
120+
121+
122+
Insert into EHR.Tasks
123+
(
124+
taskid,
125+
description,
126+
title,
127+
qcstate,
128+
formType,
129+
category,
130+
container,
131+
assignedto,
132+
created,
133+
createdby,
134+
modified,
135+
modifiedby
136+
137+
)
138+
139+
Values (
140+
141+
@TaskID,
142+
'Path Tissues ' + cast(@Date as varchar(50)) , ------ Title
143+
'PathologyTissues',
144+
18, --- Qc State (In Progress)
145+
'PathologyTissues', ------ FormType
146+
'task', ----- category,
147+
'CD17027B-C55F-102F-9907-5107380A54BE', ---- EHR Container
148+
1693, -------- Assigned To DCM Pathology
149+
getdate(), ------- Created Date
150+
1042, -------- Created By IS
151+
getdate(), ------- Modified Date
152+
1042 ----- Modified by IS
153+
154+
)
155+
156+
If @@Error <> 0
157+
GoTo Err_Proc
158+
159+
160+
161+
Select @AnimalID = rpt.AnimalID, @Date= rpt.date, @Created=TDS.created, @Createdby= TDS.createdby, @modified = TDS.modified
162+
from studydataset.c6d265_tissuedistributions TDS, onprc_ehr.Rpt_AnimalIDTissues Rpt
163+
Where TDS.participantid = Rpt.AnimalID
164+
And TDS.date = RPT.date And Rpt.searchkey = @Searchkey
165+
166+
167+
If exists (Select * from studydataset.c6d265_tissuedistributions Where participantid = @AnimalID And date = @date)
168+
Begin
169+
Update TDS
170+
set TDS.taskid = @TaskID
171+
172+
from studydataset.c6d265_tissuedistributions TDS
173+
Where TDS.participantid = @AnimalID
174+
And TDS.date = @Date
175+
176+
177+
If @@Error <> 0
178+
GoTo Err_Proc
179+
180+
End --
181+
182+
183+
Set @TempSearchkey = @SearchKey
184+
185+
186+
Select Top 1 @Searchkey = Searchkey from onprc_ehr.Rpt_AnimalIDTissues
187+
Where Searchkey > @TempSearchkey
188+
Order by Searchkey
189+
190+
191+
End -----(While)
192+
193+
------- Create a audit records
194+
195+
Insert into onprc_ehr.Rpt_AnimalidTissues_Master
196+
Select *,
197+
getdate(),
198+
'Tissue Distribution entries'
199+
from onprc_ehr.Rpt_AnimalIDTissues
200+
201+
202+
RETURN 0
203+
204+
Err_Proc:
205+
206+
Return 1
207+
208+
209+
END
210+
211+
GO
212+

onprc_ehr/resources/schemas/onprc_ehr.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,5 +1398,24 @@
13981398
<column columnName="remark"/>
13991399
</columns>
14001400
</table>
1401+
<table tableName="Rpt_AnimalIDTissues" tableDbType="TABLE">
1402+
<columns>
1403+
<column columnName="Searchkey"/>
1404+
<column columnName="animalID"/>
1405+
<column columnName="date"/>
1406+
</columns>
1407+
</table>
1408+
1409+
<table tableName="Rpt_AnimalIDTissues_Master" tableDbType="TABLE">
1410+
<columns>
1411+
<column columnName="rowid"/>
1412+
<column columnName="SearchID"/>
1413+
<column columnName="animalID"/>
1414+
<column columnName="date"/>
1415+
<column columnName="actual_Created"/>
1416+
<column columnName="remarks"/>
1417+
</columns>
1418+
</table>
1419+
14011420

14021421
</tables>

onprc_ehr/src/org/labkey/onprc_ehr/ONPRC_EHRModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public String getName()
129129
@Override
130130
public @Nullable Double getSchemaVersion()
131131
{
132-
return 24.008;
132+
return 24.009;
133133
}
134134

135135
@Override

0 commit comments

Comments
 (0)