def allowed_to_forward(self, adherence_case): allowed_case_types_and_users = ( self._allowed_case_type(adherence_case) and self._allowed_user(adherence_case) ) if not allowed_case_types_and_users: return False try: episode_case = get_episode_case_from_adherence(adherence_case.domain, adherence_case.case_id) if episode_case.closed: return False except ENikshayCaseNotFound: return False episode_case_properties = episode_case.dynamic_case_properties() adherence_case_properties = adherence_case.dynamic_case_properties() enabled = episode_case_properties.get('dots_99_enabled') == 'true' registered = episode_case_properties.get('dots_99_registered') == 'true' from_enikshay = adherence_case_properties.get('adherence_source') == 'enikshay' previously_updated = adherence_case_properties.get('dots_99_updated') == 'true' return ( enabled and registered and from_enikshay and not previously_updated and case_was_created(adherence_case) and is_valid_episode_submission(episode_case) )
def test_get_episode_case_from_adherence(self): adherence_case = self.create_adherence_cases([datetime(2017, 2, 17)])[0] self.assertEqual( get_episode_case_from_adherence(self.domain, adherence_case.case_id).case_id, self.episode_id, )
def get_payload(self, repeat_record, adherence_case): domain = adherence_case.domain person_case = get_person_case_from_occurrence( domain, get_occurrence_case_from_episode( domain, get_episode_case_from_adherence(domain, adherence_case.case_id).case_id ).case_id ) adherence_case_properties = adherence_case.dynamic_case_properties() date = parse_date(adherence_case.dynamic_case_properties().get('adherence_date')) payload = { 'beneficiary_id': person_case.case_id, 'adherence_date': date.isoformat(), 'adherence_source': adherence_case_properties.get('adherence_source'), 'adherence_value': adherence_case_properties.get('adherence_value'), } return json.dumps(payload)
def allowed_to_forward(self, adherence_case): allowed_case_types_and_users = (self._allowed_case_type(adherence_case) and self._allowed_user(adherence_case)) if not allowed_case_types_and_users: return False episode_case = get_episode_case_from_adherence(adherence_case.domain, adherence_case.case_id) episode_case_properties = episode_case.dynamic_case_properties() adherence_case_properties = adherence_case.dynamic_case_properties() enabled = episode_case_properties.get('dots_99_enabled') == 'true' registered = episode_case_properties.get( 'dots_99_registered') == 'true' from_enikshay = adherence_case_properties.get( 'adherence_source') == 'enikshay' previously_updated = adherence_case_properties.get( 'dots_99_updated') == 'true' return enabled and registered and from_enikshay and not previously_updated
def get_episode(self, adherence): assert adherence.type == CASE_TYPE_ADHERENCE if 'episode' not in self.context: self.context['episode'] = get_episode_case_from_adherence( DOMAIN, adherence.case_id) return self.context['episode']