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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. meta_auth/auth_objects.py +10 -3
  2. meta_consent/baker_recipes.py +4 -4
  3. meta_consent/consents.py +1 -1
  4. meta_consent/migrations/0025_alter_historicalsubjectconsent_first_name_and_more.py +151 -0
  5. meta_consent/models/signals.py +16 -13
  6. meta_consent/models/subject_consent_v1.py +1 -3
  7. meta_consent/tests/tests/test_form_validators.py +1 -1
  8. meta_dashboard/templates/meta_dashboard/bootstrap3/screening/listboard.html +4 -4
  9. meta_dashboard/templates/meta_dashboard/bootstrap3/subject/listboard.html +1 -2
  10. meta_edc/settings/debug.py +9 -9
  11. meta_edc/settings/defaults.py +25 -18
  12. meta_edc/settings/live.py +1 -9
  13. meta_edc/settings/uat.py +1 -14
  14. meta_edc/templates/meta_edc/bootstrap3/home.html +8 -5
  15. meta_edc/tests/test_settings.py +176 -0
  16. meta_edc/tests/tests/test_endpoints.py +20 -19
  17. meta_edc/urls.py +1 -1
  18. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/METADATA +5 -4
  19. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/RECORD +128 -74
  20. meta_prn/action_items.py +44 -2
  21. meta_prn/admin/__init__.py +3 -0
  22. meta_prn/admin/dm_referral_admin.py +49 -0
  23. meta_prn/admin/offschedule_dm_referral_admin.py +47 -0
  24. meta_prn/admin/onschedule_dm_referral_admin.py +39 -0
  25. meta_prn/baker_recipes.py +8 -1
  26. meta_prn/choices.py +2 -1
  27. meta_prn/constants.py +4 -1
  28. meta_prn/forms/__init__.py +2 -0
  29. meta_prn/forms/dm_referral_form.py +40 -0
  30. meta_prn/forms/offschedule_dm_referral_form.py +35 -0
  31. meta_prn/forms/offschedule_form.py +6 -0
  32. meta_prn/migrations/0057_historicalonscheduledmreferral_and_more.py +1156 -0
  33. meta_prn/migrations/0058_dmreferral_referral_note_and_more.py +29 -0
  34. meta_prn/migrations/0059_alter_historicaloffstudymedication_reason_and_more.py +53 -0
  35. meta_prn/models/__init__.py +13 -2
  36. meta_prn/models/dm_referral.py +39 -0
  37. meta_prn/models/offschedule.py +15 -1
  38. meta_prn/models/onschedule.py +6 -0
  39. meta_prn/models/signals.py +41 -1
  40. meta_prn/tests/tests/test_dm_referral.py +206 -0
  41. meta_screening/form_validators/screening_part_two.py +1 -1
  42. meta_screening/migrations/0062_remove_icpreferral_site_and_more.py +27 -0
  43. meta_screening/migrations/0063_alter_historicalscreeningpartone_fasting_duration_str_and_more.py +184 -0
  44. meta_screening/migrations/0064_remove_historicalscreeningpartone_fasting_duration_minutes_and_more.py +126 -0
  45. meta_screening/migrations/0065_auto_20240516_0352.py +31 -0
  46. meta_screening/migrations/0066_alter_historicalscreeningpartone_fasting_duration_delta_and_more.py +103 -0
  47. meta_screening/models/__init__.py +1 -1
  48. meta_screening/tests/meta_test_case_mixin.py +2 -2
  49. meta_screening/tests/options.py +3 -3
  50. meta_sites/__init__.py +0 -1
  51. meta_sites/sites.py +8 -7
  52. meta_subject/action_items.py +23 -0
  53. meta_subject/admin/__init__.py +1 -1
  54. meta_subject/admin/birth_outcome_admin.py +2 -3
  55. meta_subject/admin/delivery_admin.py +0 -1
  56. meta_subject/admin/diabetes/__init__.py +2 -0
  57. meta_subject/admin/diabetes/dm_diagnosis_admin.py +89 -0
  58. meta_subject/admin/{dm_referral_followup_admin.py → diabetes/dm_followup_admin.py} +15 -8
  59. meta_subject/admin/glucose_admin.py +1 -1
  60. meta_subject/admin/glucose_fbg_admin.py +34 -8
  61. meta_subject/admin/subject_visit_admin.py +4 -1
  62. meta_subject/baker_recipes.py +6 -0
  63. meta_subject/choices.py +8 -0
  64. meta_subject/constants.py +2 -1
  65. meta_subject/form_validators/__init__.py +2 -1
  66. meta_subject/form_validators/dm_diagnosis_form_validator.py +38 -0
  67. meta_subject/form_validators/dm_dx_result_form_validator.py +7 -0
  68. meta_subject/form_validators/{dm_referral_followup_form_validator.py → dm_followup_form_validator.py} +41 -2
  69. meta_subject/forms/__init__.py +1 -0
  70. meta_subject/forms/diabetes/__init__.py +3 -0
  71. meta_subject/forms/diabetes/dm_diagnosis_form.py +13 -0
  72. meta_subject/forms/diabetes/dm_dx_result_form.py +11 -0
  73. meta_subject/forms/diabetes/dm_followup_form.py +25 -0
  74. meta_subject/forms/glucose_fbg_form.py +38 -16
  75. meta_subject/forms/subject_visit_form.py +16 -0
  76. meta_subject/metadata_rules/metadata_rules.py +14 -0
  77. meta_subject/metadata_rules/predicates.py +22 -0
  78. meta_subject/migrations/0181_dmreferralfollowup_action_identifier_and_more.py +143 -0
  79. meta_subject/migrations/0182_rename_dmreferralfollowup_dmfollowup_and_more.py +54 -0
  80. meta_subject/migrations/0183_alter_dmfollowup_on_dm_medications_and_more.py +31 -0
  81. meta_subject/migrations/0184_alter_glucose_options_and_more.py +31 -0
  82. meta_subject/migrations/0185_alter_bloodresultsins_fasting_duration_str_and_more.py +82 -0
  83. meta_subject/migrations/0186_healtheconomicsupdate_singleton_field_and_more.py +55 -0
  84. meta_subject/migrations/0187_dmdiagnosis_historicaldmdiagnosis_dmdxresult_and_more.py +451 -0
  85. meta_subject/migrations/0188_historicaldmdxresult_dmdxresult.py +403 -0
  86. meta_subject/migrations/0189_alter_dmdxresult_options_and_more.py +116 -0
  87. meta_subject/migrations/0190_dmdiagnosis_dx_no_tmg_reason_and_more.py +65 -0
  88. meta_subject/migrations/0191_alter_dmdiagnosis_dx_no_tmg_reason_and_more.py +70 -0
  89. meta_subject/migrations/0192_rename_glucose_quantifier_glucosefbg_fbg_quantifier_and_more.py +44 -0
  90. meta_subject/migrations/0193_alter_glucosefbg_fbg_value_and_more.py +44 -0
  91. meta_subject/migrations/0194_remove_glucosefbg_assay_datetime_and_more.py +166 -0
  92. meta_subject/migrations/0195_alter_glucosefbg_fbg_datetime_and_more.py +27 -0
  93. meta_subject/migrations/0196_glucosefbg_fbg_not_performed_reason_and_more.py +49 -0
  94. meta_subject/migrations/0197_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
  95. meta_subject/migrations/0198_alter_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
  96. meta_subject/migrations/0199_auto_20240516_0247.py +18 -0
  97. meta_subject/migrations/0200_rename_fasting_duration_minutes_bloodresultsins_fasting_duration_delta_and_more.py +43 -0
  98. meta_subject/migrations/0201_alter_bloodresultsins_fasting_duration_delta_and_more.py +58 -0
  99. meta_subject/migrations/0202_auto_20240516_0315.py +32 -0
  100. meta_subject/migrations/0203_alter_bloodresultsins_fasting_duration_delta_and_more.py +67 -0
  101. meta_subject/migrations/0204_glucosefbg_repeat_fbg_date_and_more.py +27 -0
  102. meta_subject/migrations/0205_historicalsubjectrequisition_crf_status_and_more.py +80 -0
  103. meta_subject/migrations/0206_bloodresultsfbc_crf_status_and_more.py +62 -0
  104. meta_subject/models/__init__.py +1 -1
  105. meta_subject/models/blood_results/blood_results_fbc.py +3 -2
  106. meta_subject/models/blood_results/blood_results_hba1c.py +2 -0
  107. meta_subject/models/blood_results/blood_results_ins.py +2 -0
  108. meta_subject/models/blood_results/blood_results_lft.py +2 -0
  109. meta_subject/models/blood_results/blood_results_lipid.py +2 -0
  110. meta_subject/models/blood_results/blood_results_rft.py +2 -0
  111. meta_subject/models/diabetes/__init__.py +3 -0
  112. meta_subject/models/diabetes/dm_diagnosis.py +50 -0
  113. meta_subject/models/diabetes/dm_dx_result.py +70 -0
  114. meta_subject/models/{dm_referral_followup.py → diabetes/dm_followup.py} +18 -6
  115. meta_subject/models/glucose.py +5 -15
  116. meta_subject/models/glucose_fbg.py +40 -51
  117. meta_subject/models/health_economics/health_economics_update.py +2 -0
  118. meta_subject/models/subject_requisition.py +3 -4
  119. meta_subject/tests/tests/test_egfr.py +6 -5
  120. meta_subject/tests/tests/test_metadata_rules.py +32 -2
  121. meta_visit_schedule/constants.py +3 -1
  122. meta_visit_schedule/visit_schedules/phase_three/crfs.py +12 -1
  123. meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py +60 -0
  124. meta_visit_schedule/visit_schedules/phase_three/visit_schedule.py +2 -0
  125. meta_subject/forms/dm_referral_followup.py +0 -18
  126. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/AUTHORS +0 -0
  127. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/LICENSE +0 -0
  128. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/WHEEL +0 -0
  129. {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,126 @@
1
+ # Generated by Django 4.2.11 on 2024-05-16 00:51
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ (
10
+ "meta_screening",
11
+ "0063_alter_historicalscreeningpartone_fasting_duration_str_and_more",
12
+ ),
13
+ ]
14
+
15
+ operations = [
16
+ migrations.RemoveField(
17
+ model_name="historicalscreeningpartone",
18
+ name="fasting_duration_minutes",
19
+ ),
20
+ migrations.RemoveField(
21
+ model_name="historicalscreeningpartone",
22
+ name="repeat_fasting_duration_minutes",
23
+ ),
24
+ migrations.RemoveField(
25
+ model_name="historicalscreeningpartthree",
26
+ name="fasting_duration_minutes",
27
+ ),
28
+ migrations.RemoveField(
29
+ model_name="historicalscreeningpartthree",
30
+ name="repeat_fasting_duration_minutes",
31
+ ),
32
+ migrations.RemoveField(
33
+ model_name="historicalscreeningparttwo",
34
+ name="fasting_duration_minutes",
35
+ ),
36
+ migrations.RemoveField(
37
+ model_name="historicalscreeningparttwo",
38
+ name="repeat_fasting_duration_minutes",
39
+ ),
40
+ migrations.RemoveField(
41
+ model_name="historicalsubjectscreening",
42
+ name="fasting_duration_minutes",
43
+ ),
44
+ migrations.RemoveField(
45
+ model_name="historicalsubjectscreening",
46
+ name="repeat_fasting_duration_minutes",
47
+ ),
48
+ migrations.RemoveField(
49
+ model_name="subjectscreening",
50
+ name="fasting_duration_minutes",
51
+ ),
52
+ migrations.RemoveField(
53
+ model_name="subjectscreening",
54
+ name="repeat_fasting_duration_minutes",
55
+ ),
56
+ migrations.AddField(
57
+ model_name="historicalscreeningpartone",
58
+ name="fasting_duration_delta",
59
+ field=models.DurationField(
60
+ blank=True, help_text="system calculated value", null=True
61
+ ),
62
+ ),
63
+ migrations.AddField(
64
+ model_name="historicalscreeningpartone",
65
+ name="repeat_fasting_duration_delta",
66
+ field=models.DurationField(
67
+ blank=True, help_text="system calculated value", null=True
68
+ ),
69
+ ),
70
+ migrations.AddField(
71
+ model_name="historicalscreeningpartthree",
72
+ name="fasting_duration_delta",
73
+ field=models.DurationField(
74
+ blank=True, help_text="system calculated value", null=True
75
+ ),
76
+ ),
77
+ migrations.AddField(
78
+ model_name="historicalscreeningpartthree",
79
+ name="repeat_fasting_duration_delta",
80
+ field=models.DurationField(
81
+ blank=True, help_text="system calculated value", null=True
82
+ ),
83
+ ),
84
+ migrations.AddField(
85
+ model_name="historicalscreeningparttwo",
86
+ name="fasting_duration_delta",
87
+ field=models.DurationField(
88
+ blank=True, help_text="system calculated value", null=True
89
+ ),
90
+ ),
91
+ migrations.AddField(
92
+ model_name="historicalscreeningparttwo",
93
+ name="repeat_fasting_duration_delta",
94
+ field=models.DurationField(
95
+ blank=True, help_text="system calculated value", null=True
96
+ ),
97
+ ),
98
+ migrations.AddField(
99
+ model_name="historicalsubjectscreening",
100
+ name="fasting_duration_delta",
101
+ field=models.DurationField(
102
+ blank=True, help_text="system calculated value", null=True
103
+ ),
104
+ ),
105
+ migrations.AddField(
106
+ model_name="historicalsubjectscreening",
107
+ name="repeat_fasting_duration_delta",
108
+ field=models.DurationField(
109
+ blank=True, help_text="system calculated value", null=True
110
+ ),
111
+ ),
112
+ migrations.AddField(
113
+ model_name="subjectscreening",
114
+ name="fasting_duration_delta",
115
+ field=models.DurationField(
116
+ blank=True, help_text="system calculated value", null=True
117
+ ),
118
+ ),
119
+ migrations.AddField(
120
+ model_name="subjectscreening",
121
+ name="repeat_fasting_duration_delta",
122
+ field=models.DurationField(
123
+ blank=True, help_text="system calculated value", null=True
124
+ ),
125
+ ),
126
+ ]
@@ -0,0 +1,31 @@
1
+ # Generated by Django 4.2.11 on 2024-05-16 00:52
2
+ from django.db import migrations
3
+ from edc_model.utils import duration_hm_to_timedelta
4
+ from tqdm import tqdm
5
+
6
+
7
+ def update_duration(apps, schema_editor):
8
+ model_cls = apps.get_model("meta_screening.subjectscreening")
9
+ qs = model_cls.objects.all()
10
+ total = qs.count()
11
+ for obj in tqdm(qs, total=total):
12
+ if obj.fasting_duration_str:
13
+ tdelta = duration_hm_to_timedelta(obj.fasting_duration_str)
14
+ obj.fasting_duration_delta = tdelta
15
+ obj.save_base(update_fields=["fasting_duration_delta"])
16
+ if obj.repeat_fasting_duration_str:
17
+ tdelta = duration_hm_to_timedelta(obj.repeat_fasting_duration_str)
18
+ obj.repeat_fasting_duration_delta = tdelta
19
+ obj.save_base(update_fields=["repeat_fasting_duration_delta"])
20
+
21
+
22
+ class Migration(migrations.Migration):
23
+
24
+ dependencies = [
25
+ (
26
+ "meta_screening",
27
+ "0064_remove_historicalscreeningpartone_fasting_duration_minutes_and_more",
28
+ ),
29
+ ]
30
+
31
+ operations = [migrations.RunPython(update_duration)]
@@ -0,0 +1,103 @@
1
+ # Generated by Django 4.2.11 on 2024-05-16 01:21
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_screening", "0065_auto_20240516_0352"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="historicalscreeningpartone",
15
+ name="fasting_duration_delta",
16
+ field=models.DurationField(
17
+ blank=True,
18
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
19
+ null=True,
20
+ ),
21
+ ),
22
+ migrations.AlterField(
23
+ model_name="historicalscreeningpartone",
24
+ name="repeat_fasting_duration_delta",
25
+ field=models.DurationField(
26
+ blank=True,
27
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
28
+ null=True,
29
+ ),
30
+ ),
31
+ migrations.AlterField(
32
+ model_name="historicalscreeningpartthree",
33
+ name="fasting_duration_delta",
34
+ field=models.DurationField(
35
+ blank=True,
36
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
37
+ null=True,
38
+ ),
39
+ ),
40
+ migrations.AlterField(
41
+ model_name="historicalscreeningpartthree",
42
+ name="repeat_fasting_duration_delta",
43
+ field=models.DurationField(
44
+ blank=True,
45
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
46
+ null=True,
47
+ ),
48
+ ),
49
+ migrations.AlterField(
50
+ model_name="historicalscreeningparttwo",
51
+ name="fasting_duration_delta",
52
+ field=models.DurationField(
53
+ blank=True,
54
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
55
+ null=True,
56
+ ),
57
+ ),
58
+ migrations.AlterField(
59
+ model_name="historicalscreeningparttwo",
60
+ name="repeat_fasting_duration_delta",
61
+ field=models.DurationField(
62
+ blank=True,
63
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
64
+ null=True,
65
+ ),
66
+ ),
67
+ migrations.AlterField(
68
+ model_name="historicalsubjectscreening",
69
+ name="fasting_duration_delta",
70
+ field=models.DurationField(
71
+ blank=True,
72
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
73
+ null=True,
74
+ ),
75
+ ),
76
+ migrations.AlterField(
77
+ model_name="historicalsubjectscreening",
78
+ name="repeat_fasting_duration_delta",
79
+ field=models.DurationField(
80
+ blank=True,
81
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
82
+ null=True,
83
+ ),
84
+ ),
85
+ migrations.AlterField(
86
+ model_name="subjectscreening",
87
+ name="fasting_duration_delta",
88
+ field=models.DurationField(
89
+ blank=True,
90
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
91
+ null=True,
92
+ ),
93
+ ),
94
+ migrations.AlterField(
95
+ model_name="subjectscreening",
96
+ name="repeat_fasting_duration_delta",
97
+ field=models.DurationField(
98
+ blank=True,
99
+ help_text="system calculated to microseconds. (hours=microseconds/3.6e+9)",
100
+ null=True,
101
+ ),
102
+ ),
103
+ ]
@@ -1,4 +1,4 @@
1
- from .icp_referral import IcpReferral
1
+ # from .icp_referral import IcpReferral
2
2
  from .proxy_models import ScreeningPartOne, ScreeningPartThree, ScreeningPartTwo
