clinicedc 2.0.33__py3-none-any.whl → 2.0.35__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.

Files changed (165) hide show
  1. {clinicedc-2.0.33.dist-info → clinicedc-2.0.35.dist-info}/METADATA +1 -1
  2. {clinicedc-2.0.33.dist-info → clinicedc-2.0.35.dist-info}/RECORD +155 -165
  3. {clinicedc-2.0.33.dist-info → clinicedc-2.0.35.dist-info}/WHEEL +1 -1
  4. edc_action_item/templatetags/action_item_extras.py +1 -1
  5. edc_adverse_event/form_validator_mixins/death_report_form_validator.py +1 -1
  6. edc_adverse_event/form_validator_mixins/requires_death_report_form_validator_mixin.py +5 -3
  7. edc_adverse_event/form_validators/death_report_tmg.py +2 -2
  8. edc_adverse_event/modeladmin_mixins/ae_tmg_admin_mixin.py +1 -1
  9. edc_adverse_event/modeladmin_mixins/utils.py +1 -1
  10. edc_adverse_event/utils.py +1 -1
  11. edc_appointment/admin/appointment_admin.py +24 -24
  12. edc_appointment/admin/list_filters.py +5 -5
  13. edc_appointment/appointment_reason_updater.py +6 -5
  14. edc_appointment/appointment_status_updater.py +2 -2
  15. edc_appointment/context_processors.py +1 -2
  16. edc_appointment/creators/appointment_creator.py +9 -8
  17. edc_appointment/creators/unscheduled_appointment_creator.py +31 -24
  18. edc_appointment/creators/utils.py +35 -37
  19. edc_appointment/exceptions.py +3 -3
  20. edc_appointment/form_runners.py +2 -2
  21. edc_appointment/form_validator_mixins/next_appointment_crf_form_validator_mixin.py +5 -5
  22. edc_appointment/form_validator_mixins/window_period_form_validator_mixin.py +7 -7
  23. edc_appointment/form_validators/appointment_form_validator.py +16 -23
  24. edc_appointment/management/commands/close_appointments.py +3 -3
  25. edc_appointment/management/commands/reset_visit_code_sequences.py +1 -1
  26. edc_appointment/management/commands/update_appointment_status.py +2 -2
  27. edc_appointment/management/commands/update_skipped_appointments.py +7 -7
  28. edc_appointment/managers.py +6 -7
  29. edc_appointment/model_mixins/appointment_model_mixin.py +3 -4
  30. edc_appointment/modeladmin_mixins/next_appointment_crf_modeladmin_mixin.py +2 -2
  31. edc_appointment/modelform_mixins/next_appointment_crf_modelform_mixins.py +25 -24
  32. edc_appointment/models/signals.py +1 -1
  33. edc_appointment/skip_appointments.py +10 -29
  34. edc_appointment/utils.py +43 -47
  35. edc_appointment/view_mixins/appointment_view_mixin.py +11 -13
  36. edc_appointment/views/unscheduled_appointment_view.py +5 -6
  37. edc_consent/consent_definition.py +5 -13
  38. edc_consent/consent_definition_extension.py +0 -2
  39. edc_consent/form_validators/consent_definition_form_validator_mixin.py +26 -30
  40. edc_consent/form_validators/subject_consent_form_validator.py +3 -3
  41. edc_consent/modelform_mixins/consent_modelform_mixin/consent_modelform_validation_mixin.py +1 -1
  42. edc_consent/modelform_mixins/requires_consent_modelform_mixin.py +4 -5
  43. edc_consent/site_consents.py +13 -14
  44. edc_crf/crf_form_validator.py +13 -19
  45. edc_crf/crf_form_validator_mixins.py +2 -17
  46. edc_data_manager/admin/actions.py +1 -1
  47. edc_data_manager/admin/data_query_admin.py +1 -1
  48. edc_dx/form_validators/result_form_validator_mixin.py +1 -1
  49. edc_dx_review/medical_date.py +1 -1
  50. edc_egfr/egfr.py +4 -8
  51. edc_egfr/form_validator_mixins/egfr_form_validator_mixins.py +2 -2
  52. edc_facility/facility.py +7 -11
  53. edc_facility/holidays.py +3 -3
  54. edc_facility/models/holiday.py +1 -1
  55. edc_form_runners/form_runner.py +15 -16
  56. edc_form_validators/base_form_validator.py +5 -1
  57. edc_form_validators/date_range_validator.py +49 -61
  58. edc_form_validators/date_validator.py +1 -1
  59. edc_form_validators/extra_mixins/study_day_form_validator.py +1 -1
  60. edc_lab/form_validators/crf_requisition_form_validator_mixin.py +21 -15
  61. edc_lab/form_validators/requisition_form_validator_mixin.py +3 -3
  62. edc_lab_results/form_validator_mixins/blood_results_form_validator_mixin.py +1 -1
  63. edc_ltfu/modelform_mixins.py +1 -1
  64. edc_metadata/metadata/metadata.py +20 -7
  65. edc_metadata/metadata_rules/logic.py +5 -4
  66. edc_metadata/metadata_rules/predicate.py +22 -24
  67. edc_model_form/mixins/report_datetime_modelform_mixin.py +1 -5
  68. edc_offstudy/model_mixins/offstudy_model_mixin.py +1 -1
  69. edc_offstudy/modelform_mixins/crf/offstudy_crf_modelform_mixin.py +2 -2
  70. edc_offstudy/utils.py +4 -4
  71. edc_pdf_reports/crf_pdf_report.py +2 -1
  72. edc_pdutils/helper.py +3 -3
  73. edc_pdutils/utils/convert_dates_from_model.py +4 -3
  74. edc_pharmacy/admin/actions/confirm_stock.py +3 -3
  75. edc_pharmacy/admin/actions/delete_items_for_stock_request.py +4 -3
  76. edc_pharmacy/admin/actions/delete_order_items.py +7 -3
  77. edc_pharmacy/admin/actions/delete_receive_items.py +5 -3
  78. edc_pharmacy/admin/actions/process_repack_request.py +7 -11
  79. edc_pharmacy/admin/autocomplete_admin.py +1 -1
  80. edc_pharmacy/admin/list_filters.py +48 -46
  81. edc_pharmacy/admin/medication/assignment_admin.py +4 -4
  82. edc_pharmacy/admin/medication/dosage_guideline_admin.py +3 -3
  83. edc_pharmacy/admin/medication/formulation_admin.py +5 -5
  84. edc_pharmacy/admin/medication/medication_admin.py +3 -3
  85. edc_pharmacy/admin/prescription/rx_admin.py +2 -2
  86. edc_pharmacy/admin/prescription/rx_refill_admin.py +11 -17
  87. edc_pharmacy/admin/remove_fields_for_blinded_users.py +1 -1
  88. edc_pharmacy/admin/reports/stock_availability_admin.py +12 -8
  89. edc_pharmacy/admin/stock/allocation_admin.py +13 -17
  90. edc_pharmacy/admin/stock/allocation_proxy_admin.py +1 -2
  91. edc_pharmacy/admin/stock/confirmation_admin.py +4 -8
  92. edc_pharmacy/admin/stock/confirmation_at_site_item_admin.py +1 -1
  93. edc_pharmacy/admin/stock/container_admin.py +3 -3
  94. edc_pharmacy/admin/stock/location_admin.py +3 -6
  95. edc_pharmacy/admin/stock/lot_admin.py +9 -12
  96. edc_pharmacy/admin/stock/order_admin.py +2 -5
  97. edc_pharmacy/admin/stock/order_item_admin.py +14 -22
  98. edc_pharmacy/admin/stock/product_admin.py +6 -9
  99. edc_pharmacy/admin/stock/receive_admin.py +2 -2
  100. edc_pharmacy/admin/stock/receive_item_admin.py +3 -3
  101. edc_pharmacy/admin/stock/repack_request_admin.py +7 -10
  102. edc_pharmacy/admin/stock/stock_adjustment_admin.py +1 -1
  103. edc_pharmacy/admin/stock/stock_admin.py +17 -28
  104. edc_pharmacy/admin/stock/stock_proxy_admin.py +3 -4
  105. edc_pharmacy/admin/stock/stock_request_admin.py +6 -10
  106. edc_pharmacy/admin/stock/stock_request_item_admin.py +9 -18
  107. edc_pharmacy/admin/stock/stock_transfer_admin.py +5 -5
  108. edc_pharmacy/admin/stock/stock_transfer_item_admin.py +3 -3
  109. edc_pharmacy/admin/stock/storage_bin_admin.py +1 -1
  110. edc_pharmacy/admin/stock/storage_bin_item_admin.py +2 -2
  111. edc_pharmacy/form_validators/crf/study_medication_form_validator.py +27 -27
  112. edc_pharmacy/forms/stock/confirmation_form.py +2 -2
  113. edc_pharmacy/forms/stock/dispense_form.py +2 -2
  114. edc_pharmacy/forms/stock/lot_form.py +6 -6
  115. edc_pharmacy/forms/stock/order_form.py +4 -6
  116. edc_pharmacy/forms/stock/product_form.py +2 -3
  117. edc_pharmacy/forms/stock/receive_form.py +4 -4
  118. edc_pharmacy/forms/stock/receive_item_form.py +7 -5
  119. edc_pharmacy/forms/stock/repack_request_form.py +10 -8
  120. edc_pharmacy/forms/stock/stock_form.py +2 -3
  121. edc_pharmacy/forms/stock/stock_request_form.py +10 -8
  122. edc_pharmacy/forms/stock/stock_request_item_form.py +6 -5
  123. edc_pharmacy/forms/stock/stock_transfer_form.py +16 -14
  124. edc_pharmacy/forms/stock/supplier_form.py +2 -2
  125. edc_pharmacy/labels/label_data.py +2 -3
  126. edc_pharmacy/model_mixins/study_medication_crf_model_mixin.py +1 -1
  127. edc_pharmacy/models/medication/dosage_guideline.py +3 -3
  128. edc_pharmacy/models/model_mixins.py +12 -10
  129. edc_pharmacy/models/prescription/rx.py +1 -1
  130. edc_pharmacy/models/prescription/rx_refill.py +1 -1
  131. edc_pharmacy/models/signals.py +2 -3
  132. edc_pharmacy/models/storage/utils.py +4 -4
  133. edc_pharmacy/pdf_reports/manifest_pdf_report.py +3 -6
  134. edc_pharmacy/pdf_reports/stock_pdf_report.py +1 -3
  135. edc_pharmacy/refill/refill_creator.py +3 -4
  136. edc_protocol/validators.py +10 -16
  137. edc_reportable/forms/reportables_form_validator_mixin.py +1 -1
  138. edc_screening/form_validator_mixins.py +2 -1
  139. edc_transfer/form_validators.py +1 -1
  140. edc_transfer/model_mixins.py +1 -1
  141. edc_utils/age.py +17 -15
  142. edc_utils/date.py +7 -7
  143. edc_utils/text.py +7 -6
  144. edc_visit_schedule/exceptions.py +8 -0
  145. edc_visit_schedule/model_mixins/off_schedule_model_mixin.py +1 -1
  146. edc_visit_schedule/model_mixins/on_schedule_model_mixin.py +1 -1
  147. edc_visit_schedule/modelform_mixins/off_schedule_modelform_mixin.py +1 -3
  148. edc_visit_schedule/schedule/visit_collection.py +1 -1
  149. edc_visit_schedule/schedule/window.py +0 -2
  150. edc_visit_schedule/subject_schedule.py +1 -1
  151. edc_visit_schedule/utils.py +4 -4
  152. edc_visit_schedule/visit/visit.py +9 -3
  153. edc_visit_schedule/visit/window_period.py +1 -1
  154. edc_visit_tracking/form_validators/visit_form_validator.py +1 -1
  155. edc_metadata/metadata_wrappers/__init__.py +0 -5
  156. edc_metadata/metadata_wrappers/crf_metadata_wrapper.py +0 -5
  157. edc_metadata/metadata_wrappers/crf_metadata_wrappers.py +0 -8
  158. edc_metadata/metadata_wrappers/metadata_wrapper.py +0 -74
  159. edc_metadata/metadata_wrappers/metadata_wrappers.py +0 -33
  160. edc_metadata/metadata_wrappers/requisition_metadata_wrapper.py +0 -26
  161. edc_metadata/metadata_wrappers/requisition_metadata_wrappers.py +0 -10
  162. edc_pharmacy/management/__init__.py +0 -0
  163. edc_pharmacy/management/commands/__init__.py +0 -0
  164. edc_pharmacy/management/commands/update_initial_pharmacy_data.py +0 -10
  165. {clinicedc-2.0.33.dist-info → clinicedc-2.0.35.dist-info}/licenses/LICENSE +0 -0
