-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhighrisk_sudo.txt
More file actions
71 lines (51 loc) · 2.48 KB
/
highrisk_sudo.txt
File metadata and controls
71 lines (51 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
1. Program encounters - If there is a non-empty array on encounter type 'ANC' for concept ""High risk" Conditions", then add an observation ""High risk"" = "yes". If not, add ""High risk"" = no.
If for child Weight for Height Status == "SAM" or Weight for age Status == "Severely Underweight", then add an observation ""High risk"" = "yes". If not, add ""High risk"" = no.
-- for pregnancy
update program_encounter check "High risk" Conditions(coded concept) column
if size_of("High risk" Conditions) > 0
set "High risk" as yes
else
set "High risk" as no
-- for child
update program_encounter
check if Weight for Height Status == "SAM" or Weight for age Status == "Severely Underweight"
set "High risk" as yes
else
set "High risk" as no
2. Program enrolment - Populate the latest (by encounter date time) value of "High risk" in program encounters of type ANC to the program enrolment
for child take child Followup
-- for pregnancy and for child
write a cte with row_number patition via encounter_date_time desc
take row_number = 1 and join with program enrolment
update program enrolment
set enrolment "High risk" same as encounter "High risk"
3. Program enrolment - If "High risk" not set for it then set as "High risk" no by default
update program_enrolment set "High risk" as no
if "High risk" not available
4. Individual - Populate the latest (by enrolment date time) value of "High risk" from program enrolment into observations of registration
write a cte to with row_number partition via enrolment_date_time desc
take row_number = 1 and join individual
update individual
set individual "High risk" same as enrolment "High risk"
5. Individual - If "High risk" not available then set as "High risk" no
update individual set "High risk" as no
if "High risk" not available
6. Sync attributes - Populate sync attributes of all individual, program_enrolment and program_encounter tables with the "High risk" observation on individual. Here, do not limit to specific programs or encounter types or voided
-- for individual
update individual
set sync
if "High risk" as yes then yes
else no
-- for enrolment
update program_enrolment join with individual
set sync
if individual sync is yes then yes
else no
-- for encounter
update program_encounter join with individual
set sync
if individual sync is yes then yes
else no
7. Group Subject - Set sync concept value as no
update group Subject
set sync as no