meta-edc 0.3.15__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 (333) 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 +22 -0
  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 +1 -0
  32. meta_consent/consents.py +20 -1
  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/0026_historicalsubjectconsentv1ext_subjectconsentv1ext.py +544 -0
  39. meta_consent/migrations/0027_auto_20250111_0344.py +30 -0
  40. meta_consent/models/__init__.py +1 -0
  41. meta_consent/models/signals.py +18 -0
  42. meta_consent/models/subject_consent_v1_ext.py +29 -0
  43. meta_consent/tests/holidays.csv +1 -1
  44. meta_dashboard/locale/lg/LC_MESSAGES/django.po +30 -0
  45. meta_dashboard/locale/sw/LC_MESSAGES/django.po +11 -2
  46. meta_dashboard/navbars.py +3 -1
  47. meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/eligibility_button.html +1 -1
  48. meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/screening_button.html +1 -1
  49. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard/sidebar.html +24 -0
  50. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard.html +3 -0
  51. meta_dashboard/templatetags/meta_dashboard_extras.py +1 -1
  52. meta_dashboard/tests/holidays.csv +1 -1
  53. meta_dashboard/tests/urls.py +0 -1
  54. meta_dashboard/view_utils/__init__.py +6 -0
  55. meta_dashboard/view_utils/subject_screening_button.py +2 -2
  56. meta_dashboard/views/subject/dashboard/dashboard_view.py +38 -0
  57. meta_edc/__init__.py +7 -0
  58. meta_edc/celery.py +4 -13
  59. meta_edc/celery_live.py +18 -0
  60. meta_edc/celery_uat.py +24 -0
  61. meta_edc/management/commands/update_forms_reference.py +6 -2
  62. meta_edc/migrations/__init__.py +0 -0
  63. meta_edc/navbars.py +2 -1
  64. meta_edc/settings/debug.py +10 -2
  65. meta_edc/settings/defaults.py +58 -43
  66. meta_edc/templates/meta_edc/bootstrap3/home.html +5 -2
  67. meta_edc/tests/tests/test_endpoints.py +2 -0
  68. meta_edc/urls.py +4 -1
  69. meta_edc/wsgi.py +1 -1
  70. meta_edc/wsgi_live.py +1 -1
  71. meta_edc/wsgi_uat.py +1 -1
  72. meta_edc-0.3.50.dist-info/AUTHORS +0 -0
  73. meta_edc-0.3.50.dist-info/METADATA +766 -0
  74. {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/RECORD +316 -127
  75. {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/WHEEL +1 -1
  76. {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/top_level.txt +1 -0
  77. meta_pharmacy/admin/__init__.py +2 -0
  78. meta_pharmacy/admin/rx_admin.py +75 -0
  79. meta_pharmacy/admin/substitutions_admin.py +67 -0
  80. meta_pharmacy/admin_site.py +9 -0
  81. meta_pharmacy/apps.py +5 -0
  82. meta_pharmacy/constants.py +10 -0
  83. meta_pharmacy/forms/__init__.py +2 -0
  84. meta_pharmacy/forms/rx_form.py +16 -0
  85. meta_pharmacy/forms/substitutions_form.py +54 -0
  86. meta_pharmacy/label_configs.py +30 -0
  87. meta_pharmacy/labels/__init__.py +5 -0
  88. meta_pharmacy/labels/draw_label_for_subject_with_barcode.py +62 -0
  89. meta_pharmacy/labels/draw_label_for_subject_with_code128.py +14 -0
  90. meta_pharmacy/labels/draw_label_with_test_data.py +26 -0
  91. meta_pharmacy/labels/label_data.py +14 -0
  92. meta_pharmacy/labels/print_sheets.py +97 -0
  93. meta_pharmacy/list_data.py +8 -0
  94. meta_pharmacy/management/__init__.py +0 -0
  95. meta_pharmacy/management/commands/__init__.py +0 -0
  96. meta_pharmacy/management/commands/update_initial_pharmacy_data.py +10 -0
  97. meta_pharmacy/migrations/0002_initial.py +695 -0
  98. meta_pharmacy/migrations/0003_auto_20240909_2335.py +64 -0
  99. meta_pharmacy/migrations/0004_alter_historicalsubstitutions_report_datetime_and_more.py +23 -0
  100. meta_pharmacy/migrations/0005_auto_20240911_0352.py +17 -0
  101. meta_pharmacy/migrations/0006_lotnumber_label.py +289 -0
  102. meta_pharmacy/migrations/0007_lotnumber_medication.py +24 -0
  103. meta_pharmacy/migrations/0008_remove_lotnumber_medication_and_more.py +390 -0
  104. meta_pharmacy/migrations/0009_remove_historicalrx_slug.py +17 -0
  105. meta_pharmacy/models/__init__.py +3 -0
  106. meta_pharmacy/models/label_data.py +38 -0
  107. meta_pharmacy/models/rx.py +18 -0
  108. meta_pharmacy/models/rx_label.py +39 -0
  109. meta_pharmacy/models/substitutions.py +88 -0
  110. meta_pharmacy/urls.py +8 -0
  111. meta_pharmacy/utils/__init__.py +1 -0
  112. meta_pharmacy/utils/update_initial_pharmacy_data.py +146 -0
  113. meta_prn/action_items.py +9 -1
  114. meta_prn/admin/pregnancy_notification_admin.py +6 -2
  115. meta_prn/migrations/0034_auto_20220630_1110.py +3 -3
  116. meta_prn/migrations/0035_auto_20220630_1140.py +59 -56
  117. meta_prn/tests/tests/test_dm_referral.py +3 -6
  118. meta_reports/__init__.py +1 -0
  119. meta_reports/admin/__init__.py +15 -0
  120. meta_reports/admin/dbviews/__init__.py +14 -0
  121. meta_reports/admin/dbviews/glucose_summary_admin.py +116 -0
  122. meta_reports/admin/dbviews/imp_substitutions_admin.py +101 -0
  123. meta_reports/admin/dbviews/missing_screening_ogtt_admin/__init__.py +2 -0
  124. meta_reports/admin/dbviews/missing_screening_ogtt_admin/note_model_admin.py +53 -0
  125. meta_reports/admin/dbviews/missing_screening_ogtt_admin/unmanaged_model_admin.py +84 -0
  126. meta_reports/admin/dbviews/on_study_missing_lab_values_admin/__init__.py +1 -0
  127. meta_reports/admin/dbviews/on_study_missing_lab_values_admin/unmanaged_model_admin.py +13 -0
  128. meta_reports/admin/dbviews/on_study_missing_values_admin/__init__.py +1 -0
  129. meta_reports/admin/dbviews/on_study_missing_values_admin/unmanaged_model_admin.py +13 -0
  130. meta_reports/admin/dbviews/patient_history_missing_baseline_cd4_admin.py +58 -0
  131. meta_reports/admin/dbviews/unattended_three_in_row2_admin.py +47 -0
  132. meta_reports/admin/dbviews/unattended_three_in_row_admin.py +35 -0
  133. meta_reports/admin/dbviews/unattended_two_in_row_admin.py +34 -0
  134. meta_reports/admin/endpoints_admin.py +14 -0
  135. meta_reports/admin/endpoints_all_admin.py +13 -0
  136. meta_reports/admin/last_imp_refill_admin.py +181 -0
  137. meta_reports/admin/list_filters.py +30 -0
  138. meta_reports/admin/modeladmin_mixins.py +112 -0
  139. meta_reports/admin_site.py +5 -0
  140. meta_reports/apps.py +1 -16
  141. meta_reports/forms/__init__.py +1 -0
  142. meta_reports/forms/missing_ogtt_note_form.py +33 -0
  143. meta_reports/management/__init__.py +0 -0
  144. meta_reports/management/commands/__init__.py +0 -0
  145. meta_reports/management/commands/generate_endpoints.py +13 -0
  146. meta_reports/migrations/0001_initial.py +87 -0
  147. meta_reports/migrations/0002_patienthistorymissingbaselinecd4_and_more.py +64 -0
  148. meta_reports/migrations/0003_auto_20240618_0505.py +12 -0
  149. meta_reports/migrations/0004_alter_patienthistorymissingbaselinecd4_table.py +17 -0
  150. meta_reports/migrations/0005_endpoints.py +47 -0
  151. meta_reports/migrations/0006_endpoints_baseline_datetime.py +18 -0
  152. meta_reports/migrations/0007_alter_endpoints_endpoint_label_and_more.py +43 -0
  153. meta_reports/migrations/0008_alter_endpoints_endpoint_label.py +18 -0
  154. meta_reports/migrations/0009_alter_endpoints_options.py +21 -0
  155. meta_reports/migrations/0010_alter_patienthistorymissingbaselinecd4_options_and_more.py +49 -0
  156. meta_reports/migrations/0011_auto_20240813_0156.py +54 -0
  157. meta_reports/migrations/0012_auto_20240813_1516.py +48 -0
  158. meta_reports/migrations/0013_auto_20240813_1516.py +48 -0
  159. meta_reports/migrations/0014_auto_20240813_1517.py +48 -0
  160. meta_reports/migrations/0015_alter_endpoints_site.py +22 -0
  161. meta_reports/migrations/0016_missingscreeningogtt.py +47 -0
  162. meta_reports/migrations/0017_auto_20240819_1711.py +166 -0
  163. meta_reports/migrations/0018_auto_20240819_1713.py +54 -0
  164. meta_reports/migrations/0019_auto_20240819_1721.py +54 -0
  165. meta_reports/migrations/0020_auto_20240819_1811.py +54 -0
  166. meta_reports/migrations/0021_auto_20240819_1817.py +54 -0
  167. meta_reports/migrations/0022_auto_20240819_1832.py +54 -0
  168. meta_reports/migrations/0023_endpoints_meta_report_subject_a56b22_idx.py +20 -0
  169. meta_reports/migrations/0024_glucosesummary.py +38 -0
  170. meta_reports/migrations/0025_auto_20240822_0115.py +87 -0
  171. meta_reports/migrations/0026_auto_20240822_0120.py +54 -0
  172. meta_reports/migrations/0027_auto_20240822_0140.py +54 -0
  173. meta_reports/migrations/0028_alter_glucosesummary_options.py +22 -0
  174. meta_reports/migrations/0029_auto_20240822_0149.py +54 -0
  175. meta_reports/migrations/0030_auto_20240822_1637.py +54 -0
  176. meta_reports/migrations/0031_endpointsproxy.py +25 -0
  177. meta_reports/migrations/0032_alter_endpointsproxy_options.py +21 -0
  178. meta_reports/migrations/0033_auto_20240823_0012.py +54 -0
  179. meta_reports/migrations/0034_auto_20240823_1642.py +54 -0
  180. meta_reports/migrations/0035_historicalmissingogttnote_missingogttnote.py +457 -0
  181. meta_reports/migrations/0036_historicalmissingogttnote_fasting_and_more.py +86 -0
  182. meta_reports/migrations/0037_historicalmissingogttnote_result_status_and_more.py +51 -0
  183. meta_reports/migrations/0038_alter_historicalmissingogttnote_fasting_and_more.py +33 -0
  184. meta_reports/migrations/0039_onstudymissingvalues.py +44 -0
  185. meta_reports/migrations/0040_auto_20240824_0412.py +282 -0
  186. meta_reports/migrations/0041_auto_20240828_2229.py +14 -0
  187. meta_reports/migrations/0042_onstudymissinglabvalues.py +43 -0
  188. meta_reports/migrations/0043_auto_20240828_2309.py +88 -0
  189. meta_reports/migrations/0044_auto_20240828_2323.py +93 -0
  190. meta_reports/migrations/0045_auto_20240829_0248.py +54 -0
  191. meta_reports/migrations/0046_auto_20240829_0250.py +54 -0
  192. meta_reports/migrations/0047_impsubstitutions.py +56 -0
  193. meta_reports/migrations/0048_auto_20240909_2338.py +48 -0
  194. meta_reports/migrations/0049_auto_20240911_0327.py +54 -0
  195. meta_reports/migrations/0050_alter_endpoints_created.py +19 -0
  196. meta_reports/migrations/0051_remove_endpoints_baseline_datetime_and_more.py +40 -0
  197. meta_reports/migrations/0052_lastimpvisit.py +57 -0
  198. meta_reports/migrations/0053_rename_lastimpvisit_lastimprefill_and_more.py +31 -0
  199. meta_reports/models/__init__.py +16 -0
  200. meta_reports/models/dbviews/README +14 -0
  201. meta_reports/models/dbviews/__init__.py +9 -0
  202. meta_reports/models/dbviews/glucose_summary/__init__.py +2 -0
  203. meta_reports/models/dbviews/glucose_summary/unmanaged_model.py +35 -0
  204. meta_reports/models/dbviews/glucose_summary/view_definition.py +28 -0
  205. meta_reports/models/dbviews/imp_substitutions/__init__.py +1 -0
  206. meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +41 -0
  207. meta_reports/models/dbviews/imp_substitutions/view_definition.py +21 -0
  208. meta_reports/models/dbviews/missing_screening_ogtt/__init__.py +2 -0
  209. meta_reports/models/dbviews/missing_screening_ogtt/note_model.py +57 -0
  210. meta_reports/models/dbviews/missing_screening_ogtt/unmanaged_model.py +41 -0
  211. meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py +20 -0
  212. meta_reports/models/dbviews/on_study_missing_lab_values/__init__.py +1 -0
  213. meta_reports/models/dbviews/on_study_missing_lab_values/qa_cases.py +53 -0
  214. meta_reports/models/dbviews/on_study_missing_lab_values/unmanged_model.py +20 -0
  215. meta_reports/models/dbviews/on_study_missing_lab_values/view_definition.py +17 -0
  216. meta_reports/models/dbviews/on_study_missing_values/__init__.py +1 -0
  217. meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +54 -0
  218. meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py +20 -0
  219. meta_reports/models/dbviews/on_study_missing_values/view_definition.py +17 -0
  220. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/__init__.py +1 -0
  221. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/unmanaged_model.py +31 -0
  222. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py +21 -0
  223. meta_reports/models/dbviews/unattended_three_in_row/__init__.py +1 -0
  224. meta_reports/models/dbviews/unattended_three_in_row/unmanaged_model.py +29 -0
  225. meta_reports/models/dbviews/unattended_three_in_row/view_definition.py +31 -0
  226. meta_reports/models/dbviews/unattended_three_in_row2/__init__.py +1 -0
  227. meta_reports/models/dbviews/unattended_three_in_row2/unmanaged_model.py +29 -0
  228. meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py +50 -0
  229. meta_reports/models/dbviews/unattended_two_in_row/__init__.py +1 -0
  230. meta_reports/models/dbviews/unattended_two_in_row/unmanaged_model.py +27 -0
  231. meta_reports/models/dbviews/unattended_two_in_row/view_definition.py +30 -0
  232. meta_reports/models/endpoints.py +31 -0
  233. meta_reports/models/endpoints_proxy.py +11 -0
  234. meta_reports/models/last_imp_refill.py +34 -0
  235. meta_reports/tasks.py +12 -0
  236. meta_reports/templates/meta_reports/columns/subject_identifier_column.html +1 -0
  237. meta_reports/templates/meta_reports/endpoints_all_change_list_note.html +12 -0
  238. meta_reports/templates/meta_reports/endpoints_change_list_note.html +12 -0
  239. meta_reports/tests/test_sql_gen.py +5 -0
  240. meta_reports/urls.py +8 -0
  241. meta_reports/utils.py +0 -0
  242. meta_screening/admin/subject_screening_admin.py +1 -0
  243. meta_screening/migrations/0067_alter_historicalscreeningpartone_report_datetime_and_more.py +84 -0
  244. meta_screening/tests/holidays.csv +1 -1
  245. meta_screening/tests/meta_test_case_mixin.py +15 -0
  246. meta_sites/tests/test_sites.py +1 -1
  247. meta_subject/action_items.py +2 -2
  248. meta_subject/admin/__init__.py +2 -1
  249. meta_subject/admin/birth_outcome_admin.py +2 -0
  250. meta_subject/admin/blood_results/__init__.py +1 -1
  251. meta_subject/admin/blood_results/{blood_results_lipid_admin.py → blood_results_lipids_admin.py} +7 -7
  252. meta_subject/admin/diabetes/__init__.py +1 -1
  253. meta_subject/admin/diabetes/dm_endpoint_admin.py +35 -0
  254. meta_subject/admin/glucose_fbg_admin.py +4 -0
  255. meta_subject/admin/other_arv_regimens_admin.py +2 -0
  256. meta_subject/admin/study_medication_admin.py +10 -0
  257. meta_subject/form_validators/__init__.py +1 -1
  258. meta_subject/form_validators/dm_endpoint_form_validator.py +35 -0
  259. meta_subject/forms/__init__.py +2 -2
  260. meta_subject/forms/blood_results/__init__.py +1 -1
  261. meta_subject/forms/blood_results/{blood_results_lipid_form.py → blood_results_lipids_form.py} +5 -5
  262. meta_subject/forms/diabetes/__init__.py +1 -2
  263. meta_subject/forms/diabetes/dm_endpoint_form.py +13 -0
  264. meta_subject/forms/study_medication_form.py +35 -0
  265. meta_subject/locale/lg/LC_MESSAGES/django.po +470 -0
  266. meta_subject/locale/sw/LC_MESSAGES/django.po +191 -89
  267. meta_subject/metadata_rules/metadata_rules.py +7 -0
  268. meta_subject/metadata_rules/predicates.py +45 -8
  269. meta_subject/migrations/0107_auto_20220415_0043.py +28 -22
  270. meta_subject/migrations/0126_auto_20220719_2142.py +4 -4
  271. meta_subject/migrations/0131_auto_20220722_0411.py +28 -23
  272. meta_subject/migrations/0132_auto_20220722_1825.py +10 -6
  273. meta_subject/migrations/0135_auto_20220722_2212.py +39 -35
  274. meta_subject/migrations/0150_auto_20220914_0039.py +15 -11
  275. meta_subject/migrations/0207_alter_historicalphysicalexam_waist_circumference_and_more.py +46 -0
  276. meta_subject/migrations/0208_birthoutcomes_crf_status_and_more.py +62 -0
  277. meta_subject/migrations/0209_remove_historicaldmdxresult_dm_diagnosis_and_more.py +37 -0
  278. meta_subject/migrations/0210_remove_dmdxresult_dm_diagnosis_and_more.py +123 -0
  279. meta_subject/migrations/0211_dmendpoint_endpoint_reached_and_more.py +45 -0
  280. meta_subject/migrations/0212_auto_20240827_2222.py +23 -0
  281. meta_subject/migrations/0213_rename_bloodresultslipid_bloodresultslipids_and_more.py +35 -0
  282. meta_subject/migrations/0214_historicalstudymedication_stock_codes_and_more.py +44 -0
  283. meta_subject/migrations/0215_alter_historicalstudymedication_stock_codes_and_more.py +46 -0
  284. meta_subject/model_mixins/arv_history_model_mixin.py +3 -3
  285. meta_subject/models/__init__.py +3 -2
  286. meta_subject/models/birth_outcomes.py +6 -1
  287. meta_subject/models/blood_results/__init__.py +1 -1
  288. meta_subject/models/blood_results/{blood_results_lipid.py → blood_results_lipids.py} +3 -3
  289. meta_subject/models/diabetes/__init__.py +1 -2
  290. meta_subject/models/diabetes/dm_endpoint.py +61 -0
  291. meta_subject/models/glucose.py +4 -1
  292. meta_subject/models/physical_exam.py +1 -0
  293. meta_subject/models/signals.py +19 -0
  294. meta_subject/models/todo.txt +1 -1
  295. meta_subject/static/meta_subject/slider.css +1 -1
  296. meta_subject/templates/meta_subject/endpoint_review_instructions.html +1 -1
  297. meta_subject/templates/meta_subject/widgets/slider.html +0 -1
  298. meta_subject/tests/holidays.csv +1 -1
  299. meta_subject/tests/tests/test_medication_adherence.py +5 -1
  300. meta_subject/tests/tests/test_metadata_rules.py +2 -2
  301. meta_subject/tests/tests/test_mnsi.py +212 -121
  302. meta_subject/tests/tests/test_sf12.py +0 -12
  303. meta_visit_schedule/constants.py +4 -0
  304. meta_visit_schedule/tests/tests/test_schedule.py +4 -0
  305. meta_visit_schedule/visit_schedules/phase_three/crfs.py +75 -13
  306. meta_visit_schedule/visit_schedules/phase_three/requisitions.py +12 -0
  307. meta_visit_schedule/visit_schedules/phase_three/schedule.py +65 -2
  308. meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py +1 -1
  309. tests/etc/randomization_list.csv +1 -1
  310. {meta_edc/tests → tests}/etc/randomization_list_phase_three.csv +4 -4
  311. tests/holidays.csv +1 -1
  312. {meta_edc/tests → tests}/test_settings.py +16 -6
  313. meta_edc/tests/etc/user-aes-local.key +0 -1
  314. meta_edc/tests/etc/user-aes-restricted.key +0 -0
  315. meta_edc/tests/etc/user-rsa-local-private.pem +0 -27
  316. meta_edc/tests/etc/user-rsa-local-public.pem +0 -9
  317. meta_edc/tests/etc/user-rsa-restricted-private.pem +0 -27
  318. meta_edc/tests/etc/user-rsa-restricted-public.pem +0 -9
  319. meta_edc/tests/etc/user-salt-local.key +0 -0
  320. meta_edc/tests/etc/user-salt-restricted.key +0 -0
  321. meta_edc-0.3.15.dist-info/METADATA +0 -88
  322. meta_reports/tests/holidays.csv +0 -15
  323. meta_subject/admin/diabetes/dm_diagnosis_admin.py +0 -89
  324. meta_subject/form_validators/dm_diagnosis_form_validator.py +0 -38
  325. meta_subject/form_validators/dm_dx_result_form_validator.py +0 -7
  326. meta_subject/forms/diabetes/dm_diagnosis_form.py +0 -13
  327. meta_subject/forms/diabetes/dm_dx_result_form.py +0 -11
  328. meta_subject/models/diabetes/dm_diagnosis.py +0 -50
  329. meta_subject/models/diabetes/dm_dx_result.py +0 -70
  330. /meta_edc-0.3.15.dist-info/AUTHORS → /meta_analytics/__init__.py +0 -0
  331. /meta_pharmacy/models.py → /meta_analytics/constants.py +0 -0
  332. /meta_reports/models.py → /meta_analytics/notebooks/cleaning/__init__.py +0 -0
  333. {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/LICENSE +0 -0
@@ -0,0 +1,86 @@
1
+ # Generated by Django 5.0.8 on 2024-08-23 14:26
2
+
3
+ import django.core.validators
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ dependencies = [
10
+ ("meta_reports", "0035_historicalmissingogttnote_missingogttnote"),
11
+ ]
12
+
13
+ operations = [
14
+ migrations.AddField(
15
+ model_name="historicalmissingogttnote",
16
+ name="fasting",
17
+ field=models.CharField(
18
+ choices=[("Yes", "Yes"), ("No", "No")],
19
+ max_length=15,
20
+ null=True,
21
+ verbose_name="Did the participant fast?",
22
+ ),
23
+ ),
24
+ migrations.AddField(
25
+ model_name="historicalmissingogttnote",
26
+ name="fasting_duration_delta",
27
+ field=models.DurationField(
28
+ blank=True,
29
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
30
+ null=True,
31
+ ),
32
+ ),
33
+ migrations.AddField(
34
+ model_name="historicalmissingogttnote",
35
+ name="fasting_duration_str",
36
+ field=models.CharField(
37
+ blank=True,
38
+ help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
39
+ max_length=8,
40
+ null=True,
41
+ validators=[
42
+ django.core.validators.RegexValidator(
43
+ "^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
44
+ message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
45
+ )
46
+ ],
47
+ verbose_name="How long have they fasted in hours and/or minutes?",
48
+ ),
49
+ ),
50
+ migrations.AddField(
51
+ model_name="missingogttnote",
52
+ name="fasting",
53
+ field=models.CharField(
54
+ choices=[("Yes", "Yes"), ("No", "No")],
55
+ max_length=15,
56
+ null=True,
57
+ verbose_name="Did the participant fast?",
58
+ ),
59
+ ),
60
+ migrations.AddField(
61
+ model_name="missingogttnote",
62
+ name="fasting_duration_delta",
63
+ field=models.DurationField(
64
+ blank=True,
65
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
66
+ null=True,
67
+ ),
68
+ ),
69
+ migrations.AddField(
70
+ model_name="missingogttnote",
71
+ name="fasting_duration_str",
72
+ field=models.CharField(
73
+ blank=True,
74
+ help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
75
+ max_length=8,
76
+ null=True,
77
+ validators=[
78
+ django.core.validators.RegexValidator(
79
+ "^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
80
+ message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
81
+ )
82
+ ],
83
+ verbose_name="How long have they fasted in hours and/or minutes?",
84
+ ),
85
+ ),
86
+ ]
@@ -0,0 +1,51 @@
1
+ # Generated by Django 5.0.8 on 2024-08-23 14:40
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_reports", "0036_historicalmissingogttnote_fasting_and_more"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name="historicalmissingogttnote",
15
+ name="result_status",
16
+ field=models.CharField(
17
+ choices=[("Yes", "Yes"), ("No", "No")],
18
+ default="Yes",
19
+ max_length=25,
20
+ verbose_name="Is the OGTT result available",
21
+ ),
22
+ ),
23
+ migrations.AddField(
24
+ model_name="missingogttnote",
25
+ name="result_status",
26
+ field=models.CharField(
27
+ choices=[("Yes", "Yes"), ("No", "No")],
28
+ default="Yes",
29
+ max_length=25,
30
+ verbose_name="Is the OGTT result available",
31
+ ),
32
+ ),
33
+ migrations.AlterField(
34
+ model_name="historicalmissingogttnote",
35
+ name="status",
36
+ field=models.CharField(
37
+ choices=[("COMPLETE", "Complete"), ("not_available", "Not available")],
38
+ default="done",
39
+ max_length=25,
40
+ ),
41
+ ),
42
+ migrations.AlterField(
43
+ model_name="missingogttnote",
44
+ name="status",
45
+ field=models.CharField(
46
+ choices=[("COMPLETE", "Complete"), ("not_available", "Not available")],
47
+ default="done",
48
+ max_length=25,
49
+ ),
50
+ ),
51
+ ]
@@ -0,0 +1,33 @@
1
+ # Generated by Django 5.0.8 on 2024-08-23 15:06
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_reports", "0037_historicalmissingogttnote_result_status_and_more"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="historicalmissingogttnote",
15
+ name="fasting",
16
+ field=models.CharField(
17
+ choices=[("Yes", "Yes"), ("No", "No"), ("N/A", "Not applicable")],
18
+ default="N/A",
19
+ max_length=15,
20
+ verbose_name="Did the participant fast?",
21
+ ),
22
+ ),
23
+ migrations.AlterField(
24
+ model_name="missingogttnote",
25
+ name="fasting",
26
+ field=models.CharField(
27
+ choices=[("Yes", "Yes"), ("No", "No"), ("N/A", "Not applicable")],
28
+ default="N/A",
29
+ max_length=15,
30
+ verbose_name="Did the participant fast?",
31
+ ),
32
+ ),
33
+ ]
@@ -0,0 +1,44 @@
1
+ # Generated by Django 5.0.8 on 2024-08-23 18:58
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_reports", "0038_alter_historicalmissingogttnote_fasting_and_more"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.CreateModel(
14
+ name="OnstudyMissingValues",
15
+ fields=[
16
+ (
17
+ "id",
18
+ models.BigAutoField(
19
+ auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
20
+ ),
21
+ ),
22
+ ("report_model", models.CharField(max_length=50)),
23
+ ("subject_identifier", models.CharField(max_length=25)),
24
+ ("created", models.DateTimeField()),
25
+ ("dbtable", models.CharField(max_length=150, null=True)),
26
+ ("subject_visit_id", models.UUIDField(null=True)),
27
+ ("report_datetime", models.DateTimeField(null=True)),
28
+ ("label", models.CharField(max_length=50, null=True)),
29
+ ("visit_code", models.CharField(max_length=25, null=True)),
30
+ ("visit_code_sequence", models.IntegerField(null=True)),
31
+ ("schedule_name", models.CharField(max_length=25, null=True)),
32
+ ("user_created", models.CharField(max_length=25, null=True)),
33
+ ("user_modified", models.CharField(max_length=25, null=True)),
34
+ ("modified", models.DateTimeField(null=True)),
35
+ ],
36
+ options={
37
+ "verbose_name": "Missing values for on-study patient",
38
+ "verbose_name_plural": "Missing values for on-study patients",
39
+ "db_table": "onstudy_missing_values_view",
40
+ "managed": False,
41
+ "default_permissions": ("view", "export", "viewallsites"),
42
+ },
43
+ ),
44
+ ]
@@ -0,0 +1,282 @@
1
+ # Generated by Django 5.0.8 on 2024-08-24 01:12
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", "0039_onstudymissingvalues"),
12
+ ]
13
+
14
+ operations = [
15
+ django_db_views.operations.ViewRunPython(
16
+ code=django_db_views.migration_functions.ForwardViewMigration(
17
+ "select *, uuid() as id, now() as `created`, 'meta_reports.glucose_summary_view' as `report_model` from (SELECT v.subject_identifier, fbg_value, fbg_datetime, NULL AS `ogtt_value`, NULL AS `ogtt_datetime`, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS `fasted`, fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
18
+ "glucose_summary_view",
19
+ engine="django.db.backends.mysql",
20
+ ),
21
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
22
+ '# noqa\nselect *, uuid() as id, now() as created, \'meta_reports.glucose_summary_view\' as report_model\nfrom (\n select v.subject_identifier, fbg_value, fbg_datetime, null as \'ogtt_value\', null as \'ogtt_datetime\',\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as \'fasted\',\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucosefbg as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier\n UNION\n select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as \'fasted\',\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucose as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier\n) as A\norder by subject_identifier, fbg_datetime',
23
+ "glucose_summary_view",
24
+ engine="django.db.backends.mysql",
25
+ ),
26
+ atomic=False,
27
+ ),
28
+ django_db_views.operations.ViewRunPython(
29
+ code=django_db_views.migration_functions.ForwardViewMigration(
30
+ "select *, get_random_uuid() as id, now() as created, 'meta_reports.glucose_summary_view' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
31
+ "glucose_summary_view",
32
+ engine="django.db.backends.postgresql",
33
+ ),
34
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
35
+ '# noqa\nselect *, get_random_uuid() as id, now() as created, \'meta_reports.glucose_summary_view\' as report_model\nfrom (\n select v.subject_identifier, fbg_value, fbg_datetime, null as ogtt_value, null as ogtt_datetime,\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucosefbg as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier\n UNION\n select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucose as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier\n) as A\norder by subject_identifier, fbg_datetime',
36
+ "glucose_summary_view",
37
+ engine="django.db.backends.postgresql",
38
+ ),
39
+ atomic=False,
40
+ ),
41
+ django_db_views.operations.ViewRunPython(
42
+ code=django_db_views.migration_functions.ForwardViewMigration(
43
+ "select *, uuid() as id, datetime() as created, 'meta_reports.glucose_summary_view' as report_model from (SELECT v.subject_identifier, fbg_value, fbg_datetime, NULL AS \"ogtt_value\", NULL AS \"ogtt_datetime\", CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucosefbg AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier UNION SELECT v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime, CASE WHEN fasting = 'fasting' THEN 'Yes' WHEN fasting = 'non_fasting' THEN 'No' ELSE fasting END AS \"fasted\", fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime FROM meta_subject_glucose AS fbg LEFT JOIN meta_subject_subjectvisit AS v ON v.id = fbg.subject_visit_id LEFT JOIN meta_prn_endofstudy AS eos ON v.subject_identifier = eos.subject_identifier) as A ORDER BY subject_identifier, site_id",
44
+ "glucose_summary_view",
45
+ engine="django.db.backends.sqlite3",
46
+ ),
47
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
48
+ '# noqa\nSELECT *, lower(\n hex(randomblob(4)) || \'-\' || hex(randomblob(2)) || \'-\' || \'4\' ||\n substr(hex( randomblob(2)), 2) || \'-\' ||\n substr(\'AB89\', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || \'-\' ||\n hex(randomblob(6))\n ) as id, datetime() as `created`, \'meta_reports.glucose_summary_view\' as report_model\nfrom (\n select v.subject_identifier, fbg_value, fbg_datetime, null as ogtt_value, null as ogtt_datetime,\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucosefbg as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier\n UNION\n select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,\n case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,\n fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime\n from meta_subject_glucose as fbg\n left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id\n left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier \n ) as A\norder by subject_identifier, fbg_datetime',
49
+ "glucose_summary_view",
50
+ engine="django.db.backends.sqlite3",
51
+ ),
52
+ atomic=False,
53
+ ),
54
+ django_db_views.operations.ViewRunPython(
55
+ code=django_db_views.migration_functions.ForwardViewMigration(
56
+ "select *, uuid() as id, now() as `created`, 'meta_reports.missing_screening_ogtt_view' as `report_model` from (SELECT screening_identifier, site_id, report_datetime AS `screening_datetime`, fbg_datetime, converted_fbg_value AS `fbg_value`, converted_ogtt_value AS `ogtt_value`, fbg2_value, ogtt2_value, repeat_glucose_performed AS `repeated`, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS `subject_identifier`, id AS `original_id` FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> 'Yes') as A ORDER BY subject_identifier, site_id",
57
+ "missing_screening_ogtt_view",
58
+ engine="django.db.backends.mysql",
59
+ ),
60
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
61
+ "# noqa\n select *, uuid() as id, now() as created,\n 'meta_reports.missing_screening_ogtt_view' as report_model\n from (\n select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,\n converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, repeat_glucose_performed as repeated,\n p3_ltfu, fbg2_value, ogtt2_value, fbg2_datetime, ogtt2_datetime, consented,\n screening_identifier as subject_identifier, id as original_id\n from meta_screening_subjectscreening\n where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != \"Yes\"\n ) as A\n order by screening_identifier",
62
+ "missing_screening_ogtt_view",
63
+ engine="django.db.backends.mysql",
64
+ ),
65
+ atomic=False,
66
+ ),
67
+ django_db_views.operations.ViewRunPython(
68
+ code=django_db_views.migration_functions.ForwardViewMigration(
69
+ 'select *, get_random_uuid() as id, now() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
70
+ "missing_screening_ogtt_view",
71
+ engine="django.db.backends.postgresql",
72
+ ),
73
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
74
+ "# noqa\n select *, get_random_uuid() as id, now() as created,\n 'meta_reports.missing_screening_ogtt_view' as report_model\n from (\n select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,\n converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, repeat_glucose_performed as repeated,\n p3_ltfu, fbg2_value, ogtt2_value, fbg2_datetime, ogtt2_datetime, consented,\n screening_identifier as subject_identifier, id as original_id\n from meta_screening_subjectscreening\n where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != \"Yes\"\n ) as A\n order by screening_identifier",
75
+ "missing_screening_ogtt_view",
76
+ engine="django.db.backends.postgresql",
77
+ ),
78
+ atomic=False,
79
+ ),
80
+ django_db_views.operations.ViewRunPython(
81
+ code=django_db_views.migration_functions.ForwardViewMigration(
82
+ 'select *, uuid() as id, datetime() as created, \'meta_reports.missing_screening_ogtt_view\' as report_model from (SELECT screening_identifier, site_id, report_datetime AS "screening_datetime", fbg_datetime, converted_fbg_value AS "fbg_value", converted_ogtt_value AS "ogtt_value", fbg2_value, ogtt2_value, repeat_glucose_performed AS "repeated", p3_ltfu, fbg2_datetime, ogtt2_datetime, consented, screening_identifier AS "subject_identifier", id AS "original_id" FROM meta_screening_subjectscreening WHERE NOT converted_fbg_value IS NULL AND converted_ogtt_value IS NULL AND unsuitable_agreed <> \'Yes\') as A ORDER BY subject_identifier, site_id',
83
+ "missing_screening_ogtt_view",
84
+ engine="django.db.backends.sqlite3",
85
+ ),
86
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
87
+ "# noqa\nSELECT *, lower(\n hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n substr(hex( randomblob(2)), 2) || '-' ||\n substr('AB89', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || '-' ||\n hex(randomblob(6))\n ) as id, datetime() as `created`,\n 'meta_reports.missing_screening_ogtt_view' as report_model\n from (\n select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,\n converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, fbg2_value, ogtt2_value,\n repeat_glucose_performed as repeated, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented,\n screening_identifier as subject_identifier, id as original_id\n from meta_screening_subjectscreening\n where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != \"Yes\"\n ) as A\n order by screening_identifier",
88
+ "missing_screening_ogtt_view",
89
+ engine="django.db.backends.sqlite3",
90
+ ),
91
+ atomic=False,
92
+ ),
93
+ django_db_views.operations.ViewRunPython(
94
+ code=django_db_views.migration_functions.ForwardViewMigration(
95
+ "select *, uuid() as id, now() as `created`, '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",
96
+ "onstudy_missing_values_view",
97
+ engine="django.db.backends.mysql",
98
+ ),
99
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
100
+ "", "onstudy_missing_values_view", engine="django.db.backends.mysql"
101
+ ),
102
+ atomic=False,
103
+ ),
104
+ django_db_views.operations.ViewRunPython(
105
+ code=django_db_views.migration_functions.ForwardViewMigration(
106
+ "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",
107
+ "onstudy_missing_values_view",
108
+ engine="django.db.backends.postgresql",
109
+ ),
110
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
111
+ "", "onstudy_missing_values_view", engine="django.db.backends.postgresql"
112
+ ),
113
+ atomic=False,
114
+ ),
115
+ django_db_views.operations.ViewRunPython(
116
+ code=django_db_views.migration_functions.ForwardViewMigration(
117
+ "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",
118
+ "onstudy_missing_values_view",
119
+ engine="django.db.backends.sqlite3",
120
+ ),
121
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
122
+ "", "onstudy_missing_values_view", engine="django.db.backends.sqlite3"
123
+ ),
124
+ atomic=False,
125
+ ),
126
+ django_db_views.operations.ViewRunPython(
127
+ code=django_db_views.migration_functions.ForwardViewMigration(
128
+ "select *, uuid() as id, now() as `created`, 'meta_reports.patienthistorymissingbaselinecd4' as `report_model` from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
129
+ "patient_history_missing_baseline_cd4_view",
130
+ engine="django.db.backends.mysql",
131
+ ),
132
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
133
+ "select *, uuid() as id, now() as created, \n 'meta_reports.patienthistorymissingbaselinecd4' as report_model \n from (\n select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,\n cd4_date, crf.site_id, crf.user_created, crf.user_modified,\n crf.modified\n from meta_subject_patienthistory as crf\n left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id\n where cd4 is null or cd4_date is null\n ) as A\n order by subject_identifier",
134
+ "patient_history_missing_baseline_cd4_view",
135
+ engine="django.db.backends.mysql",
136
+ ),
137
+ atomic=False,
138
+ ),
139
+ django_db_views.operations.ViewRunPython(
140
+ code=django_db_views.migration_functions.ForwardViewMigration(
141
+ "select *, get_random_uuid() as id, now() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
142
+ "patient_history_missing_baseline_cd4_view",
143
+ engine="django.db.backends.postgresql",
144
+ ),
145
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
146
+ "select *, get_random_uuid() as id, now() as created, \n 'meta_reports.patienthistorymissingbaselinecd4' as report_model \n from (\n select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,\n cd4_date, crf.site_id, crf.user_created, crf.user_modified,\n crf.modified\n from meta_subject_patienthistory as crf\n left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id\n where cd4 is null or cd4_date is null\n ) as A\n order by subject_identifier",
147
+ "patient_history_missing_baseline_cd4_view",
148
+ engine="django.db.backends.postgresql",
149
+ ),
150
+ atomic=False,
151
+ ),
152
+ django_db_views.operations.ViewRunPython(
153
+ code=django_db_views.migration_functions.ForwardViewMigration(
154
+ "select *, uuid() as id, datetime() as created, 'meta_reports.patienthistorymissingbaselinecd4' as report_model from (SELECT subject_identifier, v.visit_code, v.visit_code_sequence, cd4, cd4_date, crf.site_id, crf.user_created, crf.user_modified, crf.modified FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON crf.subject_visit_id = v.id WHERE cd4 IS NULL OR cd4_date IS NULL) as A ORDER BY subject_identifier, site_id",
155
+ "patient_history_missing_baseline_cd4_view",
156
+ engine="django.db.backends.sqlite3",
157
+ ),
158
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
159
+ "SELECT *, lower(\n hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n substr(hex( randomblob(2)), 2) || '-' ||\n substr('AB89', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || '-' ||\n hex(randomblob(6))\n ) as id, datetime() as `created`, 'meta_reports.patienthistorymissingbaselinecd4' as report_model \n from (\n select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,\n cd4_date, crf.site_id, crf.user_created, crf.user_modified,\n crf.modified\n from meta_subject_patienthistory as crf\n left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id\n where cd4 is null or cd4_date is null\n ) as A\n order by subject_identifier",
160
+ "patient_history_missing_baseline_cd4_view",
161
+ engine="django.db.backends.sqlite3",
162
+ ),
163
+ atomic=False,
164
+ ),
165
+ django_db_views.operations.ViewRunPython(
166
+ code=django_db_views.migration_functions.ForwardViewMigration(
167
+ "select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS `interval_days`, DATEDIFF(NOW(), `first_date`) AS `from_now_days` FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `third_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL) as A ORDER BY subject_identifier, site_id",
168
+ "unattended_three_in_row_view",
169
+ engine="django.db.backends.mysql",
170
+ ),
171
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
172
+ "# noqa\n select *, uuid() as id, now() as created, 'meta_reports.unattendedthreeinrow' as `report_model` from (\n select subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, `third_value`,\n datediff(third_date, first_date) as `interval_days`,\n datediff(now(), first_date) as `from_now_days`\n from (\n select subject_identifier, site_id, appt_datetime,\n FIRST_VALUE(visit_code) OVER w as `first_value`,\n NTH_VALUE(visit_code, 2) OVER w as `second_value`,\n NTH_VALUE(visit_code, 3) OVER w as `third_value`,\n FIRST_VALUE(appt_datetime) OVER w as `first_date`,\n NTH_VALUE(appt_datetime, 3) OVER w as `third_date`\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= now()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A\n where `second_value` is not null and `third_value` is not null\n ) as B\n order by site_id, from_now_days desc",
173
+ "unattended_three_in_row_view",
174
+ engine="django.db.backends.mysql",
175
+ ),
176
+ atomic=False,
177
+ ),
178
+ django_db_views.operations.ViewRunPython(
179
+ code=django_db_views.migration_functions.ForwardViewMigration(
180
+ 'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "interval_days", CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
181
+ "unattended_three_in_row_view",
182
+ engine="django.db.backends.postgresql",
183
+ ),
184
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
185
+ "# noqa\n select *, gen_random_uuid() as id, now() as created,\n 'meta_reports.unattendedthreeinrow' as report_model\n from (\n select subject_identifier, site_id, appt_datetime, first_value, second_value, third_value,\n EXTRACT(DAY FROM third_date - first_date) as interval_days,\n EXTRACT(DAY FROM now() - first_date) as from_now_days\n from (\n select subject_identifier,site_id,appt_datetime,\n FIRST_VALUE(visit_code) OVER w as first_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as third_value,\n FIRST_VALUE(appt_datetime) OVER w as first_date,\n NTH_VALUE(appt_datetime, 3) OVER w as third_date\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= now()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A\n where second_value is not null and third_value is not null\n ) as B\n order by site_id, from_now_days desc",
186
+ "unattended_three_in_row_view",
187
+ engine="django.db.backends.postgresql",
188
+ ),
189
+ atomic=False,
190
+ ),
191
+ django_db_views.operations.ViewRunPython(
192
+ code=django_db_views.migration_functions.ForwardViewMigration(
193
+ 'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS "interval_days", CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS "from_now_days" FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 3) OVER w AS "third_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL) as A ORDER BY subject_identifier, site_id',
194
+ "unattended_three_in_row_view",
195
+ engine="django.db.backends.sqlite3",
196
+ ),
197
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
198
+ "# noqa\nSELECT *, lower(\n hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n substr(hex( randomblob(2)), 2) || '-' ||\n substr('AB89', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || '-' ||\n hex(randomblob(6))\n ) as id, datetime() as created,'meta_reports.unattendedthreeinrow' as report_model from (\n select subject_identifier, site_id, appt_datetime, first_value, second_value, third_value,\n CAST(JulianDay(third_date) - JulianDay(first_date) AS INTEGER) as interval_days,\n CAST(JulianDay(datetime()) - JulianDay(first_date) AS INTEGER) as from_now_days\n from (\n select subject_identifier, site_id, appt_datetime,\n FIRST_VALUE(visit_code) OVER w as first_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as third_value,\n FIRST_VALUE(appt_datetime) OVER w as first_date,\n NTH_VALUE(appt_datetime, 3) OVER w as third_date\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= datetime()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A\n where second_value is not null and third_value is not null\n ) as B\n order by site_id, from_now_days desc",
199
+ "unattended_three_in_row_view",
200
+ engine="django.db.backends.sqlite3",
201
+ ),
202
+ atomic=False,
203
+ ),
204
+ django_db_views.operations.ViewRunPython(
205
+ code=django_db_views.migration_functions.ForwardViewMigration(
206
+ "with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing=\"missed\" then \"New\" else appt_status end as `appt_status`,\ncase when appt_timing=\"missed\" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, now() as `created`, 'meta_reports.unattendedthreeinrow2' as `report_model` from (SELECT DISTINCT subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days, `first_status`, `second_status`, `third_status`, SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, `missed`, FIRST_VALUE(appt_status) OVER w AS `third_status`, NTH_VALUE(appt_status, 2) OVER w AS `second_status`, NTH_VALUE(appt_status, 3) OVER w AS `first_status`, FIRST_VALUE(visit_code) OVER w AS `third_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `first_value`, FIRST_VALUE(appt_datetime) OVER w AS `third_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date`, NTH_VALUE(appt_datetime, 3) OVER w AS `first_date` FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND NOT `third_value` IS NULL AND `first_status` = 'New' AND `second_status` = 'New' AND `third_status` = 'New' GROUP BY subject_identifier, site_id, `first_value`, `second_value`, `third_value`, DATEDIFF(`third_date`, `first_date`), DATEDIFF(NOW(), `first_date`), `first_status`, `second_status`, `third_status` ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id",
207
+ "unattended_three_in_row2_view",
208
+ engine="django.db.backends.mysql",
209
+ ),
210
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
211
+ "# noqa\n with appointments as (\n select subject_identifier, site_id, visit_code, visit_code_sequence, appt_datetime,\n case when appt_timing='missed' then 'New' else appt_status end as `appt_status`,\n case when appt_timing='missed' then 1 else 0 end as `missed`\n from edc_appointment_appointment\n where visit_code_sequence=0 and appt_datetime<=now()\n order by subject_identifier, appt_datetime\n )\n select *, uuid() as `id`, now() as `created`, 'meta_reports.unattendedthreeinrow2' as `report_model` from (\n select distinct subject_identifier, site_id, `first_value`, `second_value`, `third_value`,\n datediff(third_date, first_date) as `interval_days`,\n datediff(now(), first_date) as `from_now_days`,\n `first_status`, `second_status`, `third_status`, sum(missed) as `missed_count`\n from (\n select subject_identifier,site_id,appt_datetime, missed,\n FIRST_VALUE(appt_status) OVER w as `third_status`,\n NTH_VALUE(appt_status, 2) OVER w as `second_status`,\n NTH_VALUE(appt_status, 3) OVER w as `first_status`,\n FIRST_VALUE(visit_code) OVER w as `third_value`,\n NTH_VALUE(visit_code, 2) OVER w as `second_value`,\n NTH_VALUE(visit_code, 3) OVER w as `first_value`,\n FIRST_VALUE(appt_datetime) OVER w as `third_date`,\n NTH_VALUE(appt_datetime, 2) OVER w as `second_date`,\n NTH_VALUE(appt_datetime, 3) OVER w as `first_date`\n from appointments\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime desc ROWS UNBOUNDED PRECEDING)\n ) as A\n where `second_value` is not null and `third_value` is not null\n and `first_status`='New'\n and `second_status`='New'\n and `third_status`='New'\n group by subject_identifier, site_id, `first_value`, `second_value`, `third_value`,\n datediff(`third_date`, `first_date`),\n datediff(now(), `first_date`),\n `first_status`, `second_status`, `third_status`\n order by subject_identifier, site_id\n ) as B",
212
+ "unattended_three_in_row2_view",
213
+ engine="django.db.backends.mysql",
214
+ ),
215
+ atomic=False,
216
+ ),
217
+ django_db_views.operations.ViewRunPython(
218
+ code=django_db_views.migration_functions.ForwardViewMigration(
219
+ 'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST(AGE(CAST("third_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT), "first_status", "second_status", "third_status" ORDER BY subject_identifier NULLS FIRST, site_id NULLS FIRST) as A ORDER BY subject_identifier, site_id',
220
+ "unattended_three_in_row2_view",
221
+ engine="django.db.backends.postgresql",
222
+ ),
223
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
224
+ "# noqa\n with appointments as (\n select subject_identifier, site_id, visit_code, visit_code_sequence, appt_datetime,\n case when appt_timing='missed' then 'New' else appt_status end as appt_status,\n case when appt_timing='missed' then 1 else 0 end as missed\n from edc_appointment_appointment\n where visit_code_sequence=0 and appt_datetime<=now()\n order by subject_identifier, appt_datetime\n )\n select *, gen_random_uuid() as id, now() as created, 'meta_reports.unattendedthreeinrow2' as report_model\n from (\n select distinct subject_identifier, site_id, first_value, second_value, third_value,\n EXTRACT(DAY FROM third_date - first_date) as interval_days,\n EXTRACT(DAY FROM now() - first_date) as from_now_days,\n first_status, second_status, third_status, sum(missed) as missed_count\n from (\n select subject_identifier,site_id,appt_datetime, missed,\n FIRST_VALUE(appt_status) OVER w as third_status,\n NTH_VALUE(appt_status, 2) OVER w as second_status,\n NTH_VALUE(appt_status, 3) OVER w as first_status,\n FIRST_VALUE(visit_code) OVER w as third_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as first_value,\n FIRST_VALUE(appt_datetime) OVER w as third_date,\n NTH_VALUE(appt_datetime, 2) OVER w as second_date,\n NTH_VALUE(appt_datetime, 3) OVER w as first_date\n from appointments\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime desc ROWS UNBOUNDED PRECEDING)\n ) as A\n where second_value is not null and third_value is not null\n and first_status='New'\n and second_status='New'\n and third_status='New'\n group by subject_identifier, site_id, first_value, second_value, third_value,\n EXTRACT(DAY FROM third_date - first_date),\n EXTRACT(DAY FROM now() - first_date),\n first_status, second_status, third_status\n order by subject_identifier, site_id\n ) as B",
225
+ "unattended_three_in_row2_view",
226
+ engine="django.db.backends.postgresql",
227
+ ),
228
+ atomic=False,
229
+ ),
230
+ django_db_views.operations.ViewRunPython(
231
+ code=django_db_views.migration_functions.ForwardViewMigration(
232
+ 'with appointments as (select subject_identifier, site_id, visit_code, visit_code_sequence,\nappt_datetime, case when appt_timing="missed" then "New" else appt_status end as `appt_status`,\ncase when appt_timing="missed" then 1 else 0 end as `missed`\nfrom edc_appointment_appointment\nwhere visit_code_sequence=0 and appt_datetime<=now()\norder by subject_identifier, appt_datetime) select *, uuid() as id, datetime() as created, \'meta_reports.unattendedthreeinrow2\' as report_model from (SELECT DISTINCT subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days, "first_status", "second_status", "third_status", SUM(missed) AS missed_count FROM (SELECT subject_identifier, site_id, appt_datetime, "missed", FIRST_VALUE(appt_status) OVER w AS "third_status", NTH_VALUE(appt_status, 2) OVER w AS "second_status", NTH_VALUE(appt_status, 3) OVER w AS "first_status", FIRST_VALUE(visit_code) OVER w AS "third_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "first_value", FIRST_VALUE(appt_datetime) OVER w AS "third_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date", NTH_VALUE(appt_datetime, 3) OVER w AS "first_date" FROM appointments WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND NOT "third_value" IS NULL AND "first_status" = \'New\' AND "second_status" = \'New\' AND "third_status" = \'New\' GROUP BY subject_identifier, site_id, "first_value", "second_value", "third_value", CAST((JULIANDAY("third_date") - JULIANDAY("first_date")) AS INTEGER), CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER), "first_status", "second_status", "third_status" ORDER BY subject_identifier, site_id) as A ORDER BY subject_identifier, site_id',
233
+ "unattended_three_in_row2_view",
234
+ engine="django.db.backends.sqlite3",
235
+ ),
236
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
237
+ "# noqa\n with appointments as (\n select subject_identifier, site_id, visit_code, visit_code_sequence, appt_datetime,\n case when appt_timing='missed' then 'New' else appt_status end as `appt_status`,\n case when appt_timing='missed' then 1 else 0 end as `missed`\n from edc_appointment_appointment\n where visit_code_sequence=0 and appt_datetime<=now()\n order by subject_identifier, appt_datetime\n )\n SELECT *, lower(\n hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n substr(hex( randomblob(2)), 2) || '-' ||\n substr('AB89', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || '-' ||\n hex(randomblob(6))\n ) as id, datetime() as created, 'meta_reports.unattendedthreeinrow2' as report_model from (\n select distinct subject_identifier, site_id, first_value, second_value, third_value,\n CAST(JulianDay(third_date) - JulianDay(first_date) AS Integer) as interval_days,\n CAST(JulianDay(datetime()) - JulianDay(first_date) AS Integer) as from_now_days,\n first_status, second_status, third_status, sum(missed) as missed_count\n from (\n select subject_identifier,site_id,appt_datetime, missed,\n FIRST_VALUE(appt_status) OVER w as third_status,\n NTH_VALUE(appt_status, 2) OVER w as second_status,\n NTH_VALUE(appt_status, 3) OVER w as first_status,\n FIRST_VALUE(visit_code) OVER w as third_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as first_value,\n FIRST_VALUE(appt_datetime) OVER w as third_date,\n NTH_VALUE(appt_datetime, 2) OVER w as second_date,\n NTH_VALUE(appt_datetime, 3) OVER w as first_date\n from appointments\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime desc ROWS UNBOUNDED PRECEDING)\n ) as A\n where second_value is not null and third_value is not null\n and first_status='New'\n and second_status='New'\n and third_status='New'\n group by subject_identifier, site_id, first_value, second_value, third_value,\n CAST(JulianDay(third_date) - JulianDay(first_date) AS Integer),\n CAST(JulianDay(datetime()) - JulianDay(first_date) AS Integer),\n first_status, second_status, third_status\n order by subject_identifier, site_id\n ) as B",
238
+ "unattended_three_in_row2_view",
239
+ engine="django.db.backends.sqlite3",
240
+ ),
241
+ atomic=False,
242
+ ),
243
+ django_db_views.operations.ViewRunPython(
244
+ code=django_db_views.migration_functions.ForwardViewMigration(
245
+ "select *, uuid() as id, now() as `created`, 'meta_reports.unattendedtwoinrow' as `report_model` from (SELECT subject_identifier, site_id, appt_datetime, `first_value`, `second_value`, DATEDIFF(`second_date`, `first_date`) AS interval_days, DATEDIFF(NOW(), `first_date`) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS `first_value`, NTH_VALUE(visit_code, 2) OVER w AS `second_value`, NTH_VALUE(visit_code, 3) OVER w AS `third_value`, FIRST_VALUE(appt_datetime) OVER w AS `first_date`, NTH_VALUE(appt_datetime, 2) OVER w AS `second_date` FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = 'New' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT `second_value` IS NULL AND `third_value` IS NULL) as A ORDER BY site_id, from_now_days desc",
246
+ "unattended_two_in_row_view",
247
+ engine="django.db.backends.mysql",
248
+ ),
249
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
250
+ "# noqa\n select *, uuid() as `id`, now() as `created`, 'meta_reports.unattendedtwoinrow' as report_model from (\n select subject_identifier, site_id, appt_datetime, `first_value`, `second_value`,\n datediff(`second_date`, `first_date`) as `interval_days`,\n datediff(now(), `first_date`) as `from_now_days`\n from (\n select subject_identifier ,site_id, appt_datetime,\n FIRST_VALUE(`visit_code`) OVER w as `first_value`,\n NTH_VALUE(`visit_code`, 2) OVER w as `second_value`,\n NTH_VALUE(`visit_code`, 3) OVER w as `third_value`,\n FIRST_VALUE(`appt_datetime`) OVER w as `first_date`,\n NTH_VALUE(`appt_datetime`, 2) OVER w as `second_date`\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= now()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A1\n where `second_value` is not null and `third_value` is null\n ) as A2\n order by site_id, `from_now_days` desc",
251
+ "unattended_two_in_row_view",
252
+ engine="django.db.backends.mysql",
253
+ ),
254
+ atomic=False,
255
+ ),
256
+ django_db_views.operations.ViewRunPython(
257
+ code=django_db_views.migration_functions.ForwardViewMigration(
258
+ 'select *, get_random_uuid() as id, now() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST(AGE(CAST("second_date" AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS interval_days, CAST(AGE(CAST(NOW() AS TIMESTAMP), CAST("first_date" AS TIMESTAMP)) AS BIGINT) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
259
+ "unattended_two_in_row_view",
260
+ engine="django.db.backends.postgresql",
261
+ ),
262
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
263
+ "# noqa\n select *, gen_random_uuid() as id, now() as created, 'meta_reports.unattendedtwoinrow' as report_model\n from (\n select subject_identifier, site_id, appt_datetime, first_value, second_value,\n EXTRACT(DAY FROM second_date - first_date) as interval_days,\n EXTRACT(DAY FROM now() - first_date) as from_now_days\n from (\n select subject_identifier, site_id, appt_datetime,\n FIRST_VALUE(visit_code) OVER w as first_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as third_value,\n FIRST_VALUE(appt_datetime) OVER w as first_date,\n NTH_VALUE(appt_datetime, 2) OVER w as second_date\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= now()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A1\n where second_value is not null and third_value is null\n ) as A2\n order by site_id, from_now_days desc",
264
+ "unattended_two_in_row_view",
265
+ engine="django.db.backends.postgresql",
266
+ ),
267
+ atomic=False,
268
+ ),
269
+ django_db_views.operations.ViewRunPython(
270
+ code=django_db_views.migration_functions.ForwardViewMigration(
271
+ 'select *, uuid() as id, datetime() as created, \'meta_reports.unattendedtwoinrow\' as report_model from (SELECT subject_identifier, site_id, appt_datetime, "first_value", "second_value", CAST((JULIANDAY("second_date") - JULIANDAY("first_date")) AS INTEGER) AS interval_days, CAST((JULIANDAY(NOW()) - JULIANDAY("first_date")) AS INTEGER) AS from_now_days FROM (SELECT subject_identifier, site_id, appt_datetime, FIRST_VALUE(visit_code) OVER w AS "first_value", NTH_VALUE(visit_code, 2) OVER w AS "second_value", NTH_VALUE(visit_code, 3) OVER w AS "third_value", FIRST_VALUE(appt_datetime) OVER w AS "first_date", NTH_VALUE(appt_datetime, 2) OVER w AS "second_date" FROM edc_appointment_appointment WHERE visit_code_sequence = 0 AND appt_status = \'New\' AND appt_datetime <= NOW() WINDOW w AS (PARTITION BY subject_identifier ORDER BY appt_datetime ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)) AS B WHERE NOT "second_value" IS NULL AND "third_value" IS NULL) as A ORDER BY site_id, from_now_days desc',
272
+ "unattended_two_in_row_view",
273
+ engine="django.db.backends.sqlite3",
274
+ ),
275
+ reverse_code=django_db_views.migration_functions.BackwardViewMigration(
276
+ "# noqa\nSELECT *, lower(\n hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||\n substr(hex( randomblob(2)), 2) || '-' ||\n substr('AB89', 1 + (abs(random()) % 4) , 1) ||\n substr(hex(randomblob(2)), 2) || '-' ||\n hex(randomblob(6))\n ) as id, datetime() as created, 'meta_reports.unattendedtwoinrow' as report_model from (\n select subject_identifier, site_id, appt_datetime, first_value, second_value,\n CAST(JulianDay(second_date) - JulianDay(first_date) AS Integer) as interval_days,\n CAST(JulianDay(datetime()) - JulianDay(first_date) AS Integer) as from_now_days\n from (\n select subject_identifier ,site_id, appt_datetime,\n FIRST_VALUE(visit_code) OVER w as first_value,\n NTH_VALUE(visit_code, 2) OVER w as second_value,\n NTH_VALUE(visit_code, 3) OVER w as third_value,\n FIRST_VALUE(appt_datetime) OVER w as first_date,\n NTH_VALUE(appt_datetime, 2) OVER w as second_date\n from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'\n and appt_datetime <= datetime()\n WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)\n ) as A1\n where second_value is not null and third_value is null\n ) as A2\n order by site_id, from_now_days desc",
277
+ "unattended_two_in_row_view",
278
+ engine="django.db.backends.sqlite3",
279
+ ),
280
+ atomic=False,
281
+ ),
282
+ ]
@@ -0,0 +1,14 @@
1
+ # Generated by Django 5.0.8 on 2024-08-28 19:29
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", "0040_auto_20240824_0412"),
12
+ ]
13
+
14
+ operations = []