def test_get_case_blocks_from_bahmni_diagnoses(self): self.setUpRepeaterForExtCase() encounter = self.get_json('encounter_with_diagnoses') bahmni_diagnoses = encounter['bahmniDiagnoses'] case_block_kwargs, case_blocks = get_case_block_kwargs_from_bahmni_diagnoses( bahmni_diagnoses, get_diagnosis_mappings(self.repeater), ('test-case-id', 'patient', 'default-owner-id')) self.assertEqual(case_block_kwargs, {'update': {}}) self.assertEqual(len(case_blocks), 1) date_modified = case_blocks[0].date_modified.isoformat() + 'Z' date_opened = case_blocks[0].date_opened case_block = f""" <case case_id="{case_blocks[0].case_id}" » date_modified="{date_modified}" » xmlns="http://commcarehq.org/case/transaction/v2"> <create> <case_type>diagnosis</case_type> <case_name>Hypothermia</case_name> <owner_id>default-owner-id</owner_id> </create> <update> <date_opened>{date_opened}</date_opened> <certainty>CONFIRMED</certainty> <diagnosis_date>2019-10-18</diagnosis_date> <is_primary>yes</is_primary> </update> <index> <parent case_type="patient" relationship="extension">test-case-id</parent> </index> </case>""" case_block = ''.join( (l.strip() for l in case_block.split('\n'))).replace('»', '') self.assertEqual(case_blocks[0].as_text(), case_block)
def test_get_case_block_kwargs_from_bahmni_diagnoses(self): self.setUpRepeater() encounter = self.get_json('encounter_with_diagnoses') bahmni_diagnoses = encounter['bahmniDiagnoses'] case_block_kwargs, case_blocks = get_case_block_kwargs_from_bahmni_diagnoses( bahmni_diagnoses, self.repeater.diagnosis_mappings, None, None, None ) self.assertEqual(case_block_kwargs, {'owner_id': 'emergency_room_user_id', 'update': {}}) self.assertEqual(case_blocks, [])
def test_get_case_block_kwargs_from_bahmni_diagnoses(self): self.setUpRepeater() encounter = self.get_json('encounter_with_diagnoses') bahmni_diagnoses = encounter['bahmniDiagnoses'] case_block_kwargs, case_blocks = get_case_block_kwargs_from_bahmni_diagnoses( bahmni_diagnoses, get_diagnosis_mappings(self.repeater), (None, None, None)) self.assertEqual( case_block_kwargs, { 'owner_id': 'emergency_room_user_id', 'update': { 'hypothermia_diagnosis': 'yes', 'hypothermia_date': '2019-10-18' } }) self.assertEqual(case_blocks, [])