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.
- meta_auth/auth_objects.py +10 -3
- meta_consent/baker_recipes.py +4 -4
- meta_consent/consents.py +1 -1
- meta_consent/migrations/0025_alter_historicalsubjectconsent_first_name_and_more.py +151 -0
- meta_consent/models/signals.py +16 -13
- meta_consent/models/subject_consent_v1.py +1 -3
- meta_consent/tests/tests/test_form_validators.py +1 -1
- meta_dashboard/templates/meta_dashboard/bootstrap3/screening/listboard.html +4 -4
- meta_dashboard/templates/meta_dashboard/bootstrap3/subject/listboard.html +1 -2
- meta_edc/settings/debug.py +9 -9
- meta_edc/settings/defaults.py +25 -18
- meta_edc/settings/live.py +1 -9
- meta_edc/settings/uat.py +1 -14
- meta_edc/templates/meta_edc/bootstrap3/home.html +8 -5
- meta_edc/tests/test_settings.py +176 -0
- meta_edc/tests/tests/test_endpoints.py +20 -19
- meta_edc/urls.py +1 -1
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/METADATA +5 -4
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/RECORD +128 -74
- meta_prn/action_items.py +44 -2
- meta_prn/admin/__init__.py +3 -0
- meta_prn/admin/dm_referral_admin.py +49 -0
- meta_prn/admin/offschedule_dm_referral_admin.py +47 -0
- meta_prn/admin/onschedule_dm_referral_admin.py +39 -0
- meta_prn/baker_recipes.py +8 -1
- meta_prn/choices.py +2 -1
- meta_prn/constants.py +4 -1
- meta_prn/forms/__init__.py +2 -0
- meta_prn/forms/dm_referral_form.py +40 -0
- meta_prn/forms/offschedule_dm_referral_form.py +35 -0
- meta_prn/forms/offschedule_form.py +6 -0
- meta_prn/migrations/0057_historicalonscheduledmreferral_and_more.py +1156 -0
- meta_prn/migrations/0058_dmreferral_referral_note_and_more.py +29 -0
- meta_prn/migrations/0059_alter_historicaloffstudymedication_reason_and_more.py +53 -0
- meta_prn/models/__init__.py +13 -2
- meta_prn/models/dm_referral.py +39 -0
- meta_prn/models/offschedule.py +15 -1
- meta_prn/models/onschedule.py +6 -0
- meta_prn/models/signals.py +41 -1
- meta_prn/tests/tests/test_dm_referral.py +206 -0
- meta_screening/form_validators/screening_part_two.py +1 -1
- meta_screening/migrations/0062_remove_icpreferral_site_and_more.py +27 -0
- meta_screening/migrations/0063_alter_historicalscreeningpartone_fasting_duration_str_and_more.py +184 -0
- meta_screening/migrations/0064_remove_historicalscreeningpartone_fasting_duration_minutes_and_more.py +126 -0
- meta_screening/migrations/0065_auto_20240516_0352.py +31 -0
- meta_screening/migrations/0066_alter_historicalscreeningpartone_fasting_duration_delta_and_more.py +103 -0
- meta_screening/models/__init__.py +1 -1
- meta_screening/tests/meta_test_case_mixin.py +2 -2
- meta_screening/tests/options.py +3 -3
- meta_sites/__init__.py +0 -1
- meta_sites/sites.py +8 -7
- meta_subject/action_items.py +23 -0
- meta_subject/admin/__init__.py +1 -1
- meta_subject/admin/birth_outcome_admin.py +2 -3
- meta_subject/admin/delivery_admin.py +0 -1
- meta_subject/admin/diabetes/__init__.py +2 -0
- meta_subject/admin/diabetes/dm_diagnosis_admin.py +89 -0
- meta_subject/admin/{dm_referral_followup_admin.py → diabetes/dm_followup_admin.py} +15 -8
- meta_subject/admin/glucose_admin.py +1 -1
- meta_subject/admin/glucose_fbg_admin.py +34 -8
- meta_subject/admin/subject_visit_admin.py +4 -1
- meta_subject/baker_recipes.py +6 -0
- meta_subject/choices.py +8 -0
- meta_subject/constants.py +2 -1
- meta_subject/form_validators/__init__.py +2 -1
- meta_subject/form_validators/dm_diagnosis_form_validator.py +38 -0
- meta_subject/form_validators/dm_dx_result_form_validator.py +7 -0
- meta_subject/form_validators/{dm_referral_followup_form_validator.py → dm_followup_form_validator.py} +41 -2
- meta_subject/forms/__init__.py +1 -0
- meta_subject/forms/diabetes/__init__.py +3 -0
- meta_subject/forms/diabetes/dm_diagnosis_form.py +13 -0
- meta_subject/forms/diabetes/dm_dx_result_form.py +11 -0
- meta_subject/forms/diabetes/dm_followup_form.py +25 -0
- meta_subject/forms/glucose_fbg_form.py +38 -16
- meta_subject/forms/subject_visit_form.py +16 -0
- meta_subject/metadata_rules/metadata_rules.py +14 -0
- meta_subject/metadata_rules/predicates.py +22 -0
- meta_subject/migrations/0181_dmreferralfollowup_action_identifier_and_more.py +143 -0
- meta_subject/migrations/0182_rename_dmreferralfollowup_dmfollowup_and_more.py +54 -0
- meta_subject/migrations/0183_alter_dmfollowup_on_dm_medications_and_more.py +31 -0
- meta_subject/migrations/0184_alter_glucose_options_and_more.py +31 -0
- meta_subject/migrations/0185_alter_bloodresultsins_fasting_duration_str_and_more.py +82 -0
- meta_subject/migrations/0186_healtheconomicsupdate_singleton_field_and_more.py +55 -0
- meta_subject/migrations/0187_dmdiagnosis_historicaldmdiagnosis_dmdxresult_and_more.py +451 -0
- meta_subject/migrations/0188_historicaldmdxresult_dmdxresult.py +403 -0
- meta_subject/migrations/0189_alter_dmdxresult_options_and_more.py +116 -0
- meta_subject/migrations/0190_dmdiagnosis_dx_no_tmg_reason_and_more.py +65 -0
- meta_subject/migrations/0191_alter_dmdiagnosis_dx_no_tmg_reason_and_more.py +70 -0
- meta_subject/migrations/0192_rename_glucose_quantifier_glucosefbg_fbg_quantifier_and_more.py +44 -0
- meta_subject/migrations/0193_alter_glucosefbg_fbg_value_and_more.py +44 -0
- meta_subject/migrations/0194_remove_glucosefbg_assay_datetime_and_more.py +166 -0
- meta_subject/migrations/0195_alter_glucosefbg_fbg_datetime_and_more.py +27 -0
- meta_subject/migrations/0196_glucosefbg_fbg_not_performed_reason_and_more.py +49 -0
- meta_subject/migrations/0197_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
- meta_subject/migrations/0198_alter_glucosefbg_fasting_duration_estimated_and_more.py +33 -0
- meta_subject/migrations/0199_auto_20240516_0247.py +18 -0
- meta_subject/migrations/0200_rename_fasting_duration_minutes_bloodresultsins_fasting_duration_delta_and_more.py +43 -0
- meta_subject/migrations/0201_alter_bloodresultsins_fasting_duration_delta_and_more.py +58 -0
- meta_subject/migrations/0202_auto_20240516_0315.py +32 -0
- meta_subject/migrations/0203_alter_bloodresultsins_fasting_duration_delta_and_more.py +67 -0
- meta_subject/migrations/0204_glucosefbg_repeat_fbg_date_and_more.py +27 -0
- meta_subject/migrations/0205_historicalsubjectrequisition_crf_status_and_more.py +80 -0
- meta_subject/migrations/0206_bloodresultsfbc_crf_status_and_more.py +62 -0
- meta_subject/models/__init__.py +1 -1
- meta_subject/models/blood_results/blood_results_fbc.py +3 -2
- meta_subject/models/blood_results/blood_results_hba1c.py +2 -0
- meta_subject/models/blood_results/blood_results_ins.py +2 -0
- meta_subject/models/blood_results/blood_results_lft.py +2 -0
- meta_subject/models/blood_results/blood_results_lipid.py +2 -0
- meta_subject/models/blood_results/blood_results_rft.py +2 -0
- meta_subject/models/diabetes/__init__.py +3 -0
- meta_subject/models/diabetes/dm_diagnosis.py +50 -0
- meta_subject/models/diabetes/dm_dx_result.py +70 -0
- meta_subject/models/{dm_referral_followup.py → diabetes/dm_followup.py} +18 -6
- meta_subject/models/glucose.py +5 -15
- meta_subject/models/glucose_fbg.py +40 -51
- meta_subject/models/health_economics/health_economics_update.py +2 -0
- meta_subject/models/subject_requisition.py +3 -4
- meta_subject/tests/tests/test_egfr.py +6 -5
- meta_subject/tests/tests/test_metadata_rules.py +32 -2
- meta_visit_schedule/constants.py +3 -1
- meta_visit_schedule/visit_schedules/phase_three/crfs.py +12 -1
- meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py +60 -0
- meta_visit_schedule/visit_schedules/phase_three/visit_schedule.py +2 -0
- meta_subject/forms/dm_referral_followup.py +0 -18
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/AUTHORS +0 -0
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/LICENSE +0 -0
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/WHEEL +0 -0
- {meta_edc-0.3.7.dist-info → meta_edc-0.3.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated by Django 4.2.11 on 2024-04-04 16:47
|
2
|
+
|
3
|
+
from django.db import migrations, models
|
4
|
+
|
5
|
+
|
6
|
+
class Migration(migrations.Migration):
|
7
|
+
|
8
|
+
dependencies = [
|
9
|
+
("meta_prn", "0057_historicalonscheduledmreferral_and_more"),
|
10
|
+
]
|
11
|
+
|
12
|
+
operations = [
|
13
|
+
migrations.AddField(
|
14
|
+
model_name="dmreferral",
|
15
|
+
name="referral_note",
|
16
|
+
field=models.TextField(
|
17
|
+
null=True,
|
18
|
+
verbose_name="Please provide a brief history of the diabetes diagnosis that lead to this referral",
|
19
|
+
),
|
20
|
+
),
|
21
|
+
migrations.AddField(
|
22
|
+
model_name="historicaldmreferral",
|
23
|
+
name="referral_note",
|
24
|
+
field=models.TextField(
|
25
|
+
null=True,
|
26
|
+
verbose_name="Please provide a brief history of the diabetes diagnosis that lead to this referral",
|
27
|
+
),
|
28
|
+
),
|
29
|
+
]
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Generated by Django 5.0.4 on 2024-04-18 23:46
|
2
|
+
|
3
|
+
from django.db import migrations, models
|
4
|
+
|
5
|
+
|
6
|
+
class Migration(migrations.Migration):
|
7
|
+
|
8
|
+
dependencies = [
|
9
|
+
("meta_prn", "0058_dmreferral_referral_note_and_more"),
|
10
|
+
]
|
11
|
+
|
12
|
+
operations = [
|
13
|
+
migrations.AlterField(
|
14
|
+
model_name="historicaloffstudymedication",
|
15
|
+
name="reason",
|
16
|
+
field=models.CharField(
|
17
|
+
choices=[
|
18
|
+
("pregnancy", "Pregnancy"),
|
19
|
+
("sae", "Participant is experiencing a serious adverse event"),
|
20
|
+
(
|
21
|
+
"clinician",
|
22
|
+
"Other condition that justifies discontinuation of treatment in the clinician's opinion (specify below)",
|
23
|
+
),
|
24
|
+
("investigator", " Investigator decision"),
|
25
|
+
("referral", "Referral to Diabetes clinic"),
|
26
|
+
("patient", "Patient decision"),
|
27
|
+
("OTHER", "Other reason (specify below)"),
|
28
|
+
],
|
29
|
+
max_length=25,
|
30
|
+
verbose_name="Reason for stopping study medication",
|
31
|
+
),
|
32
|
+
),
|
33
|
+
migrations.AlterField(
|
34
|
+
model_name="offstudymedication",
|
35
|
+
name="reason",
|
36
|
+
field=models.CharField(
|
37
|
+
choices=[
|
38
|
+
("pregnancy", "Pregnancy"),
|
39
|
+
("sae", "Participant is experiencing a serious adverse event"),
|
40
|
+
(
|
41
|
+
"clinician",
|
42
|
+
"Other condition that justifies discontinuation of treatment in the clinician's opinion (specify below)",
|
43
|
+
),
|
44
|
+
("investigator", " Investigator decision"),
|
45
|
+
("referral", "Referral to Diabetes clinic"),
|
46
|
+
("patient", "Patient decision"),
|
47
|
+
("OTHER", "Other reason (specify below)"),
|
48
|
+
],
|
49
|
+
max_length=25,
|
50
|
+
verbose_name="Reason for stopping study medication",
|
51
|
+
),
|
52
|
+
),
|
53
|
+
]
|
meta_prn/models/__init__.py
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
+
from .dm_referral import DmReferral
|
1
2
|
from .end_of_study import EndOfStudy
|
2
3
|
from .loss_to_followup import LossToFollowup
|
3
4
|
from .off_study_medication import OffStudyMedication
|
4
|
-
from .offschedule import
|
5
|
-
|
5
|
+
from .offschedule import (
|
6
|
+
OffSchedule,
|
7
|
+
OffScheduleDmReferral,
|
8
|
+
OffSchedulePostnatal,
|
9
|
+
OffSchedulePregnancy,
|
10
|
+
)
|
11
|
+
from .onschedule import (
|
12
|
+
OnSchedule,
|
13
|
+
OnScheduleDmReferral,
|
14
|
+
OnSchedulePostnatal,
|
15
|
+
OnSchedulePregnancy,
|
16
|
+
)
|
6
17
|
from .pregnancy_notification import PregnancyNotification
|
7
18
|
from .protocol_incident import ProtocolIncident
|
8
19
|
from .signals import (
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from django.db import models
|
2
|
+
from edc_action_item.models import ActionModelMixin
|
3
|
+
from edc_identifier.model_mixins import UniqueSubjectIdentifierFieldMixin
|
4
|
+
from edc_model.models import BaseUuidModel
|
5
|
+
from edc_sites.model_mixins import SiteModelMixin
|
6
|
+
from edc_utils.date import get_utcnow
|
7
|
+
|
8
|
+
from ..constants import DM_REFFERAL_ACTION
|
9
|
+
|
10
|
+
|
11
|
+
class DmReferral(
|
12
|
+
SiteModelMixin,
|
13
|
+
ActionModelMixin,
|
14
|
+
UniqueSubjectIdentifierFieldMixin,
|
15
|
+
BaseUuidModel,
|
16
|
+
):
|
17
|
+
|
18
|
+
action_name = DM_REFFERAL_ACTION
|
19
|
+
|
20
|
+
report_datetime = models.DateTimeField(
|
21
|
+
verbose_name="Report date and time", default=get_utcnow
|
22
|
+
)
|
23
|
+
|
24
|
+
referral_date = models.DateField(
|
25
|
+
verbose_name="Date of referral to diabetes clinic",
|
26
|
+
)
|
27
|
+
|
28
|
+
referral_note = models.TextField(
|
29
|
+
verbose_name=(
|
30
|
+
"Please provide a brief history of the "
|
31
|
+
"diabetes diagnosis that lead to this referral"
|
32
|
+
),
|
33
|
+
null=True,
|
34
|
+
blank=False,
|
35
|
+
)
|
36
|
+
|
37
|
+
class Meta(ActionModelMixin.Meta, BaseUuidModel.Meta):
|
38
|
+
verbose_name = "Diabetes referral"
|
39
|
+
verbose_name_plural = "Diabetes referral"
|
meta_prn/models/offschedule.py
CHANGED
@@ -4,7 +4,11 @@ from edc_sites.model_mixins import SiteModelMixin
|
|
4
4
|
from edc_visit_schedule.constants import OFFSCHEDULE_ACTION
|
5
5
|
from edc_visit_schedule.model_mixins import OffScheduleModelMixin
|
6
6
|
|
7
|
-
from ..constants import
|
7
|
+
from ..constants import (
|
8
|
+
OFFSCHEDULE_DM_REFERRAL_ACTION,
|
9
|
+
OFFSCHEDULE_POSTNATAL_ACTION,
|
10
|
+
OFFSCHEDULE_PREGNANCY_ACTION,
|
11
|
+
)
|
8
12
|
|
9
13
|
|
10
14
|
class OffSchedule(SiteModelMixin, ActionModelMixin, OffScheduleModelMixin, BaseUuidModel):
|
@@ -34,3 +38,13 @@ class OffSchedulePostnatal(
|
|
34
38
|
class Meta(OffScheduleModelMixin.Meta, BaseUuidModel.Meta):
|
35
39
|
verbose_name = "Off-schedule: post-natal"
|
36
40
|
verbose_name_plural = "Off-schedule: post-natal"
|
41
|
+
|
42
|
+
|
43
|
+
class OffScheduleDmReferral(
|
44
|
+
SiteModelMixin, ActionModelMixin, OffScheduleModelMixin, BaseUuidModel
|
45
|
+
):
|
46
|
+
action_name = OFFSCHEDULE_DM_REFERRAL_ACTION
|
47
|
+
|
48
|
+
class Meta(OffScheduleModelMixin.Meta, BaseUuidModel.Meta):
|
49
|
+
verbose_name = "Off-schedule: DM Referral"
|
50
|
+
verbose_name_plural = "Off-schedule: DM Referral"
|
meta_prn/models/onschedule.py
CHANGED
@@ -18,3 +18,9 @@ class OnSchedulePregnancy(OnScheduleModelMixin, SiteModelMixin, BaseUuidModel):
|
|
18
18
|
class OnSchedulePostnatal(OnScheduleModelMixin, SiteModelMixin, BaseUuidModel):
|
19
19
|
class Meta(OnScheduleModelMixin.Meta):
|
20
20
|
pass
|
21
|
+
|
22
|
+
|
23
|
+
class OnScheduleDmReferral(OnScheduleModelMixin, SiteModelMixin, BaseUuidModel):
|
24
|
+
class Meta(OnScheduleModelMixin.Meta, BaseUuidModel.Meta):
|
25
|
+
verbose_name = "On-schedule: DM Referral"
|
26
|
+
verbose_name_plural = "On-schedule: DM Referral"
|
meta_prn/models/signals.py
CHANGED
@@ -5,8 +5,15 @@ from edc_constants.constants import YES
|
|
5
5
|
from edc_visit_schedule.site_visit_schedules import site_visit_schedules
|
6
6
|
|
7
7
|
from meta_subject.models import SubjectVisit, UrinePregnancy
|
8
|
-
from meta_visit_schedule.constants import
|
8
|
+
from meta_visit_schedule.constants import (
|
9
|
+
SCHEDULE,
|
10
|
+
SCHEDULE_DM_REFERRAL,
|
11
|
+
SCHEDULE_PREGNANCY,
|
12
|
+
VISIT_SCHEDULE,
|
13
|
+
)
|
9
14
|
|
15
|
+
from . import OffScheduleDmReferral
|
16
|
+
from .dm_referral import DmReferral
|
10
17
|
from .offschedule import OffSchedule
|
11
18
|
from .pregnancy_notification import PregnancyNotification
|
12
19
|
|
@@ -63,3 +70,36 @@ def update_urine_pregnancy_on_pregnancy_notification_on_post_save(
|
|
63
70
|
notified_datetime=instance.report_datetime,
|
64
71
|
notified=True,
|
65
72
|
)
|
73
|
+
|
74
|
+
|
75
|
+
@receiver(
|
76
|
+
post_save,
|
77
|
+
weak=False,
|
78
|
+
sender=DmReferral,
|
79
|
+
dispatch_uid="update_schedule_on_dm_referral_post_save",
|
80
|
+
)
|
81
|
+
def update_schedule_on_dm_referral_post_save(sender, instance, raw, **kwargs):
|
82
|
+
if not raw:
|
83
|
+
try:
|
84
|
+
OffScheduleDmReferral.objects.get(subject_identifier=instance.subject_identifier)
|
85
|
+
except ObjectDoesNotExist:
|
86
|
+
last_subject_visit = (
|
87
|
+
SubjectVisit.objects.filter(
|
88
|
+
subject_identifier=instance.subject_identifier,
|
89
|
+
schedule_name=SCHEDULE,
|
90
|
+
)
|
91
|
+
.order_by("report_datetime")
|
92
|
+
.last()
|
93
|
+
)
|
94
|
+
visit_schedule = site_visit_schedules.get_visit_schedule(
|
95
|
+
visit_schedule_name=VISIT_SCHEDULE
|
96
|
+
)
|
97
|
+
schedule = visit_schedule.schedules.get(SCHEDULE)
|
98
|
+
schedule.take_off_schedule(
|
99
|
+
instance.subject_identifier, last_subject_visit.report_datetime
|
100
|
+
)
|
101
|
+
schedule = visit_schedule.schedules.get(SCHEDULE_DM_REFERRAL)
|
102
|
+
schedule.put_on_schedule(
|
103
|
+
onschedule_datetime=last_subject_visit.report_datetime,
|
104
|
+
subject_identifier=instance.subject_identifier,
|
105
|
+
)
|
@@ -0,0 +1,206 @@
|
|
1
|
+
from dateutil.relativedelta import relativedelta
|
2
|
+
from django.core.exceptions import ObjectDoesNotExist
|
3
|
+
from django.test import TestCase, tag
|
4
|
+
from edc_action_item.models import ActionItem
|
5
|
+
from edc_appointment.constants import COMPLETE_APPT
|
6
|
+
from edc_appointment.models import Appointment
|
7
|
+
from edc_constants.constants import CLOSED, FEMALE, NEW, NO, PATIENT, YES
|
8
|
+
from edc_pharmacy.constants import IN_PROGRESS_APPT
|
9
|
+
from edc_utils import get_utcnow
|
10
|
+
from edc_visit_schedule.constants import MONTH1, OFFSCHEDULE_ACTION
|
11
|
+
from edc_visit_tracking.constants import SCHEDULED
|
12
|
+
|
13
|
+
from meta_lists.models import MissedReferralReasons
|
14
|
+
from meta_prn.constants import (
|
15
|
+
OFFSCHEDULE_DM_REFERRAL_ACTION,
|
16
|
+
OFFSTUDY_MEDICATION_ACTION,
|
17
|
+
)
|
18
|
+
from meta_prn.models import DmReferral, OnScheduleDmReferral
|
19
|
+
from meta_screening.tests.meta_test_case_mixin import MetaTestCaseMixin
|
20
|
+
from meta_subject.constants import DM_FOLLOWUP_ACTION
|
21
|
+
from meta_subject.models import DmDiagnosis, DmFollowup, SubjectVisit
|
22
|
+
from meta_visit_schedule.constants import DM_BASELINE, DM_FOLLOWUP, SCHEDULE_DM_REFERRAL
|
23
|
+
|
24
|
+
|
25
|
+
@tag("1")
|
26
|
+
class TestDmReferral(MetaTestCaseMixin, TestCase):
|
27
|
+
def setUp(self):
|
28
|
+
super().setUp()
|
29
|
+
self.subject_visit = self.get_subject_visit(gender=FEMALE)
|
30
|
+
|
31
|
+
def test_dm_referral_puts_subject_on_dm_followup_schedule(self):
|
32
|
+
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
33
|
+
subject_visit = self.get_next_subject_visit(subject_visit)
|
34
|
+
self.assertEqual(subject_visit.visit_code, MONTH1)
|
35
|
+
dm_referral = DmReferral.objects.create(
|
36
|
+
subject_identifier=subject_visit.subject_identifier,
|
37
|
+
report_datetime=get_utcnow(),
|
38
|
+
referral_date=get_utcnow(),
|
39
|
+
)
|
40
|
+
self.assertIsNotNone(dm_referral.report_datetime)
|
41
|
+
self.assertIsNotNone(dm_referral.referral_date)
|
42
|
+
self.assertIsNotNone(dm_referral.action_identifier)
|
43
|
+
|
44
|
+
# verify subject is on DM Followup schedule
|
45
|
+
try:
|
46
|
+
OnScheduleDmReferral.objects.get(
|
47
|
+
subject_identifier=subject_visit.subject_identifier
|
48
|
+
)
|
49
|
+
except ObjectDoesNotExist:
|
50
|
+
self.fail("OnScheduleDmReferral unexpectedly does not exist")
|
51
|
+
|
52
|
+
@tag("1")
|
53
|
+
def test_dm_referral_action_creates_offschedule_action(self):
|
54
|
+
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
55
|
+
subject_visit = self.get_next_subject_visit(subject_visit)
|
56
|
+
self.assertEqual(subject_visit.visit_code, MONTH1)
|
57
|
+
dm_referral = DmReferral.objects.create(
|
58
|
+
subject_identifier=subject_visit.subject_identifier,
|
59
|
+
report_datetime=get_utcnow(),
|
60
|
+
referral_date=get_utcnow(),
|
61
|
+
)
|
62
|
+
self.assertIsNotNone(dm_referral.report_datetime)
|
63
|
+
self.assertIsNotNone(dm_referral.referral_date)
|
64
|
+
self.assertIsNotNone(dm_referral.action_identifier)
|
65
|
+
|
66
|
+
try:
|
67
|
+
ActionItem.objects.get(
|
68
|
+
subject_identifier=subject_visit.subject_identifier,
|
69
|
+
action_type__name=OFFSCHEDULE_ACTION,
|
70
|
+
status=CLOSED,
|
71
|
+
)
|
72
|
+
except ObjectDoesNotExist:
|
73
|
+
self.fail(f"{OFFSCHEDULE_ACTION} Action item unexpectedly does not exist")
|
74
|
+
|
75
|
+
def test_dm_referral_creates_offstudy_med_action(self):
|
76
|
+
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
77
|
+
subject_visit = self.get_next_subject_visit(subject_visit)
|
78
|
+
self.assertEqual(subject_visit.visit_code, MONTH1)
|
79
|
+
dm_referral = DmReferral.objects.create(
|
80
|
+
subject_identifier=subject_visit.subject_identifier,
|
81
|
+
report_datetime=get_utcnow(),
|
82
|
+
referral_date=get_utcnow(),
|
83
|
+
)
|
84
|
+
self.assertIsNotNone(dm_referral.report_datetime)
|
85
|
+
self.assertIsNotNone(dm_referral.referral_date)
|
86
|
+
self.assertIsNotNone(dm_referral.action_identifier)
|
87
|
+
|
88
|
+
# verify action items are created
|
89
|
+
try:
|
90
|
+
ActionItem.objects.get(
|
91
|
+
subject_identifier=subject_visit.subject_identifier,
|
92
|
+
action_type__name=OFFSTUDY_MEDICATION_ACTION,
|
93
|
+
status=NEW,
|
94
|
+
)
|
95
|
+
except ObjectDoesNotExist:
|
96
|
+
self.fail(f"{OFFSTUDY_MEDICATION_ACTION} Action item unexpectedly does not exist")
|
97
|
+
|
98
|
+
def test_dm_referral_creates_dm_followup_action(self):
|
99
|
+
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
100
|
+
subject_visit = self.get_next_subject_visit(subject_visit)
|
101
|
+
self.assertEqual(subject_visit.visit_code, MONTH1)
|
102
|
+
dm_referral = DmReferral.objects.create(
|
103
|
+
subject_identifier=subject_visit.subject_identifier,
|
104
|
+
report_datetime=get_utcnow(),
|
105
|
+
referral_date=get_utcnow(),
|
106
|
+
)
|
107
|
+
self.assertIsNotNone(dm_referral.report_datetime)
|
108
|
+
self.assertIsNotNone(dm_referral.referral_date)
|
109
|
+
self.assertIsNotNone(dm_referral.action_identifier)
|
110
|
+
|
111
|
+
try:
|
112
|
+
ActionItem.objects.get(
|
113
|
+
subject_identifier=subject_visit.subject_identifier,
|
114
|
+
action_type__name=DM_FOLLOWUP_ACTION,
|
115
|
+
status=NEW,
|
116
|
+
)
|
117
|
+
except ObjectDoesNotExist:
|
118
|
+
self.fail(f"{DM_FOLLOWUP_ACTION} Action item unexpectedly does not exist")
|
119
|
+
|
120
|
+
@tag("1")
|
121
|
+
def test_dm_referral2(self):
|
122
|
+
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
123
|
+
subject_visit = self.get_next_subject_visit(subject_visit)
|
124
|
+
self.assertEqual(subject_visit.visit_code, MONTH1)
|
125
|
+
referral_datetime = subject_visit.report_datetime
|
126
|
+
DmReferral.objects.create(
|
127
|
+
subject_identifier=subject_visit.subject_identifier,
|
128
|
+
report_datetime=referral_datetime,
|
129
|
+
referral_date=referral_datetime.date(),
|
130
|
+
)
|
131
|
+
|
132
|
+
# Add DM Baseline
|
133
|
+
appointment = Appointment.objects.get(
|
134
|
+
subject_identifier=subject_visit.subject_identifier,
|
135
|
+
schedule_name=SCHEDULE_DM_REFERRAL,
|
136
|
+
visit_code=DM_BASELINE,
|
137
|
+
)
|
138
|
+
appointment.appt_status = IN_PROGRESS_APPT
|
139
|
+
appointment.save()
|
140
|
+
|
141
|
+
subject_visit = SubjectVisit.objects.create(
|
142
|
+
appointment=appointment,
|
143
|
+
subject_identifier=subject_visit.subject_identifier,
|
144
|
+
report_datetime=appointment.appt_datetime,
|
145
|
+
reason=SCHEDULED,
|
146
|
+
info_source=PATIENT,
|
147
|
+
)
|
148
|
+
|
149
|
+
DmDiagnosis.objects.create(
|
150
|
+
subject_visit=subject_visit,
|
151
|
+
report_datetime=get_utcnow(),
|
152
|
+
dx_date=referral_datetime.date(),
|
153
|
+
dx_initiated_by="fbg_confirmed",
|
154
|
+
dx_tmg=YES,
|
155
|
+
dx_tmg_date=referral_datetime.date(),
|
156
|
+
)
|
157
|
+
|
158
|
+
# Add DM Followup
|
159
|
+
followup_datetime = referral_datetime + relativedelta(months=6)
|
160
|
+
appointment = Appointment.objects.get(
|
161
|
+
subject_identifier=subject_visit.subject_identifier,
|
162
|
+
schedule_name=SCHEDULE_DM_REFERRAL,
|
163
|
+
visit_code=DM_FOLLOWUP,
|
164
|
+
)
|
165
|
+
appointment.appt_status = IN_PROGRESS_APPT
|
166
|
+
appointment.save()
|
167
|
+
|
168
|
+
subject_visit = SubjectVisit.objects.create(
|
169
|
+
appointment=appointment,
|
170
|
+
subject_identifier=subject_visit.subject_identifier,
|
171
|
+
report_datetime=appointment.appt_datetime,
|
172
|
+
reason=SCHEDULED,
|
173
|
+
info_source=PATIENT,
|
174
|
+
)
|
175
|
+
|
176
|
+
dm_followup = DmFollowup.objects.create(
|
177
|
+
subject_visit=subject_visit,
|
178
|
+
report_datetime=followup_datetime,
|
179
|
+
referral_date=referral_datetime.date(),
|
180
|
+
attended=NO,
|
181
|
+
on_dm_medications=NO,
|
182
|
+
)
|
183
|
+
dm_followup.missed_referral_reasons.set([MissedReferralReasons.objects.all()[0]])
|
184
|
+
|
185
|
+
appointment.appt_status = COMPLETE_APPT
|
186
|
+
appointment.save()
|
187
|
+
|
188
|
+
try:
|
189
|
+
ActionItem.objects.get(
|
190
|
+
subject_identifier=subject_visit.subject_identifier,
|
191
|
+
action_type__name=DM_FOLLOWUP_ACTION,
|
192
|
+
status=CLOSED,
|
193
|
+
)
|
194
|
+
except ObjectDoesNotExist:
|
195
|
+
self.fail(f"{DM_FOLLOWUP_ACTION} Action item unexpectedly does not exist")
|
196
|
+
|
197
|
+
try:
|
198
|
+
ActionItem.objects.get(
|
199
|
+
subject_identifier=subject_visit.subject_identifier,
|
200
|
+
action_type__name=OFFSCHEDULE_DM_REFERRAL_ACTION,
|
201
|
+
status=NEW,
|
202
|
+
)
|
203
|
+
except ObjectDoesNotExist:
|
204
|
+
self.fail(
|
205
|
+
f"{OFFSCHEDULE_DM_REFERRAL_ACTION} Action item unexpectedly does not exist"
|
206
|
+
)
|
@@ -80,7 +80,7 @@ class ScreeningPartTwoFormValidator(PrnFormValidatorMixin, FormValidator):
|
|
80
80
|
{
|
81
81
|
self.report_datetime_field_attr: (
|
82
82
|
"Cannot be before `Part One` report datetime. "
|
83
|
-
f"Expected date after {dte}."
|
83
|
+
f"Expected date after {dte}. Got {self.report_datetime}"
|
84
84
|
)
|
85
85
|
},
|
86
86
|
INVALID_ERROR,
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated by Django 4.2.11 on 2024-03-27 19:41
|
2
|
+
|
3
|
+
from django.db import migrations
|
4
|
+
|
5
|
+
|
6
|
+
class Migration(migrations.Migration):
|
7
|
+
|
8
|
+
dependencies = [
|
9
|
+
("meta_screening", "0061_alter_historicalicpreferral_site_and_more"),
|
10
|
+
]
|
11
|
+
|
12
|
+
operations = [
|
13
|
+
migrations.RemoveField(
|
14
|
+
model_name="icpreferral",
|
15
|
+
name="site",
|
16
|
+
),
|
17
|
+
migrations.RemoveField(
|
18
|
+
model_name="icpreferral",
|
19
|
+
name="subject_screening",
|
20
|
+
),
|
21
|
+
migrations.DeleteModel(
|
22
|
+
name="HistoricalIcpReferral",
|
23
|
+
),
|
24
|
+
migrations.DeleteModel(
|
25
|
+
name="IcpReferral",
|
26
|
+
),
|
27
|
+
]
|
meta_screening/migrations/0063_alter_historicalscreeningpartone_fasting_duration_str_and_more.py
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
# Generated by Django 5.0.4 on 2024-04-18 23:46
|
2
|
+
|
3
|
+
import django.core.validators
|
4
|
+
from django.db import migrations, models
|
5
|
+
|
6
|
+
|
7
|
+
class Migration(migrations.Migration):
|
8
|
+
|
9
|
+
dependencies = [
|
10
|
+
("meta_screening", "0062_remove_icpreferral_site_and_more"),
|
11
|
+
]
|
12
|
+
|
13
|
+
operations = [
|
14
|
+
migrations.AlterField(
|
15
|
+
model_name="historicalscreeningpartone",
|
16
|
+
name="fasting_duration_str",
|
17
|
+
field=models.CharField(
|
18
|
+
blank=True,
|
19
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
20
|
+
max_length=8,
|
21
|
+
null=True,
|
22
|
+
validators=[
|
23
|
+
django.core.validators.RegexValidator(
|
24
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
25
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
26
|
+
)
|
27
|
+
],
|
28
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
29
|
+
),
|
30
|
+
),
|
31
|
+
migrations.AlterField(
|
32
|
+
model_name="historicalscreeningpartone",
|
33
|
+
name="repeat_fasting_duration_str",
|
34
|
+
field=models.CharField(
|
35
|
+
blank=True,
|
36
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
37
|
+
max_length=8,
|
38
|
+
null=True,
|
39
|
+
validators=[
|
40
|
+
django.core.validators.RegexValidator(
|
41
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
42
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
43
|
+
)
|
44
|
+
],
|
45
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
46
|
+
),
|
47
|
+
),
|
48
|
+
migrations.AlterField(
|
49
|
+
model_name="historicalscreeningpartthree",
|
50
|
+
name="fasting_duration_str",
|
51
|
+
field=models.CharField(
|
52
|
+
blank=True,
|
53
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
54
|
+
max_length=8,
|
55
|
+
null=True,
|
56
|
+
validators=[
|
57
|
+
django.core.validators.RegexValidator(
|
58
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
59
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
60
|
+
)
|
61
|
+
],
|
62
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
63
|
+
),
|
64
|
+
),
|
65
|
+
migrations.AlterField(
|
66
|
+
model_name="historicalscreeningpartthree",
|
67
|
+
name="repeat_fasting_duration_str",
|
68
|
+
field=models.CharField(
|
69
|
+
blank=True,
|
70
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
71
|
+
max_length=8,
|
72
|
+
null=True,
|
73
|
+
validators=[
|
74
|
+
django.core.validators.RegexValidator(
|
75
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
76
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
77
|
+
)
|
78
|
+
],
|
79
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
80
|
+
),
|
81
|
+
),
|
82
|
+
migrations.AlterField(
|
83
|
+
model_name="historicalscreeningparttwo",
|
84
|
+
name="fasting_duration_str",
|
85
|
+
field=models.CharField(
|
86
|
+
blank=True,
|
87
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
88
|
+
max_length=8,
|
89
|
+
null=True,
|
90
|
+
validators=[
|
91
|
+
django.core.validators.RegexValidator(
|
92
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
93
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
94
|
+
)
|
95
|
+
],
|
96
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
97
|
+
),
|
98
|
+
),
|
99
|
+
migrations.AlterField(
|
100
|
+
model_name="historicalscreeningparttwo",
|
101
|
+
name="repeat_fasting_duration_str",
|
102
|
+
field=models.CharField(
|
103
|
+
blank=True,
|
104
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
105
|
+
max_length=8,
|
106
|
+
null=True,
|
107
|
+
validators=[
|
108
|
+
django.core.validators.RegexValidator(
|
109
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
110
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
111
|
+
)
|
112
|
+
],
|
113
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
114
|
+
),
|
115
|
+
),
|
116
|
+
migrations.AlterField(
|
117
|
+
model_name="historicalsubjectscreening",
|
118
|
+
name="fasting_duration_str",
|
119
|
+
field=models.CharField(
|
120
|
+
blank=True,
|
121
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
122
|
+
max_length=8,
|
123
|
+
null=True,
|
124
|
+
validators=[
|
125
|
+
django.core.validators.RegexValidator(
|
126
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
127
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
128
|
+
)
|
129
|
+
],
|
130
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
131
|
+
),
|
132
|
+
),
|
133
|
+
migrations.AlterField(
|
134
|
+
model_name="historicalsubjectscreening",
|
135
|
+
name="repeat_fasting_duration_str",
|
136
|
+
field=models.CharField(
|
137
|
+
blank=True,
|
138
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
139
|
+
max_length=8,
|
140
|
+
null=True,
|
141
|
+
validators=[
|
142
|
+
django.core.validators.RegexValidator(
|
143
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
144
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
145
|
+
)
|
146
|
+
],
|
147
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
148
|
+
),
|
149
|
+
),
|
150
|
+
migrations.AlterField(
|
151
|
+
model_name="subjectscreening",
|
152
|
+
name="fasting_duration_str",
|
153
|
+
field=models.CharField(
|
154
|
+
blank=True,
|
155
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
156
|
+
max_length=8,
|
157
|
+
null=True,
|
158
|
+
validators=[
|
159
|
+
django.core.validators.RegexValidator(
|
160
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
161
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
162
|
+
)
|
163
|
+
],
|
164
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
165
|
+
),
|
166
|
+
),
|
167
|
+
migrations.AlterField(
|
168
|
+
model_name="subjectscreening",
|
169
|
+
name="repeat_fasting_duration_str",
|
170
|
+
field=models.CharField(
|
171
|
+
blank=True,
|
172
|
+
help_text="As reported by patient. Duration of fast. Format is `HHhMMm`. For example 1h23m, 12h7m, etc",
|
173
|
+
max_length=8,
|
174
|
+
null=True,
|
175
|
+
validators=[
|
176
|
+
django.core.validators.RegexValidator(
|
177
|
+
"^([0-9]{1,3}h([0-5]?[0-9]m)?)$",
|
178
|
+
message="Invalid format. Expected something like 1h20m, 11h5m, etc. No spaces allowed.",
|
179
|
+
)
|
180
|
+
],
|
181
|
+
verbose_name="How long have they fasted in hours and/or minutes?",
|
182
|
+
),
|
183
|
+
),
|
184
|
+
]
|