Beispiel #1
0
    def allowed_to_forward(self, episode_case):
        if not self.case_types_and_users_allowed(episode_case):
            return False

        case_properties = episode_case.dynamic_case_properties()
        prescription_total_days = _cast_to_int(
            case_properties.get("prescription_total_days", 0))
        treatment_options = case_properties.get("treatment_options")
        if treatment_options == "fdc":
            meets_days_threshold = prescription_total_days >= 168
        else:
            meets_days_threshold = prescription_total_days >= 180

        enrolled_in_private_sector = case_properties.get(
            ENROLLED_IN_PRIVATE) == 'true'
        not_sent = case_properties.get(
            "event_{}".format(SUCCESSFUL_TREATMENT_EVENT)) != "sent"
        return (
            not_sent and enrolled_in_private_sector
            and is_valid_archived_submission(episode_case) and
            (case_properties_changed(episode_case, ["treatment_outcome"])
             and case_properties.get("treatment_outcome") in
             ("cured", "treatment_completed")) or
            (case_properties_changed(episode_case, ["prescription_total_days"])
             and meets_days_threshold))
Beispiel #2
0
    def allowed_to_forward(self, episode_case):
        allowed_case_types_and_users = self._allowed_case_type(
            episode_case) and self._allowed_user(episode_case)
        if not allowed_case_types_and_users:
            return False

        episode_case_properties = episode_case.dynamic_case_properties()
        return (episode_case_properties.get('nikshay_id', False)
                and case_properties_changed(episode_case, [TREATMENT_OUTCOME])
                and episode_case_properties.get(TREATMENT_OUTCOME)
                in treatment_outcome.keys()
                and is_valid_archived_submission(episode_case))
Beispiel #3
0
    def allowed_to_forward(self, episode_case):
        if not self.case_types_and_users_allowed(episode_case):
            return False

        enrolled_in_private_sector = episode_case.get_case_property(
            ENROLLED_IN_PRIVATE) == 'true'
        not_sent = episode_case.get_case_property(
            "event_{}".format(SUCCESSFUL_TREATMENT_EVENT)) != "sent"

        return (not_sent and enrolled_in_private_sector
                and is_valid_archived_submission(episode_case)
                and xor(self._treatment_completed(episode_case),
                        self._met_prescription_days_threshold(episode_case)))
Beispiel #4
0
    def allowed_to_forward(self, episode_case):
        allowed_case_types_and_users = self._allowed_case_type(
            episode_case) and self._allowed_user(episode_case)
        if not allowed_case_types_and_users:
            return False

        episode_case_properties = episode_case.dynamic_case_properties()
        return (
            not (episode_case_properties.get(ENROLLED_IN_PRIVATE) == 'true')
            and
            (  # has a nikshay id already or is a valid submission probably waiting notification
                episode_case_properties.get('nikshay_id')
                or valid_nikshay_patient_registration(episode_case_properties))
            and case_properties_changed(episode_case, [TREATMENT_OUTCOME]) and
            episode_case_properties.get(TREATMENT_OUTCOME) in treatment_outcome
            and is_valid_archived_submission(episode_case))