3
3
  from .signals import update_p3_ltfu_on_post_save
4
4
  from .subject_refusal import SubjectRefusal
@@ -21,7 +21,7 @@ from model_bakery import baker
21
21
 
22
22
  from meta_edc.meta_version import PHASE_THREE
23
23
  from meta_pharmacy.prepare_meta_pharmacy import prepare_meta_pharmacy
24
- from meta_sites import fqdn
24
+ from meta_sites.sites import domain_suffix
25
25
  from meta_subject.models import SubjectVisit
26
26
  from meta_visit_schedule.constants import DAY1
27
27
 
@@ -40,7 +40,7 @@ from .options import (
40
40
 
41
41
 
42
42
  class MetaTestCaseMixin(AppointmentTestCaseMixin):
43
- fqdn = fqdn
43
+ fqdn = domain_suffix
44
44
 
45
45
  default_sites = sites.get_by_country("tanzania", aslist=True)
46
46
 
@@ -54,18 +54,18 @@ def get_part_one_eligible_options():
54
54
  return options
55
55
 
56
56
 
57
- def get_part_two_eligible_options():
57
+ def get_part_two_eligible_options(report_datetime: datetime = None) -> dict:
58
58
  options = dict(
59
59
  acute_condition=NO,
60
60
  acute_metabolic_acidosis=NO,
61
61
  advised_to_fast=YES,
62
62
  alcoholism=NO,
63
63
  already_fasted=NO,
64
- appt_datetime=now + relativedelta(days=10),
64
+ appt_datetime=report_datetime or (now + relativedelta(days=10)),
65
65
  congestive_heart_failure=NO,
66
66
  liver_disease=NO,
67
67
  metformin_sensitivity=NO,
68
- part_two_report_datetime=now,
68
+ part_two_report_datetime=report_datetime or now,
69
69
  renal_function_condition=NO,
70
70
  tissue_hypoxia_condition=NO,
71
71
  has_dm=NO,
meta_sites/__init__.py CHANGED
@@ -1 +0,0 @@
1
- from .sites import all_sites, fqdn # noqa
meta_sites/sites.py CHANGED
@@ -1,7 +1,8 @@
1
+ from django.conf import settings
1
2
  from edc_sites.single_site import SingleSite
2
3
  from edc_sites.site import sites as site_sites
3
4
 
4
- fqdn = "meta3.clinicedc.org"
5
+ domain_suffix = settings.EDC_SITES_DOMAIN_SUFFIX
5
6
  languages = ["sw", "en", "mas"]
6
7
 
7
8
  all_sites = [
@@ -11,7 +12,7 @@ all_sites = [
11
12
  title="Hindu Mandal Hospital",
12
13
  country="tanzania",
13
14
  country_code="tz",
14
- domain=f"hindu-mandal.tz.{fqdn}",
15
+ domain=f"hindu-mandal.tz.{domain_suffix}",
15
16
  language_codes=languages,
16
17
  ),
17
18
  SingleSite(
@@ -20,7 +21,7 @@ all_sites = [
20
21
  title="Amana Hospital",
21
22
  country="tanzania",
22
23
  country_code="tz",
23
- domain=f"amana.tz.{fqdn}",
24
+ domain=f"amana.tz.{domain_suffix}",
24
25
  language_codes=languages,
25
26
  ),
26
27
  SingleSite(
@@ -29,7 +30,7 @@ all_sites = [
29
30
  title="Temeke Hospital",
30
31
  country="tanzania",
31
32
  country_code="tz",
32
- domain=f"temeke.tz.{fqdn}",
33
+ domain=f"temeke.tz.{domain_suffix}",
33
34
  language_codes=languages,
34
35
  ),
35
36
  SingleSite(
@@ -39,7 +40,7 @@ all_sites = [
39
40
  country="tanzania",
40
41
  country_code="tz",
41
42
  language_codes=languages,
42
- domain=f"mwananyamala.tz.{fqdn}",
43
+ domain=f"mwananyamala.tz.{domain_suffix}",
43
44
  ),
44
45
  SingleSite(
45
46
  50,
@@ -48,7 +49,7 @@ all_sites = [
48
49
  country="tanzania",
49
50
  country_code="tz",
50
51
  language_codes=languages,
51
- domain=f"mbagala.tz.{fqdn}",
52
+ domain=f"mbagala.tz.{domain_suffix}",
52
53
  ),
53
54
  SingleSite(
54
55
  60,
@@ -57,7 +58,7 @@ all_sites = [
57
58
  country="tanzania",
58
59
  country_code="tz",
59
60
  language_codes=languages,
60
- domain=f"mnazi-moja.tz.{fqdn}",
61
+ domain=f"mnazi-moja.tz.{domain_suffix}",
61
62
  ),
62
63
  ]
63
64
 
@@ -20,12 +20,15 @@ from edc_visit_schedule.utils import is_baseline
20
20
  from edc_visit_tracking.constants import MISSED_VISIT
21
21
 
22
22
  from meta_prn.constants import (
23
+ DM_REFFERAL_ACTION,
24
+ OFFSCHEDULE_DM_REFERRAL_ACTION,
23
25
  OFFSCHEDULE_PREGNANCY_ACTION,
24
26
  PREGNANCY_NOTIFICATION_ACTION,
25
27
  )
26
28
 
27
29
  from .constants import (
28
30
  DELIVERY_ACTION,
31
+ DM_FOLLOWUP_ACTION,
29
32
  FOLLOWUP_EXAMINATION_ACTION,
30
33
  MISSED_VISIT_ACTION,
31
34
  URINE_PREGNANCY_ACTION,
@@ -150,6 +153,25 @@ class EgfrDropNotificationAction(ActionWithNotification):
150
153
  return self.reference_obj.report_status != NEW
151
154
 
152
155
 
156
+ class DmFollowAction(ActionWithNotification):
157
+ name = DM_FOLLOWUP_ACTION
158
+ display_name = "Diabetes Followup"
159
+ notification_display_name = "Diabetes Followup"
160
+ parent_action_names = [DM_REFFERAL_ACTION]
161
+ reference_model = "meta_subject.dmfollowup"
162
+ show_link_to_changelist = True
163
+ show_link_to_add = False
164
+ show_on_dashboard = False
165
+ create_by_user = False
166
+ create_by_action = True
167
+ admin_site_name = "meta_subject_admin"
168
+ priority = HIGH_PRIORITY
169
+
170
+ def get_next_actions(self):
171
+ next_actions = [OFFSCHEDULE_DM_REFERRAL_ACTION]
172
+ return next_actions
173
+
174
+
153
175
  def register_actions():
154
176
  for action_item_cls in [
155
177
  BloodResultsFbcAction,
@@ -162,6 +184,7 @@ def register_actions():
162
184
  UrinePregnancyAction,
163
185
  DeliveryAction,
164
186
  EgfrDropNotificationAction,
187
+ DmFollowAction,
165
188
  ]:
166
189
  try:
167
190
  site_action_items.register(action_item_cls)
@@ -9,7 +9,7 @@ from .complications_admin import ComplicationsAdmin
9
9
  from .complications_glycemia_admin import ComplicationsGlycemiaAdmin
10
10
  from .concomitant_medication_admin import ConcomitantMedicationAdmin
11
11
  from .delivery_admin import DeliveryAdmin
12
- from .dm_referral_followup_admin import DmReferralFollowupAdmin
12
+ from .diabetes import DmFollowupAdmin
13
13
  from .egfr_drop_notification_admin import EgfrDropNotificationAdmin
14
14
  from .eq5d3l_admin import Eq5d3lAdmin
15
15
  from .followup_examination_admin import FollowupExaminationAdmin
@@ -60,15 +60,14 @@ class BirthOutcomesAdmin(
60
60
  def get_search_fields(self, request) -> Tuple[str, ...]:
61
61
  fields = super().get_search_fields(request)
62
62
  custom_fields = (
63
- "delivery__action_identifier__subject_visit__subject_identifier",
63
+ "delivery__subject_visit__subject_identifier",
64
64
  "delivery__action_identifier",
65
- "delivery__tracking_identifier",
66
65
  )
67
66
  return tuple(set(fields + custom_fields))
68
67
 
69
68
  @admin.display
70
69
  def delivery_report(self, obj=None, label=None):
71
- url = reverse("meta_prn_admin:meta_prn_delivery_changelist")
70
+ url = reverse("meta_subject_admin:meta_subject_delivery_changelist")
72
71
  url = f"{url}?q={obj.subject_identifier}"
73
72
  context = dict(title="Delivery", url=url, label="Delivery")
74
73
  return render_to_string("dashboard_button.html", context=context)
@@ -109,7 +109,6 @@ class DeliveryAdmin(
109
109
  search_fields = (
110
110
  "subject_visit__subject_identifier",
111
111
  "action_identifier",
112
- "tracking_identifier",
113
112
  )
114
113
 
115
114
  @admin.display
@@ -0,0 +1,2 @@
1
+ from .dm_diagnosis_admin import DmDiagnosisAdmin
2
+ from .dm_followup_admin import DmFollowupAdmin
@@ -0,0 +1,89 @@
1
+ from django.contrib import admin
2
+ from django_audit_fields.admin import audit_fieldset_tuple
3
+ from edc_crf.fieldset import crf_status_fieldset
4
+ from edc_form_label.form_label_modeladmin_mixin import FormLabelModelAdminMixin
5
+ from edc_model_admin.history import SimpleHistoryAdmin
6
+ from edc_model_admin.mixins import TabularInlineMixin
7
+
8
+ from ...admin_site import meta_subject_admin
9
+ from ...forms import DmDiagnosisForm, DmDxResultForm
10
+ from ...models import DmDiagnosis, DmDxResult
11
+ from ..modeladmin import CrfModelAdminMixin
12
+
13
+
14
+ class DmDxResultInline(
15
+ TabularInlineMixin,
16
+ admin.TabularInline,
17
+ ):
18
+
19
+ form = DmDxResultForm
20
+ extra = 1
21
+ view_on_site = False
22
+ min_num = 1
23
+ insert_before_fieldset = "Comments"
24
+ verbose_name_plural = "Results used in the decision to diagnose"
25
+
26
+ fieldsets = (
27
+ [
28
+ "Lab results",
29
+ {
30
+ "description": "List the lab results used for this decision",
31
+ "fields": (
32
+ "report_date",
33
+ "utestid",
34
+ "value",
35
+ "fasted",
36
+ "comment",
37
+ ),
38
+ },
39
+ ],
40
+ )
41
+
42
+ def get_formset(self, request, obj=None, **kwargs):
43
+ formset = super().get_formset(request, obj=None, **kwargs)
44
+ formset.validate_min = True
45
+ return formset
46
+
47
+ model = DmDxResult
48
+ form = DmDxResultForm
49
+
50
+
51
+ @admin.register(DmDiagnosis, site=meta_subject_admin)
52
+ class DmDiagnosisAdmin(
53
+ CrfModelAdminMixin,
54
+ FormLabelModelAdminMixin,
55
+ SimpleHistoryAdmin,
56
+ ):
57
+ form = DmDiagnosisForm
58
+
59
+ inlines = [DmDxResultInline]
60
+
61
+ fieldsets = (
62
+ (None, {"fields": ("subject_visit", "report_datetime")}),
63
+ (
64
+ "Diagnosis",
65
+ {
66
+ "fields": (
67
+ "dx_date",
68
+ "dx_initiated_by",
69
+ "dx_initiated_by_other",
70
+ "dx_tmg",
71
+ "dx_tmg_date",
72
+ "dx_no_tmg_reason",
73
+ ),
74
+ },
75
+ ),
76
+ (
77
+ "Comments",
78
+ {
79
+ "fields": ("comments",),
80
+ },
81
+ ),
82
+ crf_status_fieldset,
83
+ audit_fieldset_tuple,
84
+ )
85
+
86
+ radio_fields = {
87
+ "dx_initiated_by": admin.VERTICAL,
88
+ "dx_tmg": admin.VERTICAL,
89
+ }
@@ -1,21 +1,25 @@
1
1
  from django.contrib import admin
2
2
  from django_audit_fields.admin import audit_fieldset_tuple
3
+ from edc_action_item import ActionItemModelAdminMixin, action_fieldset_tuple
3
4
  from edc_adherence.model_admin_mixin import get_visual_score_fieldset_tuple
4
5
  from edc_crf.fieldset import crf_status_fieldset
5
6
  from edc_form_label.form_label_modeladmin_mixin import FormLabelModelAdminMixin
6
7
  from edc_model_admin.history import SimpleHistoryAdmin
7
8
 
8
- from ..admin_site import meta_subject_admin
9
- from ..forms.dm_referral_followup import DmReferralFollowupForm
10
- from ..models import DmReferralFollowup
11
- from .modeladmin import CrfModelAdminMixin
9
+ from ...admin_site import meta_subject_admin
10
+ from ...forms import DmFollowupForm
11
+ from ...models import DmFollowup
12
+ from ..modeladmin import CrfModelAdminMixin
12
13
 
13
14
 
14
- @admin.register(DmReferralFollowup, site=meta_subject_admin)
15
- class DmReferralFollowupAdmin(
16
- CrfModelAdminMixin, FormLabelModelAdminMixin, SimpleHistoryAdmin
15
+ @admin.register(DmFollowup, site=meta_subject_admin)
16
+ class DmFollowupAdmin(
17
+ CrfModelAdminMixin,
18
+ FormLabelModelAdminMixin,
19
+ ActionItemModelAdminMixin,
20
+ SimpleHistoryAdmin,
17
21
  ):
18
- form = DmReferralFollowupForm
22
+ form = DmFollowupForm
19
23
 
20
24
  fieldsets = (
21
25
  (None, {"fields": ("subject_visit", "report_datetime")}),
@@ -49,6 +53,7 @@ class DmReferralFollowupAdmin(
49
53
  "Diabetes treatment",
50
54
  {
51
55
  "fields": (
56
+ "treatment_prescribed",
52
57
  "dm_treatments",
53
58
  "on_dm_medications",
54
59
  "dm_medications_init_date",
@@ -68,6 +73,7 @@ class DmReferralFollowupAdmin(
68
73
  ),
69
74
  get_visual_score_fieldset_tuple(),
70
75
  crf_status_fieldset,
76
+ action_fieldset_tuple,
71
77
  audit_fieldset_tuple,
72
78
  )
73
79
 
@@ -86,4 +92,5 @@ class DmReferralFollowupAdmin(
86
92
  "on_dm_medications": admin.VERTICAL,
87
93
  "medications_adherent": admin.VERTICAL,
88
94
  "last_missed_pill": admin.VERTICAL,
95
+ "treatment_prescribed": admin.VERTICAL,
89
96
  }
@@ -32,7 +32,7 @@ class GlucoseAdmin(CrfModelAdminMixin, SimpleHistoryAdmin):
32
32
  },
33
33
  ),
34
34
  (
35
- "FBG",
35
+ "Blood Glucose",
36
36
  {
37
37
  "fields": (
38
38
  "fbg_performed",
@@ -19,27 +19,53 @@ class GlucoseFbgAdmin(CrfModelAdminMixin, SimpleHistoryAdmin):
19
19
 
20
20
  fieldsets = [
21
21
  (None, {"fields": ("subject_visit", "report_datetime")}),
22
- ("Fasting", {"fields": ["fasting"]}),
23
- ("Result", {"fields": ["assay_datetime", "glucose_value", "glucose_units"]}),
22
+ (
23
+ "Fasting",
24
+ {
25
+ "fields": (
26
+ "fasting",
27
+ "fasting_duration_str",
28
+ )
29
+ },
30
+ ),
31
+ (
32
+ "Blood Glucose",
33
+ {
34
+ "fields": (
35
+ "fbg_performed",
36
+ "fbg_not_performed_reason",
37
+ "fbg_datetime",
38
+ "fbg_value",
39
+ "fbg_units",
40
+ )
41
+ },
42
+ ),
43
+ (
44
+ "Confirmation appointment",
45
+ {
46
+ "description": (
47
+ "If blood glucose value is >= 7.0 mmol/L, schedule an "
48
+ "appointment within 1 week to confirm"
49
+ ),
50
+ "fields": ("repeat_fbg_date",),
51
+ },
52
+ ),
24
53
  ]
25
54
 
26
55
  radio_fields = {
27
56
  "fasting": admin.VERTICAL,
28
- "glucose_units": admin.VERTICAL,
57
+ "fbg_units": admin.VERTICAL,
58
+ "fbg_performed": admin.VERTICAL,
29
59
  }
30
60
 
31
61
  @admin.display(description="FBG", ordering="fbg_value")
32
62
  def fbg(self, obj=None):
33
63
  return obj.fbg_value
34
64
 
35
- @admin.display(description="OGTT", ordering="ogtt_value")
36
- def ogtt(self, obj=None):
37
- return obj.ogtt_value
38
-
39
65
  def get_list_display(self, request) -> tuple[str, ...]:
40
66
  list_display = super().get_list_display(request)
41
67
  list_display = list(list_display)
42
- list_display.insert(3, "ogtt")
68
+ # list_display.insert(3, "ogtt")
43
69
  list_display.insert(3, "fbg")
44
70
  list_display = tuple(list_display)
45
71
  return list_display