meta-edc 0.3.27__py3-none-any.whl → 0.3.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/METADATA +2 -2
  2. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/RECORD +26 -17
  3. meta_reports/admin/__init__.py +1 -0
  4. meta_reports/admin/unmanaged/__init__.py +1 -0
  5. meta_reports/admin/unmanaged/on_study_missing_values_admin/__init__.py +1 -0
  6. meta_reports/admin/unmanaged/on_study_missing_values_admin/unmanaged_model_admin.py +13 -0
  7. meta_reports/migrations/0039_onstudymissingvalues.py +44 -0
  8. meta_reports/migrations/0040_auto_20240824_0412.py +282 -0
  9. meta_reports/models/__init__.py +1 -0
  10. meta_reports/models/dbviews/__init__.py +1 -0
  11. meta_reports/models/dbviews/glucose_summary/view_definition.py +14 -59
  12. meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py +14 -49
  13. meta_reports/models/dbviews/on_study_missing_values/__init__.py +1 -0
  14. meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +53 -0
  15. meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py +20 -0
  16. meta_reports/models/dbviews/on_study_missing_values/view_definition.py +20 -0
  17. meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py +13 -47
  18. meta_reports/models/dbviews/unattended_three_in_row/view_definition.py +20 -67
  19. meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py +44 -128
  20. meta_reports/models/dbviews/unattended_two_in_row/view_definition.py +25 -72
  21. meta_reports/utils.py +0 -0
  22. meta_subject/model_mixins/arv_history_model_mixin.py +3 -3
  23. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/AUTHORS +0 -0
  24. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/LICENSE +0 -0
  25. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/WHEEL +0 -0
  26. {meta_edc-0.3.27.dist-info → meta_edc-0.3.29.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: meta-edc
3
- Version: 0.3.27
3
+ Version: 0.3.29
4
4
  Summary: META Trial EDC (http://www.isrctn.com/ISRCTN76157257)
5
5
  Home-page: https://github.com/meta-trial/meta-edc
6
6
  Author: Erik van Widenfelt
@@ -20,7 +20,7 @@ Requires-Python: >=3.12
20
20
  Description-Content-Type: text/x-rst
21
21
  License-File: LICENSE
22
22
  License-File: AUTHORS
23
- Requires-Dist: edc ==0.6.4
23
+ Requires-Dist: edc ==0.6.6
24
24
  Requires-Dist: edc-microscopy
25
25
  Requires-Dist: beautifulsoup4
26
26
  Requires-Dist: edc-analytics
@@ -433,12 +433,13 @@ meta_reports/death_report.py,sha256=mJw08jMxOWIAtsKQN8zCP64HIrxW1fb48D9OXqEMpM0,
433
433
  meta_reports/pdf_report.py,sha256=9lWnRc_BNieDFXC4VgA0QHK6g_ct58u8tupPRsbRvV0,2395
434
434
  meta_reports/tasks.py,sha256=wPzfm99Hox1AIvt1KxYg1r6g9v8ta2AHOHesoN6AxEk,370
435
435
  meta_reports/urls.py,sha256=_c6AMrK4U5MsyFSU2JSPNfiZlbhuw24C7CyPNYpqGd0,206
436
- meta_reports/admin/__init__.py,sha256=OOVq30qqC5s7SVkWGO-AVHVOeyIrCXcfBGcpahAOrIo,344
436
+ meta_reports/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
437
+ meta_reports/admin/__init__.py,sha256=ZSXo6YJnLOCnfib5km39Jt3CjwRoBjwW97i5dYyLI1U,375
437
438
  meta_reports/admin/endpoints_admin.py,sha256=L4mDLNIkR6203RI3ImBYel2kevaH_Nwa6KMYuoDwyNU,518
438
439
  meta_reports/admin/endpoints_all_admin.py,sha256=_czdezZf9fSjwZJmO-3HbmdXrXP6nk8-HdiweqUzPRE,476
439
440
  meta_reports/admin/list_filters.py,sha256=pByBzz9-qGwqBfdZFlByxJUZDTJQXOTWfNLjmK8KF00,870
440
441
  meta_reports/admin/modeladmin_mixins.py,sha256=YgzUjGlzG5S3i8daVaexBpZ8WAEPBjlhktsRIvOkyo4,3752
441
- meta_reports/admin/unmanaged/__init__.py,sha256=56wDkwrBBt-50mQNHK9UiIRZAOBpsKk4Ui5PwWvb-Nk,471
442
+ meta_reports/admin/unmanaged/__init__.py,sha256=ZfHhQlZsU0M8algxk8coWqO5ZYRPhv_ofaiWkRGO1zo,540
442
443
  meta_reports/admin/unmanaged/glucose_summary_admin.py,sha256=NqnDKx5l0Q-2xxRGdnf50DaRX1Sn8-DC0jHSk96LkRo,4005
443
444
  meta_reports/admin/unmanaged/patient_history_missing_baseline_cd4_admin.py,sha256=XyroEqxlX816xrdi0IVSelNPxPBWi96niKa-MQVGkck,2058
444
445
  meta_reports/admin/unmanaged/unattended_three_in_row2_admin.py,sha256=0r13KRr0gsH2osmSlffRV11SpSBpWM612AYl-GOoYm0,1347
@@ -447,6 +448,8 @@ meta_reports/admin/unmanaged/unattended_two_in_row_admin.py,sha256=tbnga05uTMgdK
447
448
  meta_reports/admin/unmanaged/missing_screening_ogtt_admin/__init__.py,sha256=UZMypicuUuZ2jD2Rf0hcDUi-oBUf7_3fgyV5KacIJtE,117
448
449
  meta_reports/admin/unmanaged/missing_screening_ogtt_admin/note_model_admin.py,sha256=RcksbJ9HinK71iN9Pr_xMp-voj17pBqjLZpfMTJ7300,1357
449
450
  meta_reports/admin/unmanaged/missing_screening_ogtt_admin/unmanaged_model_admin.py,sha256=1pWmmqk6LADkPWqyxcS8nwC-KwMjuN8O7fmG_AbcA3g,2644
451
+ meta_reports/admin/unmanaged/on_study_missing_values_admin/__init__.py,sha256=6JBeWQzw56s-LvIBlhHVSys5HviEkAF2Xt8REJNeYOI,61
452
+ meta_reports/admin/unmanaged/on_study_missing_values_admin/unmanaged_model_admin.py,sha256=kCgKIxVTsEeIxdl1NfytR8JXEPw7cStJ_Lqc-VuHdkY,503
450
453
  meta_reports/forms/__init__.py,sha256=F5AIupgum2dWL1_HqQCjLkrpMzjQ2dbo065hlkXBTNY,56
451
454
  meta_reports/forms/missing_ogtt_note_form.py,sha256=nUG5uNqE-U6KtY9m-S48bricyERKHd95GkWn364oT1Q,1445
452
455
  meta_reports/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -490,31 +493,37 @@ meta_reports/migrations/0035_historicalmissingogttnote_missingogttnote.py,sha256
490
493
  meta_reports/migrations/0036_historicalmissingogttnote_fasting_and_more.py,sha256=sr0xr1MslT-jXD_mNr59IY3R1QPcq5Bpa6vc67VHBY4,3167
491
494
  meta_reports/migrations/0037_historicalmissingogttnote_result_status_and_more.py,sha256=FdGYLdu4zTxoDO9PCI2wlDS43fxfNGtynCKYABs5cAg,1600
492
495
  meta_reports/migrations/0038_alter_historicalmissingogttnote_fasting_and_more.py,sha256=-HljbT033-M0XZanZfcEA8jXmW3vhLoigdEC3hE5jOs,1010
496
+ meta_reports/migrations/0039_onstudymissingvalues.py,sha256=Tpr_0vujhzWEDYKKBNJevwJ6dkv22ImPIMcv1HQNqwk,1889
497
+ meta_reports/migrations/0040_auto_20240824_0412.py,sha256=mgUvizbsZUqEVDxu4EMymJ0L2vKaoAxyhjZkc1dUFDI,67126
493
498
  meta_reports/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
494
- meta_reports/models/__init__.py,sha256=mdSLwykOHh_Y9QSS9HeTes8SDie_Y4aRU8yYXehTjpA,303
499
+ meta_reports/models/__init__.py,sha256=0vX02FxHfknB7dzM_QS-H7smlXwmA3fZNv6m1KfQKAs,329
495
500
  meta_reports/models/endpoints.py,sha256=HfxQuKkzu883xbTeVfIEktN-ARoGe1qC6KgEAzRtV5E,925
496
501
  meta_reports/models/endpoints_proxy.py,sha256=3h3JGaPmnJedFPVWGrk4idV4YtdihqiCI5W7QomwG4E,318
497
502
  meta_reports/models/dbviews/README,sha256=GdeboB7Xqb-Qo_rE1ondcxP8Ps93MIjLzCePQCePig0,686
498
- meta_reports/models/dbviews/__init__.py,sha256=tE_j0PeMl-r97-KNATY9tdQYiw0sNH39s8E2PAyk2Q4,388
503
+ meta_reports/models/dbviews/__init__.py,sha256=tr-7SqSYb-QMc5SNLUx20yzyDcHS1sHVajhpwJp-3sg,446
499
504
  meta_reports/models/dbviews/glucose_summary/__init__.py,sha256=Tfgjso4TpxMCidAdRJp8g1Ykqqa43yWlQSotzAaORAo,93
500
505
  meta_reports/models/dbviews/glucose_summary/unmanaged_model.py,sha256=uqhD5JLXtyQ94zpG5Puxodjzli3quE4GgiFi7en6EeM,1055
501
- meta_reports/models/dbviews/glucose_summary/view_definition.py,sha256=f_lUpaKRMa1Z0y8Y7DPB2qbHEPeEXBDXr2FnM5yD55s,4029
506
+ meta_reports/models/dbviews/glucose_summary/view_definition.py,sha256=Fc5KN-It9dcBvRta-b26kUl8uQEHA19vrYIhNRqe2Xo,1512
502
507
  meta_reports/models/dbviews/missing_screening_ogtt/__init__.py,sha256=7uX_2HfVU-3G1O_xecfGnE5_pcX5eceiRaapeDQtzIw,105
503
508
  meta_reports/models/dbviews/missing_screening_ogtt/note_model.py,sha256=JHItVS11WDFg3lTe7ayH9T7Epd-VvXXD_79FssrmAwc,1813
504
509
  meta_reports/models/dbviews/missing_screening_ogtt/unmanaged_model.py,sha256=_XFzpOiMoxr-F0ebKNEnyXqS6dnb3P5tBRnZlbrQ2x8,1346
505
- meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py,sha256=2f7A0VLcb5ZGee8Us3SPLeExayCTXrGlCHt3j7072HY,2638
510
+ meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py,sha256=xgTBpq-SKhuXkABy3wYgCfGXeC9xBLhiCAc8Qqy0HqQ,1042
511
+ meta_reports/models/dbviews/on_study_missing_values/__init__.py,sha256=bxRAXRocUIdUCg9jARlztOE2co9LqgHbBOkU1Bykz9M,49
512
+ meta_reports/models/dbviews/on_study_missing_values/qa_cases.py,sha256=VtzhDyBIfTIHZkwMOY2kDPuv5mSS0uTHpsJ7C3gjodU,1757
513
+ meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py,sha256=TQptzrx1Xv-sE_3ioO9BZ1ZE7CKZG8JWXsFD6-ZxI8k,632
514
+ meta_reports/models/dbviews/on_study_missing_values/view_definition.py,sha256=f0NnQm2FheNBeuFQ5P5UPjReo7ETXIJ0LSqVKzDq0xs,608
506
515
  meta_reports/models/dbviews/patient_history_missing_baseline_cd4/__init__.py,sha256=eIyKY9mdIE3-J2vtQtY7MOg_RQkwKj7aserwO5PBNQQ,62
507
516
  meta_reports/models/dbviews/patient_history_missing_baseline_cd4/unmanaged_model.py,sha256=7TbSZJLdprIO8FvVq5a_MUXgiEvqAZ5NrirQVfH8Fnk,957
508
- meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py,sha256=AlraPbMyJ_bdfb2sBPbNT-CP_dUK8nSFh9bH1j3DTmw,2066
517
+ meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py,sha256=tO7f3l6IjaAMxJjgHcPuq4dy2wfj0DxQ2YqM-IY99ow,848
509
518
  meta_reports/models/dbviews/unattended_three_in_row/__init__.py,sha256=VW4jP7OqHsKXMCJCZiDGcIDYufXKJJ6ZJDRRhh1sQg0,50
510
519
  meta_reports/models/dbviews/unattended_three_in_row/unmanaged_model.py,sha256=0rIn4h_CYjo3ALoKhVTZ84zcN2zL57enXRh_LVR7k6E,951
511
- meta_reports/models/dbviews/unattended_three_in_row/view_definition.py,sha256=hblOA439iLsvLjt2x7JofN7lji-l4oEFj4QkzLYraaM,3781
520
+ meta_reports/models/dbviews/unattended_three_in_row/view_definition.py,sha256=WfCtj08hAt-TWXu06C96PVmJ83B-1dxweD61M0nBR_M,1458
512
521
  meta_reports/models/dbviews/unattended_three_in_row2/__init__.py,sha256=NjCXNy7Oo2htvyiJU8P5C-X9fnd5mxvT9cY9eExoWfA,51
513
522
  meta_reports/models/dbviews/unattended_three_in_row2/unmanaged_model.py,sha256=uWhlYXU6ppP-bm-bLH9bV9liL9MZhWDIJO_P_i8IdKU,979
514
- meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py,sha256=AIIyJPzyvLFWaJx8o4gbzfhGYsBaS7ihScDPKHEzNfg,7134
523
+ meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py,sha256=12pxem-DmxrMc7PfB1S7NoniUDQCbIZ2L3jVzrV9xZg,2239
515
524
  meta_reports/models/dbviews/unattended_two_in_row/__init__.py,sha256=-ZZTOTTDZN5-zUj6gyvAyRrJgVPo0AyYZkHsgms6_Og,48
516
525
  meta_reports/models/dbviews/unattended_two_in_row/unmanaged_model.py,sha256=jrHsOHC0dhLoSQjY1PIlEQe9q_9Epv_ZNGXQtkTXbCs,870
517
- meta_reports/models/dbviews/unattended_two_in_row/view_definition.py,sha256=Sg953RI5Sf7GwIf7FM3mDWZl8ursJcixNnILKxxCwQ4,3998
526
+ meta_reports/models/dbviews/unattended_two_in_row/view_definition.py,sha256=fT-LngyxVBGVc5SIF5Fb2fUskvcC6-balydSkVDtueY,1379
518
527
  meta_reports/models/unmanaged/README,sha256=GdeboB7Xqb-Qo_rE1ondcxP8Ps93MIjLzCePQCePig0,686
519
528
  meta_reports/models/unmanaged/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
520
529
  meta_reports/models/unmanaged/patient_history_missing_baseline_cd4.py,sha256=kyw91RklvGzBU8HrE3vEH1XLUs5X5mALdozd9nTnYsI,825
@@ -997,7 +1006,7 @@ meta_subject/migrations/0210_remove_dmdxresult_dm_diagnosis_and_more.py,sha256=_
997
1006
  meta_subject/migrations/0211_dmendpoint_endpoint_reached_and_more.py,sha256=e5lG4G_F4uPR862lOvR_rACONzyMpg5duH-39QXAxLA,1615
998
1007
  meta_subject/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
999
1008
  meta_subject/model_mixins/__init__.py,sha256=6DdDDOwDdagrz6Q7X9lxuAVszsFWFhwPqLz4JOD85Wo,286
1000
- meta_subject/model_mixins/arv_history_model_mixin.py,sha256=2bcJDtp40IkTBtqQt3nUah43OC76xPrlrx-N5sQ_bnI,2904
1009
+ meta_subject/model_mixins/arv_history_model_mixin.py,sha256=6ILacF2koyYmwZIFHmmQO1uIT1eWzrahXxhAlxpQiX0,2898
1001
1010
  meta_subject/model_mixins/crf_model_mixin.py,sha256=UK1ycbYwaZ8LSNTJm74QJ5c-01HDXOApDy5k9LM4RKM,248
1002
1011
  meta_subject/model_mixins/crf_with_action_model_mixin.py,sha256=q1Q16YyPjQlpDtCPOXRkO5C7Vr7JO_QL8xWC48Uz33M,298
1003
1012
  meta_subject/model_mixins/search_slug_model_mixin.py,sha256=r5KmTykU0qV4JymMMKP2IBwAP8Z5hDnVJix-rO2PvME,296
@@ -1099,9 +1108,9 @@ tests/etc/user-rsa-restricted-private.pem,sha256=CUcHW9bznWdmmASN00hCzvxFPAFl4N2
1099
1108
  tests/etc/user-rsa-restricted-public.pem,sha256=mt84djoL-uHw6Wc5SJh0zml6VzXulnf8eQSFg7-fheg,450
1100
1109
  tests/etc/user-salt-local.key,sha256=x5anBw9fvbHurczouT3CjrkWb_xs7Ypm1htIJsgiuiw,256
1101
1110
  tests/etc/user-salt-restricted.key,sha256=pxmpcfBRNB-4C6wTvHXz-9fOfJgKIFOjaAF8ZFfa4q4,256
1102
- meta_edc-0.3.27.dist-info/AUTHORS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1103
- meta_edc-0.3.27.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
1104
- meta_edc-0.3.27.dist-info/METADATA,sha256=68sA26BGzAb-V0fZ_kCaih0dYEN_i5TmqXAafSlPDxI,2810
1105
- meta_edc-0.3.27.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
1106
- meta_edc-0.3.27.dist-info/top_level.txt,sha256=RkzjNXwRq2kg_uZ_1bDwPUntijSXoY2YBqtByDwvvrc,244
1107
- meta_edc-0.3.27.dist-info/RECORD,,
1111
+ meta_edc-0.3.29.dist-info/AUTHORS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1112
+ meta_edc-0.3.29.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
1113
+ meta_edc-0.3.29.dist-info/METADATA,sha256=ViDWoSS_-jxUMJmAfDyOyQHiAvPYo_yrLi7rYI6Gvro,2810
1114
+ meta_edc-0.3.29.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
1115
+ meta_edc-0.3.29.dist-info/top_level.txt,sha256=RkzjNXwRq2kg_uZ_1bDwPUntijSXoY2YBqtByDwvvrc,244
1116
+ meta_edc-0.3.29.dist-info/RECORD,,
@@ -4,6 +4,7 @@ from .unmanaged import (
4
4
  GlucoseSummaryAdmin,
5
5
  MissingOgttNoteModelAdmin,
6
6
  MissingScreeningOgttAdmin,
7
+ OnStudyMissingValuesAdmin,
7
8
  PatientHistoryMissingBaselineCd4Admin,
8
9
  UnattendedThreeInRow2Admin,
9
10
  UnattendedThreeInRowAdmin,
@@ -3,6 +3,7 @@ from .missing_screening_ogtt_admin import (
3
3
  MissingOgttNoteModelAdmin,
4
4
  MissingScreeningOgttAdmin,
5
5
  )
6
+ from .on_study_missing_values_admin import OnStudyMissingValuesAdmin
6
7
  from .patient_history_missing_baseline_cd4_admin import (
7
8
  PatientHistoryMissingBaselineCd4Admin,
8
9
  )
@@ -0,0 +1 @@
1
+ from .unmanaged_model_admin import OnStudyMissingValuesAdmin
@@ -0,0 +1,13 @@
1
+ from django.contrib import admin
2
+ from edc_qareports.modeladmin_mixins import OnStudyMissingValuesModelAdminMixin
3
+
4
+ from ....admin_site import meta_reports_admin
5
+ from ....models import OnStudyMissingValues
6
+
7
+
8
+ @admin.register(OnStudyMissingValues, site=meta_reports_admin)
9
+ class OnStudyMissingValuesAdmin(OnStudyMissingValuesModelAdminMixin, admin.ModelAdmin):
10
+
11
+ include_note_column: bool = True
12
+ project_reports_admin: str = "meta_reports_admin"
13
+ project_subject_admin: str = "meta_subject_admin"
@@ -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
+ ]
@@ -3,6 +3,7 @@ from .dbviews import (
3
3
  GlucoseSummary,
4
4
  MissingOgttNote,
5
5
  MissingScreeningOgtt,
6
+ OnStudyMissingValues,
6
7
  PatientHistoryMissingBaselineCd4,
7
8
  UnattendedThreeInRow,
8
9
  UnattendedThreeInRow2,
@@ -1,5 +1,6 @@
1
1
  from .glucose_summary import GlucoseSummary
2
2
  from .missing_screening_ogtt import NOTE_STATUSES, MissingOgttNote, MissingScreeningOgtt
3
+ from .on_study_missing_values import OnStudyMissingValues
3
4
  from .patient_history_missing_baseline_cd4 import PatientHistoryMissingBaselineCd4
4
5
  from .unattended_three_in_row import UnattendedThreeInRow
5
6
  from .unattended_three_in_row2 import UnattendedThreeInRow2