forked from botswana-harvard/edc-visit-tracking
-
Notifications
You must be signed in to change notification settings - Fork 1
/
subject_visit_missed_model_mixin.py
114 lines (93 loc) · 3.52 KB
/
subject_visit_missed_model_mixin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from django.core.validators import MinValueValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from edc_constants.choices import ALIVE_DEAD_UNKNOWN, YES_NO, YES_NO_NA
from edc_constants.constants import NO, NOT_APPLICABLE
from edc_model import models as edc_models
from edc_model.validators import date_not_future
from edc_protocol.validators import date_not_before_study_start
from ..constants import VISIT_MISSED_ACTION
class SubjectVisitMissedModelMixin(models.Model):
"""Declare with:
missed_reasons = models.ManyToManyField(SubjectVisitMissedReasons, blank=True)
And include in your `lists` app:
class SubjectVisitMissed(
CrfModelMixin,
SubjectVisitMissedModelMixin,
edc_models.BaseUuidModel):
subject_visit = models.OneToOneField(
settings.SUBJECT_VISIT_MODEL,
on_delete=models.PROTECT,
)
missed_reasons = models.ManyToManyField(
SubjectVisitMissedReasons, blank=True
)
class Meta(CrfModelMixin.Meta, edc_models.BaseUuidModel.Meta):
verbose_name = "Missed Visit Report"
verbose_name_plural = "Missed Visit Report"
"""
action_name = VISIT_MISSED_ACTION
survival_status = models.CharField(
verbose_name=_("Survival status"),
max_length=25,
choices=ALIVE_DEAD_UNKNOWN,
help_text=_("If deceased, complete the death report"),
)
contact_attempted = models.CharField(
verbose_name=_(
"Were any attempts made to contact the participant "
"since the expected appointment date?"
),
max_length=25,
choices=YES_NO,
help_text=_("Not including pre-appointment reminders"),
)
contact_attempts_count = models.IntegerField(
verbose_name=_(
"Number of attempts made to contact participant"
"since the expected appointment date"
),
validators=[MinValueValidator(1)],
help_text=_(
"Not including pre-appointment reminders. Multiple attempts "
"on the same day count as a single attempt."
),
null=True,
blank=True,
)
contact_attempts_explained = models.TextField(
verbose_name=_("If contact not made and less than 3 attempts, please explain"),
null=True,
blank=True,
)
contact_last_date = models.DateField(
verbose_name=_("Date of last telephone contact/attempt"),
validators=[date_not_future, date_not_before_study_start],
null=True,
blank=True,
)
contact_made = models.CharField(
verbose_name=_("Was contact finally made with the participant?"),
max_length=25,
choices=YES_NO_NA,
default=NOT_APPLICABLE,
)
missed_reasons = models.ManyToManyField(
"edc_visit_tracking.SubjectVisitMissedReasons", blank=True
)
missed_reasons_other = edc_models.OtherCharField()
ltfu = models.CharField(
verbose_name=_("Has the participant met the protocol criteria for lost to follow up?"),
max_length=15,
choices=YES_NO_NA,
default=NO,
help_text=_("If 'Yes', complete the Loss to Follow up form"),
)
comment = models.TextField(
verbose_name=_("Please provide further details, if any"),
null=True,
blank=True,
)
class Meta:
abstract = True
indexes = [models.Index(fields=["action_identifier", "site", "id"])]