meta-edc 0.3.28__py3-none-any.whl → 0.3.30__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.
- meta_ae/action_items.py +2 -2
- meta_edc/settings/defaults.py +0 -1
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/METADATA +2 -2
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/RECORD +63 -39
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/WHEEL +1 -1
- meta_reports/admin/__init__.py +5 -3
- meta_reports/admin/{unmanaged → dbviews}/__init__.py +2 -0
- meta_reports/admin/dbviews/on_study_missing_lab_values_admin/__init__.py +1 -0
- meta_reports/admin/dbviews/on_study_missing_lab_values_admin/unmanaged_model_admin.py +13 -0
- meta_reports/admin/dbviews/on_study_missing_values_admin/__init__.py +1 -0
- meta_reports/admin/dbviews/on_study_missing_values_admin/unmanaged_model_admin.py +13 -0
- meta_reports/admin/modeladmin_mixins.py +1 -5
- meta_reports/migrations/0039_onstudymissingvalues.py +44 -0
- meta_reports/migrations/0040_auto_20240824_0412.py +282 -0
- meta_reports/migrations/0041_auto_20240828_2229.py +14 -0
- meta_reports/migrations/0042_onstudymissinglabvalues.py +43 -0
- meta_reports/migrations/0043_auto_20240828_2309.py +87 -0
- meta_reports/migrations/0044_auto_20240828_2323.py +93 -0
- meta_reports/migrations/0045_auto_20240829_0248.py +54 -0
- meta_reports/migrations/0046_auto_20240829_0250.py +54 -0
- meta_reports/models/__init__.py +2 -0
- meta_reports/models/dbviews/__init__.py +2 -0
- meta_reports/models/dbviews/glucose_summary/view_definition.py +14 -59
- meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py +14 -49
- meta_reports/models/dbviews/on_study_missing_lab_values/__init__.py +1 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/qa_cases.py +53 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/unmanged_model.py +20 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/view_definition.py +17 -0
- meta_reports/models/dbviews/on_study_missing_values/__init__.py +1 -0
- meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +55 -0
- meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py +20 -0
- meta_reports/models/dbviews/on_study_missing_values/view_definition.py +17 -0
- meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py +13 -47
- meta_reports/models/dbviews/unattended_three_in_row/view_definition.py +20 -67
- meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py +44 -128
- meta_reports/models/dbviews/unattended_two_in_row/view_definition.py +25 -72
- meta_reports/tests/test_sql_gen.py +5 -0
- meta_reports/utils.py +0 -0
- meta_subject/action_items.py +2 -2
- meta_subject/admin/__init__.py +1 -0
- meta_subject/admin/blood_results/__init__.py +1 -1
- meta_subject/admin/blood_results/{blood_results_lipid_admin.py → blood_results_lipids_admin.py} +7 -7
- meta_subject/forms/__init__.py +1 -1
- meta_subject/forms/blood_results/__init__.py +1 -1
- meta_subject/forms/blood_results/{blood_results_lipid_form.py → blood_results_lipids_form.py} +5 -5
- meta_subject/migrations/0212_auto_20240827_2222.py +23 -0
- meta_subject/migrations/0213_rename_bloodresultslipid_bloodresultslipids_and_more.py +35 -0
- meta_subject/model_mixins/arv_history_model_mixin.py +3 -3
- meta_subject/models/__init__.py +1 -1
- meta_subject/models/blood_results/__init__.py +1 -1
- meta_subject/models/blood_results/{blood_results_lipid.py → blood_results_lipids.py} +3 -3
- meta_visit_schedule/visit_schedules/phase_three/crfs.py +6 -6
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/AUTHORS +0 -0
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/LICENSE +0 -0
- {meta_edc-0.3.28.dist-info → meta_edc-0.3.30.dist-info}/top_level.txt +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/glucose_summary_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/missing_screening_ogtt_admin/__init__.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/missing_screening_ogtt_admin/note_model_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/missing_screening_ogtt_admin/unmanaged_model_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/patient_history_missing_baseline_cd4_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/unattended_three_in_row2_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/unattended_three_in_row_admin.py +0 -0
- /meta_reports/admin/{unmanaged → dbviews}/unattended_two_in_row_admin.py +0 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by Django 5.0.8 on 2024-08-28 23:50
|
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", "0045_auto_20240829_0248"),
|
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`, 'onstudy_missing_values_view' as `report_model` from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
18
|
+
"onstudy_missing_values_view",
|
19
|
+
engine="django.db.backends.mysql",
|
20
|
+
),
|
21
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
22
|
+
"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 OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
23
|
+
"onstudy_missing_values_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, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
31
|
+
"onstudy_missing_values_view",
|
32
|
+
engine="django.db.backends.postgresql",
|
33
|
+
),
|
34
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
35
|
+
"select *, get_random_uuid() as id, now() as created, '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 OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
36
|
+
"onstudy_missing_values_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, 'onstudy_missing_values_view' as report_model from (SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No HIV Diagnosis date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.hiv_diagnosis_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No VL value or VL date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.viral_load IS NULL OR crf.viral_load_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No CD4 value or CD4 date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.cd4 IS NULL OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
44
|
+
"onstudy_missing_values_view",
|
45
|
+
engine="django.db.backends.sqlite3",
|
46
|
+
),
|
47
|
+
reverse_code=django_db_views.migration_functions.BackwardViewMigration(
|
48
|
+
"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 OR crf.cd4_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'No current ARV start date but previous ARV is YES' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE crf.has_previous_arv_regimen = 'Yes' AND crf.current_arv_regimen_start_date IS NULL GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.patienthistory' AS label_lower, 'Other current ARV regimen missing' AS label, COUNT(*) AS records FROM meta_subject_patienthistory AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id LEFT JOIN meta_lists_arvregimens AS arvregimen ON crf.current_arv_regimen_id = arvregimen.id WHERE crf.other_current_arv_regimen IS NULL AND arvregimen.name = 'OTHER' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified UNION SELECT v.subject_identifier, crf.id AS original_id, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified, 'meta_subject.glucose' AS label_lower, 'FBG/OGTT: missing OGTT' AS label, COUNT(*) AS records FROM meta_subject_glucose AS crf LEFT JOIN meta_subject_subjectvisit AS v ON v.id = crf.subject_visit_id WHERE (NOT crf.fbg_value IS NULL AND crf.ogtt_value IS NULL) AND ogtt_performed = 'Yes' GROUP BY v.subject_identifier, crf.subject_visit_id, crf.report_datetime, crf.site_id, v.visit_code, v.visit_code_sequence, v.schedule_name, crf.modified) as A ORDER BY subject_identifier, site_id",
|
49
|
+
"onstudy_missing_values_view",
|
50
|
+
engine="django.db.backends.sqlite3",
|
51
|
+
),
|
52
|
+
atomic=False,
|
53
|
+
),
|
54
|
+
]
|
meta_reports/models/__init__.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
from .glucose_summary import GlucoseSummary
|
2
2
|
from .missing_screening_ogtt import NOTE_STATUSES, MissingOgttNote, MissingScreeningOgtt
|
3
|
+
from .on_study_missing_lab_values import OnStudyMissingLabValues
|
4
|
+
from .on_study_missing_values import OnStudyMissingValues
|
3
5
|
from .patient_history_missing_baseline_cd4 import PatientHistoryMissingBaselineCd4
|
4
6
|
from .unattended_three_in_row import UnattendedThreeInRow
|
5
7
|
from .unattended_three_in_row2 import UnattendedThreeInRow2
|
@@ -1,73 +1,28 @@
|
|
1
|
-
|
2
|
-
select *, uuid() as id, now() as created, 'meta_reports.glucose_summary_view' as report_model
|
3
|
-
from (
|
4
|
-
select v.subject_identifier, fbg_value, fbg_datetime, null as 'ogtt_value', null as 'ogtt_datetime',
|
5
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as 'fasted',
|
6
|
-
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
7
|
-
from meta_subject_glucosefbg as fbg
|
8
|
-
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
9
|
-
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
10
|
-
UNION
|
11
|
-
select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,
|
12
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as 'fasted',
|
13
|
-
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
14
|
-
from meta_subject_glucose as fbg
|
15
|
-
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
16
|
-
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
17
|
-
) as A
|
18
|
-
order by subject_identifier, fbg_datetime;
|
19
|
-
"""
|
1
|
+
from edc_qareports.sql_generator import SqlViewGenerator
|
20
2
|
|
21
|
-
pg_view: str = """ # noqa
|
22
|
-
select *, get_random_uuid() as id, now() as created, 'meta_reports.glucose_summary_view' as report_model
|
23
|
-
from (
|
24
|
-
select v.subject_identifier, fbg_value, fbg_datetime, null as ogtt_value, null as ogtt_datetime,
|
25
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,
|
26
|
-
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
27
|
-
from meta_subject_glucosefbg as fbg
|
28
|
-
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
29
|
-
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
30
|
-
UNION
|
31
|
-
select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,
|
32
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,
|
33
|
-
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
34
|
-
from meta_subject_glucose as fbg
|
35
|
-
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
36
|
-
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
37
|
-
) as A
|
38
|
-
order by subject_identifier, fbg_datetime;
|
39
|
-
"""
|
40
3
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
substr('AB89', 1 + (abs(random()) % 4) , 1) ||
|
46
|
-
substr(hex(randomblob(2)), 2) || '-' ||
|
47
|
-
hex(randomblob(6))
|
48
|
-
) as id, datetime() as `created`, 'meta_reports.glucose_summary_view' as report_model
|
49
|
-
from (
|
50
|
-
select v.subject_identifier, fbg_value, fbg_datetime, null as ogtt_value, null as ogtt_datetime,
|
51
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted,
|
4
|
+
def get_view_definition() -> dict:
|
5
|
+
subquery = """
|
6
|
+
select v.subject_identifier, fbg_value, fbg_datetime, null as `ogtt_value`, null as `ogtt_datetime`,
|
7
|
+
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as `fasted`,
|
52
8
|
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
53
9
|
from meta_subject_glucosefbg as fbg
|
54
10
|
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
55
11
|
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
56
12
|
UNION
|
57
13
|
select v.subject_identifier, fbg_value, fbg_datetime, ogtt_value, ogtt_datetime,
|
58
|
-
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as fasted
|
14
|
+
case when fasting="fasting" then "Yes" when fasting="non_fasting" then "No" else fasting end as `fasted`,
|
59
15
|
fbg.site_id, v.visit_code, v.visit_code_sequence, v.appointment_id, eos.offstudy_datetime
|
60
16
|
from meta_subject_glucose as fbg
|
61
17
|
left join meta_subject_subjectvisit as v on v.id=fbg.subject_visit_id
|
62
18
|
left join meta_prn_endofstudy as eos on v.subject_identifier=eos.subject_identifier
|
63
|
-
|
64
|
-
|
65
|
-
""
|
66
|
-
|
67
|
-
|
68
|
-
def get_view_definition() -> dict:
|
19
|
+
""" # noqa
|
20
|
+
sql_view = SqlViewGenerator(
|
21
|
+
report_model="meta_reports.glucose_summary_view",
|
22
|
+
ordering=["subject_identifier", "site_id"],
|
23
|
+
)
|
69
24
|
return {
|
70
|
-
"django.db.backends.mysql":
|
71
|
-
"django.db.backends.postgresql":
|
72
|
-
"django.db.backends.sqlite3":
|
25
|
+
"django.db.backends.mysql": sql_view.as_mysql(subquery),
|
26
|
+
"django.db.backends.postgresql": sql_view.as_postgres(subquery),
|
27
|
+
"django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
|
73
28
|
}
|
@@ -1,55 +1,20 @@
|
|
1
|
-
|
2
|
-
select *, uuid() as id, now() as created,
|
3
|
-
'meta_reports.missing_screening_ogtt_view' as report_model
|
4
|
-
from (
|
5
|
-
select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,
|
6
|
-
converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, repeat_glucose_performed as repeated,
|
7
|
-
p3_ltfu, fbg2_value, ogtt2_value, fbg2_datetime, ogtt2_datetime, consented,
|
8
|
-
screening_identifier as subject_identifier, id as original_id
|
9
|
-
from meta_screening_subjectscreening
|
10
|
-
where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != "Yes"
|
11
|
-
) as A
|
12
|
-
order by screening_identifier
|
13
|
-
"""
|
1
|
+
from edc_qareports.sql_generator import SqlViewGenerator
|
14
2
|
|
15
|
-
pg_view: str = """ # noqa
|
16
|
-
select *, get_random_uuid() as id, now() as created,
|
17
|
-
'meta_reports.missing_screening_ogtt_view' as report_model
|
18
|
-
from (
|
19
|
-
select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,
|
20
|
-
converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, repeat_glucose_performed as repeated,
|
21
|
-
p3_ltfu, fbg2_value, ogtt2_value, fbg2_datetime, ogtt2_datetime, consented,
|
22
|
-
screening_identifier as subject_identifier, id as original_id
|
23
|
-
from meta_screening_subjectscreening
|
24
|
-
where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != "Yes"
|
25
|
-
) as A
|
26
|
-
order by screening_identifier
|
27
|
-
"""
|
28
3
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
substr(hex(randomblob(2)), 2) || '-' ||
|
35
|
-
hex(randomblob(6))
|
36
|
-
) as id, datetime() as `created`,
|
37
|
-
'meta_reports.missing_screening_ogtt_view' as report_model
|
38
|
-
from (
|
39
|
-
select screening_identifier, site_id, report_datetime as 'screening_datetime', fbg_datetime,
|
40
|
-
converted_fbg_value as fbg_value, converted_ogtt_value as ogtt_value, fbg2_value, ogtt2_value,
|
41
|
-
repeat_glucose_performed as repeated, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented,
|
42
|
-
screening_identifier as subject_identifier, id as original_id
|
4
|
+
def get_view_definition() -> dict:
|
5
|
+
subquery = """select screening_identifier, site_id, report_datetime as `screening_datetime`, fbg_datetime,
|
6
|
+
converted_fbg_value as `fbg_value`, converted_ogtt_value as `ogtt_value`, fbg2_value, ogtt2_value,
|
7
|
+
repeat_glucose_performed as `repeated`, p3_ltfu, fbg2_datetime, ogtt2_datetime, consented,
|
8
|
+
screening_identifier as `subject_identifier`, id as `original_id`
|
43
9
|
from meta_screening_subjectscreening
|
44
10
|
where converted_fbg_value is not null and converted_ogtt_value is null and unsuitable_agreed != "Yes"
|
45
|
-
|
46
|
-
|
47
|
-
""
|
48
|
-
|
49
|
-
|
50
|
-
def get_view_definition() -> dict:
|
11
|
+
""" # noqa
|
12
|
+
sql_view = SqlViewGenerator(
|
13
|
+
report_model="meta_reports.missing_screening_ogtt_view",
|
14
|
+
ordering=["subject_identifier", "site_id"],
|
15
|
+
)
|
51
16
|
return {
|
52
|
-
"django.db.backends.mysql":
|
53
|
-
"django.db.backends.postgresql":
|
54
|
-
"django.db.backends.sqlite3":
|
17
|
+
"django.db.backends.mysql": sql_view.as_mysql(subquery),
|
18
|
+
"django.db.backends.postgresql": sql_view.as_postgres(subquery),
|
19
|
+
"django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
|
55
20
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
from .unmanged_model import OnStudyMissingLabValues
|
@@ -0,0 +1,53 @@
|
|
1
|
+
from edc_lab_panel.constants import FBC, LFT, LIPIDS, RFT
|
2
|
+
from edc_lab_panel.panels import fbc_panel, lft_panel, lipids_panel, rft_panel
|
3
|
+
from edc_qareports.sql_generator import CrfCase, RequisitionCase
|
4
|
+
|
5
|
+
qa_cases = [
|
6
|
+
RequisitionCase(
|
7
|
+
label="FBC requisitioned but not entered",
|
8
|
+
dbtable="meta_subject_bloodresultsfbc",
|
9
|
+
label_lower="meta_subject.bloodresultsfbc",
|
10
|
+
panel=FBC,
|
11
|
+
),
|
12
|
+
RequisitionCase(
|
13
|
+
label="RFT requisitioned but not entered",
|
14
|
+
dbtable="meta_subject_bloodresultsrft",
|
15
|
+
label_lower="meta_subject.bloodresultsrft",
|
16
|
+
panel=RFT,
|
17
|
+
),
|
18
|
+
RequisitionCase(
|
19
|
+
label="LFT requisitioned but not entered",
|
20
|
+
dbtable="meta_subject_bloodresultslft",
|
21
|
+
label_lower="meta_subject.bloodresultslft",
|
22
|
+
panel=LFT,
|
23
|
+
),
|
24
|
+
RequisitionCase(
|
25
|
+
label="LIPIDS requisitioned but not entered",
|
26
|
+
dbtable="meta_subject_bloodresultslipids",
|
27
|
+
label_lower="meta_subject.bloodresultslipids",
|
28
|
+
panel=LIPIDS,
|
29
|
+
),
|
30
|
+
]
|
31
|
+
|
32
|
+
panels = {FBC: fbc_panel, RFT: rft_panel, LFT: lft_panel, LIPIDS: lipids_panel}
|
33
|
+
for abbrev, panel in panels.items():
|
34
|
+
for utest_id in panel.utest_ids:
|
35
|
+
try:
|
36
|
+
utest_id, _ = utest_id
|
37
|
+
except ValueError:
|
38
|
+
pass
|
39
|
+
qa_cases.append(
|
40
|
+
CrfCase(
|
41
|
+
label=f"{abbrev.upper()}: missing {utest_id} value/units",
|
42
|
+
dbtable=f"meta_subject_bloodresults{abbrev.lower()}",
|
43
|
+
label_lower=f"meta_subject.bloodresults{abbrev.lower()}",
|
44
|
+
where=f"crf.{utest_id}_value is null or crf.{utest_id}_units is null",
|
45
|
+
)
|
46
|
+
)
|
47
|
+
|
48
|
+
CrfCase(
|
49
|
+
label="No UREA value",
|
50
|
+
dbtable="meta_subject_bloodresultsrft",
|
51
|
+
label_lower="meta_subject.bloodresultsrft",
|
52
|
+
where="crf.urea_value is null or crf.urea_units is null",
|
53
|
+
),
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from django_db_views.db_view import DBView
|
2
|
+
from edc_qareports.model_mixins import (
|
3
|
+
OnStudyMissingValuesModelMixin,
|
4
|
+
QaReportModelMixin,
|
5
|
+
qa_reports_permissions,
|
6
|
+
)
|
7
|
+
|
8
|
+
from .view_definition import get_view_definition
|
9
|
+
|
10
|
+
|
11
|
+
class OnStudyMissingLabValues(OnStudyMissingValuesModelMixin, QaReportModelMixin, DBView):
|
12
|
+
|
13
|
+
view_definition = get_view_definition()
|
14
|
+
|
15
|
+
class Meta:
|
16
|
+
managed = False
|
17
|
+
db_table = "onstudy_missing_lab_values_view"
|
18
|
+
verbose_name = "Missing Lab values for on-study patient"
|
19
|
+
verbose_name_plural = "Missing Lab values for on-study patients"
|
20
|
+
default_permissions = qa_reports_permissions
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from edc_qareports.sql_generator import SqlViewGenerator
|
2
|
+
|
3
|
+
from .qa_cases import qa_cases
|
4
|
+
|
5
|
+
|
6
|
+
def get_view_definition() -> dict:
|
7
|
+
subquery = " UNION ".join([qa_case.sql for qa_case in qa_cases])
|
8
|
+
sql_view = SqlViewGenerator(
|
9
|
+
report_model="onstudy_missing_lab_values_view",
|
10
|
+
ordering=["subject_identifier", "site_id"],
|
11
|
+
)
|
12
|
+
|
13
|
+
return {
|
14
|
+
"django.db.backends.mysql": sql_view.as_mysql(subquery),
|
15
|
+
"django.db.backends.postgresql": sql_view.as_postgres(subquery),
|
16
|
+
"django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
|
17
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
from .unmanged_model import OnStudyMissingValues
|
@@ -0,0 +1,55 @@
|
|
1
|
+
from edc_constants.constants import OTHER, YES
|
2
|
+
from edc_qareports.sql_generator import CrfCase
|
3
|
+
|
4
|
+
qa_cases = [
|
5
|
+
CrfCase(
|
6
|
+
label="No HIV Diagnosis date",
|
7
|
+
dbtable="meta_subject_patienthistory",
|
8
|
+
label_lower="meta_subject.patienthistory",
|
9
|
+
fld_name="hiv_diagnosis_date",
|
10
|
+
),
|
11
|
+
CrfCase(
|
12
|
+
label="No VL value or VL date",
|
13
|
+
dbtable="meta_subject_patienthistory",
|
14
|
+
label_lower="meta_subject.patienthistory",
|
15
|
+
fld_name="viral_load_date",
|
16
|
+
where="crf.viral_load is null or crf.viral_load_date is null",
|
17
|
+
),
|
18
|
+
CrfCase(
|
19
|
+
label="No CD4 value or CD4 date",
|
20
|
+
dbtable="meta_subject_patienthistory",
|
21
|
+
label_lower="meta_subject.patienthistory",
|
22
|
+
where="crf.cd4 is null or crf.cd4_date is null",
|
23
|
+
),
|
24
|
+
CrfCase(
|
25
|
+
label="No current ARV start date",
|
26
|
+
dbtable="meta_subject_patienthistory",
|
27
|
+
label_lower="meta_subject.patienthistory",
|
28
|
+
fld_name="current_arv_regimen_start_date",
|
29
|
+
),
|
30
|
+
CrfCase(
|
31
|
+
label="No current ARV start date but previous ARV is YES",
|
32
|
+
dbtable="meta_subject_patienthistory",
|
33
|
+
label_lower="meta_subject.patienthistory",
|
34
|
+
where=(
|
35
|
+
f"crf.has_previous_arv_regimen ='{YES}' and "
|
36
|
+
"crf.current_arv_regimen_start_date is null"
|
37
|
+
),
|
38
|
+
),
|
39
|
+
CrfCase(
|
40
|
+
label="Other current ARV regimen missing",
|
41
|
+
dbtable="meta_subject_patienthistory",
|
42
|
+
label_lower="meta_subject.patienthistory",
|
43
|
+
where=f"crf.other_current_arv_regimen is null and arvregimen.name='{OTHER}'",
|
44
|
+
list_tables=[("current_arv_regimen_id", "meta_lists_arvregimens", "arvregimen")],
|
45
|
+
),
|
46
|
+
CrfCase(
|
47
|
+
label="FBG/OGTT: missing OGTT",
|
48
|
+
dbtable="meta_subject_glucose",
|
49
|
+
label_lower="meta_subject.glucose",
|
50
|
+
where=(
|
51
|
+
"(crf.fbg_value is not null and crf.ogtt_value is null) "
|
52
|
+
f"and ogtt_performed='{YES}'"
|
53
|
+
),
|
54
|
+
),
|
55
|
+
]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from django_db_views.db_view import DBView
|
2
|
+
from edc_qareports.model_mixins import (
|
3
|
+
OnStudyMissingValuesModelMixin,
|
4
|
+
QaReportModelMixin,
|
5
|
+
qa_reports_permissions,
|
6
|
+
)
|
7
|
+
|
8
|
+
from .view_definition import get_view_definition
|
9
|
+
|
10
|
+
|
11
|
+
class OnStudyMissingValues(OnStudyMissingValuesModelMixin, QaReportModelMixin, DBView):
|
12
|
+
|
13
|
+
view_definition = get_view_definition()
|
14
|
+
|
15
|
+
class Meta:
|
16
|
+
managed = False
|
17
|
+
db_table = "onstudy_missing_values_view"
|
18
|
+
verbose_name = "Missing values for on-study patient"
|
19
|
+
verbose_name_plural = "Missing values for on-study patients"
|
20
|
+
default_permissions = qa_reports_permissions
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from edc_qareports.sql_generator import SqlViewGenerator
|
2
|
+
|
3
|
+
from .qa_cases import qa_cases
|
4
|
+
|
5
|
+
|
6
|
+
def get_view_definition() -> dict:
|
7
|
+
subquery = " UNION ".join([qa_case.sql for qa_case in qa_cases])
|
8
|
+
sql_view = SqlViewGenerator(
|
9
|
+
report_model="onstudy_missing_values_view",
|
10
|
+
ordering=["subject_identifier", "site_id"],
|
11
|
+
)
|
12
|
+
|
13
|
+
return {
|
14
|
+
"django.db.backends.mysql": sql_view.as_mysql(subquery),
|
15
|
+
"django.db.backends.postgresql": sql_view.as_postgres(subquery),
|
16
|
+
"django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
|
17
|
+
}
|
@@ -1,55 +1,21 @@
|
|
1
|
-
|
2
|
-
select *, uuid() as id, now() as created,
|
3
|
-
'meta_reports.patienthistorymissingbaselinecd4' as report_model
|
4
|
-
from (
|
5
|
-
select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,
|
6
|
-
cd4_date, crf.site_id, crf.user_created, crf.user_modified,
|
7
|
-
crf.modified
|
8
|
-
from meta_subject_patienthistory as crf
|
9
|
-
left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id
|
10
|
-
where cd4 is null or cd4_date is null
|
11
|
-
) as A
|
12
|
-
order by subject_identifier
|
13
|
-
"""
|
1
|
+
from edc_qareports.sql_generator import SqlViewGenerator
|
14
2
|
|
15
|
-
pg_view: str = """
|
16
|
-
select *, get_random_uuid() as id, now() as created,
|
17
|
-
'meta_reports.patienthistorymissingbaselinecd4' as report_model
|
18
|
-
from (
|
19
|
-
select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,
|
20
|
-
cd4_date, crf.site_id, crf.user_created, crf.user_modified,
|
21
|
-
crf.modified
|
22
|
-
from meta_subject_patienthistory as crf
|
23
|
-
left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id
|
24
|
-
where cd4 is null or cd4_date is null
|
25
|
-
) as A
|
26
|
-
order by subject_identifier
|
27
|
-
"""
|
28
3
|
|
29
|
-
|
30
|
-
|
31
|
-
hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
|
32
|
-
substr(hex( randomblob(2)), 2) || '-' ||
|
33
|
-
substr('AB89', 1 + (abs(random()) % 4) , 1) ||
|
34
|
-
substr(hex(randomblob(2)), 2) || '-' ||
|
35
|
-
hex(randomblob(6))
|
36
|
-
) as id, datetime() as `created`,
|
37
|
-
'meta_reports.patienthistorymissingbaselinecd4' as report_model
|
38
|
-
from (
|
4
|
+
def get_view_definition() -> dict:
|
5
|
+
subquery = """
|
39
6
|
select subject_identifier, v.visit_code, v.visit_code_sequence,cd4,
|
40
|
-
|
41
|
-
|
7
|
+
cd4_date, crf.site_id, crf.user_created, crf.user_modified,
|
8
|
+
crf.modified
|
42
9
|
from meta_subject_patienthistory as crf
|
43
10
|
left join meta_subject_subjectvisit as v on crf.subject_visit_id=v.id
|
44
11
|
where cd4 is null or cd4_date is null
|
45
|
-
|
46
|
-
|
47
|
-
""
|
48
|
-
|
49
|
-
|
50
|
-
def get_view_definition() -> dict:
|
12
|
+
"""
|
13
|
+
sql_view = SqlViewGenerator(
|
14
|
+
report_model="meta_reports.patienthistorymissingbaselinecd4",
|
15
|
+
ordering=["subject_identifier", "site_id"],
|
16
|
+
)
|
51
17
|
return {
|
52
|
-
"django.db.backends.mysql":
|
53
|
-
"django.db.backends.postgresql":
|
54
|
-
"django.db.backends.sqlite3":
|
18
|
+
"django.db.backends.mysql": sql_view.as_mysql(subquery),
|
19
|
+
"django.db.backends.postgresql": sql_view.as_postgres(subquery),
|
20
|
+
"django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
|
55
21
|
}
|