@@ -9,7 +9,7 @@ from edc_identifier.model_mixins import UniqueSubjectIdentifierFieldMixin
9
9
  from edc_model.validators import datetime_not_future
10
10
  from edc_model_fields.fields import OtherCharField
11
11
  from edc_protocol.validators import datetime_not_before_study_start
12
- from edc_utils import convert_php_dateformat
12
+ from edc_utils.text import convert_php_dateformat
13
13
  from edc_visit_schedule.utils import (
14
14
  off_all_schedules_or_raise,
15
15
  offstudy_datetime_after_all_offschedule_datetimes,
@@ -1,7 +1,7 @@
1
1
  from django import forms
2
2
  from django.core.exceptions import ObjectDoesNotExist
3
3
 
4
- from edc_utils import formatted_datetime
4
+ from edc_utils.text import formatted_datetime
5
5
  from edc_visit_schedule.site_visit_schedules import site_visit_schedules
6
6
 
7
7
  from ...utils import OffstudyError, raise_if_offstudy
@@ -54,4 +54,4 @@ class OffstudyCrfModelFormMixin:
54
54
  report_datetime=self.report_datetime,
55
55
  )
56
56
  except OffstudyError as e:
57
- raise forms.ValidationError(e)
57
+ raise forms.ValidationError(str(e)) from e
edc_offstudy/utils.py CHANGED
@@ -7,7 +7,7 @@ from django.apps import apps as django_apps
7
7
  from django.core.exceptions import ObjectDoesNotExist
