meta-edc 0.3.7__py3-none-any.whl → 0.3.50__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (411) hide show
  1. meta_ae/action_items.py +2 -2
  2. meta_ae/migrations/0017_auto_20221130_2257.py +12 -7
  3. meta_ae/tests/holidays.csv +1 -1
  4. meta_analytics/README.rst +17 -0
  5. meta_analytics/dataframes/__init__.py +19 -0
  6. meta_analytics/dataframes/constants.py +33 -0
  7. meta_analytics/dataframes/enrolled/__init__.py +1 -0
  8. meta_analytics/dataframes/enrolled/get_glucose_df.py +122 -0
  9. meta_analytics/dataframes/get_eos_df.py +26 -0
  10. meta_analytics/dataframes/get_last_imp_visits_df.py +101 -0
  11. meta_analytics/dataframes/glucose_endpoints/__init__.py +2 -0
  12. meta_analytics/dataframes/glucose_endpoints/endpoint_by_date.py +183 -0
  13. meta_analytics/dataframes/glucose_endpoints/glucose_endpoints_by_date.py +531 -0
  14. meta_analytics/dataframes/screening/__init__.py +2 -0
  15. meta_analytics/dataframes/screening/get_glucose_tested_only_df.py +20 -0
  16. meta_analytics/dataframes/screening/get_screening_df.py +163 -0
  17. meta_analytics/dataframes/utils.py +65 -0
  18. meta_analytics/get_tables.py +81 -0
  19. meta_analytics/tables/__init__.py +2 -0
  20. meta_analytics/tables/eligible.py +106 -0
  21. meta_analytics/tables/enrolled/__init__.py +0 -0
  22. meta_analytics/tables/enrolled/glucose.py +28 -0
  23. meta_analytics/tables/has_dm.py +61 -0
  24. meta_analytics/tests/__init__.py +0 -0
  25. meta_analytics/tests/test_endpoints_by_date.py +94 -0
  26. meta_auth/auth_objects.py +32 -3
  27. meta_auth/auths.py +18 -3
  28. meta_consent/action_items.py +18 -1
  29. meta_consent/admin/__init__.py +1 -0
  30. meta_consent/admin/subject_consent_v1_ext_admin.py +45 -0
  31. meta_consent/baker_recipes.py +5 -4
  32. meta_consent/consents.py +21 -2
  33. meta_consent/constants.py +1 -0
  34. meta_consent/forms/__init__.py +1 -0
  35. meta_consent/forms/subject_consent_v1_ext_form.py +16 -0
  36. meta_consent/locale/lg/LC_MESSAGES/django.po +69 -0
  37. meta_consent/locale/sw/LC_MESSAGES/django.po +12 -12
  38. meta_consent/migrations/0025_alter_historicalsubjectconsent_first_name_and_more.py +151 -0
  39. meta_consent/migrations/0026_historicalsubjectconsentv1ext_subjectconsentv1ext.py +544 -0
  40. meta_consent/migrations/0027_auto_20250111_0344.py +30 -0
  41. meta_consent/models/__init__.py +1 -0
  42. meta_consent/models/signals.py +34 -13
  43. meta_consent/models/subject_consent_v1.py +1 -3
  44. meta_consent/models/subject_consent_v1_ext.py +29 -0
  45. meta_consent/tests/holidays.csv +1 -1
  46. meta_consent/tests/tests/test_form_validators.py +1 -1
  47. meta_dashboard/locale/lg/LC_MESSAGES/django.po +30 -0
  48. meta_dashboard/locale/sw/LC_MESSAGES/django.po +11 -2
  49. meta_dashboard/navbars.py +3 -1
  50. meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/eligibility_button.html +1 -1
  51. meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/screening_button.html +1 -1
  52. meta_dashboard/templates/meta_dashboard/bootstrap3/screening/listboard.html +4 -4
  53. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard/sidebar.html +24 -0
  54. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard.html +3 -0
  55. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/listboard.html +1 -2
  56. meta_dashboard/templatetags/meta_dashboard_extras.py +1 -1
  57. meta_dashboard/tests/holidays.csv +1 -1
  58. meta_dashboard/tests/urls.py +0 -1
  59. meta_dashboard/view_utils/__init__.py +6 -0
  60. meta_dashboard/view_utils/subject_screening_button.py +2 -2
  61. meta_dashboard/views/subject/dashboard/dashboard_view.py +38 -0
  62. meta_edc/__init__.py +7 -0
  63. meta_edc/celery.py +4 -13
  64. meta_edc/celery_live.py +18 -0
  65. meta_edc/celery_uat.py +24 -0
  66. meta_edc/management/commands/update_forms_reference.py +6 -2
  67. meta_edc/migrations/__init__.py +0 -0
  68. meta_edc/navbars.py +2 -1
  69. meta_edc/settings/debug.py +17 -9
  70. meta_edc/settings/defaults.py +82 -60
  71. meta_edc/settings/live.py +1 -9
  72. meta_edc/settings/uat.py +1 -14
  73. meta_edc/templates/meta_edc/bootstrap3/home.html +13 -7
  74. meta_edc/tests/tests/test_endpoints.py +22 -19
  75. meta_edc/urls.py +5 -2
  76. meta_edc/wsgi.py +1 -1
  77. meta_edc/wsgi_live.py +1 -1
  78. meta_edc/wsgi_uat.py +1 -1
  79. meta_edc-0.3.50.dist-info/AUTHORS +0 -0
  80. meta_edc-0.3.50.dist-info/METADATA +766 -0
  81. {meta_edc-0.3.7.dist-info → meta_edc-0.3.50.dist-info}/RECORD +400 -157
  82. {meta_edc-0.3.7.dist-info → meta_edc-0.3.50.dist-info}/WHEEL +1 -1
  83. {meta_edc-0.3.7.dist-info → meta_edc-0.3.50.dist-info}/top_level.txt +1 -0
  84. meta_pharmacy/admin/__init__.py +2 -0
  85. meta_pharmacy/admin/rx_admin.py +75 -0
  86. meta_pharmacy/admin/substitutions_admin.py +67 -0
  87. meta_pharmacy/admin_site.py +9 -0
  88. meta_pharmacy/apps.py +5 -0
  89. meta_pharmacy/constants.py +10 -0
  90. meta_pharmacy/forms/__init__.py +2 -0
  91. meta_pharmacy/forms/rx_form.py +16 -0
  92. meta_pharmacy/forms/substitutions_form.py +54 -0
  93. meta_pharmacy/label_configs.py +30 -0
  94. meta_pharmacy/labels/__init__.py +5 -0
  95. meta_pharmacy/labels/draw_label_for_subject_with_barcode.py +62 -0
  96. meta_pharmacy/labels/draw_label_for_subject_with_code128.py +14 -0
  97. meta_pharmacy/labels/draw_label_with_test_data.py +26 -0
  98. meta_pharmacy/labels/label_data.py +14 -0
  99. meta_pharmacy/labels/print_sheets.py +97 -0
  100. meta_pharmacy/list_data.py +8 -0
  101. meta_pharmacy/management/__init__.py +0 -0
  102. meta_pharmacy/management/commands/__init__.py +0 -0
  103. meta_pharmacy/management/commands/update_initial_pharmacy_data.py +10 -0
  104. meta_pharmacy/migrations/0002_initial.py +695 -0
  105. meta_pharmacy/migrations/0003_auto_20240909_2335.py +64 -0
  106. meta_pharmacy/migrations/0004_alter_historicalsubstitutions_report_datetime_and_more.py +23 -0
  107. meta_pharmacy/migrations/0005_auto_20240911_0352.py +17 -0
  108. meta_pharmacy/migrations/0006_lotnumber_label.py +289 -0
  109. meta_pharmacy/migrations/0007_lotnumber_medication.py +24 -0
  110. meta_pharmacy/migrations/0008_remove_lotnumber_medication_and_more.py +390 -0
  111. meta_pharmacy/migrations/0009_remove_historicalrx_slug.py +17 -0
  112. meta_pharmacy/models/__init__.py +3 -0
  113. meta_pharmacy/models/label_data.py +38 -0
  114. meta_pharmacy/models/rx.py +18 -0
  115. meta_pharmacy/models/rx_label.py +39 -0
  116. meta_pharmacy/models/substitutions.py +88 -0
  117. meta_pharmacy/urls.py +8 -0
  118. meta_pharmacy/utils/__init__.py +1 -0
  119. meta_pharmacy/utils/update_initial_pharmacy_data.py +146 -0
  120. meta_prn/action_items.py +52 -2
  121. meta_prn/admin/__init__.py +3 -0
  122. meta_prn/admin/dm_referral_admin.py +49 -0
  123. meta_prn/admin/offschedule_dm_referral_admin.py +47 -0
  124. meta_prn/admin/onschedule_dm_referral_admin.py +39 -0
  125. meta_prn/admin/pregnancy_notification_admin.py +6 -2
  126. meta_prn/baker_recipes.py +8 -1
  127. meta_prn/choices.py +2 -1
  128. meta_prn/constants.py +4 -1
  129. meta_prn/forms/__init__.py +2 -0
  130. meta_prn/forms/dm_referral_form.py +40 -0
  131. meta_prn/forms/offschedule_dm_referral_form.py +35 -0
  132. meta_prn/forms/offschedule_form.py +6 -0
  133. meta_prn/migrations/0034_auto_20220630_1110.py +3 -3
  134. meta_prn/migrations/0035_auto_20220630_1140.py +59 -56
  135. meta_prn/migrations/0057_historicalonscheduledmreferral_and_more.py +1156 -0
  136. meta_prn/migrations/0058_dmreferral_referral_note_and_more.py +29 -0
  137. meta_prn/migrations/0059_alter_historicaloffstudymedication_reason_and_more.py +53 -0
  138. meta_prn/models/__init__.py +13 -2
  139. meta_prn/models/dm_referral.py +39 -0
  140. meta_prn/models/offschedule.py +15 -1
  141. meta_prn/models/onschedule.py +6 -0
  142. meta_prn/models/signals.py +41 -1
  143. meta_prn/tests/tests/test_dm_referral.py +203 -0
  144. meta_reports/__init__.py +1 -0
  145. meta_reports/admin/__init__.py +15 -0
  146. meta_reports/admin/dbviews/__init__.py +14 -0
  147. meta_reports/admin/dbviews/glucose_summary_admin.py +116 -0
  148. meta_reports/admin/dbviews/imp_substitutions_admin.py +101 -0
  149. meta_reports/admin/dbviews/missing_screening_ogtt_admin/__init__.py +2 -0
  150. meta_reports/admin/dbviews/missing_screening_ogtt_admin/note_model_admin.py +53 -0
  151. meta_reports/admin/dbviews/missing_screening_ogtt_admin/unmanaged_model_admin.py +84 -0
  152. meta_reports/admin/dbviews/on_study_missing_lab_values_admin/__init__.py +1 -0
  153. meta_reports/admin/dbviews/on_study_missing_lab_values_admin/unmanaged_model_admin.py +13 -0
  154. meta_reports/admin/dbviews/on_study_missing_values_admin/__init__.py +1 -0
  155. meta_reports/admin/dbviews/on_study_missing_values_admin/unmanaged_model_admin.py +13 -0
  156. meta_reports/admin/dbviews/patient_history_missing_baseline_cd4_admin.py +58 -0
  157. meta_reports/admin/dbviews/unattended_three_in_row2_admin.py +47 -0
  158. meta_reports/admin/dbviews/unattended_three_in_row_admin.py +35 -0
  159. meta_reports/admin/dbviews/unattended_two_in_row_admin.py +34 -0
  160. meta_reports/admin/endpoints_admin.py +14 -0
  161. meta_reports/admin/endpoints_all_admin.py +13 -0
  162. meta_reports/admin/last_imp_refill_admin.py +181 -0
  163. meta_reports/admin/list_filters.py +30 -0
  164. meta_reports/admin/modeladmin_mixins.py +112 -0
  165. meta_reports/admin_site.py +5 -0
  166. meta_reports/apps.py +1 -16
  167. meta_reports/forms/__init__.py +1 -0
  168. meta_reports/forms/missing_ogtt_note_form.py +33 -0
  169. meta_reports/management/__init__.py +0 -0
  170. meta_reports/management/commands/__init__.py +0 -0
  171. meta_reports/management/commands/generate_endpoints.py +13 -0
  172. meta_reports/migrations/0001_initial.py +87 -0
  173. meta_reports/migrations/0002_patienthistorymissingbaselinecd4_and_more.py +64 -0
  174. meta_reports/migrations/0003_auto_20240618_0505.py +12 -0
  175. meta_reports/migrations/0004_alter_patienthistorymissingbaselinecd4_table.py +17 -0
  176. meta_reports/migrations/0005_endpoints.py +47 -0
  177. meta_reports/migrations/0006_endpoints_baseline_datetime.py +18 -0
  178. meta_reports/migrations/0007_alter_endpoints_endpoint_label_and_more.py +43 -0
  179. meta_reports/migrations/0008_alter_endpoints_endpoint_label.py +18 -0
  180. meta_reports/migrations/0009_alter_endpoints_options.py +21 -0
  181. meta_reports/migrations/0010_alter_patienthistorymissingbaselinecd4_options_and_more.py +49 -0
  182. meta_reports/migrations/0011_auto_20240813_0156.py +54 -0
  183. meta_reports/migrations/0012_auto_20240813_1516.py +48 -0
  184. meta_reports/migrations/0013_auto_20240813_1516.py +48 -0
  185. meta_reports/migrations/0014_auto_20240813_1517.py +48 -0
  186. meta_reports/migrations/0015_alter_endpoints_site.py +22 -0
  187. meta_reports/migrations/0016_missingscreeningogtt.py +47 -0
  188. meta_reports/migrations/0017_auto_20240819_1711.py +166 -0
  189. meta_reports/migrations/0018_auto_20240819_1713.py +54 -0
  190. meta_reports/migrations/0019_auto_20240819_1721.py +54 -0
  191. meta_reports/migrations/0020_auto_20240819_1811.py +54 -0
  192. meta_reports/migrations/0021_auto_20240819_1817.py +54 -0
  193. meta_reports/migrations/0022_auto_20240819_1832.py +54 -0
  194. meta_reports/migrations/0023_endpoints_meta_report_subject_a56b22_idx.py +20 -0
  195. meta_reports/migrations/0024_glucosesummary.py +38 -0
  196. meta_reports/migrations/0025_auto_20240822_0115.py +87 -0
  197. meta_reports/migrations/0026_auto_20240822_0120.py +54 -0
  198. meta_reports/migrations/0027_auto_20240822_0140.py +54 -0
  199. meta_reports/migrations/0028_alter_glucosesummary_options.py +22 -0
  200. meta_reports/migrations/0029_auto_20240822_0149.py +54 -0
  201. meta_reports/migrations/0030_auto_20240822_1637.py +54 -0
  202. meta_reports/migrations/0031_endpointsproxy.py +25 -0
  203. meta_reports/migrations/0032_alter_endpointsproxy_options.py +21 -0
  204. meta_reports/migrations/0033_auto_20240823_0012.py +54 -0
  205. meta_reports/migrations/0034_auto_20240823_1642.py +54 -0
  206. meta_reports/migrations/0035_historicalmissingogttnote_missingogttnote.py +457 -0
  207. meta_reports/migrations/0036_historicalmissingogttnote_fasting_and_more.py +86 -0
  208. meta_reports/migrations/0037_historicalmissingogttnote_result_status_and_more.py +51 -0
  209. meta_reports/migrations/0038_alter_historicalmissingogttnote_fasting_and_more.py +33 -0
  210. meta_reports/migrations/0039_onstudymissingvalues.py +44 -0
  211. meta_reports/migrations/0040_auto_20240824_0412.py +282 -0
  212. meta_reports/migrations/0041_auto_20240828_2229.py +14 -0
  213. meta_reports/migrations/0042_onstudymissinglabvalues.py +43 -0
  214. meta_reports/migrations/0043_auto_20240828_2309.py +88 -0
  215. meta_reports/migrations/0044_auto_20240828_2323.py +93 -0
  216. meta_reports/migrations/0045_auto_20240829_0248.py +54 -0
  217. meta_reports/migrations/0046_auto_20240829_0250.py +54 -0
  218. meta_reports/migrations/0047_impsubstitutions.py +56 -0
  219. meta_reports/migrations/0048_auto_20240909_2338.py +48 -0
  220. meta_reports/migrations/0049_auto_20240911_0327.py +54 -0
  221. meta_reports/migrations/0050_alter_endpoints_created.py +19 -0
  222. meta_reports/migrations/0051_remove_endpoints_baseline_datetime_and_more.py +40 -0
  223. meta_reports/migrations/0052_lastimpvisit.py +57 -0
  224. meta_reports/migrations/0053_rename_lastimpvisit_lastimprefill_and_more.py +31 -0
  225. meta_reports/models/__init__.py +16 -0
  226. meta_reports/models/dbviews/README +14 -0
  227. meta_reports/models/dbviews/__init__.py +9 -0
  228. meta_reports/models/dbviews/glucose_summary/__init__.py +2 -0
  229. meta_reports/models/dbviews/glucose_summary/unmanaged_model.py +35 -0
  230. meta_reports/models/dbviews/glucose_summary/view_definition.py +28 -0
  231. meta_reports/models/dbviews/imp_substitutions/__init__.py +1 -0
  232. meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +41 -0
  233. meta_reports/models/dbviews/imp_substitutions/view_definition.py +21 -0
  234. meta_reports/models/dbviews/missing_screening_ogtt/__init__.py +2 -0
  235. meta_reports/models/dbviews/missing_screening_ogtt/note_model.py +57 -0
  236. meta_reports/models/dbviews/missing_screening_ogtt/unmanaged_model.py +41 -0
  237. meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py +20 -0
  238. meta_reports/models/dbviews/on_study_missing_lab_values/__init__.py +1 -0
  239. meta_reports/models/dbviews/on_study_missing_lab_values/qa_cases.py +53 -0
  240. meta_reports/models/dbviews/on_study_missing_lab_values/unmanged_model.py +20 -0
  241. meta_reports/models/dbviews/on_study_missing_lab_values/view_definition.py +17 -0
  242. meta_reports/models/dbviews/on_study_missing_values/__init__.py +1 -0
  243. meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +54 -0
  244. meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py +20 -0
  245. meta_reports/models/dbviews/on_study_missing_values/view_definition.py +17 -0
  246. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/__init__.py +1 -0
  247. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/unmanaged_model.py +31 -0
  248. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py +21 -0
  249. meta_reports/models/dbviews/unattended_three_in_row/__init__.py +1 -0
  250. meta_reports/models/dbviews/unattended_three_in_row/unmanaged_model.py +29 -0
  251. meta_reports/models/dbviews/unattended_three_in_row/view_definition.py +31 -0
  252. meta_reports/models/dbviews/unattended_three_in_row2/__init__.py +1 -0
  253. meta_reports/models/dbviews/unattended_three_in_row2/unmanaged_model.py +29 -0
  254. meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py +50 -0
  255. meta_reports/models/dbviews/unattended_two_in_row/__init__.py +1 -0
  256. meta_reports/models/dbviews/unattended_two_in_row/unmanaged_model.py +27 -0
  257. meta_reports/models/dbviews/unattended_two_in_row/view_definition.py +30 -0
  258. meta_reports/models/endpoints.py +31 -0
  259. meta_reports/models/endpoints_proxy.py +11 -0
  260. meta_reports/models/last_imp_refill.py +34 -0
  261. meta_reports/tasks.py +12 -0
  262. meta_reports/templates/meta_reports/columns/subject_identifier_column.html +1 -0
  263. meta_reports/templates/meta_reports/endpoints_all_change_list_note.html +12 -0
  264. meta_reports/templates/meta_reports/endpoints_change_list_note.html +12 -0
  265. meta_reports/tests/test_sql_gen.py +5 -0
  266. meta_reports/urls.py +8 -0
  267. meta_reports/utils.py +0 -0
  268. meta_screening/admin/subject_screening_admin.py +1 -0
  269. meta_screening/form_validators/screening_part_two.py +1 -1
  270. meta_screening/migrations/0062_remove_icpreferral_site_and_more.py +27 -0
  271. meta_screening/migrations/0063_alter_historicalscreeningpartone_fasting_duration_str_and_more.py +184 -0
  272. meta_screening/migrations/0064_remove_historicalscreeningpartone_fasting_duration_minutes_and_more.py +126 -0
  273. meta_screening/migrations/0065_auto_20240516_0352.py +31 -0
  274. meta_screening/migrations/0066_alter_historicalscreeningpartone_fasting_duration_delta_and_more.py +103 -0
  275. meta_screening/migrations/0067_alter_historicalscreeningpartone_report_datetime_and_more.py +84 -0
  276. meta_screening/models/__init__.py +1 -1
  277. meta_screening/tests/holidays.csv +1 -1
  278. meta_screening/tests/meta_test_case_mixin.py +17 -2
  279. meta_screening/tests/options.py +3 -3
  280. meta_sites/__init__.py +0 -1
  281. meta_sites/sites.py +8 -7
  282. meta_sites/tests/test_sites.py +1 -1
  283. meta_subject/action_items.py +25 -2
  284. meta_subject/admin/__init__.py +2 -1
  285. meta_subject/admin/birth_outcome_admin.py +4 -3
  286. meta_subject/admin/blood_results/__init__.py +1 -1
  287. meta_subject/admin/blood_results/{blood_results_lipid_admin.py → blood_results_lipids_admin.py} +7 -7
  288. meta_subject/admin/delivery_admin.py +0 -1
  289. meta_subject/admin/diabetes/__init__.py +2 -0
  290. meta_subject/admin/diabetes/dm_endpoint_admin.py +35 -0
  291. meta_subject/admin/{dm_referral_followup_admin.py → diabetes/dm_followup_admin.py} +15 -8
  292. meta_subject/admin/glucose_admin.py +1 -1
  293. meta_subject/admin/glucose_fbg_admin.py +38 -8
  294. meta_subject/admin/other_arv_regimens_admin.py +2 -0
  295. meta_subject/admin/study_medication_admin.py +10 -0
  296. meta_subject/admin/subject_visit_admin.py +4 -1
  297. meta_subject/baker_recipes.py +6 -0
  298. meta_subject/choices.py +8 -0
  299. meta_subject/constants.py +2 -1
  300. meta_subject/form_validators/__init__.py +2 -1
  301. meta_subject/form_validators/dm_endpoint_form_validator.py +35 -0
  302. meta_subject/form_validators/{dm_referral_followup_form_validator.py → dm_followup_form_validator.py} +41 -2
  303. meta_subject/forms/__init__.py +2 -1
  304. meta_subject/forms/blood_results/__init__.py +1 -1
  305. meta_subject/forms/blood_results/{blood_results_lipid_form.py → blood_results_lipids_form.py} +5 -5
  306. meta_subject/forms/diabetes/__init__.py +2 -0
  307. meta_subject/forms/diabetes/dm_endpoint_form.py +13 -0
  308. meta_subject/forms/diabetes/dm_followup_form.py +25 -0
  309. meta_subject/forms/glucose_fbg_form.py +38 -16
  310. meta_subject/forms/study_medication_form.py +35 -0
  311. meta_subject/forms/subject_visit_form.py +16 -0
  312. meta_subject/locale/lg/LC_MESSAGES/django.po +470 -0
  313. meta_subject/locale/sw/LC_MESSAGES/django.po +191 -89
  314. meta_subject/metadata_rules/metadata_rules.py +21 -0
  315. meta_subject/metadata_rules/predicates.py +67 -8
  316. meta_subject/migrations/0107_auto_20220415_0043.py +28 -22
  317. meta_subject/migrations/0126_auto_20220719_2142.py +4 -4
  318. meta_subject/migrations/0131_auto_20220722_0411.py +28 -23
  319. meta_subject/migrations/0132_auto_20220722_1825.py +10 -6
  320. meta_subject/migrations/0135_auto_20220722_2212.py +39 -35
  321. meta_subject/migrations/0150_auto_20220914_0039.py +15 -11
  322. meta_subject/migrations/0181_dmreferralfollowup_action_identifier_and_more.py +143 -0
  323. meta_subject/migrations/0182_rename_dmreferralfollowup_dmfollowup_and_more.py +54 -0
  324. meta_subject/migrations/0183_alter_dmfollowup_on_dm_medications_and_more.py +31 -0
  325. meta_subject/migrations/0184_alter_glucose_options_and_more.py +31 -0
  326. meta_subject/migrations/0185_alter_bloodresultsins_fasting_duration_str_and_more.py +82 -0
  327. meta_subject/migrations/0186_healtheconomicsupdate_singleton_field_and_more.py +55 -0
  328. meta_subject/migrations/0187_dmdiagnosis_historicaldmdiagnosis_dmdxresult_and_more.py +451 -0
  329. meta_subject/migrations/0188_historicaldmdxresult_dmdxresult.py +403 -0
  330. meta_subject/migrations/0189_alter_dmdxresult_options_and_more.py +116 -0
  331. meta_subject/migrations/0190_dmdiagnosis_dx_no_tmg_reason_and_more.py +65 -0
  332. meta_subject/migrations/0191_alter_dmdiagnosis_dx_no_tmg_reason_and_more.py +70 -0
  333. meta_subject/migrations/0192_rename_glucose_quantifier_glucosefbg_fbg_quantifier_and_more.py +44 -0
  334. meta_subject/migrations/0193_alter_glucosefbg_fbg_value_and_more.py +44 -0
  335. meta_subject/migrations/0194_remove_glucosefbg_assay_datetime_and_more.py +166 -0
  336. meta_subject/migrations/0195_alter_glucosefbg_fbg_datetime_and_more.py +27 -0
  337. meta_subject/migrations/0196_glucosefbg_fbg_not_performed_reason_and_more.py +49 -0
  338. meta_subject/migrations/0197_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
  339. meta_subject/migrations/0198_alter_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
  340. meta_subject/migrations/0199_auto_20240516_0247.py +18 -0
  341. meta_subject/migrations/0200_rename_fasting_duration_minutes_bloodresultsins_fasting_duration_delta_and_more.py +43 -0
  342. meta_subject/migrations/0201_alter_bloodresultsins_fasting_duration_delta_and_more.py +58 -0
  343. meta_subject/migrations/0202_auto_20240516_0315.py +32 -0
  344. meta_subject/migrations/0203_alter_bloodresultsins_fasting_duration_delta_and_more.py +67 -0
  345. meta_subject/migrations/0204_glucosefbg_repeat_fbg_date_and_more.py +27 -0
  346. meta_subject/migrations/0205_historicalsubjectrequisition_crf_status_and_more.py +80 -0
  347. meta_subject/migrations/0206_bloodresultsfbc_crf_status_and_more.py +62 -0
  348. meta_subject/migrations/0207_alter_historicalphysicalexam_waist_circumference_and_more.py +46 -0
  349. meta_subject/migrations/0208_birthoutcomes_crf_status_and_more.py +62 -0
  350. meta_subject/migrations/0209_remove_historicaldmdxresult_dm_diagnosis_and_more.py +37 -0
  351. meta_subject/migrations/0210_remove_dmdxresult_dm_diagnosis_and_more.py +123 -0
  352. meta_subject/migrations/0211_dmendpoint_endpoint_reached_and_more.py +45 -0
  353. meta_subject/migrations/0212_auto_20240827_2222.py +23 -0
  354. meta_subject/migrations/0213_rename_bloodresultslipid_bloodresultslipids_and_more.py +35 -0
  355. meta_subject/migrations/0214_historicalstudymedication_stock_codes_and_more.py +44 -0
  356. meta_subject/migrations/0215_alter_historicalstudymedication_stock_codes_and_more.py +46 -0
  357. meta_subject/model_mixins/arv_history_model_mixin.py +3 -3
  358. meta_subject/models/__init__.py +3 -2
  359. meta_subject/models/birth_outcomes.py +6 -1
  360. meta_subject/models/blood_results/__init__.py +1 -1
  361. meta_subject/models/blood_results/blood_results_fbc.py +3 -2
  362. meta_subject/models/blood_results/blood_results_hba1c.py +2 -0
  363. meta_subject/models/blood_results/blood_results_ins.py +2 -0
  364. meta_subject/models/blood_results/blood_results_lft.py +2 -0
  365. meta_subject/models/blood_results/{blood_results_lipid.py → blood_results_lipids.py} +5 -3
  366. meta_subject/models/blood_results/blood_results_rft.py +2 -0
  367. meta_subject/models/diabetes/__init__.py +2 -0
  368. meta_subject/models/diabetes/dm_endpoint.py +61 -0
  369. meta_subject/models/{dm_referral_followup.py → diabetes/dm_followup.py} +18 -6
  370. meta_subject/models/glucose.py +7 -14
  371. meta_subject/models/glucose_fbg.py +40 -51
  372. meta_subject/models/health_economics/health_economics_update.py +2 -0
  373. meta_subject/models/physical_exam.py +1 -0
  374. meta_subject/models/signals.py +19 -0
  375. meta_subject/models/subject_requisition.py +3 -4
  376. meta_subject/models/todo.txt +1 -1
  377. meta_subject/static/meta_subject/slider.css +1 -1
  378. meta_subject/templates/meta_subject/endpoint_review_instructions.html +1 -1
  379. meta_subject/templates/meta_subject/widgets/slider.html +0 -1
  380. meta_subject/tests/holidays.csv +1 -1
  381. meta_subject/tests/tests/test_egfr.py +6 -5
  382. meta_subject/tests/tests/test_medication_adherence.py +5 -1
  383. meta_subject/tests/tests/test_metadata_rules.py +34 -4
  384. meta_subject/tests/tests/test_mnsi.py +212 -121
  385. meta_subject/tests/tests/test_sf12.py +0 -12
  386. meta_visit_schedule/constants.py +7 -1
  387. meta_visit_schedule/tests/tests/test_schedule.py +4 -0
  388. meta_visit_schedule/visit_schedules/phase_three/crfs.py +87 -14
  389. meta_visit_schedule/visit_schedules/phase_three/requisitions.py +12 -0
  390. meta_visit_schedule/visit_schedules/phase_three/schedule.py +65 -2
  391. meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py +60 -0
  392. meta_visit_schedule/visit_schedules/phase_three/visit_schedule.py +2 -0
  393. tests/etc/randomization_list.csv +1 -1
  394. {meta_edc/tests → tests}/etc/randomization_list_phase_three.csv +4 -4
  395. tests/holidays.csv +1 -1
  396. tests/test_settings.py +186 -0
  397. meta_edc/tests/etc/user-aes-local.key +0 -1
  398. meta_edc/tests/etc/user-aes-restricted.key +0 -0
  399. meta_edc/tests/etc/user-rsa-local-private.pem +0 -27
  400. meta_edc/tests/etc/user-rsa-local-public.pem +0 -9
  401. meta_edc/tests/etc/user-rsa-restricted-private.pem +0 -27
  402. meta_edc/tests/etc/user-rsa-restricted-public.pem +0 -9
  403. meta_edc/tests/etc/user-salt-local.key +0 -0
  404. meta_edc/tests/etc/user-salt-restricted.key +0 -0
  405. meta_edc-0.3.7.dist-info/METADATA +0 -87
  406. meta_reports/tests/holidays.csv +0 -15
  407. meta_subject/forms/dm_referral_followup.py +0 -18
  408. /meta_edc-0.3.7.dist-info/AUTHORS → /meta_analytics/__init__.py +0 -0
  409. /meta_pharmacy/models.py → /meta_analytics/constants.py +0 -0
  410. /meta_reports/models.py → /meta_analytics/notebooks/cleaning/__init__.py +0 -0
  411. {meta_edc-0.3.7.dist-info → meta_edc-0.3.50.dist-info}/LICENSE +0 -0
