def _set_external_id(info, external_id, repeater_id): """ Set "external_id" property on the case represented by ``info``. """ case_block = CaseBlock( case_id=info.case_id, external_id=external_id, create=False, ) submit_case_blocks( [case_block.as_text()], info.domain, xmlns=XMLNS_FHIR, device_id=f'FHIRRepeater-{repeater_id}', )
def delete_case_property( domain: str, case_id: str, case_property: str, ): """ Delete the OpenMRS identifier on the case. """ members = dict(inspect.getmembers(CaseBlock.__init__.__code__)) case_block_args = members['co_varnames'] if case_property in case_block_args: case_block_kwargs = {case_property: None} else: case_block_kwargs = {"update": {case_property: None}} case_block = CaseBlock(case_id=case_id, create=False, **case_block_kwargs) submit_case_blocks([case_block.as_text()], domain, xmlns=XMLNS_OPENMRS)
def _set_external_id(info, external_id, repeater_id): """ Set "external_id" property on the case represented by ``info``. """ case_block = CaseBlock( case_id=info.case_id, external_id=external_id, create=False, ) submit_case_blocks( [case_block.as_text()], info.domain, xmlns=XMLNS_FHIR, device_id=f'FHIRRepeater-{repeater_id}', ) # If case was matched, set external_id to update remote resource info.extra_fields['external_id'] = external_id
def test_forms_touching_live_case_not_deleted(self): case_id = uuid.uuid4().hex caseblock = CaseBlock( create=True, case_id=case_id, owner_id=self.commcare_user._id, user_id=self.commcare_user._id, ) xform, _ = submit_case_blocks(caseblock.as_text(), self.domain) # other user submits form against the case and another case not owned by the user # should NOT get deleted since this form touches a case that's still 'alive' double_case_xform, _ = submit_case_blocks([ CaseBlock( create=False, case_id=case_id, ).as_text(), CaseBlock( create=True, case_id=uuid.uuid4().hex, owner_id=self.other_user._id, user_id=self.other_user._id, ).as_text() ], self.domain, user_id=self.other_user._id) self.commcare_user.retire() self.assertTrue( FormAccessors(self.domain).get_form(xform.form_id).is_deleted) self.assertFalse( FormAccessors(self.domain).get_form( double_case_xform.form_id).is_deleted) # When the other user is deleted then the form should get deleted since it no-longer touches # any 'live' cases. self.other_user.retire() self.assertTrue( FormAccessors(self.domain).get_form( double_case_xform.form_id).is_deleted)