def test_trigger(self): # Create case that doesn't meet trigger cases = self.create_case_structure() self.assign_person_to_location(self.pcp.location_id) update_case( self.domain, self.episode_id, { 'bets_first_prescription_voucher_redeemed': 'false', 'created_by_user_type': 'pac', ENROLLED_IN_PRIVATE: "true", }, ) self.assertEqual(0, len(self.repeat_records().all())) # Meet trigger update_case(self.domain, self.episode_id, {"bets_first_prescription_voucher_redeemed": "true"}) self.assertEqual(1, len(self.repeat_records().all())) # Make sure same case doesn't trigger event again payload_generator = BETSAYUSHReferralPayloadGenerator(None) payload_generator.handle_success( MockResponse(201, {"success": "hooray"}), cases[self.episode_id], None) update_case(self.domain, self.episode_id, {"bets_first_prescription_voucher_redeemed": "false"}) update_case(self.domain, self.episode_id, {"bets_first_prescription_voucher_redeemed": "true"}) self.assertEqual(1, len(self.repeat_records().all()))
def test_prescription_total_days_trigger(self): # Create case that doesn't meet trigger cases = self.create_case_structure() self.assign_person_to_location(self.pcp.location_id) update_case( self.domain, self.episode_id, { 'treatment_outcome': 'not_evaluated', 'prescription_total_days': 100, 'treatment_options': 'fdc', ENROLLED_IN_PRIVATE: "true", }, ) case = cases[self.episode_id] self.assertEqual(0, len(self.repeat_records().all())) # Meet trigger update_case(self.domain, case.case_id, {"prescription_total_days": "169"}) self.assertEqual(1, len(self.repeat_records().all())) # Make sure same case doesn't trigger event again payload_generator = BETSSuccessfulTreatmentPayloadGenerator(None) payload_generator.handle_success( MockResponse(201, {"success": "hooray"}), case, None) update_case(self.domain, case.case_id, {"foo": "bar"}) self.assertEqual(1, len(self.repeat_records().all()))
def test_trigger(self): # voucher not approved self.create_case_structure() self.assign_person_to_location(self.pcp.location_id) prescription = self.create_prescription_case() voucher = self.create_voucher_case(prescription.case_id, { "voucher_type": "prescription", 'state': 'not approved' }) self.assertEqual(0, len(self.repeat_records().all())) # voucher approved update_case(self.domain, voucher.case_id, {"state": "approved"}) self.assertEqual(1, len(self.repeat_records().all())) # Changing state to some other state doesn't create another record update_case(self.domain, voucher.case_id, {"state": "foo"}) self.assertEqual(1, len(self.repeat_records().all())) # Approving voucher again doesn't create new record payload_generator = ChemistBETSVoucherPayloadGenerator(None) payload_generator.handle_success( MockResponse(201, {"success": "hooray"}), voucher, None) update_case(self.domain, voucher.case_id, {"state": "approved"}) self.assertEqual(1, len(self.repeat_records().all()))
def test_trigger(self): # episode that does not meet trigger cases = self.create_case_structure() self.assign_person_to_location(self.pcp.location_id) update_case( self.domain, self.episode_id, { 'prescription_total_days': 20, ENROLLED_IN_PRIVATE: "true", }, ) case = cases[self.episode_id] self.assertEqual(0, len(self.repeat_records().all())) # meet trigger conditions update_case(self.domain, case.case_id, { "prescription_total_days": 181, }) self.assertEqual(1, len(self.repeat_records().all())) # trigger only once payload_generator = BETS180TreatmentPayloadGenerator(None) payload_generator.handle_success( MockResponse(201, {"success": "hooray"}), case, None) update_case(self.domain, case.case_id, {"prescription_total_days": "182"}) self.assertEqual(1, len(self.repeat_records().all()))
def test_trigger(self): # Create case that doesn't meet trigger cases = self.create_case_structure() self.assign_person_to_location(self.pcp.location_id) update_case( self.domain, self.episode_id, { FIRST_PRESCRIPTION_VOUCHER_REDEEMED: 'false', ENROLLED_IN_PRIVATE: "true", }, ) case = cases[self.episode_id] self.assertEqual(0, len(self.repeat_records().all())) # Meet trigger update_case(self.domain, case.case_id, {"bets_first_prescription_voucher_redeemed": "true"}) self.assertEqual(1, len(self.repeat_records().all())) # Make sure same case doesn't trigger event again payload_generator = BETSDiagnosisAndNotificationPayloadGenerator(None) payload_generator.handle_success( MockResponse(201, {"success": "hooray"}), case, None) update_case(self.domain, case.case_id, {"foo": "bar"}) self.assertEqual(1, len(self.repeat_records().all()))