(repeater, patient_uuid)
Fetch patient from OpenMRS, submit case update for all mapped case
    properties.

    .. NOTE:: OpenMRS UUID must be saved to "external_id" case property
Fetch patient from OpenMRS, submit case update for all mapped case
    properties.
Fetch patient from OpenMRS submit case update for all mapped case properties .
def update_patient(repeater, patient_uuid):
    """
    Fetch patient from OpenMRS, submit case update for all mapped case
    properties.

    .. NOTE:: OpenMRS UUID must be saved to "external_id" case property

    """
    if len(repeater.white_listed_case_types) != 1:
        raise ConfigurationError(_(
            f'{repeater.domain}: {repeater}: Error in settings: Unable to update '
            f'patients from OpenMRS unless only one case type is specified.'
        ))
    case_type = repeater.white_listed_case_types[0]
    try:
        patient = get_patient_by_uuid(repeater.requests, patient_uuid)
    except (RequestException, ValueError) as err:
        raise OpenmrsException(_(
            f'{repeater.domain}: {repeater}: Error fetching Patient '
            f'{patient_uuid!r}: {err}'
        )) from err

    case, error = importer_util.lookup_case(
        EXTERNAL_ID,
        patient_uuid,
        repeater.domain,
        case_type=case_type,
    )
    if error == LookupErrors.NotFound:
        if not repeater.openmrs_config.case_config.import_creates_cases:
            # We can't create cases via the Atom feed, just update them.
            # Nothing to do here.
            return
        default_owner: Optional[CommCareUser] = repeater.first_user
        case_block = get_addpatient_caseblock(case_type, default_owner, patient, repeater)
    elif error == LookupErrors.MultipleResults:
        # Multiple cases have been matched to the same patient.
        # Could be caused by:
        # * The cases were given the same identifier value. It could
        #   be user error, or case config assumed identifier was
        #   unique but it wasn't.
        # * PatientFinder matched badly.
        # * Race condition where a patient was previously added to
        #   both CommCare and OpenMRS.
        raise DuplicateCaseMatch(_(
            f'{repeater.domain}: {repeater}: More than one case found '
            f'matching unique OpenMRS UUID. case external_id: "{patient_uuid}"'
        ))
    else:
        case_block = get_updatepatient_caseblock(case, patient, repeater)

    if case_block:
        submit_case_blocks(
            [case_block.as_text()],
            repeater.domain,
            xmlns=XMLNS_OPENMRS,
            device_id=OPENMRS_ATOM_FEED_DEVICE_ID + repeater.get_id,
        )
def update_patient ( repeater , patient_uuid ) : if len ( repeater . white_listed_case_types ) != 1 : raise ConfigurationError ( _ ( f'{repeater.domain}: {repeater}: Error in settings: Unable to update ' f'patients from OpenMRS unless only one case type is specified.' ) ) case_type = repeater . white_listed_case_types [ 0 ] try : patient = get_patient_by_uuid ( repeater . requests , patient_uuid ) except ( RequestException , ValueError ) as err : raise OpenmrsException ( _ ( f'{repeater.domain}: {repeater}: Error fetching Patient ' f'{patient_uuid!r}: {err}' ) ) from err case , error = importer_util . lookup_case ( EXTERNAL_ID , patient_uuid , repeater . domain , case_type = case_type , ) if error == LookupErrors . NotFound : if not repeater . openmrs_config . case_config . import_creates_cases : # We can't create cases via the Atom feed, just update them. # Nothing to do here. return default_owner : Optional [ CommCareUser ] = repeater . first_user case_block = get_addpatient_caseblock ( case_type , default_owner , patient , repeater ) elif error == LookupErrors . MultipleResults : # Multiple cases have been matched to the same patient. # Could be caused by: # * The cases were given the same identifier value. It could #   be user error, or case config assumed identifier was #   unique but it wasn't. # * PatientFinder matched badly. # * Race condition where a patient was previously added to #   both CommCare and OpenMRS. raise DuplicateCaseMatch ( _ ( f'{repeater.domain}: {repeater}: More than one case found ' f'matching unique OpenMRS UUID. case external_id: "{patient_uuid}"' ) ) else : case_block = get_updatepatient_caseblock ( case , patient , repeater ) if case_block : submit_case_blocks ( [ case_block . as_text ( ) ] , repeater . domain , xmlns = XMLNS_OPENMRS , device_id = OPENMRS_ATOM_FEED_DEVICE_ID + repeater . get_id , )