clinicedc 2.0.7__py3-none-any.whl → 2.0.8__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 clinicedc might be problematic. Click here for more details.
- {clinicedc-2.0.7.dist-info → clinicedc-2.0.8.dist-info}/METADATA +1 -1
- {clinicedc-2.0.7.dist-info → clinicedc-2.0.8.dist-info}/RECORD +134 -137
- {clinicedc-2.0.7.dist-info → clinicedc-2.0.8.dist-info}/WHEEL +1 -1
- edc_action_item/auths.py +37 -32
- edc_action_item/models/action_model_mixin.py +1 -2
- edc_action_item/models/signals.py +22 -23
- edc_action_item/site_action_items.py +5 -9
- edc_action_item/utils.py +3 -3
- edc_adverse_event/auths.py +55 -51
- edc_adverse_event/model_mixins/ae_tmg/ae_tmg_methods_model_mixin.py +2 -4
- edc_appointment/auths.py +14 -10
- edc_appointment/creators/appointment_creator.py +1 -1
- edc_appointment/creators/appointments_creator.py +1 -1
- edc_appointment/model_mixins/appointment_methods_model_mixin.py +2 -3
- edc_appointment/model_mixins/appointment_model_mixin.py +31 -28
- edc_appointment/models/appointment.py +1 -1
- edc_appointment/utils.py +19 -24
- edc_auth/auth_objects/__init__.py +2 -20
- edc_auth/auth_objects/default_groups.py +13 -11
- edc_auth/auth_objects/default_roles.py +26 -24
- edc_auth/auth_updater/auth_updater.py +13 -2
- edc_auth/auth_updater/group_updater.py +12 -10
- edc_auth/auth_updater/role_updater.py +2 -2
- edc_auth/constants.py +10 -0
- edc_auth/import_users.py +3 -3
- edc_auth/models/user_profile.py +14 -11
- edc_auth/site_auths.py +80 -67
- edc_consent/auths.py +18 -12
- edc_constants/constants.py +1 -0
- edc_crf/auths.py +5 -0
- edc_dashboard/auths.py +10 -6
- edc_dashboard/url_config.py +92 -83
- edc_dashboard/url_names.py +4 -4
- edc_dashboard/view_mixins/url_request_context_mixin.py +6 -5
- edc_data_manager/admin/data_query_admin.py +12 -11
- edc_data_manager/auths.py +37 -34
- edc_data_manager/rule/query_rule_wrapper.py +7 -7
- edc_export/archive_exporter.py +3 -2
- edc_export/auths.py +32 -28
- edc_export/model_exporter/model_exporter.py +4 -1
- edc_facility/auths.py +8 -3
- edc_facility/facility.py +8 -9
- edc_form_label/custom_label_condition.py +11 -8
- edc_form_label/form_label.py +1 -1
- edc_form_runners/auths.py +11 -6
- edc_form_validators/applicable_field_validator.py +7 -6
- edc_form_validators/base_form_validator.py +8 -9
- edc_form_validators/other_specify_field_validator.py +2 -8
- edc_form_validators/required_field_validator.py +19 -16
- edc_identifier/research_identifier.py +11 -10
- edc_identifier/simple_identifier.py +8 -2
- edc_lab/auths.py +26 -23
- edc_lab/lab/aliquot_creator.py +5 -8
- edc_lab/lab/primary_aliquot.py +14 -5
- edc_lab/model_mixins/requisition/requisition_model_mixin.py +6 -8
- edc_lab/models/aliquot.py +2 -2
- edc_lab/models/manifest/manifest.py +2 -2
- edc_lab/models/manifest/manifest_item.py +1 -1
- edc_lab_dashboard/auths.py +16 -11
- edc_lab_results/calculate_missing.py +8 -8
- edc_lab_results/form_validator_mixins/blood_results_form_validator_mixin.py +2 -2
- edc_lab_results/get_summary.py +26 -25
- edc_lab_results/model_mixins/blood_result_model_mixin.py +2 -0
- edc_label/auths.py +6 -1
- edc_label/label_template.py +8 -8
- edc_list_data/load_model_data.py +3 -3
- edc_list_data/post_migrate_signals.py +1 -1
- edc_list_data/preload_data.py +2 -2
- edc_list_data/row.py +1 -1
- edc_list_data/site_list_data.py +6 -5
- edc_locator/auths.py +18 -13
- edc_metadata/auths.py +11 -7
- edc_metadata/metadata/metadata.py +1 -1
- edc_metadata/metadata_rules/crf/crf_rule.py +1 -1
- edc_metadata/metadata_rules/metadata_rule_evaluator.py +5 -3
- edc_metadata/metadata_rules/rule.py +2 -3
- edc_metadata/metadata_rules/rule_evaluator.py +1 -1
- edc_metadata/model_mixins/updates/updates_crf_metadata_model_mixin.py +7 -4
- edc_metadata/model_mixins/updates/updates_requisition_metadata_model_mixin.py +5 -2
- edc_metadata/models/signals.py +10 -11
- edc_navbar/auths.py +18 -13
- edc_notification/auths.py +9 -4
- edc_notification/notification/graded_event_notification.py +2 -2
- edc_notification/notification/model_notification.py +3 -30
- edc_notification/notification/new_model_notification.py +1 -1
- edc_notification/notification/notification.py +1 -1
- edc_notification/notification/updated_model_notification.py +2 -2
- edc_offstudy/auths.py +12 -7
- edc_pdutils/df_exporters/csv_model_exporter.py +5 -2
- edc_pharmacy/auths.py +19 -15
- edc_pharmacy/models/medication/formulation.py +5 -7
- edc_pharmacy/prescribe/create_prescription.py +3 -3
- edc_pharmacy/utils/confirm_stock.py +1 -1
- edc_pharmacy/utils/confirm_stock_at_site.py +1 -1
- edc_pharmacy/views/confirmation_at_site_view.py +6 -9
- edc_prn/admin_site.py +5 -0
- edc_prn/prn.py +10 -11
- edc_prn/urls.py +11 -0
- edc_protocol_incident/action_items.py +4 -4
- edc_protocol_incident/auths.py +27 -20
- edc_pylabels/auths.py +6 -1
- edc_qareports/auths.py +11 -7
- edc_randomization/admin.py +30 -24
- edc_randomization/auths.py +12 -7
- edc_randomization/randomizer.py +22 -20
- edc_randomization/utils.py +17 -16
- edc_refusal/auths.py +7 -2
- edc_refusal/model_mixins.py +1 -1
- edc_registration/auths.py +28 -23
- edc_registration/model_mixins/updates_or_creates_registered_subject_model_mixin.py +13 -4
- edc_registration/models/registered_subject.py +1 -1
- edc_reportable/utils/get_reference_range_collection.py +2 -3
- edc_reportable/utils/load_data.py +1 -1
- edc_review_dashboard/auths.py +23 -18
- edc_screening/age_evaluator.py +3 -3
- edc_screening/auths.py +35 -30
- edc_screening/eligibility.py +1 -1
- edc_screening/gender_evaluator.py +1 -1
- edc_screening/model_mixins/eligibility_model_mixin.py +0 -2
- edc_screening/model_mixins/screening_methods_model_mixin.py +1 -1
- edc_screening/screening_eligibility.py +2 -4
- edc_screening/utils.py +9 -9
- edc_search/generate_slug.py +26 -0
- edc_search/model_mixins.py +10 -21
- edc_sites/auths.py +8 -3
- edc_subject_dashboard/auths.py +27 -22
- edc_timepoint/apps.py +0 -21
- edc_unblinding/auths.py +9 -4
- edc_utils/__init__.py +3 -1
- edc_utils/show_urls.py +29 -2
- edc_visit_schedule/auths.py +6 -1
- edc_visit_schedule/site_visit_schedules.py +2 -2
- edc_visit_tracking/models/signals.py +2 -2
- edc_form_label/models.py +0 -0
- edc_search/constants.py +0 -1
- edc_search/models.py +0 -0
- edc_search/search_slug.py +0 -51
- edc_search/updater.py +0 -30
- edc_search/wsgi.py +0 -7
- {clinicedc-2.0.7.dist-info → clinicedc-2.0.8.dist-info}/licenses/LICENSE +0 -0
|
@@ -136,15 +136,13 @@ class RequisitionModelMixin(
|
|
|
136
136
|
|
|
137
137
|
def get_search_slug_fields(self):
|
|
138
138
|
fields = super().get_search_slug_fields()
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
]
|
|
139
|
+
return (
|
|
140
|
+
*fields,
|
|
141
|
+
"subject_identifier",
|
|
142
|
+
"requisition_identifier",
|
|
143
|
+
"human_readable_identifier",
|
|
144
|
+
"identifier_prefix",
|
|
146
145
|
)
|
|
147
|
-
return fields
|
|
148
146
|
|
|
149
147
|
class Meta(NonUniqueSubjectIdentifierFieldMixin.Meta):
|
|
150
148
|
abstract = True
|
edc_lab/models/aliquot.py
CHANGED
|
@@ -24,13 +24,13 @@ class Aliquot(
|
|
|
24
24
|
BaseUuidModel,
|
|
25
25
|
):
|
|
26
26
|
def get_search_slug_fields(self):
|
|
27
|
-
return
|
|
27
|
+
return (
|
|
28
28
|
"aliquot_identifier",
|
|
29
29
|
"human_readable_identifier",
|
|
30
30
|
"subject_identifier",
|
|
31
31
|
"parent_identifier",
|
|
32
32
|
"requisition_identifier",
|
|
33
|
-
|
|
33
|
+
)
|
|
34
34
|
|
|
35
35
|
objects = Manager()
|
|
36
36
|
|
|
@@ -21,12 +21,12 @@ class Manifest(ManifestModelMixin, PdfReportModelMixin, SearchSlugModelMixin, Ba
|
|
|
21
21
|
pdf_report_cls = ManifestPdfReport
|
|
22
22
|
|
|
23
23
|
def get_search_slug_fields(self):
|
|
24
|
-
return
|
|
24
|
+
return (
|
|
25
25
|
"manifest_identifier",
|
|
26
26
|
"human_readable_identifier",
|
|
27
27
|
"shipper.name",
|
|
28
28
|
"consignee.name",
|
|
29
|
-
|
|
29
|
+
)
|
|
30
30
|
|
|
31
31
|
consignee = models.ForeignKey(Consignee, verbose_name="Consignee", on_delete=PROTECT)
|
|
32
32
|
|
|
@@ -17,7 +17,7 @@ class ManifestItemManager(SearchSlugManager, models.Manager):
|
|
|
17
17
|
|
|
18
18
|
class ManifestItem(SiteModelMixin, SearchSlugModelMixin, VerifyModelMixin, BaseUuidModel):
|
|
19
19
|
def get_search_slug_fields(self):
|
|
20
|
-
return
|
|
20
|
+
return "identifier", "human_readable_identifier"
|
|
21
21
|
|
|
22
22
|
manifest = models.ForeignKey(Manifest, on_delete=PROTECT)
|
|
23
23
|
|
edc_lab_dashboard/auths.py
CHANGED
|
@@ -8,16 +8,21 @@ from edc_lab_dashboard.auth_objects import (
|
|
|
8
8
|
lab_navbar_tuples,
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
site_auths.add_post_update_func(
|
|
12
|
-
"edc_lab_dashboard", remove_default_model_permissions_from_edc_permissions
|
|
13
|
-
)
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
def update_site_auths():
|
|
13
|
+
site_auths.add_post_update_func(
|
|
14
|
+
"edc_lab_dashboard", remove_default_model_permissions_from_edc_permissions
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
site_auths.add_custom_permissions_tuples(
|
|
18
|
+
model="edc_lab_dashboard.edcpermissions", codename_tuples=lab_navbar_tuples
|
|
19
|
+
)
|
|
20
|
+
site_auths.add_custom_permissions_tuples(
|
|
21
|
+
model="edc_lab_dashboard.edcpermissions", codename_tuples=lab_dashboard_tuples
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
site_auths.update_group(*lab_dashboard_codenames, *lab_navbar_codenames, name=LAB)
|
|
25
|
+
site_auths.update_group(*lab_dashboard_codenames, *lab_navbar_codenames, name=LAB_VIEW)
|
|
26
|
+
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
site_auths.update_group(*lab_dashboard_codenames, *lab_navbar_codenames, name=LAB_VIEW)
|
|
28
|
+
update_site_auths()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import contextlib
|
|
1
2
|
from typing import Any
|
|
2
3
|
|
|
3
4
|
|
|
@@ -20,11 +21,10 @@ def calculate_missing(obj: Any, panel: Any) -> tuple[int, str | None]:
|
|
|
20
21
|
missing = []
|
|
21
22
|
for utest_id in panel.utest_ids:
|
|
22
23
|
for field in fields:
|
|
23
|
-
|
|
24
|
-
utest_id, _ = utest_id
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return len(missing), ",".join(missing) if missing else None
|
|
24
|
+
with contextlib.suppress(ValueError):
|
|
25
|
+
utest_id, _ = utest_id # noqa: PLW2901
|
|
26
|
+
if field == utest_id or (
|
|
27
|
+
field == f"{utest_id}_value" and getattr(obj, field) is None
|
|
28
|
+
):
|
|
29
|
+
missing.append(field)
|
|
30
|
+
return len(missing), ",".join(missing) if missing else ""
|
|
@@ -51,13 +51,13 @@ class BloodResultsFormValidatorMixin(
|
|
|
51
51
|
self.required_if_not_none(
|
|
52
52
|
field=f"{utest_id}{self.value_field_suffix or ''}",
|
|
53
53
|
field_required=f"{utest_id}_abnormal",
|
|
54
|
-
field_required_evaluate_as_int=
|
|
54
|
+
field_required_evaluate_as_int=False,
|
|
55
55
|
)
|
|
56
56
|
if f"{utest_id}_reportable" in self.cleaned_data:
|
|
57
57
|
self.required_if_not_none(
|
|
58
58
|
field=f"{utest_id}{self.value_field_suffix or ''}",
|
|
59
59
|
field_required=f"{utest_id}_reportable",
|
|
60
|
-
field_required_evaluate_as_int=
|
|
60
|
+
field_required_evaluate_as_int=False,
|
|
61
61
|
)
|
|
62
62
|
self.evaluate_value(prefix=utest_id)
|
|
63
63
|
self.validate_reportable_fields(
|
edc_lab_results/get_summary.py
CHANGED
|
@@ -18,36 +18,37 @@ def get_summary(obj) -> tuple[list[str], list[str], list[str]]:
|
|
|
18
18
|
except ValueError:
|
|
19
19
|
utest_id = field_name
|
|
20
20
|
reference_range_collection = get_reference_range_collection(obj)
|
|
21
|
-
if units := getattr(obj, f"{utest_id}_units", None)
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (units := getattr(obj, f"{utest_id}_units", None)) and (
|
|
22
|
+
value := getattr(obj, field_name)
|
|
23
|
+
):
|
|
24
|
+
opts.update(units=units, label=utest_id)
|
|
25
|
+
try:
|
|
26
|
+
grading_data, grading_eval_phrase = reference_range_collection.get_grade(
|
|
27
|
+
value, **opts
|
|
28
|
+
)
|
|
29
|
+
except NotEvaluated as e:
|
|
30
|
+
errors.append(f"{e}.")
|
|
31
|
+
grading_data = None
|
|
32
|
+
grading_eval_phrase = None
|
|
33
|
+
if (
|
|
34
|
+
grading_data
|
|
35
|
+
and grading_data.grade
|
|
36
|
+
in reference_range_collection.reportable_grades(utest_id)
|
|
37
|
+
):
|
|
38
|
+
setattr(obj, f"{utest_id}_grade", grading_data.grade)
|
|
39
|
+
setattr(obj, f"{utest_id}_grade_description", grading_data.description)
|
|
40
|
+
reportable.append(f"{grading_eval_phrase}")
|
|
41
|
+
else:
|
|
24
42
|
try:
|
|
25
|
-
|
|
43
|
+
is_normal, normal_data = reference_range_collection.is_normal(
|
|
26
44
|
value, **opts
|
|
27
45
|
)
|
|
28
46
|
except NotEvaluated as e:
|
|
29
47
|
errors.append(f"{e}.")
|
|
30
|
-
grading_data = None
|
|
31
|
-
grading_eval_phrase = None
|
|
32
|
-
if (
|
|
33
|
-
grading_data
|
|
34
|
-
and grading_data.grade
|
|
35
|
-
in reference_range_collection.reportable_grades(utest_id)
|
|
36
|
-
):
|
|
37
|
-
setattr(obj, f"{utest_id}_grade", grading_data.grade)
|
|
38
|
-
setattr(obj, f"{utest_id}_grade_description", grading_data.description)
|
|
39
|
-
reportable.append(f"{grading_eval_phrase}")
|
|
40
48
|
else:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
value
|
|
49
|
+
if is_normal is False:
|
|
50
|
+
abnormal.append(
|
|
51
|
+
f"{normal_data.label}: {value} {units} "
|
|
52
|
+
f"{normal_data.phrase} Abnormal"
|
|
44
53
|
)
|
|
45
|
-
except NotEvaluated as e:
|
|
46
|
-
errors.append(f"{e}.")
|
|
47
|
-
else:
|
|
48
|
-
if is_normal is False:
|
|
49
|
-
abnormal.append(
|
|
50
|
-
f"{normal_data.label}: {value} {units} "
|
|
51
|
-
f"{normal_data.phrase} Abnormal"
|
|
52
|
-
)
|
|
53
54
|
return reportable, abnormal, errors
|
|
@@ -70,6 +70,8 @@ class BloodResultsMethodsModelMixin(models.Model):
|
|
|
70
70
|
return get_summary(self)
|
|
71
71
|
|
|
72
72
|
def get_summary_options(self: Any) -> dict:
|
|
73
|
+
# note: gender and dob are queried from RegisteredSubject
|
|
74
|
+
# in reportables
|
|
73
75
|
return dict(
|
|
74
76
|
subject_identifier=self.subject_visit.subject_identifier,
|
|
75
77
|
report_datetime=self.report_datetime,
|
edc_label/auths.py
CHANGED
|
@@ -2,4 +2,9 @@ from edc_auth.site_auths import site_auths
|
|
|
2
2
|
|
|
3
3
|
from .auth_objects import LABELING, codenames
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
def update_site_auths():
|
|
7
|
+
site_auths.add_group(*codenames, name=LABELING, no_delete=False)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
update_site_auths()
|
edc_label/label_template.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
from pathlib import Path
|
|
2
2
|
from string import Template
|
|
3
3
|
|
|
4
4
|
from django.apps import apps as django_apps
|
|
@@ -19,27 +19,27 @@ class LabelTemplate:
|
|
|
19
19
|
zpl_label_template = django_apps.get_model(
|
|
20
20
|
"edc_label.zpllabeltemplates"
|
|
21
21
|
).objects.get(name=self.template_name)
|
|
22
|
-
except ObjectDoesNotExist:
|
|
22
|
+
except ObjectDoesNotExist as e:
|
|
23
23
|
if static_files_path:
|
|
24
|
-
path = finders.find(
|
|
24
|
+
path = finders.find(str(Path(static_files_path) / template_name))
|
|
25
25
|
else:
|
|
26
26
|
app_config = django_apps.get_app_config("edc_label")
|
|
27
27
|
try:
|
|
28
28
|
path = app_config.label_templates[template_name]
|
|
29
|
-
except KeyError:
|
|
29
|
+
except KeyError as e:
|
|
30
30
|
raise LabelTemplateError(
|
|
31
31
|
f"Invalid label template name. "
|
|
32
32
|
f"Expected one of {list(app_config.label_templates.keys())}. "
|
|
33
33
|
f"Got '{template_name}'. "
|
|
34
34
|
f"See edc_label.app_config."
|
|
35
|
-
)
|
|
36
|
-
if not
|
|
35
|
+
) from e
|
|
36
|
+
if not path or not Path(path).exists():
|
|
37
37
|
raise LabelTemplateError(
|
|
38
38
|
f"Invalid label template path. "
|
|
39
39
|
f"Looking for template '{template_name}'. "
|
|
40
40
|
f"Got {path}. See edc_label.app_config."
|
|
41
|
-
)
|
|
42
|
-
with
|
|
41
|
+
) from e
|
|
42
|
+
with Path(path).open("r") as f:
|
|
43
43
|
self.template = f.read()
|
|
44
44
|
else:
|
|
45
45
|
self.template = zpl_label_template.zpl_data.strip()
|
edc_list_data/load_model_data.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import contextlib
|
|
2
|
+
|
|
1
3
|
from django.apps import AppConfig
|
|
2
4
|
from django.apps import apps as django_apps
|
|
3
5
|
from django.core.exceptions import ObjectDoesNotExist
|
|
@@ -34,10 +36,8 @@ def load_model_data(model_data: dict, apps: AppConfig | None = None) -> int:
|
|
|
34
36
|
try:
|
|
35
37
|
obj = model.objects.get(**{unique_field: opts.get(unique_field)})
|
|
36
38
|
except ObjectDoesNotExist:
|
|
37
|
-
|
|
39
|
+
with contextlib.suppress(IntegrityError):
|
|
38
40
|
model.objects.create(**opts)
|
|
39
|
-
except IntegrityError:
|
|
40
|
-
pass
|
|
41
41
|
else:
|
|
42
42
|
for key, value in opts.items():
|
|
43
43
|
setattr(obj, key, value)
|
|
@@ -6,7 +6,7 @@ style = color_style()
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def post_migrate_list_data(sender=None, **kwargs):
|
|
9
|
-
from .site_list_data import get_autodiscover_enabled, site_list_data
|
|
9
|
+
from .site_list_data import get_autodiscover_enabled, site_list_data # noqa: PLC0415
|
|
10
10
|
|
|
11
11
|
if get_autodiscover_enabled():
|
|
12
12
|
sys.stdout.write(style.MIGRATE_HEADING("Updating list data:\n"))
|
edc_list_data/preload_data.py
CHANGED
|
@@ -11,7 +11,7 @@ style = color_style()
|
|
|
11
11
|
class PreloadData:
|
|
12
12
|
def __init__(
|
|
13
13
|
self,
|
|
14
|
-
list_data: dict[str, list[tuple[str | int, str]]]
|
|
14
|
+
list_data: dict[str, list[tuple[str | int, str]]],
|
|
15
15
|
model_data: dict | None = None,
|
|
16
16
|
list_data_model_name: str | None = None,
|
|
17
17
|
apps: AppConfig = None,
|
|
@@ -24,7 +24,7 @@ class PreloadData:
|
|
|
24
24
|
if self.model_data:
|
|
25
25
|
self.item_count += self.load_model_data()
|
|
26
26
|
|
|
27
|
-
def load_list_data(self, model_name: str
|
|
27
|
+
def load_list_data(self, model_name: str, apps: AppConfig | None = None) -> int:
|
|
28
28
|
return load_list_data(self.list_data, model_name=model_name, apps=apps)
|
|
29
29
|
|
|
30
30
|
def load_model_data(self, apps: AppConfig | None = None) -> int:
|
edc_list_data/row.py
CHANGED
|
@@ -24,7 +24,7 @@ class Row:
|
|
|
24
24
|
@dataclass
|
|
25
25
|
class AsListData:
|
|
26
26
|
data: tuple[tuple[str, str, str], ...] | Choices
|
|
27
|
-
rows: list[Row
|
|
27
|
+
rows: list[Row] | None = field(default_factory=list, init=False)
|
|
28
28
|
|
|
29
29
|
def __post_init__(self):
|
|
30
30
|
for tpl in self.data:
|
edc_list_data/site_list_data.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import contextlib
|
|
1
2
|
import copy
|
|
2
3
|
import sys
|
|
3
4
|
from importlib import import_module
|
|
@@ -51,7 +52,7 @@ class SiteListData:
|
|
|
51
52
|
if app_name and app_name in self.app_names:
|
|
52
53
|
raise AlreadyLoaded(f"App already loaded. Got {app_name}.")
|
|
53
54
|
self.app_names.append(app_name)
|
|
54
|
-
opts =
|
|
55
|
+
opts = {k: v for k, v in self._get_options(module).items()}
|
|
55
56
|
sys.stdout.write(f" - registered {self.module_name} from '{module.__name__}'\n")
|
|
56
57
|
if opts.get(self.module_name):
|
|
57
58
|
self._replace_list_data_or_raise_on_duplicate(module, opts)
|
|
@@ -60,6 +61,8 @@ class SiteListData:
|
|
|
60
61
|
def load_data(self) -> None:
|
|
61
62
|
"""Calls `load` class with each list_data dictionary module to
|
|
62
63
|
update database `list` tables.
|
|
64
|
+
|
|
65
|
+
See post_migrate_list_data.
|
|
63
66
|
"""
|
|
64
67
|
style = color_style()
|
|
65
68
|
for module_name, opts in self.registry.items():
|
|
@@ -142,10 +145,8 @@ class SiteListData:
|
|
|
142
145
|
):
|
|
143
146
|
sys.stdout.write(f" * checking sites for `{self.module_name}` ...\n")
|
|
144
147
|
for app_name in django_apps.app_configs:
|
|
145
|
-
|
|
148
|
+
with contextlib.suppress(ModuleNotFoundError):
|
|
146
149
|
self._import_and_register(app_name)
|
|
147
|
-
except ModuleNotFoundError:
|
|
148
|
-
pass
|
|
149
150
|
|
|
150
151
|
def _import_and_register(self, app_name: str) -> None:
|
|
151
152
|
mod = import_module(app_name)
|
|
@@ -155,7 +156,7 @@ class SiteListData:
|
|
|
155
156
|
except ImportError as e:
|
|
156
157
|
site_list_data.registry = before_import_registry
|
|
157
158
|
if module_has_submodule(mod, self.module_name):
|
|
158
|
-
raise SiteListDataError(f"{e} See {app_name}.{self.module_name}")
|
|
159
|
+
raise SiteListDataError(f"{e} See {app_name}.{self.module_name}") from e
|
|
159
160
|
else:
|
|
160
161
|
self.register(module, app_name=app_name)
|
|
161
162
|
|
edc_locator/auths.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
from edc_auth.constants import PII, PII_VIEW
|
|
2
2
|
from edc_auth.site_auths import site_auths
|
|
3
3
|
|
|
4
|
-
site_auths.update_group(
|
|
5
|
-
"edc_locator.add_subjectlocator",
|
|
6
|
-
"edc_locator.change_subjectlocator",
|
|
7
|
-
"edc_locator.view_historicalsubjectlocator",
|
|
8
|
-
"edc_locator.view_subjectlocator",
|
|
9
|
-
name=PII,
|
|
10
|
-
)
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
def update_site_auths():
|
|
6
|
+
site_auths.update_group(
|
|
7
|
+
"edc_locator.add_subjectlocator",
|
|
8
|
+
"edc_locator.change_subjectlocator",
|
|
9
|
+
"edc_locator.view_historicalsubjectlocator",
|
|
10
|
+
"edc_locator.view_subjectlocator",
|
|
11
|
+
name=PII,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
site_auths.update_group(
|
|
15
|
+
"edc_locator.view_historicalsubjectlocator",
|
|
16
|
+
"edc_locator.view_subjectlocator",
|
|
17
|
+
name=PII_VIEW,
|
|
18
|
+
)
|
|
19
|
+
site_auths.add_pii_model("edc_locator.subjectlocator")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
update_site_auths()
|
edc_metadata/auths.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
from django.apps import apps as django_apps
|
|
2
2
|
|
|
3
3
|
from edc_auth.site_auths import site_auths
|
|
4
|
+
from edc_export.constants import EXPORT
|
|
4
5
|
|
|
5
|
-
if django_apps.is_installed("edc_export"):
|
|
6
|
-
from edc_export.constants import EXPORT
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
def update_site_auths():
|
|
8
|
+
if django_apps.is_installed("edc_export"):
|
|
9
|
+
site_auths.update_group(
|
|
10
|
+
"edc_metadata.export_crfmetadata",
|
|
11
|
+
"edc_metadata.export_requisitionmetadata",
|
|
12
|
+
name=EXPORT,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
update_site_auths()
|
|
@@ -110,7 +110,7 @@ class CrfCreator(SourceModelMetadataMixin):
|
|
|
110
110
|
metadata_obj = self.metadata_model_cls.objects.create(**opts)
|
|
111
111
|
except IntegrityError as e:
|
|
112
112
|
msg = f"Integrity error creating. Tried with {opts}. Got {e}."
|
|
113
|
-
raise CreatesMetadataError(msg)
|
|
113
|
+
raise CreatesMetadataError(msg) from e
|
|
114
114
|
else:
|
|
115
115
|
if not registered:
|
|
116
116
|
metadata_obj.delete()
|
|
@@ -29,9 +29,11 @@ class MetadataRuleEvaluator:
|
|
|
29
29
|
if not self.app_labels:
|
|
30
30
|
for rule_groups in site_metadata_rules.registry.values():
|
|
31
31
|
for rule_group in rule_groups:
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (
|
|
33
|
+
rule_group._meta.related_visit_model == self.related_visit_model
|
|
34
|
+
and rule_group._meta.app_label not in self.app_labels
|
|
35
|
+
):
|
|
36
|
+
self.app_labels.append(rule_group._meta.app_label)
|
|
35
37
|
|
|
36
38
|
def evaluate_rules(self) -> None:
|
|
37
39
|
for app_label in self.app_labels:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import contextlib
|
|
3
4
|
from typing import TYPE_CHECKING
|
|
4
5
|
|
|
5
6
|
from edc_appointment.constants import MISSED_APPT
|
|
@@ -91,8 +92,6 @@ class Rule:
|
|
|
91
92
|
try:
|
|
92
93
|
field_names = [self.predicate.attr]
|
|
93
94
|
except AttributeError:
|
|
94
|
-
|
|
95
|
+
with contextlib.suppress(AttributeError):
|
|
95
96
|
field_names = self.predicate.attrs
|
|
96
|
-
except AttributeError:
|
|
97
|
-
pass
|
|
98
97
|
return field_names
|
|
@@ -50,16 +50,19 @@ class UpdatesCrfMetadataModelMixin(UpdatesMetadataModelMixin):
|
|
|
50
50
|
return django_apps.get_model(metadata_model)
|
|
51
51
|
|
|
52
52
|
@property
|
|
53
|
-
def metadata_default_entry_status(self: CrfModel) -> str:
|
|
53
|
+
def metadata_default_entry_status(self: CrfModel) -> str | None:
|
|
54
54
|
"""Returns a string that represents the default entry status
|
|
55
55
|
of the CRF in the visit schedule.
|
|
56
56
|
"""
|
|
57
57
|
crfs_prn = self.metadata_visit_object.crfs_prn
|
|
58
58
|
if self.related_visit.visit_code_sequence != 0:
|
|
59
|
-
crfs = self.metadata_visit_object.crfs_unscheduled.forms
|
|
59
|
+
crfs = (*self.metadata_visit_object.crfs_unscheduled.forms, *crfs_prn.forms)
|
|
60
60
|
else:
|
|
61
|
-
crfs = self.metadata_visit_object.crfs.forms
|
|
62
|
-
|
|
61
|
+
crfs = (*self.metadata_visit_object.crfs.forms, *crfs_prn.forms)
|
|
62
|
+
try:
|
|
63
|
+
crf = next(c for c in crfs if c.model == self._meta.label_lower)
|
|
64
|
+
except StopIteration:
|
|
65
|
+
return None
|
|
63
66
|
return REQUIRED if crf.required else NOT_REQUIRED
|
|
64
67
|
|
|
65
68
|
class Meta:
|
|
@@ -50,7 +50,7 @@ class UpdatesRequisitionMetadataModelMixin(UpdatesMetadataModelMixin):
|
|
|
50
50
|
return options
|
|
51
51
|
|
|
52
52
|
@property
|
|
53
|
-
def metadata_default_entry_status(self: RequisitionModel) -> str:
|
|
53
|
+
def metadata_default_entry_status(self: RequisitionModel) -> str | None:
|
|
54
54
|
"""Returns a string that represents the configured
|
|
55
55
|
entry status of the requisition in the visit schedule.
|
|
56
56
|
"""
|
|
@@ -64,7 +64,10 @@ class UpdatesRequisitionMetadataModelMixin(UpdatesMetadataModelMixin):
|
|
|
64
64
|
requisitions = (
|
|
65
65
|
self.metadata_visit_object.requisitions.forms + requisitions_prn.forms
|
|
66
66
|
)
|
|
67
|
-
|
|
67
|
+
try:
|
|
68
|
+
requisition = next(r for r in requisitions if r.panel.name == self.panel.name)
|
|
69
|
+
except StopIteration:
|
|
70
|
+
return None
|
|
68
71
|
return REQUIRED if requisition.required else NOT_REQUIRED
|
|
69
72
|
|
|
70
73
|
@property
|
edc_metadata/models/signals.py
CHANGED
|
@@ -94,14 +94,13 @@ def metadata_reset_on_post_delete(sender, instance, using, **kwargs) -> None:
|
|
|
94
94
|
def metadata_update_previous_timepoints_for_singleton_on_post_save(
|
|
95
95
|
sender, instance, raw, created, using, **kwargs
|
|
96
96
|
):
|
|
97
|
-
if
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
appointment = appointment.relative_previous_with_related_visit
|
|
97
|
+
if (
|
|
98
|
+
not raw
|
|
99
|
+
and not kwargs.get("update_fields")
|
|
100
|
+
and isinstance(instance, (SingletonCrfModelMixin,))
|
|
101
|
+
):
|
|
102
|
+
appointment = instance.related_visit.appointment.relative_previous_with_related_visit
|
|
103
|
+
while appointment:
|
|
104
|
+
if appointment.related_visit:
|
|
105
|
+
refresh_metadata_for_timepoint(appointment.related_visit, allow_create=False)
|
|
106
|
+
appointment = appointment.relative_previous_with_related_visit
|
edc_navbar/auths.py
CHANGED
|
@@ -4,17 +4,22 @@ from edc_auth.utils import remove_default_model_permissions_from_edc_permissions
|
|
|
4
4
|
|
|
5
5
|
from .auth_objects import custom_codename_tuples
|
|
6
6
|
|
|
7
|
-
site_auths.add_post_update_func(
|
|
8
|
-
"edc_navbar", remove_default_model_permissions_from_edc_permissions
|
|
9
|
-
)
|
|
10
|
-
site_auths.add_custom_permissions_tuples(
|
|
11
|
-
model="edc_navbar.edcpermissions", codename_tuples=custom_codename_tuples
|
|
12
|
-
)
|
|
13
7
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
8
|
+
def update_site_auths():
|
|
9
|
+
site_auths.add_post_update_func(
|
|
10
|
+
"edc_navbar", remove_default_model_permissions_from_edc_permissions
|
|
11
|
+
)
|
|
12
|
+
site_auths.add_custom_permissions_tuples(
|
|
13
|
+
model="edc_navbar.edcpermissions", codename_tuples=custom_codename_tuples
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
site_auths.update_group(
|
|
17
|
+
"edc_navbar.nav_administration",
|
|
18
|
+
"edc_navbar.nav_home",
|
|
19
|
+
"edc_navbar.nav_logout",
|
|
20
|
+
"edc_navbar.nav_public",
|
|
21
|
+
name=EVERYONE,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
update_site_auths()
|
edc_notification/auths.py
CHANGED
|
@@ -6,7 +6,12 @@ from edc_export.constants import EXPORT
|
|
|
6
6
|
|
|
7
7
|
from .auth_objects import NOTIFICATION, codenames
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
site_auths.
|
|
12
|
-
|
|
9
|
+
|
|
10
|
+
def update_site_auths():
|
|
11
|
+
site_auths.add_group(*codenames, name=NOTIFICATION)
|
|
12
|
+
if django_apps.is_installed("edc_export"):
|
|
13
|
+
site_auths.update_group("edc_notification.export_notification", name=EXPORT)
|
|
14
|
+
site_auths.update_role(NOTIFICATION, name=ACCOUNT_MANAGER_ROLE)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
update_site_auths()
|
|
@@ -4,8 +4,8 @@ from .model_notification import ModelNotification
|
|
|
4
4
|
class GradedEventNotification(ModelNotification):
|
|
5
5
|
grade: int | None = None
|
|
6
6
|
model: str | None = None
|
|
7
|
-
create_fields =
|
|
8
|
-
update_fields =
|
|
7
|
+
create_fields: tuple[str] = ("ae_grade",)
|
|
8
|
+
update_fields: tuple[str] = ("ae_grade",)
|
|
9
9
|
|
|
10
10
|
def field_value_condition_on_create(self, field, current_value):
|
|
11
11
|
return str(current_value) == str(self.grade)
|