@@ -0,0 +1,43 @@
1
+ # Generated by Django 5.0.8 on 2024-08-28 19:49
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_reports", "0041_auto_20240828_2229"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.CreateModel(
14
+ name="OnStudyMissingLabValues",
15
+ fields=[
16
+ (
17
+ "id",
18
+ models.BigAutoField(
19
+ auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
20
+ ),
21
+ ),
22
+ ("original_id", models.UUIDField(null=True)),
23
+ ("label_lower", models.CharField(max_length=150, null=True)),
24
+ ("subject_visit_id", models.UUIDField(null=True)),
25
+ ("report_datetime", models.DateTimeField(null=True)),
26
+ ("label", models.CharField(max_length=50, null=True)),
27
+ ("visit_code", models.CharField(max_length=25, null=True)),
28
+ ("visit_code_sequence", models.IntegerField(null=True)),
29
+ ("schedule_name", models.CharField(max_length=25, null=True)),
30
+ ("modified", models.DateTimeField(null=True)),
31
+ ("report_model", models.CharField(max_length=50)),
32
+ ("subject_identifier", models.CharField(max_length=25)),
33
+ ("created", models.DateTimeField()),
34
+ ],
35
+ options={
36
+ "verbose_name": "Missing Lab values for on-study patient",
37
+ "verbose_name_plural": "Missing Lab values for on-study patients",
38
+ "db_table": "onstudy_missing_lab_values_view",
39
+ "managed": False,
40
+ "default_permissions": ("view", "export", "viewallsites"),
41
+ },
42
+ ),
43
+ ]
@@ -0,0 +1,88 @@
1
+ # Generated by Django 5.0.8 on 2024-08-28 20:09
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", "0042_onstudymissinglabvalues"),
12
+ ("meta_subject", "0213_rename_bloodresultslipid_bloodresultslipids_and_more"),
13
+ ]
14
+
15
+ operations = [
16
+ django_db_views.operations.ViewRunPython(
17
+ code=django_db_views.migration_functions.ForwardViewMigration(
18
+ "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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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",
19
+ "onstudy_missing_lab_values_view",
20
+ engine="django.db.backends.mysql",
21
+ ),
22
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
23
+ "", "onstudy_missing_lab_values_view", engine="django.db.backends.mysql"
24
+ ),
25
+ atomic=False,
26
+ ),
27
+ django_db_views.operations.ViewRunPython(
28
+ code=django_db_views.migration_functions.ForwardViewMigration(
29
+ "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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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",
30
+ "onstudy_missing_lab_values_view",
31
+ engine="django.db.backends.postgresql",
32
+ ),
33
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
34
+ "", "onstudy_missing_lab_values_view", engine="django.db.backends.postgresql"
35
+ ),
36
+ atomic=False,
37
+ ),
38
+ django_db_views.operations.ViewRunPython(
39
+ code=django_db_views.migration_functions.ForwardViewMigration(
40
+ "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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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' 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 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",
41
+ "onstudy_missing_lab_values_view",
42
+ engine="django.db.backends.sqlite3",
43
+ ),
44
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
45
+ "", "onstudy_missing_lab_values_view", engine="django.db.backends.sqlite3"
46
+ ),
47
+ atomic=False,
48
+ ),
49
+ django_db_views.operations.ViewRunPython(
50
+ code=django_db_views.migration_functions.ForwardViewMigration(
51
+ "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' 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 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 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_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' 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 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 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_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.bloodresultsrft' AS label_lower, 'No URIC acid value' 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 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, 'No UREA value' 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.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",
52
+ "onstudy_missing_values_view",
53
+ engine="django.db.backends.mysql",
54
+ ),
55
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
56
+ "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' 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 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 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_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' 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 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 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_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) as A ORDER BY subject_identifier, site_id",
57
+ "onstudy_missing_values_view",
58
+ engine="django.db.backends.mysql",
59
+ ),
60
+ atomic=False,
61
+ ),
62
+ django_db_views.operations.ViewRunPython(
63
+ code=django_db_views.migration_functions.ForwardViewMigration(
64
+ "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' 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 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 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_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' 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 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 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_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.bloodresultsrft' AS label_lower, 'No URIC acid value' 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 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, 'No UREA value' 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.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",
65
+ "onstudy_missing_values_view",
66
+ engine="django.db.backends.postgresql",
67
+ ),
68
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
69
+ "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' 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 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 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_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' 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 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 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_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) as A ORDER BY subject_identifier, site_id",
70
+ "onstudy_missing_values_view",
71
+ engine="django.db.backends.postgresql",
72
+ ),
73
+ atomic=False,
74
+ ),
75
+ django_db_views.operations.ViewRunPython(
76
+ code=django_db_views.migration_functions.ForwardViewMigration(
77
+ "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' 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 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 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_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' 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 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 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_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.bloodresultsrft' AS label_lower, 'No URIC acid value' 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 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, 'No UREA value' 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.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",
78
+ "onstudy_missing_values_view",
79
+ engine="django.db.backends.sqlite3",
80
+ ),
81
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
82
+ "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' 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 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 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_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' 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 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 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_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) as A ORDER BY subject_identifier, site_id",
83
+ "onstudy_missing_values_view",
84
+ engine="django.db.backends.sqlite3",
85
+ ),
86
+ atomic=False,
87
+ ),
88
+ ]