Beispiel #1
0
    def get_next_actions(self):
        next_actions = []

        # add AE followup to next_actions if followup.
        next_actions = self.append_to_next_if_required(
            next_actions=next_actions,
            action_name=self.name,
            required=self.reference_obj.followup == YES,
        )

        # add Death report to next_actions if G5/Death
        next_actions = self.append_to_next_if_required(
            next_actions=next_actions,
            action_name=DEATH_REPORT_ACTION,
            required=(self.reference_obj.outcome == DEAD
                      or self.reference_obj.ae_grade == GRADE5),
        )

        # add Study termination to next_actions if LTFU
        if self.reference_obj.outcome == LOST_TO_FOLLOWUP:
            for offschedule_model in get_offschedule_models(
                    subject_identifier=self.subject_identifier,
                    report_datetime=self.reference_obj.report_datetime,
            ):
                action_cls = site_action_items.get_by_model(
                    model=offschedule_model)
                next_actions = self.append_to_next_if_required(
                    next_actions=next_actions,
                    action_name=action_cls.name,
                    required=True,
                )
        return next_actions
Beispiel #2
0
    def append_next_off_schedule_action(self, next_actions):
        """Appends an off schedule action to the list for each
        schedule the subject is on.

        If subject was already taken off schedule, skip. For example,
        if re-saving the DeathReport, subject may have already been
        taken off schedule.
        """
        offschedule_models = get_offschedule_models(
            subject_identifier=self.subject_identifier,
            report_datetime=self.reference_obj.report_datetime,
        )
        for off_schedule_model in offschedule_models:
            off_schedule_cls = django_apps.get_model(off_schedule_model)
            try:
                off_schedule_cls.objects.get(
                    subject_identifier=self.subject_identifier)
            except ObjectDoesNotExist:
                next_actions.append(off_schedule_cls.action_name)
        return next_actions
Beispiel #3
0
 def offschedule_models(self):
     """Returns a list of offschedule models, in label_lower format."""
     return get_offschedule_models(
         subject_identifier=self.subject_identifier,
         report_datetime=self.reference_obj.report_datetime,
     )