meta-edc 1.1.12__py3-none-any.whl → 1.1.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of meta-edc might be problematic. Click here for more details.
- meta_ae/action_items.py +15 -18
- meta_dashboard/view_utils/subject_screening_button.py +3 -3
- {meta_edc-1.1.12.dist-info → meta_edc-1.1.14.dist-info}/METADATA +7 -6
- {meta_edc-1.1.12.dist-info → meta_edc-1.1.14.dist-info}/RECORD +8 -7
- meta_rando/randomizers.py +1 -1
- meta_reports/migrations/0060_auto_20250926_0242.py +366 -0
- {meta_edc-1.1.12.dist-info → meta_edc-1.1.14.dist-info}/WHEEL +0 -0
- {meta_edc-1.1.12.dist-info → meta_edc-1.1.14.dist-info}/licenses/LICENSE +0 -0
meta_ae/action_items.py
CHANGED
|
@@ -43,7 +43,7 @@ class AeFollowupAction(ActionWithNotification):
|
|
|
43
43
|
name = AE_FOLLOWUP_ACTION
|
|
44
44
|
display_name = "Submit AE Followup Report"
|
|
45
45
|
notification_display_name = "AE Followup Report"
|
|
46
|
-
parent_action_names =
|
|
46
|
+
parent_action_names = (AE_INITIAL_ACTION, AE_FOLLOWUP_ACTION)
|
|
47
47
|
reference_model = "meta_ae.aefollowup"
|
|
48
48
|
related_reference_model = "meta_ae.aeinitial"
|
|
49
49
|
related_reference_fk_attr = "ae_initial"
|
|
@@ -61,7 +61,7 @@ class AeFollowupAction(ActionWithNotification):
|
|
|
61
61
|
priority = HIGH_PRIORITY
|
|
62
62
|
|
|
63
63
|
def get_next_actions(self):
|
|
64
|
-
next_actions =
|
|
64
|
+
next_actions = ()
|
|
65
65
|
|
|
66
66
|
# add AE followup to next_actions if followup.
|
|
67
67
|
next_actions = self.append_to_next_if_required(
|
|
@@ -98,14 +98,14 @@ class AeInitialAction(ActionWithNotification):
|
|
|
98
98
|
name = AE_INITIAL_ACTION
|
|
99
99
|
display_name = "Submit AE Initial Report"
|
|
100
100
|
notification_display_name = "AE Initial Report"
|
|
101
|
-
parent_action_names =
|
|
101
|
+
parent_action_names = (
|
|
102
102
|
BLOOD_RESULTS_LIPIDS_ACTION,
|
|
103
103
|
BLOOD_RESULTS_GLU_ACTION,
|
|
104
104
|
BLOOD_RESULTS_LFT_ACTION,
|
|
105
105
|
BLOOD_RESULTS_RFT_ACTION,
|
|
106
106
|
BLOOD_RESULTS_FBC_ACTION,
|
|
107
107
|
FOLLOWUP_EXAMINATION_ACTION,
|
|
108
|
-
|
|
108
|
+
)
|
|
109
109
|
reference_model = "meta_ae.aeinitial"
|
|
110
110
|
show_link_to_changelist = True
|
|
111
111
|
show_link_to_add = True
|
|
@@ -118,7 +118,7 @@ class AeInitialAction(ActionWithNotification):
|
|
|
118
118
|
|
|
119
119
|
1. Add death report action if death
|
|
120
120
|
"""
|
|
121
|
-
next_actions =
|
|
121
|
+
next_actions = ()
|
|
122
122
|
deceased = (
|
|
123
123
|
self.reference_obj.ae_grade == GRADE5 or self.reference_obj.sae_reason.name == DEAD
|
|
124
124
|
)
|
|
@@ -156,20 +156,18 @@ class AeInitialAction(ActionWithNotification):
|
|
|
156
156
|
required=self.reference_obj.ae_grade == GRADE4,
|
|
157
157
|
)
|
|
158
158
|
# add next AeTmgAction if G3 and is an SAE
|
|
159
|
-
|
|
159
|
+
return self.append_to_next_if_required(
|
|
160
160
|
next_actions=next_actions,
|
|
161
161
|
action_name=AE_TMG_ACTION,
|
|
162
162
|
required=(self.reference_obj.ae_grade == GRADE3 and self.reference_obj.sae == YES),
|
|
163
163
|
)
|
|
164
164
|
|
|
165
|
-
return next_actions
|
|
166
|
-
|
|
167
165
|
|
|
168
166
|
class AeSusarAction(ActionWithNotification):
|
|
169
167
|
name = AE_SUSAR_ACTION
|
|
170
168
|
display_name = "Submit AE SUSAR Report"
|
|
171
169
|
notification_display_name = "AE SUSAR Report"
|
|
172
|
-
parent_action_names =
|
|
170
|
+
parent_action_names = (AE_INITIAL_ACTION,)
|
|
173
171
|
reference_model = "meta_ae.aesusar"
|
|
174
172
|
related_reference_model = "meta_ae.aeinitial"
|
|
175
173
|
related_reference_fk_attr = "ae_initial"
|
|
@@ -184,7 +182,7 @@ class AeTmgAction(ActionWithNotification):
|
|
|
184
182
|
name = AE_TMG_ACTION
|
|
185
183
|
display_name = "TMG AE Report pending"
|
|
186
184
|
notification_display_name = "TMG AE Report"
|
|
187
|
-
parent_action_names =
|
|
185
|
+
parent_action_names = (AE_INITIAL_ACTION, AE_FOLLOWUP_ACTION, AE_TMG_ACTION)
|
|
188
186
|
reference_model = "meta_ae.aetmg"
|
|
189
187
|
related_reference_model = "meta_ae.aeinitial"
|
|
190
188
|
related_reference_fk_attr = "ae_initial"
|
|
@@ -204,13 +202,13 @@ class DeathReportAction(PregnancyActionItemMixin, ActionWithNotification):
|
|
|
204
202
|
display_name = "Submit Death Report"
|
|
205
203
|
notification_display_name = "Death Report"
|
|
206
204
|
reference_model = "meta_ae.deathreport"
|
|
207
|
-
parent_action_names =
|
|
205
|
+
parent_action_names = (AE_INITIAL_ACTION, AE_FOLLOWUP_ACTION)
|
|
208
206
|
show_link_to_changelist = True
|
|
209
207
|
show_link_to_add = True
|
|
210
208
|
admin_site_name = "meta_ae_admin"
|
|
211
209
|
priority = HIGH_PRIORITY
|
|
212
210
|
singleton = True
|
|
213
|
-
dirty_fields =
|
|
211
|
+
dirty_fields = ("cause_of_death",)
|
|
214
212
|
|
|
215
213
|
def get_next_actions(self):
|
|
216
214
|
"""Adds 1 DEATHReportTMG if not yet created and
|
|
@@ -242,7 +240,7 @@ class DeathReportTmgAction(ActionWithNotification):
|
|
|
242
240
|
name = DEATH_REPORT_TMG_ACTION
|
|
243
241
|
display_name = "TMG Death Report pending"
|
|
244
242
|
notification_display_name = "TMG Death Report"
|
|
245
|
-
parent_action_names =
|
|
243
|
+
parent_action_names = (DEATH_REPORT_ACTION, DEATH_REPORT_TMG_ACTION)
|
|
246
244
|
reference_model = "meta_ae.deathreporttmg"
|
|
247
245
|
related_reference_model = "meta_ae.deathreport"
|
|
248
246
|
related_reference_fk_attr = "death_report"
|
|
@@ -301,12 +299,11 @@ class DeathReportTmgAction(ActionWithNotification):
|
|
|
301
299
|
)
|
|
302
300
|
.count()
|
|
303
301
|
< 2
|
|
302
|
+
) and (
|
|
303
|
+
self.reference_obj.cause_of_death
|
|
304
|
+
!= self.related_action_item.reference_obj.cause_of_death
|
|
304
305
|
):
|
|
305
|
-
|
|
306
|
-
self.reference_obj.cause_of_death
|
|
307
|
-
!= self.related_action_item.reference_obj.cause_of_death
|
|
308
|
-
):
|
|
309
|
-
next_actions = ["self"]
|
|
306
|
+
next_actions = ["self"]
|
|
310
307
|
return next_actions
|
|
311
308
|
|
|
312
309
|
|
|
@@ -42,7 +42,7 @@ class SubjectScreeningButton(BaseSubjectScreeningButton):
|
|
|
42
42
|
|
|
43
43
|
@dataclass
|
|
44
44
|
class SubjectScreeningPartOneButton(SubjectScreeningButton):
|
|
45
|
-
model_obj: ScreeningPartOne = None
|
|
45
|
+
model_obj: ScreeningPartOne | None = None
|
|
46
46
|
model_cls: type[ScreeningPartOne] = field(default=ScreeningPartOne)
|
|
47
47
|
|
|
48
48
|
@property
|
|
@@ -52,7 +52,7 @@ class SubjectScreeningPartOneButton(SubjectScreeningButton):
|
|
|
52
52
|
|
|
53
53
|
@dataclass
|
|
54
54
|
class SubjectScreeningPartTwoButton(SubjectScreeningButton):
|
|
55
|
-
model_obj: ScreeningPartTwo = None
|
|
55
|
+
model_obj: ScreeningPartTwo | None = None
|
|
56
56
|
model_cls: type[ScreeningPartTwo] = field(default=ScreeningPartTwo)
|
|
57
57
|
|
|
58
58
|
@property
|
|
@@ -84,7 +84,7 @@ class SubjectScreeningPartTwoButton(SubjectScreeningButton):
|
|
|
84
84
|
|
|
85
85
|
@dataclass
|
|
86
86
|
class SubjectScreeningPartThreeButton(SubjectScreeningButton):
|
|
87
|
-
model_obj: ScreeningPartThree = None
|
|
87
|
+
model_obj: ScreeningPartThree | None = None
|
|
88
88
|
model_cls: type[ScreeningPartThree] = field(default=ScreeningPartThree)
|
|
89
89
|
|
|
90
90
|
@property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meta-edc
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.14
|
|
4
4
|
Summary: META Trial EDC (https://www.isrctn.com/ISRCTN76157257)
|
|
5
5
|
Keywords: django,clinicedc,META EDC,EDC,clinical trials,META Trial,ISRCTN76157257
|
|
6
6
|
Author: Erik van Widenfelt, Jonathan Willitts
|
|
@@ -15,13 +15,14 @@ Classifier: Intended Audience :: Science/Research
|
|
|
15
15
|
Classifier: Operating System :: OS Independent
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
-
Requires-Dist: clinicedc>=2.0.
|
|
18
|
+
Requires-Dist: clinicedc>=2.0.25
|
|
19
19
|
Requires-Dist: edc-he>=1.1.0
|
|
20
20
|
Requires-Dist: edc-microscopy>=1.1.1
|
|
21
21
|
Requires-Dist: edc-mnsi>=1.1.3
|
|
22
22
|
Requires-Dist: edc-phq9>=1.0.1
|
|
23
23
|
Requires-Dist: edc-qol>=1.1.2
|
|
24
|
-
Requires-
|
|
24
|
+
Requires-Dist: psycopg2>=2.9.10
|
|
25
|
+
Requires-Python: >=3.12, <3.14
|
|
25
26
|
Description-Content-Type: text/x-rst
|
|
26
27
|
|
|
27
28
|
|pypi| |actions| |codecov| |downloads| |clinicedc|
|
|
@@ -88,8 +89,8 @@ Assuming you are logged into the account ``myaccount``:
|
|
|
88
89
|
mkdir ~/edc && \
|
|
89
90
|
cd ~/edc && \
|
|
90
91
|
uv venv && \
|
|
91
|
-
uv pip install -U meta-edc==1.1.
|
|
92
|
-
wget https://raw.githubusercontent.com/meta-trial/meta-edc/1.1.
|
|
92
|
+
uv pip install -U meta-edc==1.1.13 && \
|
|
93
|
+
wget https://raw.githubusercontent.com/meta-trial/meta-edc/1.1.13/manage.py && \
|
|
93
94
|
uv pip freeze | grep meta-edc
|
|
94
95
|
|
|
95
96
|
Copy your ``.env`` file to ``~/.etc``.
|
|
@@ -139,7 +140,7 @@ From the above example:
|
|
|
139
140
|
|
|
140
141
|
cd ~/edc && \
|
|
141
142
|
uv venv --clear && \
|
|
142
|
-
uv pip install -U meta-edc==1.1.
|
|
143
|
+
uv pip install -U meta-edc==1.1.13 && \
|
|
143
144
|
wget -O manage.py https://raw.githubusercontent.com/meta-trial/meta-edc/1.1.10/manage.py && \
|
|
144
145
|
uv pip freeze | grep meta-edc && \
|
|
145
146
|
python manage.py check
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
meta_ae/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
meta_ae/action_items.py,sha256=
|
|
2
|
+
meta_ae/action_items.py,sha256=En5TW-eKihIaaR9NlLky1iPQXKKdvcZ2rFZgXW4SDs4,11386
|
|
3
3
|
meta_ae/admin/__init__.py,sha256=9-rzs_MPw54bbD29CDmoufTnSOBJgphPfEjv6L6gpS0,610
|
|
4
4
|
meta_ae/admin/ae_followup_admin.py,sha256=0JNXm-wI7QFlxKR5O_KKbz-ZA7tG_e0Ei7zu28i-qDs,484
|
|
5
5
|
meta_ae/admin/ae_initial_admin.py,sha256=npZV7o1TVB_jQSRCVD_fK4UR991OF4lh1ezWVXFHEuc,913
|
|
@@ -196,7 +196,7 @@ meta_dashboard/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
|
196
196
|
meta_dashboard/templatetags/meta_dashboard_extras.py,sha256=e_6NxocyfQ-ZNuhoRy5X_jKailKkOMNtDL-FVYMANck,3652
|
|
197
197
|
meta_dashboard/urls.py,sha256=Nr9bQyY82rzsYecbD2hClGsiAfcT5UQIiwbKSalbHyg,1193
|
|
198
198
|
meta_dashboard/view_utils/__init__.py,sha256=2O0Jvf-bdCU9SZRNhozeHMPax3qHUr-ts24d5khOKQk,335
|
|
199
|
-
meta_dashboard/view_utils/subject_screening_button.py,sha256=
|
|
199
|
+
meta_dashboard/view_utils/subject_screening_button.py,sha256=zxeQsELFkC263DlaEEvw6CfKc2SwrEem4r_IuyGe3U0,3220
|
|
200
200
|
meta_dashboard/views/__init__.py,sha256=7AT2QxwhggrtA_EYvIad6XhoBB8Q8aPi949JBG1lagc,378
|
|
201
201
|
meta_dashboard/views/ae/__init__.py,sha256=UVrz4wSiJInvGsWKwSfpLISXJY98sJpvGSq44IxFkpA,172
|
|
202
202
|
meta_dashboard/views/ae/ae_listboard_view.py,sha256=CnHBeQkLJaWYMxP0LBo110OverSiKgncRoqSw0xZaLw,468
|
|
@@ -453,7 +453,7 @@ meta_rando/migrations/0005_alter_randomizationlist_options_and_more.py,sha256=GB
|
|
|
453
453
|
meta_rando/migrations/0006_alter_historicalrandomizationlist_allocated_user_and_more.py,sha256=XS6srUOHPAJWqsTLLPCHmcIKlOkEky95JrH1739gL2w,4584
|
|
454
454
|
meta_rando/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
455
455
|
meta_rando/models.py,sha256=GYFxlzBRcihpSe1tpfLGkD1NaMKA6kfGhgv-cz5hqk8,532
|
|
456
|
-
meta_rando/randomizers.py,sha256=
|
|
456
|
+
meta_rando/randomizers.py,sha256=GpsV3kkqd-HupfnQw6Y7R172ZpOEpIbmVkXOwsOf-HA,1592
|
|
457
457
|
meta_reports/__init__.py,sha256=huYR-GaImMWZqv6puEYfY7y_8m1OA_hRVXRYNBvNLkQ,80
|
|
458
458
|
meta_reports/admin/__init__.py,sha256=V-rlMJJZCgnDaMOwk5PgZNIclOp_FW2y9yc-iCLQFHA,910
|
|
459
459
|
meta_reports/admin/dbviews/__init__.py,sha256=qKaXgFKLUaRZ9IbeRVuPWCkltAyXi4a91D7I8gQ7D7Q,1024
|
|
@@ -543,6 +543,7 @@ meta_reports/migrations/0056_auto_20250422_2214.py,sha256=Tv1hp6K4GlSfUs-c7dzydP
|
|
|
543
543
|
meta_reports/migrations/0057_auto_20250422_2224.py,sha256=pGj-5Cr__ScaNtb8ROzm_4_Ke6jR8QlIIeXFAwiA5f8,9457
|
|
544
544
|
meta_reports/migrations/0058_auto_20250422_2232.py,sha256=SZ2RS5jUVhgnirgU2XAU-EIDtsbUWD1GDl5jg_hMTrc,9743
|
|
545
545
|
meta_reports/migrations/0059_alter_endpoints_created_and_more.py,sha256=pLpV2JkdlclK9J7zwMrEvHsORk7zKBIWoo8RkvaraPs,5633
|
|
546
|
+
meta_reports/migrations/0060_auto_20250926_0242.py,sha256=gdaOXPmSHFj7W8u94dAi45oL6w_c8f0d0GH-RoOmRNQ,192265
|
|
546
547
|
meta_reports/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
547
548
|
meta_reports/models/__init__.py,sha256=uWbQPzDXUxdfuau5aaUDkqMynJeMOKgS5e-8xjuD53A,798
|
|
548
549
|
meta_reports/models/dbviews/README,sha256=GdeboB7Xqb-Qo_rE1ondcxP8Ps93MIjLzCePQCePig0,686
|
|
@@ -1130,7 +1131,7 @@ meta_visit_schedule/visit_schedules/phase_three/schedule.py,sha256=LU1HRaV6o1UeK
|
|
|
1130
1131
|
meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py,sha256=q12p5wXc2D7lSiJVBnoSQw8Q3vL6uDx1t3PuDJO-Z-U,1735
|
|
1131
1132
|
meta_visit_schedule/visit_schedules/phase_three/schedule_pregnancy.py,sha256=bEpbpCX3vfZmnsqudr0z8PU5kiaX4ws1sO5Im98Mo28,1106
|
|
1132
1133
|
meta_visit_schedule/visit_schedules/phase_three/visit_schedule.py,sha256=ak4qazeKlpIlvpqrK9hDDO0fwWuWyvb4Ec-JU31IJxc,654
|
|
1133
|
-
meta_edc-1.1.
|
|
1134
|
-
meta_edc-1.1.
|
|
1135
|
-
meta_edc-1.1.
|
|
1136
|
-
meta_edc-1.1.
|
|
1134
|
+
meta_edc-1.1.14.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
1135
|
+
meta_edc-1.1.14.dist-info/WHEEL,sha256=-neZj6nU9KAMg2CnCY6T3w8J53nx1kFGw_9HfoSzM60,79
|
|
1136
|
+
meta_edc-1.1.14.dist-info/METADATA,sha256=oTdRVUZ9lAmHSleA-Ej5I9G8kOfi1wKSERJGo8wUJrc,5168
|
|
1137
|
+
meta_edc-1.1.14.dist-info/RECORD,,
|
meta_rando/randomizers.py
CHANGED
|
@@ -30,7 +30,7 @@ class RandomizerPhaseThree(Randomizer):
|
|
|
30
30
|
model = "meta_rando.randomizationlist"
|
|
31
31
|
filename = "randomization_list_phase_three.csv"
|
|
32
32
|
importer_cls = RandomizationListImporterPhaseThree
|
|
33
|
-
extra_csv_fieldnames =
|
|
33
|
+
extra_csv_fieldnames = ("gender",)
|
|
34
34
|
|
|
35
35
|
def __init__(self, gender=None, **kwargs):
|
|
36
36
|
self.gender = gender
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
# Generated by Django 5.2.6 on 2025-09-25 23:42
|
|
2
|
+
|
|
3
|
+
import django_db_views.migration_functions
|
|
4
|
+
import django_db_views.operations
|
|
5
|
+
from django.db import migrations
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Migration(migrations.Migration):
|
|
9
|
+
|
|
10
|
+
dependencies = [
|
|
11
|
+
("meta_reports", "0059_alter_endpoints_created_and_more"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
operations = [
|
|
15
|
+
django_db_views.operations.ViewRunPython(
|
|
16
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
17
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.glucosesummaryview' as `report_model` from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS `ogtt_value`, NULL AS `ogtt_units`, NULL AS `ogtt_datetime`, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
18
|
+
"meta_reports_glucosesummaryview",
|
|
19
|
+
engine="django.db.backends.mysql",
|
|
20
|
+
),
|
|
21
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
22
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.glucosesummaryview' as `report_model` from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS `ogtt_value`, NULL AS `ogtt_units`, NULL AS `ogtt_datetime`, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
23
|
+
"meta_reports_glucosesummaryview",
|
|
24
|
+
engine="django.db.backends.mysql",
|
|
25
|
+
),
|
|
26
|
+
atomic=False,
|
|
27
|
+
),
|
|
28
|
+
django_db_views.operations.ViewRunPython(
|
|
29
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
30
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.glucosesummaryview' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_units\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
31
|
+
"meta_reports_glucosesummaryview",
|
|
32
|
+
engine="django.db.backends.postgresql",
|
|
33
|
+
),
|
|
34
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
35
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.glucosesummaryview' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_units\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
36
|
+
"meta_reports_glucosesummaryview",
|
|
37
|
+
engine="django.db.backends.postgresql",
|
|
38
|
+
),
|
|
39
|
+
atomic=False,
|
|
40
|
+
),
|
|
41
|
+
django_db_views.operations.ViewRunPython(
|
|
42
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
43
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.glucosesummaryview' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_units\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
44
|
+
"meta_reports_glucosesummaryview",
|
|
45
|
+
engine="django.db.backends.sqlite3",
|
|
46
|
+
),
|
|
47
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
48
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.glucosesummaryview' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_units\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucosefbg' AS source FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_units, fbg_datetime, ogtt_value, ogtt_units, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.report_datetime, v.appointment_id, eos.offstudy_datetime, fasting_duration_delta, 'meta_subject.glucose' AS source FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
49
|
+
"meta_reports_glucosesummaryview",
|
|
50
|
+
engine="django.db.backends.sqlite3",
|
|
51
|
+
),
|
|
52
|
+
atomic=False,
|
|
53
|
+
),
|
|
54
|
+
django_db_views.operations.ViewRunPython(
|
|
55
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
56
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.imp_subjectitutions_view' as `report_model` from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
57
|
+
"imp_subjectitutions_view",
|
|
58
|
+
engine="django.db.backends.mysql",
|
|
59
|
+
),
|
|
60
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
61
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.imp_subjectitutions_view' as `report_model` from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
62
|
+
"imp_subjectitutions_view",
|
|
63
|
+
engine="django.db.backends.mysql",
|
|
64
|
+
),
|
|
65
|
+
atomic=False,
|
|
66
|
+
),
|
|
67
|
+
django_db_views.operations.ViewRunPython(
|
|
68
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
69
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.imp_subjectitutions_view' as report_model from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier NULLS FIRST) as A ORDER BY subject_identifier, site_id",
|
|
70
|
+
"imp_subjectitutions_view",
|
|
71
|
+
engine="django.db.backends.postgresql",
|
|
72
|
+
),
|
|
73
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
74
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.imp_subjectitutions_view' as report_model from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier NULLS FIRST) as A ORDER BY subject_identifier, site_id",
|
|
75
|
+
"imp_subjectitutions_view",
|
|
76
|
+
engine="django.db.backends.postgresql",
|
|
77
|
+
),
|
|
78
|
+
atomic=False,
|
|
79
|
+
),
|
|
80
|
+
django_db_views.operations.ViewRunPython(
|
|
81
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
82
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.imp_subjectitutions_view' as report_model from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
83
|
+
"imp_subjectitutions_view",
|
|
84
|
+
engine="django.db.backends.sqlite3",
|
|
85
|
+
),
|
|
86
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
87
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.imp_subjectitutions_view' as report_model from (SELECT s.subject_identifier, s.sid, s.dispensed_sid, arm_match, s.report_datetime, r.allocated_datetime, s.site_id, s.user_created, s.user_modified, s.modified, s.id AS original_id FROM meta_pharmacy_substitutions AS s LEFT JOIN meta_rando_randomizationlist AS r ON r.subject_identifier = s.subject_identifier ORDER BY s.subject_identifier) as A ORDER BY subject_identifier, site_id",
|
|
88
|
+
"imp_subjectitutions_view",
|
|
89
|
+
engine="django.db.backends.sqlite3",
|
|
90
|
+
),
|
|
91
|
+
atomic=False,
|
|
92
|
+
),
|
|
93
|
+
django_db_views.operations.ViewRunPython(
|
|
94
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
95
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.missing_screening_ogtt_view' as `report_model` from (SELECT screening_identifier, site_id, report_datetime AS `screening_datetime`, fbg_datetime, converted_fbg_value AS `fbg_value`, converted_ogtt_value AS `ogtt_value`, fbg2_value, ogtt2_value, repeat_glucose_performed AS `repeated`, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS `subject_identifier`, id AS `original_id` FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> 'Yes') as A ORDER BY subject_identifier, site_id",
|
|
96
|
+
"missing_screening_ogtt_view",
|
|
97
|
+
engine="django.db.backends.mysql",
|
|
98
|
+
),
|
|
99
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
100
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.missing_screening_ogtt_view' as `report_model` from (SELECT screening_identifier, site_id, report_datetime AS `screening_datetime`, fbg_datetime, converted_fbg_value AS `fbg_value`, converted_ogtt_value AS `ogtt_value`, fbg2_value, ogtt2_value, repeat_glucose_performed AS `repeated`, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS `subject_identifier`, id AS `original_id` FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> 'Yes') as A ORDER BY subject_identifier, site_id",
|
|
101
|
+
"missing_screening_ogtt_view",
|
|
102
|
+
engine="django.db.backends.mysql",
|
|
103
|
+
),
|
|
104
|
+
atomic=False,
|
|
105
|
+
),
|
|
106
|
+
django_db_views.operations.ViewRunPython(
|
|
107
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
108
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
|
|
109
|
+
"missing_screening_ogtt_view",
|
|
110
|
+
engine="django.db.backends.postgresql",
|
|
111
|
+
),
|
|
112
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
113
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
|
|
114
|
+
"missing_screening_ogtt_view",
|
|
115
|
+
engine="django.db.backends.postgresql",
|
|
116
|
+
),
|
|
117
|
+
atomic=False,
|
|
118
|
+
),
|
|
119
|
+
django_db_views.operations.ViewRunPython(
|
|
120
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
121
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
|
|
122
|
+
"missing_screening_ogtt_view",
|
|
123
|
+
engine="django.db.backends.sqlite3",
|
|
124
|
+
),
|
|
125
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
126
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
|
|
127
|
+
"missing_screening_ogtt_view",
|
|
128
|
+
engine="django.db.backends.sqlite3",
|
|
129
|
+
),
|
|
130
|
+
atomic=False,
|
|
131
|
+
),
|
|
132
|
+
django_db_views.operations.ViewRunPython(
|
|
133
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
134
|
+
"select *, uuid() as id, now() as `created`, 'onstudy_missing_lab_values_view' as `report_model` from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
135
|
+
"onstudy_missing_lab_values_view",
|
|
136
|
+
engine="django.db.backends.mysql",
|
|
137
|
+
),
|
|
138
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
139
|
+
"select *, uuid() as id, now() as `created`, 'onstudy_missing_lab_values_view' as `report_model` from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
140
|
+
"onstudy_missing_lab_values_view",
|
|
141
|
+
engine="django.db.backends.mysql",
|
|
142
|
+
),
|
|
143
|
+
atomic=False,
|
|
144
|
+
),
|
|
145
|
+
django_db_views.operations.ViewRunPython(
|
|
146
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
147
|
+
"select *, get_random_uuid() as id, now() as created, 'onstudy_missing_lab_values_view' as report_model from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
148
|
+
"onstudy_missing_lab_values_view",
|
|
149
|
+
engine="django.db.backends.postgresql",
|
|
150
|
+
),
|
|
151
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
152
|
+
"select *, get_random_uuid() as id, now() as created, 'onstudy_missing_lab_values_view' as report_model from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
153
|
+
"onstudy_missing_lab_values_view",
|
|
154
|
+
engine="django.db.backends.postgresql",
|
|
155
|
+
),
|
|
156
|
+
atomic=False,
|
|
157
|
+
),
|
|
158
|
+
django_db_views.operations.ViewRunPython(
|
|
159
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
160
|
+
"select *, uuid() as id, datetime() as created, 'onstudy_missing_lab_values_view' as report_model from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
161
|
+
"onstudy_missing_lab_values_view",
|
|
162
|
+
engine="django.db.backends.sqlite3",
|
|
163
|
+
),
|
|
164
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
165
|
+
"select *, uuid() as id, datetime() as created, 'onstudy_missing_lab_values_view' as report_model from (SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsfbc AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'fbc' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultsrft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'RFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslft AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LFT' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT req.subject_identifier, req.id AS original_id, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS requisitioned but not entered' AS label, COUNT(*) AS records FROM meta_subject_subjectrequisition AS req LEFT JOIN meta_subject_bloodresultslipids AS crf ON req.id = crf.requisition_id LEFT JOIN meta_subject_subjectvisit AS v ON v.id = req.subject_visit_id LEFT JOIN edc_lab_panel AS panel ON req.panel_id = panel.id WHERE panel.name = 'LIPIDS' AND req.is_drawn = 'Yes' AND crf.id IS NULL GROUP BY req.id, req.subject_identifier, req.subject_visit_id, req.report_datetime, req.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, req.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing haemoglobin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.haemoglobin_value IS NULL OR crf.haemoglobin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing hct value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hct_value IS NULL OR crf.hct_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing rbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.rbc_value IS NULL OR crf.rbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing wbc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.wbc_value IS NULL OR crf.wbc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing platelets value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.platelets_value IS NULL OR crf.platelets_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mcv value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mcv_value IS NULL OR crf.mcv_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mch value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mch_value IS NULL OR crf.mch_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsfbc' AS label_lower, 'FBC: missing mchc value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsfbc AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.mchc_value IS NULL OR crf.mchc_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing urea value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.urea_value IS NULL OR crf.urea_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing creatinine value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.creatinine_value IS NULL OR crf.creatinine_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing uric_acid value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.uric_acid_value IS NULL OR crf.uric_acid_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_value IS NULL OR crf.egfr_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultsrft' AS label_lower, 'RFT: missing egfr_drop value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultsrft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.egfr_drop_value IS NULL OR crf.egfr_drop_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ast value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ast_value IS NULL OR crf.ast_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alt_value IS NULL OR crf.alt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing alp value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.alp_value IS NULL OR crf.alp_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing amylase value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.amylase_value IS NULL OR crf.amylase_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing ggt value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ggt_value IS NULL OR crf.ggt_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslft' AS label_lower, 'LFT: missing albumin value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslft AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.albumin_value IS NULL OR crf.albumin_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing ldl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.ldl_value IS NULL OR crf.ldl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing hdl value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hdl_value IS NULL OR crf.hdl_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing trig value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.trig_value IS NULL OR crf.trig_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.bloodresultslipids' AS label_lower, 'LIPIDS: missing chol value/units' AS label, COUNT(*) AS records FROM meta_subject_bloodresultslipids AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.chol_value IS NULL OR crf.chol_units IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
166
|
+
"onstudy_missing_lab_values_view",
|
|
167
|
+
engine="django.db.backends.sqlite3",
|
|
168
|
+
),
|
|
169
|
+
atomic=False,
|
|
170
|
+
),
|
|
171
|
+
django_db_views.operations.ViewRunPython(
|
|
172
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
173
|
+
"select *, uuid() as id, now() as `created`, 'onstudy_missing_values_view' as `report_model` from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Weight' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.weight IS NULL AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Waist circumference 36/48m' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.waist_circumference_measured = 'Yes' AND crf.waist_circumference IS NULL) OR (crf.waist_circumference IS NULL AND v.visit_code IN ('1360', '1480') AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
174
|
+
"onstudy_missing_values_view",
|
|
175
|
+
engine="django.db.backends.mysql",
|
|
176
|
+
),
|
|
177
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
178
|
+
"select *, uuid() as id, now() as `created`, 'onstudy_missing_values_view' as `report_model` from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
179
|
+
"onstudy_missing_values_view",
|
|
180
|
+
engine="django.db.backends.mysql",
|
|
181
|
+
),
|
|
182
|
+
atomic=False,
|
|
183
|
+
),
|
|
184
|
+
django_db_views.operations.ViewRunPython(
|
|
185
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
186
|
+
"select *, get_random_uuid() as id, now() as created, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Weight' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.weight IS NULL AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Waist circumference 36/48m' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.waist_circumference_measured = 'Yes' AND crf.waist_circumference IS NULL) OR (crf.waist_circumference IS NULL AND v.visit_code IN ('1360', '1480') AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
187
|
+
"onstudy_missing_values_view",
|
|
188
|
+
engine="django.db.backends.postgresql",
|
|
189
|
+
),
|
|
190
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
191
|
+
"select *, get_random_uuid() as id, now() as created, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
192
|
+
"onstudy_missing_values_view",
|
|
193
|
+
engine="django.db.backends.postgresql",
|
|
194
|
+
),
|
|
195
|
+
atomic=False,
|
|
196
|
+
),
|
|
197
|
+
django_db_views.operations.ViewRunPython(
|
|
198
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
199
|
+
"select *, uuid() as id, datetime() as created, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Weight' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.weight IS NULL AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.followupvitals' AS label_lower, 'Waist circumference 36/48m' AS label, COUNT(*) AS records FROM meta_subject_followupvitals AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (crf.waist_circumference_measured = 'Yes' AND crf.waist_circumference IS NULL) OR (crf.waist_circumference IS NULL AND v.visit_code IN ('1360', '1480') AND v.visit_code_sequence = 0) GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
200
|
+
"onstudy_missing_values_view",
|
|
201
|
+
engine="django.db.backends.sqlite3",
|
|
202
|
+
),
|
|
203
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
204
|
+
"select *, uuid() as id, datetime() as created, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
|
205
|
+
"onstudy_missing_values_view",
|
|
206
|
+
engine="django.db.backends.sqlite3",
|
|
207
|
+
),
|
|
208
|
+
atomic=False,
|
|
209
|
+
),
|
|
210
|
+
django_db_views.operations.ViewRunPython(
|
|
211
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
212
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.patienthistorymissingbaselinecd4' as `report_model` from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
213
|
+
"patient_history_missing_baseline_cd4_view",
|
|
214
|
+
engine="django.db.backends.mysql",
|
|
215
|
+
),
|
|
216
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
217
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.patienthistorymissingbaselinecd4' as `report_model` from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
218
|
+
"patient_history_missing_baseline_cd4_view",
|
|
219
|
+
engine="django.db.backends.mysql",
|
|
220
|
+
),
|
|
221
|
+
atomic=False,
|
|
222
|
+
),
|
|
223
|
+
django_db_views.operations.ViewRunPython(
|
|
224
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
225
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
226
|
+
"patient_history_missing_baseline_cd4_view",
|
|
227
|
+
engine="django.db.backends.postgresql",
|
|
228
|
+
),
|
|
229
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
230
|
+
"select *, get_random_uuid() as id, now() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
231
|
+
"patient_history_missing_baseline_cd4_view",
|
|
232
|
+
engine="django.db.backends.postgresql",
|
|
233
|
+
),
|
|
234
|
+
atomic=False,
|
|
235
|
+
),
|
|
236
|
+
django_db_views.operations.ViewRunPython(
|
|
237
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
238
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
239
|
+
"patient_history_missing_baseline_cd4_view",
|
|
240
|
+
engine="django.db.backends.sqlite3",
|
|
241
|
+
),
|
|
242
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
243
|
+
"select *, uuid() as id, datetime() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
244
|
+
"patient_history_missing_baseline_cd4_view",
|
|
245
|
+
engine="django.db.backends.sqlite3",
|
|
246
|
+
),
|
|
247
|
+
atomic=False,
|
|
248
|
+
),
|
|
249
|
+
django_db_views.operations.ViewRunPython(
|
|
250
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
251
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS `interval_days`, DATEDIFF(NOW(), `first_date`) AS `from_now_days` FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `third_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
252
|
+
"unattended_three_in_row_view",
|
|
253
|
+
engine="django.db.backends.mysql",
|
|
254
|
+
),
|
|
255
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
256
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS `interval_days`, DATEDIFF(NOW(), `first_date`) AS `from_now_days` FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `third_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL) as A ORDER BY subject_identifier, site_id",
|
|
257
|
+
"unattended_three_in_row_view",
|
|
258
|
+
engine="django.db.backends.mysql",
|
|
259
|
+
),
|
|
260
|
+
atomic=False,
|
|
261
|
+
),
|
|
262
|
+
django_db_views.operations.ViewRunPython(
|
|
263
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
264
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "interval_days", CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
|
|
265
|
+
"unattended_three_in_row_view",
|
|
266
|
+
engine="django.db.backends.postgresql",
|
|
267
|
+
),
|
|
268
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
269
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "interval_days", CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
|
|
270
|
+
"unattended_three_in_row_view",
|
|
271
|
+
engine="django.db.backends.postgresql",
|
|
272
|
+
),
|
|
273
|
+
atomic=False,
|
|
274
|
+
),
|
|
275
|
+
django_db_views.operations.ViewRunPython(
|
|
276
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
277
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS "interval_days", CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
|
|
278
|
+
"unattended_three_in_row_view",
|
|
279
|
+
engine="django.db.backends.sqlite3",
|
|
280
|
+
),
|
|
281
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
282
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS "interval_days", CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
|
|
283
|
+
"unattended_three_in_row_view",
|
|
284
|
+
engine="django.db.backends.sqlite3",
|
|
285
|
+
),
|
|
286
|
+
atomic=False,
|
|
287
|
+
),
|
|
288
|
+
django_db_views.operations.ViewRunPython(
|
|
289
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
290
|
+
"with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing=\"missed\" then \"New\" else appt_status end as `appt_status`,\ncase when appt_timing=\"missed\" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow2' as `report_model` from (SELECT DISTINCT subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days, `first_status`, `second_status`, `third_status`, SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, `missed`, FIRST_VALUE(appt_status) OVER w AS `third_status`, NTH_VALUE(appt_status, 2) OVER w AS `second_status`, NTH_VALUE(appt_status, 3) OVER w AS `first_status`, FIRST_VALUE(visit_code) OVER w AS `third_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `first_value`, FIRST_VALUE(appt_datetime) OVER w AS `third_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `first_date` FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL AND `first_status` = 'New' AND `second_status` = 'New' AND `third_status` = 'New' GROUP BY subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`), DATEDIFF(NOW(), `first_date`), `first_status`, `second_status`, `third_status` ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id",
|
|
291
|
+
"unattended_three_in_row2_view",
|
|
292
|
+
engine="django.db.backends.mysql",
|
|
293
|
+
),
|
|
294
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
295
|
+
"with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing=\"missed\" then \"New\" else appt_status end as `appt_status`,\ncase when appt_timing=\"missed\" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow2' as `report_model` from (SELECT DISTINCT subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days, `first_status`, `second_status`, `third_status`, SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, `missed`, FIRST_VALUE(appt_status) OVER w AS `third_status`, NTH_VALUE(appt_status, 2) OVER w AS `second_status`, NTH_VALUE(appt_status, 3) OVER w AS `first_status`, FIRST_VALUE(visit_code) OVER w AS `third_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `first_value`, FIRST_VALUE(appt_datetime) OVER w AS `third_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `first_date` FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL AND `first_status` = 'New' AND `second_status` = 'New' AND `third_status` = 'New' GROUP BY subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`), DATEDIFF(NOW(), `first_date`), `first_status`, `second_status`, `third_status` ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id",
|
|
296
|
+
"unattended_three_in_row2_view",
|
|
297
|
+
engine="django.db.backends.mysql",
|
|
298
|
+
),
|
|
299
|
+
atomic=False,
|
|
300
|
+
),
|
|
301
|
+
django_db_views.operations.ViewRunPython(
|
|
302
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
303
|
+
'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), "first_status", "second_status", "third_status" ORDER BY subject_identifier NULLS FIRST, site_id NULLS FIRST) as A ORDER BY subject_identifier, site_id',
|
|
304
|
+
"unattended_three_in_row2_view",
|
|
305
|
+
engine="django.db.backends.postgresql",
|
|
306
|
+
),
|
|
307
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
308
|
+
'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), "first_status", "second_status", "third_status" ORDER BY subject_identifier NULLS FIRST, site_id NULLS FIRST) as A ORDER BY subject_identifier, site_id',
|
|
309
|
+
"unattended_three_in_row2_view",
|
|
310
|
+
engine="django.db.backends.postgresql",
|
|
311
|
+
),
|
|
312
|
+
atomic=False,
|
|
313
|
+
),
|
|
314
|
+
django_db_views.operations.ViewRunPython(
|
|
315
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
316
|
+
'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER), CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER), "first_status", "second_status", "third_status" ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id',
|
|
317
|
+
"unattended_three_in_row2_view",
|
|
318
|
+
engine="django.db.backends.sqlite3",
|
|
319
|
+
),
|
|
320
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
321
|
+
'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER), CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER), "first_status", "second_status", "third_status" ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id',
|
|
322
|
+
"unattended_three_in_row2_view",
|
|
323
|
+
engine="django.db.backends.sqlite3",
|
|
324
|
+
),
|
|
325
|
+
atomic=False,
|
|
326
|
+
),
|
|
327
|
+
django_db_views.operations.ViewRunPython(
|
|
328
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
329
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.unattendedtwoinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, DATEDIFF(`second_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND `third_value` IS NULL) as A ORDER BY site_id, from_now_days desc",
|
|
330
|
+
"unattended_two_in_row_view",
|
|
331
|
+
engine="django.db.backends.mysql",
|
|
332
|
+
),
|
|
333
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
334
|
+
"select *, uuid() as id, now() as `created`, 'meta_reports.unattendedtwoinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, DATEDIFF(`second_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND `third_value` IS NULL) as A ORDER BY site_id, from_now_days desc",
|
|
335
|
+
"unattended_two_in_row_view",
|
|
336
|
+
engine="django.db.backends.mysql",
|
|
337
|
+
),
|
|
338
|
+
atomic=False,
|
|
339
|
+
),
|
|
340
|
+
django_db_views.operations.ViewRunPython(
|
|
341
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
342
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST(AGE(CAST("second_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
|
|
343
|
+
"unattended_two_in_row_view",
|
|
344
|
+
engine="django.db.backends.postgresql",
|
|
345
|
+
),
|
|
346
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
347
|
+
'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST(AGE(CAST("second_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
|
|
348
|
+
"unattended_two_in_row_view",
|
|
349
|
+
engine="django.db.backends.postgresql",
|
|
350
|
+
),
|
|
351
|
+
atomic=False,
|
|
352
|
+
),
|
|
353
|
+
django_db_views.operations.ViewRunPython(
|
|
354
|
+
code=django_db_views.migration_functions.ForwardViewMigration(
|
|
355
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST((JULIANDAY("second_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
|
|
356
|
+
"unattended_two_in_row_view",
|
|
357
|
+
engine="django.db.backends.sqlite3",
|
|
358
|
+
),
|
|
359
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
|
360
|
+
'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST((JULIANDAY("second_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
|
|
361
|
+
"unattended_two_in_row_view",
|
|
362
|
+
engine="django.db.backends.sqlite3",
|
|
363
|
+
),
|
|
364
|
+
atomic=False,
|
|
365
|
+
),
|
|
366
|
+
]
|
|
File without changes
|
|
File without changes
|