meta-edc 0.3.28__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.28.dist-info → meta_edc-0.3.29.dist-info}/METADATA +2 -2
  2. {meta_edc-0.3.28.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.28.dist-info → meta_edc-0.3.29.dist-info}/AUTHORS +0 -0
  24. {meta_edc-0.3.28.dist-info → meta_edc-0.3.29.dist-info}/LICENSE +0 -0
  25. {meta_edc-0.3.28.dist-info → meta_edc-0.3.29.dist-info}/WHEEL +0 -0
  26. {meta_edc-0.3.28.dist-info → meta_edc-0.3.29.dist-info}/top_level.txt +0 -0
@@ -1,77 +1,30 @@
1
- mysql_view = """ # noqa
2
- select *, uuid() as `id`, now() as `created`, 'meta_reports.unattendedtwoinrow' as report_model from (
3
- select subject_identifier, site_id, appt_datetime, `first_value`, `second_value`,
4
- datediff(`second_date`, `first_date`) as `interval_days`,
5
- datediff(now(), `first_date`) as `from_now_days`
6
- from (
7
- select subject_identifier ,site_id, appt_datetime,
8
- FIRST_VALUE(`visit_code`) OVER w as `first_value`,
9
- NTH_VALUE(`visit_code`, 2) OVER w as `second_value`,
10
- NTH_VALUE(`visit_code`, 3) OVER w as `third_value`,
11
- FIRST_VALUE(`appt_datetime`) OVER w as `first_date`,
12
- NTH_VALUE(`appt_datetime`, 2) OVER w as `second_date`
13
- from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'
14
- and appt_datetime <= now()
15
- WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)
16
- ) as A1
17
- where `second_value` is not null and `third_value` is null
18
- ) as A2
19
- order by site_id, `from_now_days` desc
20
- """
21
-
22
- pg_view = """ # noqa
23
- select *, gen_random_uuid() as id, now() as created, 'meta_reports.unattendedtwoinrow' as report_model
24
- from (
25
- select subject_identifier, site_id, appt_datetime, first_value, second_value,
26
- EXTRACT(DAY FROM second_date - first_date) as interval_days,
27
- EXTRACT(DAY FROM now() - first_date) as from_now_days
28
- from (
29
- select subject_identifier, site_id, appt_datetime,
30
- FIRST_VALUE(visit_code) OVER w as first_value,
31
- NTH_VALUE(visit_code, 2) OVER w as second_value,
32
- NTH_VALUE(visit_code, 3) OVER w as third_value,
33
- FIRST_VALUE(appt_datetime) OVER w as first_date,
34
- NTH_VALUE(appt_datetime, 2) OVER w as second_date
35
- from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'
36
- and appt_datetime <= now()
37
- WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)
38
- ) as A1
39
- where second_value is not null and third_value is null
40
- ) as A2
41
- order by site_id, from_now_days desc
42
- """
43
-
44
- sqlite3_view = """ # noqa
45
- SELECT *, lower(
46
- hex(randomblob(4)) || '-' || hex(randomblob(2)) || '-' || '4' ||
47
- substr(hex( randomblob(2)), 2) || '-' ||
48
- substr('AB89', 1 + (abs(random()) % 4) , 1) ||
49
- substr(hex(randomblob(2)), 2) || '-' ||
50
- hex(randomblob(6))
51
- ) as id, datetime() as created, 'meta_reports.unattendedtwoinrow' as report_model from (
52
- select subject_identifier, site_id, appt_datetime, first_value, second_value,
53
- CAST(JulianDay(second_date) - JulianDay(first_date) AS Integer) as interval_days,
54
- CAST(JulianDay(datetime()) - JulianDay(first_date) AS Integer) as from_now_days
55
- from (
56
- select subject_identifier ,site_id, appt_datetime,
57
- FIRST_VALUE(visit_code) OVER w as first_value,
58
- NTH_VALUE(visit_code, 2) OVER w as second_value,
59
- NTH_VALUE(visit_code, 3) OVER w as third_value,
60
- FIRST_VALUE(appt_datetime) OVER w as first_date,
61
- NTH_VALUE(appt_datetime, 2) OVER w as second_date
62
- from edc_appointment_appointment where visit_code_sequence=0 and appt_status='New'
63
- and appt_datetime <= datetime()
64
- WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)
65
- ) as A1
66
- where second_value is not null and third_value is null
67
- ) as A2
68
- order by site_id, from_now_days desc
69
- """
1
+ from edc_qareports.sql_generator import SqlViewGenerator
70
2
 