8
8
  from django.db import transaction
9
9
 
10
- from edc_utils import formatted_datetime, to_utc
10
+ from edc_utils.text import formatted_datetime
11
11
  from edc_visit_schedule.site_visit_schedules import site_visit_schedules
12
12
 
13
13
  from .exceptions import OffstudyError
@@ -33,9 +33,9 @@ def get_offstudy_model_cls() -> OffstudyModelMixin:
33
33
 
34
34
 
35
35
  def raise_if_offstudy(
36
+ subject_identifier: str,
37
+ report_datetime: datetime,
36
38
  source_obj: Model | None = None,
37
- subject_identifier: str = None,
38
- report_datetime: datetime = None,
39
39
  ) -> OffstudyModelMixin | None:
40
40
  """Returns None or raises OffstudyError"""
41
41
  obj = None
@@ -43,7 +43,7 @@ def raise_if_offstudy(
43
43
  with transaction.atomic():
44
44
  obj = get_offstudy_model_cls().objects.get(
45
45
  subject_identifier=subject_identifier,
46
- offstudy_datetime__lt=to_utc(report_datetime),
46
+ offstudy_datetime__lt=report_datetime,
47
47
  )
48
48
  except ObjectDoesNotExist:
49
49
  pass
@@ -23,8 +23,9 @@ from edc_data_manager.get_longitudinal_value import (
23
23
  )
24
24
  from edc_protocol.research_protocol_config import ResearchProtocolConfig
25
25
  from edc_randomization.auth_objects import RANDO_UNBLINDED
26
- from edc_utils import formatted_age, get_static_file
26
+ from edc_utils.age import formatted_age
27
27
  from edc_utils.date import to_local
28
+ from edc_utils.get_static_file import get_static_file
28
29
 
29
30
  from .report import Report
30
31
 
edc_pdutils/helper.py CHANGED
@@ -1,3 +1,5 @@
1
+ import contextlib
2
+
1
3
  import pandas as pd
2
4
  from django.conf import settings
3
5
 
@@ -38,10 +40,8 @@ class Helper:
38
40
  """Returns a value as Yes/No/not_sure given
39
41
  1, 0 True, False, etc.
40
42
  """
41
- try:
43
+ with contextlib.suppress(ValueError):
42
44
  value = str(int(value))
43
- except ValueError:
44
- pass
45
45
  if value in ["1", "True"]:
46
46
  value = YES
47
47
  elif value in ["0", "False"]:
@@ -16,9 +16,10 @@ def convert_dates_from_model(
16
16
  """
17
17
  date_cols = []
18
18
  for field_cls in model_cls._meta.get_fields():
19
- if field_cls.get_internal_type() in date_datatypes:
20
- if field_cls.name in source_df.columns:
21
- date_cols.append(field_cls.name)
19
+ if (field_cls.get_internal_type() in date_datatypes) and (
20
+ field_cls.name in source_df.columns
21
+ ):
22
+ date_cols.append(field_cls.name) # noqa: PERF401
22
23
  if date_cols:
23
24
  source_df[date_cols] = source_df[date_cols].apply(pd.to_datetime, errors="coerce")
24
25
  if normalize:
@@ -6,7 +6,7 @@ from django.contrib import admin, messages
6
6
  from django.db.models import QuerySet
7
7
  from django.http import HttpResponseRedirect
8
8
  from django.urls import reverse
9
- from django.utils.translation import gettext
9
+ from django.utils.translation import gettext as _
10
10
 
11
11
  from ...models import Receive, RepackRequest, Stock
12
12
 
@@ -17,7 +17,7 @@ def confirm_repacked_stock_action(modeladmin, request, queryset: QuerySet[Repack
17
17
  messages.add_message(
18
18
  request,
19
19
  messages.ERROR,
20
- gettext("Select one and only one item"),
20
+ _("Select one and only one item"),
21
21
  )
22
22
  else:
23
23
  return confirm_stock_from_queryset(modeladmin, request, queryset)
@@ -30,7 +30,7 @@ def confirm_received_stock_action(modeladmin, request, queryset: QuerySet[Repack
30
30
  messages.add_message(
31
31
  request,
32
32
  messages.ERROR,
33
- gettext("Select one and only one item"),
33
+ _("Select one and only one item"),
34
34
  )
35
35
  else:
36
36
  return confirm_stock_from_queryset(modeladmin, request, queryset)
@@ -1,5 +1,5 @@
1
1
  from django.contrib import messages
2
- from django.utils.translation import gettext
2
+ from django.utils.translation import gettext as _
3
3
 
4
4
  from ...models import StockRequestItem
5
5
 
@@ -9,7 +9,7 @@ def delete_items_for_stock_request_action(modeladmin, request, queryset):
9
9
  messages.add_message(
10
10
  request,
11
11
  messages.ERROR,
12
- gettext("Select one and only one item"),
12
+ _("Select one and only one item"),
13
13
  )
14
14
  else:
15
15
  stock_request = queryset.first()
@@ -17,5 +17,6 @@ def delete_items_for_stock_request_action(modeladmin, request, queryset):
17
17
  messages.add_message(
18
18
  request,
19
19
  messages.SUCCESS,
20
- gettext(f"Delete {deleted} items for {stock_request}"),
20
+ _("Delete %(deleted)s items for %(stock_request)s")
21
+ % dict(deleted=deleted, stock_request=stock_request),
21
22
  )
@@ -23,14 +23,18 @@ def delete_order_items_action(modeladmin, request, queryset: QuerySet[OrderItem]
23
23
  messages.add_message(
24
24
  request,
25
25
  messages.SUCCESS,
26
- gettext(f"Successfully deleted {success_count} {OrderItem._meta.verbose_name}."),
26
+ gettext("Successfully deleted %(success_count)s %(verbose_name)s.")
27
+ % dict(
28
+ success_count=success_count, verbose_name_plural=OrderItem._meta.verbose_name
29
+ ),
27
30
  )
28
31
  if failed_count > 0:
29
32
  messages.add_message(
30
33
  request,
31
34
  messages.ERROR,
32
35
  gettext(
33
- f"Unable to deleted {failed_count} {OrderItem._meta.verbose_name}. "
36
+ "Unable to deleted %(failed_count)s %(verbose_name)s. "
34
37
  "Confirmed stock items exist."
35
- ),
38
+ )
39
+ % dict(failed_count=failed_count, verbose_name=OrderItem._meta.verbose_name),
36
40
  )
@@ -20,14 +20,16 @@ def delete_receive_items_action(modeladmin, request, queryset: QuerySet[ReceiveI
20
20
  messages.add_message(
21
21
  request,
22
22
  messages.SUCCESS,
23
- gettext(f"Successfully deleted {success_count} {ReceiveItem._meta.verbose_name}."),
23
+ gettext("Successfully deleted %(success_count)s %(verbose_name)s.")
24
+ % dict(success_count=success_count, verbose_name=ReceiveItem._meta.verbose_name),
24
25
  )
25
26
  if failed_count > 0:
26
27
  messages.add_message(
27
28
  request,
28
29
  messages.ERROR,
29
30
  gettext(
30
- f"Unable to deleted {failed_count} {ReceiveItem._meta.verbose_name}. "
31
+ "Unable to deleted %(failed_count)s %(verbose_name)s. "
31
32
  "Confirmed stock items exist."
32
- ),
33
+ )
34
+ % dict(failed_count=failed_count, verbose_name=ReceiveItem._meta.verbose_name),
33
35
  )
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  from django.contrib import admin, messages
4
4
  from django.http import HttpResponseRedirect
5
5
  from django.urls import reverse
6
- from django.utils.html import format_html
7
6
  from django.utils.safestring import mark_safe
8
7
 
9
8
  from edc_utils.celery import run_task_sync_or_async
@@ -34,16 +33,13 @@ def process_repack_request_action(modeladmin, request, queryset):
34
33
  messages.add_message(
35
34
  request,
36
35
  messages.SUCCESS,
37
- format_html(
38
- "{}",
39
- mark_safe(
40
- "Repack request submitted. <BR>Next, go to the ACTION menu below and "
41
- "(1)`Print labels`. Then (2) Label your stock "
42
- "containers with the printed labels. "
43
- "Once all stock is labelled, go to the ACTION menu below and "
44
- "(3) Select `Confirm repacked and labelled stock`. "
45
- f"Scan in the labels to CONFIRM the stock. ({task_id})"
46
- ), # nosec B703, B308
36
+ mark_safe( # noqa: S308
37
+ "Repack request submitted. <BR>Next, go to the ACTION menu below and "
38
+ "(1)`Print labels`. Then (2) Label your stock "
39
+ "containers with the printed labels. "
40
+ "Once all stock is labelled, go to the ACTION menu below and "
41
+ "(3) Select `Confirm repacked and labelled stock`. "
42
+ f"Scan in the labels to CONFIRM the stock. ({task_id})"
47
43
  ),
48
44
  )
49
45
  if task_id:
@@ -14,4 +14,4 @@ class VisitScheduleAdmin(ModelAdmin):
14
14
  @register(SiteProxy, site=edc_pharmacy_admin)
15
15
  class SiteProxyAdmin(ModelAdmin):
16
16
  ordering = ("name",)
17
- search_fields = ["id", "name"]
17
+ search_fields = ("id", "name")
@@ -14,14 +14,15 @@ class MedicationsListFilter(SimpleListFilter):
14
14
  title = "Medication"
15
15
  parameter_name = "medication_name"
16
16
 
17
- def lookups(self, request, model_admin):
18
- medications = []
19
- for medication in Medication.objects.all().order_by("name"):
20
- medications.append((medication.name, medication.name.replace("_", " ").title()))
17
+ def lookups(self, request, model_admin) -> tuple[tuple[str, str], ...]: # noqa: ARG002
18
+ medications = [
19
+ (medication.name, medication.name.replace("_", " ").title())
20
+ for medication in Medication.objects.all().order_by("name")
21
+ ]
21
22
  medications.append(("none", "None"))
22
23
  return tuple(medications)
23
24
 
24
- def queryset(self, request, queryset):
25
+ def queryset(self, request, queryset): # noqa: ARG002
25
26
  """Returns a queryset if the Medication name is in the list of sites"""
26
27
  qs = None
27
28
  if self.value():
@@ -40,10 +41,10 @@ class ConfirmedListFilter(SimpleListFilter):
40
41
  title = "Confirmed"
41
42
  parameter_name = "confirmation"
42
43
 
43
- def lookups(self, request, model_admin):
44
+ def lookups(self, request, model_admin) -> tuple[tuple[str, str], ...]: # noqa: ARG002
44
45
  return YES_NO
45
46
 
46
- def queryset(self, request, queryset):
47
+ def queryset(self, request, queryset): # noqa: ARG002
47
48
  qs = None
48
49
  if self.value():
49
50
  if self.value() == YES:
@@ -57,10 +58,10 @@ class AllocationListFilter(SimpleListFilter):
57
58
  title = "Allocated"
58
59
  parameter_name = "allocated"
59
60
 
60
- def lookups(self, request, model_admin):
61
+ def lookups(self, request, model_admin): # noqa: ARG002
61
62
  return YES_NO_NA
62
63
 
63
- def queryset(self, request, queryset):
64
+ def queryset(self, request, queryset): # noqa: ARG002
64
65
  qs = None
65
66
  if self.value():
66
67
  if self.value() == YES:
@@ -88,10 +89,10 @@ class StockItemAllocationListFilter(SimpleListFilter):
88
89
  title = "Allocated"
89
90
  parameter_name = "allocated"
90
91
 
91
- def lookups(self, request, model_admin):
92
+ def lookups(self, request, model_admin): # noqa: ARG002
92
93
  return YES_NO
93
94
 
94
- def queryset(self, request, queryset):
95
+ def queryset(self, request, queryset): # noqa: ARG002
95
96
  qs = None
96
97
  if self.value():
97
98
  if self.value() == YES:
@@ -105,10 +106,10 @@ class StockItemTransferredListFilter(SimpleListFilter):
105
106
  title = "Transferred"
106
107
  parameter_name = "transferred"
107
108
 
108
- def lookups(self, request, model_admin):
109
+ def lookups(self, request, model_admin): # noqa: ARG002
109
110
  return YES_NO
110
111
 
111
- def queryset(self, request, queryset):
112
+ def queryset(self, request, queryset): # noqa: ARG002
112
113
  qs = None
113
114
  if self.value():
114
115
  if self.value() == YES:
@@ -128,10 +129,10 @@ class TransferredListFilter(SimpleListFilter):
128
129
  title = "Transferred"
129
130
  parameter_name = "transferred"
130
131
 
131
- def lookups(self, request, model_admin):
132
+ def lookups(self, request, model_admin): # noqa: ARG002
132
133
  return YES_NO_NA
133
134
 
134
- def queryset(self, request, queryset):
135
+ def queryset(self, request, queryset): # noqa: ARG002
135
136
  qs = None
136
137
  if self.value():
137
138
  if self.value() == YES:
@@ -159,13 +160,14 @@ class AssignmentListFilter(SimpleListFilter):
159
160
  count=Count(self.lookup_str)
160
161
  )
161
162
  if not blinded_user(request):
162
- choices = []
163
- for name in [ann.get(self.lookup_str) for ann in groupby]:
164
- choices.append((name, name or "None"))
163
+ choices = [
164
+ (name, name or "None")
165
+ for name in [ann.get(self.lookup_str) for ann in groupby]
166
+ ]
165
167
  return tuple(choices)
166
168
  return ("****", "****"), ("****", "****")
167
169
 
168
- def queryset(self, request, queryset):
170
+ def queryset(self, request, queryset): # noqa: ARG002
169
171
  qs = None
170
172
  if self.value():
171
173
  qs = queryset.filter(**{self.lookup_str: self.value()})
@@ -182,13 +184,13 @@ class HasOrderNumFilter(SimpleListFilter):
182
184
  title = "Has Order #"
183
185
  parameter_name = "has_order_num"
184
186
 
185
- def lookups(self, request, model_admin):
187
+ def lookups(self, request, model_admin): # noqa: ARG002
186
188
  return YES_NO
187
189
 
188
- def queryset(self, request, queryset):
190
+ def queryset(self, request, queryset): # noqa: ARG002
189
191
  qs = None
190
192
  if self.value():
191
- isnull = True if self.value() == NO else False
193
+ isnull = self.value() == NO
192
194
  qs = queryset.filter(receive_item__order_item__order__isnull=isnull)
193
195
  return qs
194
196
 
@@ -197,13 +199,13 @@ class HasReceiveNumFilter(SimpleListFilter):
197
199
  title = "Has Receive #"
198
200
  parameter_name = "has_receive_num"
199
201
 
200
- def lookups(self, request, model_admin):
202
+ def lookups(self, request, model_admin): # noqa: ARG002
201
203
  return YES_NO
202
204
 
203
- def queryset(self, request, queryset):
205
+ def queryset(self, request, queryset): # noqa: ARG002
204
206
  qs = None
205
207
  if self.value():
206
- isnull = True if self.value() == NO else False
208
+ isnull = self.value() == NO
207
209
  qs = queryset.filter(receive_item__receive__isnull=isnull)
208
210
  return qs
209
211
 
@@ -212,13 +214,13 @@ class HasRepackNumFilter(SimpleListFilter):
212
214
  title = "Has Repack #"
213
215
  parameter_name = "has_repack_num"
214
216
 
215
- def lookups(self, request, model_admin):
217
+ def lookups(self, request, model_admin): # noqa: ARG002
216
218
  return YES_NO
217
219
 
218
- def queryset(self, request, queryset):
220
+ def queryset(self, request, queryset): # noqa: ARG002
219
221
  qs = None
220
222
  if self.value():
221
- isnull = True if self.value() == NO else False
223
+ isnull = self.value() == NO
222
224
  qs = queryset.filter(repack_request__isnull=isnull)
223
225
  return qs
224
226
 
@@ -227,10 +229,10 @@ class TransferredFilter(SimpleListFilter):
227
229
  title = "Transferred to site"
228
230
  parameter_name = "transferred"
229
231
 
230
- def lookups(self, request, model_admin):
232
+ def lookups(self, request, model_admin): # noqa: ARG002
231
233
  return (YES, YES), (NO, NO)
232
234
 
233
- def queryset(self, request, queryset):
235
+ def queryset(self, request, queryset): # noqa: ARG002
234
236
  qs = None
235
237
  if self.value():
236
238
  opts = dict(
@@ -249,10 +251,10 @@ class ConfirmedAtSiteFilter(SimpleListFilter):
249
251
  title = "Confirmed at site"
250
252
  parameter_name = "confirmed_at_site"
251
253
 
252
- def lookups(self, request, model_admin):
254
+ def lookups(self, request, model_admin): # noqa: ARG002
253
255
  return (YES, YES), (NO, NO)
254
256
 
255
- def queryset(self, request, queryset):
257
+ def queryset(self, request, queryset): # noqa: ARG002
256
258
  qs = None
257
259
  if self.value():
258
260
  opts = dict(
@@ -272,10 +274,10 @@ class StoredAtSiteFilter(SimpleListFilter):
272
274
  title = "Stored at site"
273
275
  parameter_name = "stored_at_site_now"
274
276
 
275
- def lookups(self, request, model_admin):
277
+ def lookups(self, request, model_admin): # noqa: ARG002
276
278
  return YES_NO_NA
277
279
 
278
- def queryset(self, request, queryset):
280
+ def queryset(self, request, queryset): # noqa: ARG002
279
281
  qs = None
280
282
  if self.value():
281
283
  if self.value() == YES:
@@ -315,10 +317,10 @@ class DispensedFilter(SimpleListFilter):
315
317
  title = "Dispensed"
316
318
  parameter_name = "dispensed"
317
319
 
318
- def lookups(self, request, model_admin):
320
+ def lookups(self, request, model_admin): # noqa: ARG002
319
321
  return YES_NO
320
322
 
321
- def queryset(self, request, queryset):
323
+ def queryset(self, request, queryset): # noqa: ARG002
322
324
  qs = None
323
325
  if self.value():
324
326
  opts = dict(
@@ -339,10 +341,10 @@ class HasCodesListFilter(SimpleListFilter):
339
341
  title = "Has codes"
340
342
  parameter_name = "has_codes"
341
343
 
342
- def lookups(self, request, model_admin):
344
+ def lookups(self, request, model_admin): # noqa: ARG002
343
345
  return (YES, YES), (NO, NO)
344
346
 
345
- def queryset(self, request, queryset):
347
+ def queryset(self, request, queryset): # noqa: ARG002
346
348
  qs = None
347
349
  if self.value():
348
350
  if self.value() == YES:
@@ -356,14 +358,14 @@ class StockRequestItemPendingListFilter(SimpleListFilter):
356
358
  title = "Request Status"
357
359
  parameter_name = "item_status"
358
360
 
359
- def lookups(self, request, model_admin):
361
+ def lookups(self, request, model_admin): # noqa: ARG002
360
362
  return (
361
363
  ("not_allocated", "Not allocated"),
362
364
  ("allocated_only", "Allocated only"),
363
365
  ("transferred", "Allocation and transferred"),
364
366
  )
365
367
 
366
- def queryset(self, request, queryset):
368
+ def queryset(self, request, queryset): # noqa: ARG002
367
369
  qs = None
368
370
  if self.value():
369
371
  if self.value() == "not_allocated":
@@ -387,14 +389,14 @@ class OrderItemStatusListFilter(SimpleListFilter):
387
389
  title = "Status"
388
390
  parameter_name = "order_item_status"
389
391
 
390
- def lookups(self, request, model_admin):
392
+ def lookups(self, request, model_admin): # noqa: ARG002
391
393
  return (
392
394
  (NEW, _("New")),
393
395
  (PARTIAL, _("Partial")),
394
396
  (RECEIVED, _("Received")),
395
397
  )
396
398
 
397
- def queryset(self, request, queryset):
399
+ def queryset(self, request, queryset): # noqa: ARG002
398
400
  qs = None
399
401
  if self.value():
400
402
  if self.value() == RECEIVED:
@@ -410,10 +412,10 @@ class DecantedListFilter(SimpleListFilter):
410
412
  title = "Decanted"
411
413
  parameter_name = "decanted"
412
414
 
413
- def lookups(self, request, model_admin):
415
+ def lookups(self, request, model_admin): # noqa: ARG002
414
416
  return YES_NO
415
417
 
416
- def queryset(self, request, queryset):
418
+ def queryset(self, request, queryset): # noqa: ARG002
417
419
  qs = None
418
420
  if self.value():
419
421
  if self.value() == YES:
@@ -427,10 +429,10 @@ class StorageBinItemDispensedFilter(SimpleListFilter):
427
429
  title = "Dispensed"
428
430
  parameter_name = "dispensed"
429
431
 
430
- def lookups(self, request, model_admin):
432
+ def lookups(self, request, model_admin): # noqa: ARG002
431
433
  return (YES, YES), (NO, NO)
432
434
 
433
- def queryset(self, request, queryset):
435
+ def queryset(self, request, queryset): # noqa: ARG002
434
436
  qs = None
435
437
  if self.value():
436
438
  if self.value() == YES:
@@ -28,16 +28,16 @@ class AssignmentAdmin(ModelAdminMixin, admin.ModelAdmin):
28
28
  audit_fieldset_tuple,
29
29
  )
30
30
 
31
- list_display: tuple[str, ...] = (
31
+ list_display = (
32
32
  "name",
33
33
  "display_name",
34
34
  "created",
35
35
  "modified",
36
36
  )
37
37
 
38
- search_fields: tuple[str, ...] = ("name", "display_name")
38
+ search_fields = ("name", "display_name")
39
39
 
40
- def get_readonly_fields(self, request, obj=None):
40
+ def get_readonly_fields(self, request, obj=None): # noqa: ARG002
41
41
  if obj:
42
- return self.readonly_fields + ("name",)
42
+ return tuple({*self.readonly_fields, "name"})
43
43
  return self.readonly_fields
@@ -11,7 +11,7 @@ from ..model_admin_mixin import ModelAdminMixin
11
11
  class DosageGuidelineAdmin(ModelAdminMixin, admin.ModelAdmin):
12
12
  show_object_tools = True
13
13
 
14
- autocomplete_fields = ["medication"]
14
+ autocomplete_fields = ("medication",)
15
15
 
16
16
  form = DosageGuidelineForm
17
17
 
@@ -32,5 +32,5 @@ class DosageGuidelineAdmin(ModelAdminMixin, admin.ModelAdmin):
32
32
  audit_fieldset_tuple,
33
33
  )
34
34
 
35
- list_display: tuple[str, ...] = ("__str__", "modified", "user_modified")
36
- search_fields: tuple[str, ...] = ("medication__name",)
35
+ list_display = ("__str__", "modified", "user_modified")
36
+ search_fields = ("medication__name",)
@@ -11,7 +11,7 @@ from ..model_admin_mixin import ModelAdminMixin
11
11
  class FormulationAdmin(ModelAdminMixin, admin.ModelAdmin):
12
12
  show_object_tools = True
13
13
 
14
- autocomplete_fields = ["medication"]
14
+ autocomplete_fields = ("medication",)
15
15
 
16
16
  form = FormulationForm
17
17
 
@@ -45,13 +45,13 @@ class FormulationAdmin(ModelAdminMixin, admin.ModelAdmin):
45
45
  audit_fieldset_tuple,
46
46
  )
47
47
 
48
- radio_fields = {
48
+ radio_fields = { # noqa: RUF012
49
49
  "units": admin.VERTICAL,
50
50
  "formulation_type": admin.VERTICAL,
51
51
  "route": admin.VERTICAL,
52
52
  }
53
53
 
54
- list_filter: tuple[str, ...] = (
54
+ list_filter = (
55
55
  "imp",
56
56
  "strength",
57
57
  "units",
@@ -68,6 +68,6 @@ class FormulationAdmin(ModelAdminMixin, admin.ModelAdmin):
68
68
  "route",
69
69
  )
70
70
 
71
- search_fields: tuple[str, ...] = ("medication__name",)
71
+ search_fields = ("medication__name",)
72
72
 
73
- ordering: tuple[str, ...] = ("medication__name",)
73
+ ordering = ("medication__name",)
@@ -21,8 +21,8 @@ class MedicationAdmin(ModelAdminMixin, admin.ModelAdmin):
21
21
  audit_fieldset_tuple,
22
22
  )
23
23
 
24
- list_display: tuple[str, ...] = ("name", "display_name", "created", "modified")
24
+ list_display = ("name", "display_name", "created", "modified")
25
25
 
26
- search_fields: tuple[str, ...] = ("name",)
26
+ search_fields = ("name",)
27
27
 
28
- ordering: tuple[str, ...] = ("name",)
28
+ ordering = ("name",)
@@ -76,14 +76,14 @@ class RxAdmin(ModelAdminSubjectDashboardMixin, admin.ModelAdmin):
76
76
  )
77
77
 
78
78
  @admin.display
79
- def add_refill(self, obj=None, label=None):
79
+ def add_refill(self, obj=None, label=None): # noqa: ARG002
80
80
  url = reverse("edc_pharmacy_admin:edc_pharmacy_rxrefill_add")
81
81
  url = f"{url}?rx={obj.id}"
82
82
  context = dict(title="Add refill", url=url, label="Add refill")
83
83
  return render_to_string("edc_subject_dashboard/dashboard_button.html", context=context)
84
84
 
85
85
  @admin.display
86
- def refills(self, obj=None, label=None):
86
+ def refills(self, obj=None, label=None): # noqa: ARG002
87
87
  url = reverse("edc_pharmacy_admin:edc_pharmacy_rxrefill_changelist")
88
88
  url = f"{url}?q={obj.id}"
89
89
  context = dict(title="RX items", url=url, label="Refills")