Skip to content

Commit

Permalink
Merge branch 'develop' into feat/488-serum-crag-lte-21-days-old-eligible
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Jun 11, 2024
2 parents 8182ed4 + 8c4ce20 commit 46aa8b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 74 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changes
------
- update Subject Screening to extend window for serum crag to be
up to 21 days (#488-3)
- bump to edc 0.5.91

0.1.53
------
Expand Down
79 changes: 6 additions & 73 deletions effect_ae/action_items.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from django.apps import apps as django_apps
from django.conf import settings
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist
from django.utils.html import format_html
from edc_action_item import ActionWithNotification, site_action_items
from edc_adverse_event.action_items import (
DeathReportTmgAction,
DeathReportTmgSecondAction,
)
from edc_adverse_event.constants import (
AE_FOLLOWUP_ACTION,
AE_INITIAL_ACTION,
Expand Down Expand Up @@ -226,80 +230,9 @@ def get_next_actions(self):
return next_actions


class DeathReportTmgAction(ActionWithNotification):
name = DEATH_REPORT_TMG_ACTION
display_name = "TMG Death Report pending"
notification_display_name = "TMG Death Report"
parent_action_names = [DEATH_REPORT_ACTION, DEATH_REPORT_TMG_ACTION]
reference_model = "effect_ae.deathreporttmg"
related_reference_model = "effect_ae.deathreport"
related_reference_fk_attr = "death_report"
priority = HIGH_PRIORITY
create_by_user = False
color_style = "info"
show_link_to_changelist = True
admin_site_name = "effect_ae_admin"
instructions = format_html("This report is to be completed by the TMG only.")

def reopen_action_item_on_change(self):
"""Do not reopen if status is CLOSED."""
return self.reference_obj.report_status != CLOSED

@property
def matching_cause_of_death(self):
"""Returns True if cause_of_death on TMG Death Report matches
cause_of_death on Death Report.
"""
return (
self.reference_obj.death_report.cause_of_death == self.reference_obj.cause_of_death
)

def close_action_item_on_save(self):
if self.matching_cause_of_death:
self.delete_children_if_new(parent_action_item=self.action_item)
return self.reference_obj.report_status == CLOSED

def get_next_actions(self):
"""Returns a second DeathReportTmgAction if the
submitted report does not match the cause of death
of the original death report.
Also, no more than two DeathReportTmgAction can exist.
"""
next_actions = []
try:
self.action_item_model_cls().objects.get(
parent_action_item=self.related_action_item,
related_action_item=self.related_action_item,
action_type__name=self.name,
)
except ObjectDoesNotExist:
pass
except MultipleObjectsReturned:
# because more than one action item has the same
# parent_action_item and related_action_item. this
# only occurs for older data.
pass
else:
if (
self.action_item_model_cls()
.objects.filter(
related_action_item=self.related_action_item,
action_type__name=self.name,
)
.count()
< 2
):
if (
self.reference_obj.cause_of_death
!= self.related_action_item.reference_obj.cause_of_death
):
next_actions = ["self"]
return next_actions


site_action_items.register(DeathReportAction)
site_action_items.register(DeathReportTmgAction)
site_action_items.register(DeathReportTmgSecondAction)
site_action_items.register(AeFollowupAction)
site_action_items.register(AeInitialAction)
site_action_items.register(AeSusarAction)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ zip_safe = False
include_package_data = True
packages = find:
install_requires =
edc==0.5.89
edc==0.5.91
edc-csf==0.3.6
edc-microbiology==0.3.10
beautifulsoup4
Expand Down

0 comments on commit 46aa8b5

Please sign in to comment.