71
3
 
72
4
  def get_view_definition() -> dict:
5
+ subquery = """
6
+ select subject_identifier, site_id, appt_datetime, `first_value`, `second_value`,
7
+ datediff(`second_date`, `first_date`) as interval_days,
8
+ datediff(now(), `first_date`) as from_now_days
9
+ from (
10
+ select subject_identifier ,site_id, appt_datetime,
11
+ FIRST_VALUE(visit_code) OVER w as `first_value`,
12
+ NTH_VALUE(visit_code, 2) OVER w as `second_value`,
13
+ NTH_VALUE(visit_code, 3) OVER w as `third_value`,
14
+ FIRST_VALUE(appt_datetime) OVER w as `first_date`,
15
+ NTH_VALUE(appt_datetime, 2) OVER w as `second_date`
16
+ from edc_appointment_appointment where visit_code_sequence=0 and appt_status="New"
17
+ and appt_datetime <= now()
18
+ WINDOW w as (PARTITION BY subject_identifier order by appt_datetime ROWS UNBOUNDED PRECEDING)
19
+ ) as B
20
+ where `second_value` is not null and `third_value` is null""" # noqa
21
+
22
+ sql_view = SqlViewGenerator(
23
+ report_model="meta_reports.unattendedtwoinrow",
24
+ ordering=["site_id", "~from_now_days"],
25
+ )
73
26
  return {
74
- "django.db.backends.mysql": mysql_view,
75
- "django.db.backends.postgresql": pg_view,
76
- "django.db.backends.sqlite3": sqlite3_view,
27
+ "django.db.backends.mysql": sql_view.as_mysql(subquery),
28
+ "django.db.backends.postgresql": sql_view.as_postgres(subquery),
29
+ "django.db.backends.sqlite3": sql_view.as_sqlite(subquery),
77
30
  }
meta_reports/utils.py ADDED
File without changes
@@ -44,7 +44,7 @@ class ArvHistoryModelMixin(models.Model):
44
44
  ArvRegimens,
45
45
  on_delete=models.PROTECT,
46
46
  related_name="current_arv_regimen",
47
- verbose_name=("Which antiretroviral therapy regimen is the patient currently on?"),
47
+ verbose_name="Which antiretroviral therapy regimen is the patient currently on?",
48
48
  null=True,
49
49
  blank=False,
50
50
  )
@@ -69,7 +69,7 @@ class ArvHistoryModelMixin(models.Model):
69
69
  ArvRegimens,
70
70
  on_delete=models.PROTECT,
71
71
  related_name="previous_arv_regimen",
72
- verbose_name=("Which antiretroviral therapy regimen was the patient previously on?"),
72
+ verbose_name="Which antiretroviral therapy regimen was the patient previously on?",
73
73
  null=True,
74
74
  blank=True,
75
75
  )
@@ -77,7 +77,7 @@ class ArvHistoryModelMixin(models.Model):
77
77
  other_previous_arv_regimen = OtherCharField(null=True, blank=True)
78
78
 
79
79
  on_oi_prophylaxis = models.CharField(
80
- verbose_name=("Is the patient on any prophylaxis against opportunistic infections?"),
80
+ verbose_name="Is the patient on any prophylaxis against opportunistic infections?",
81
81
  max_length=15,
82
82
  choices=YES_NO,
83
83
  )