meta-edc 1.2.5__py3-none-any.whl → 1.2.7__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.
Potentially problematic release.
This version of meta-edc might be problematic. Click here for more details.
- meta_analytics/dataframes/constants.py +3 -1
- meta_analytics/dataframes/get_glucose_df.py +13 -3
- meta_analytics/dataframes/glucose_endpoints/endpoint_by_date.py +27 -5
- meta_analytics/dataframes/glucose_endpoints/glucose_endpoints_by_date.py +61 -8
- meta_analytics/dataframes/screening/get_screening_df.py +1 -5
- meta_consent/migrations/0035_alter_historicalsubjectconsent_consent_definition_name_and_more.py +43 -0
- meta_dashboard/navbars.py +2 -6
- meta_dashboard/urls.py +5 -5
- meta_dashboard/views/screening/listboard_view.py +2 -3
- meta_dashboard/views/subject/dashboard/dashboard_view.py +4 -5
- meta_dashboard/views/subject/listboard/listboard_view.py +2 -3
- meta_edc/settings/debug.py +2 -2
- meta_edc/settings/defaults.py +2 -0
- {meta_edc-1.2.5.dist-info → meta_edc-1.2.7.dist-info}/METADATA +5 -5
- {meta_edc-1.2.5.dist-info → meta_edc-1.2.7.dist-info}/RECORD +41 -29
- {meta_edc-1.2.5.dist-info → meta_edc-1.2.7.dist-info}/WHEEL +1 -1
- meta_prn/forms/offschedule_form.py +25 -0
- meta_screening/admin/subject_screening_admin.py +4 -3
- meta_subject/admin/__init__.py +2 -0
- meta_subject/admin/glucose_fbg_admin.py +12 -1
- meta_subject/admin/hiv_exit_review_admin.py +49 -0
- meta_subject/form_validators/__init__.py +4 -0
- meta_subject/form_validators/glucose_fbg_form_validator.py +77 -0
- meta_subject/form_validators/glucose_form_validator.py +10 -82
- meta_subject/form_validators/hiv_exit_review_form_validator.py +18 -0
- meta_subject/form_validators/mixins.py +95 -0
- meta_subject/forms/__init__.py +2 -0
- meta_subject/forms/glucose_fbg_form.py +1 -46
- meta_subject/forms/hiv_exit_review_form.py +13 -0
- meta_subject/migrations/0235_glucosefbg_endpoint_today_and_more.py +606 -0
- meta_subject/migrations/0236_alter_historicalhivexitreview_other_current_arv_regimen_and_more.py +58 -0
- meta_subject/migrations/0237_historicalhivexitreview_singleton_field_and_more.py +68 -0
- meta_subject/migrations/0238_historicalhivexitreview_available_and_more.py +88 -0
- meta_subject/model_mixins/__init__.py +2 -0
- meta_subject/model_mixins/arv_history_model_mixin.py +3 -44
- meta_subject/model_mixins/arv_review_model_mixin.py +53 -0
- meta_subject/models/__init__.py +2 -0
- meta_subject/models/glucose_fbg.py +15 -1
- meta_subject/models/hiv_exit_review.py +44 -0
- meta_visit_schedule/visit_schedules/phase_three/crfs.py +14 -0
- {meta_edc-1.2.5.dist-info → meta_edc-1.2.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
|
|
3
|
+
from edc_constants.constants import NO, PENDING, YES
|
|
4
|
+
from edc_form_validators import INVALID_ERROR
|
|
5
|
+
|
|
6
|
+
from meta_reports.models import GlucoseSummary
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class EndpointValidatorMixin:
|
|
10
|
+
def validate_endpoint_fields(self):
|
|
11
|
+
is_endpoint = self.is_endpoint()
|
|
12
|
+
if is_endpoint == YES and self.cleaned_data.get("endpoint_today") != YES:
|
|
13
|
+
self.raise_validation_error(
|
|
14
|
+
{
|
|
15
|
+
"endpoint_today": (
|
|
16
|
+
"Participant has reached a study endpoint today. Expected YES"
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
INVALID_ERROR,
|
|
20
|
+
)
|
|
21
|
+
elif is_endpoint == PENDING and self.cleaned_data.get("endpoint_today") != PENDING:
|
|
22
|
+
self.raise_validation_error(
|
|
23
|
+
{
|
|
24
|
+
"endpoint_today": (
|
|
25
|
+
"Participant has not reached a study endpoint today. "
|
|
26
|
+
"Expected to repeat FBG"
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
INVALID_ERROR,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
elif is_endpoint == NO and self.cleaned_data.get("endpoint_today") != NO:
|
|
33
|
+
self.raise_validation_error(
|
|
34
|
+
{"endpoint_today": "Participant has not reached a study endpoint today"},
|
|
35
|
+
INVALID_ERROR,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def is_endpoint(self):
|
|
39
|
+
value = NO
|
|
40
|
+
if (
|
|
41
|
+
self.cleaned_data.get("fbg_value")
|
|
42
|
+
and self.cleaned_data.get("ogtt_value")
|
|
43
|
+
and self.cleaned_data.get("fbg_value") >= Decimal("7.0")
|
|
44
|
+
and self.cleaned_data.get("ogtt_value") >= Decimal("11.1")
|
|
45
|
+
) or (
|
|
46
|
+
self.cleaned_data.get("fbg_value")
|
|
47
|
+
and self.cleaned_data.get("ogtt_value")
|
|
48
|
+
and self.cleaned_data.get("fbg_value") < Decimal("7.0")
|
|
49
|
+
and self.cleaned_data.get("ogtt_value") >= Decimal("11.1")
|
|
50
|
+
):
|
|
51
|
+
value = YES
|
|
52
|
+
elif (
|
|
53
|
+
self.cleaned_data.get("fbg_value")
|
|
54
|
+
and self.cleaned_data.get("ogtt_value")
|
|
55
|
+
and self.cleaned_data.get("fbg_value") >= Decimal("7.0")
|
|
56
|
+
and self.cleaned_data.get("ogtt_value") < Decimal("11.1")
|
|
57
|
+
):
|
|
58
|
+
# is there a previous FBG>=7.0 in sequence or do you need to repeat?
|
|
59
|
+
previous_obj = (
|
|
60
|
+
GlucoseSummary.objects.filter(
|
|
61
|
+
subject_identifier=self.subject_identifier,
|
|
62
|
+
fbg_datetime__lt=self.cleaned_data.get("fbg_datetime"),
|
|
63
|
+
)
|
|
64
|
+
.order_by("fbg_datetime")
|
|
65
|
+
.last()
|
|
66
|
+
)
|
|
67
|
+
if previous_obj and previous_obj.fbg_value >= Decimal("7.0"):
|
|
68
|
+
value = YES
|
|
69
|
+
else:
|
|
70
|
+
# you need to schedule a repeat
|
|
71
|
+
value = PENDING
|
|
72
|
+
return value
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class RepeatFbgDateValidatorMixin:
|
|
76
|
+
def validate_repeat_fbg_date(self):
|
|
77
|
+
if self.cleaned_data.get("repeat_fbg_date"):
|
|
78
|
+
delta = (
|
|
79
|
+
self.cleaned_data.get("repeat_fbg_date")
|
|
80
|
+
- self.cleaned_data.get("fbg_datetime").date()
|
|
81
|
+
)
|
|
82
|
+
if delta.days < 7:
|
|
83
|
+
self.raise_validation_error(
|
|
84
|
+
{"repeat_fbg_date": "Must be at least 7 days from the FBG date above"},
|
|
85
|
+
INVALID_ERROR,
|
|
86
|
+
)
|
|
87
|
+
if delta.days > 10:
|
|
88
|
+
self.raise_validation_error(
|
|
89
|
+
{
|
|
90
|
+
"repeat_fbg_date": (
|
|
91
|
+
"Must be no more than 10 days from the FBG date above"
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
INVALID_ERROR,
|
|
95
|
+
)
|
meta_subject/forms/__init__.py
CHANGED
|
@@ -19,6 +19,7 @@ from .glucose_fbg_form import GlucoseFbgForm
|
|
|
19
19
|
from .glucose_form import GlucoseForm
|
|
20
20
|
from .health_economics import HealthEconomicsSimpleForm, HealthEconomicsUpdateForm
|
|
21
21
|
from .hepatitis_test_form import HepatitisTestForm
|
|
22
|
+
from .hiv_exit_review_form import HivExitReviewForm
|
|
22
23
|
from .malaria_test_form import MalariaTestForm
|
|
23
24
|
from .medication_adherence_form import MedicationAdherenceForm
|
|
24
25
|
from .mnsi_form import MnsiForm
|
|
@@ -59,6 +60,7 @@ __all__ = [
|
|
|
59
60
|
"HealthEconomicsSimpleForm",
|
|
60
61
|
"HealthEconomicsUpdateForm",
|
|
61
62
|
"HepatitisTestForm",
|
|
63
|
+
"HivExitReviewForm",
|
|
62
64
|
"MalariaTestForm",
|
|
63
65
|
"MedicationAdherenceForm",
|
|
64
66
|
"MnsiForm",
|
|
@@ -1,55 +1,10 @@
|
|
|
1
|
-
from decimal import Decimal
|
|
2
|
-
|
|
3
1
|
from django import forms
|
|
4
|
-
from edc_constants.constants import NO, YES
|
|
5
|
-
from edc_crf.crf_form_validator import CrfFormValidator
|
|
6
2
|
from edc_crf.modelform_mixins import CrfModelFormMixin
|
|
7
|
-
from edc_form_validators import INVALID_ERROR
|
|
8
|
-
from edc_glucose.utils import validate_glucose_as_millimoles_per_liter
|
|
9
3
|
|
|
4
|
+
from ..form_validators import GlucoseFbgFormValidator
|
|
10
5
|
from ..models import GlucoseFbg
|
|
11
6
|
|
|
12
7
|
|
|
13
|
-
class GlucoseFbgFormValidator(CrfFormValidator):
|
|
14
|
-
def clean(self):
|
|
15
|
-
converted_value = None
|
|
16
|
-
self.required_if(YES, field="fasting", field_required="fasting_duration_str")
|
|
17
|
-
self.required_if(NO, field="fbg_performed", field_required="fbg_not_performed_reason")
|
|
18
|
-
self.required_if(YES, field="fbg_performed", field_required="fbg_datetime")
|
|
19
|
-
if self.cleaned_data.get("fbg_datetime") and self.cleaned_data.get(
|
|
20
|
-
"fbg_datetime"
|
|
21
|
-
) < self.cleaned_data.get("report_datetime"):
|
|
22
|
-
self.raise_validation_error(
|
|
23
|
-
{"fbg_datetime": "Invalid. Must be on or after report date above"},
|
|
24
|
-
INVALID_ERROR,
|
|
25
|
-
)
|
|
26
|
-
self.required_if(YES, field="fbg_performed", field_required="fbg_value")
|
|
27
|
-
if self.cleaned_data.get("fbg_value") is not None:
|
|
28
|
-
converted_value = validate_glucose_as_millimoles_per_liter(
|
|
29
|
-
"fbg", self.cleaned_data
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
self.applicable_if(YES, field="fbg_performed", field_applicable="fbg_units")
|
|
33
|
-
|
|
34
|
-
# repeat_fbg_date
|
|
35
|
-
condition = converted_value and converted_value >= Decimal("7.0")
|
|
36
|
-
self.required_if_true(condition, field_required="repeat_fbg_date")
|
|
37
|
-
if self.cleaned_data.get("repeat_fbg_date") and self.cleaned_data.get("fbg_datetime"):
|
|
38
|
-
diffdays = (
|
|
39
|
-
self.cleaned_data.get("repeat_fbg_date")
|
|
40
|
-
- self.cleaned_data.get("fbg_datetime").date()
|
|
41
|
-
).days
|
|
42
|
-
if not (7 <= diffdays <= 10):
|
|
43
|
-
self.raise_validation_error(
|
|
44
|
-
{
|
|
45
|
-
"repeat_fbg_date": (
|
|
46
|
-
f"Must be 7 to 10 days from date measured above. Got {diffdays}."
|
|
47
|
-
)
|
|
48
|
-
},
|
|
49
|
-
INVALID_ERROR,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
53
8
|
class GlucoseFbgForm(CrfModelFormMixin, forms.ModelForm):
|
|
54
9
|
form_validator_cls = GlucoseFbgFormValidator
|
|
55
10
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from django import forms
|
|
2
|
+
from edc_crf.modelform_mixins import CrfModelFormMixin
|
|
3
|
+
|
|
4
|
+
from ..form_validators import HivExitReviewFormValidator
|
|
5
|
+
from ..models import HivExitReview
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HivExitReviewForm(CrfModelFormMixin, forms.ModelForm):
|
|
9
|
+
form_validator_cls = HivExitReviewFormValidator
|
|
10
|
+
|
|
11
|
+
class Meta:
|
|
12
|
+
model = HivExitReview
|
|
13
|
+
fields = "__all__"
|