openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/library/api/workers/UpdatePatientWorker.java
/**
     * Update patient.
     *
     * @param patient          the patient
     * @param callbackListener the callback listener
     */
Update patient.
@param patient          the patient
@param callbackListener the callback listener
Update patient . @param patient the patient @param callbackListener the callback listener
public void updatePatient(final Patient patient, @Nullable final DefaultResponseCallback callbackListener) {
        PatientDtoUpdate patientDto = patient.getUpdatedPatientDto();
        if (NetworkUtils.isOnline()) {
            Call<PatientDto> call = restApi.updatePatient(patientDto, patient.getUuid(), "full");
            call.enqueue(new Callback<PatientDto>() {
                @Override
                public void onResponse(@NonNull Call<PatientDto> call, @NonNull Response<PatientDto> response) {
                    if (response.isSuccessful()) {
                        PatientDto patientDto = response.body();
                        patient.setBirthdate(patientDto.getPerson().getBirthdate());
                        patient.setUuid(patient.getUuid());
                        if (patient.getPhoto() != null) {
                            uploadPatientPhoto(patient);
                        }
                        new PatientDAO().updatePatient(patient.getId(), patient);
                        if (callbackListener != null) {
                            callbackListener.onResponse();
                        }
                    } else {
                        if (callbackListener != null) {
                            callbackListener.onErrorResponse(response.message());
                        }
                    }
                }
                @Override
                public void onFailure(@NonNull Call<PatientDto> call, @NonNull Throwable t) {
                    if (callbackListener != null) {
                        callbackListener.onErrorResponse(t.getMessage());
                    }
                }
            });
        }
    }
public void updatePatient ( final Patient patient , @ Nullable final DefaultResponseCallback callbackListener ) { PatientDtoUpdate patientDto = patient . getUpdatedPatientDto ( ) ; if ( NetworkUtils . isOnline ( ) ) { Call < PatientDto > call = restApi . updatePatient ( patientDto , patient . getUuid ( ) , "full" ) ; call . enqueue ( new Callback < PatientDto > ( ) { @ Override public void onResponse ( @ NonNull Call < PatientDto > call , @ NonNull Response < PatientDto > response ) { if ( response . isSuccessful ( ) ) { PatientDto patientDto = response . body ( ) ; patient . setBirthdate ( patientDto . getPerson ( ) . getBirthdate ( ) ) ; patient . setUuid ( patient . getUuid ( ) ) ; if ( patient . getPhoto ( ) != null ) { uploadPatientPhoto ( patient ) ; } new PatientDAO ( ) . updatePatient ( patient . getId ( ) , patient ) ; if ( callbackListener != null ) { callbackListener . onResponse ( ) ; } } else { if ( callbackListener != null ) { callbackListener . onErrorResponse ( response . message ( ) ) ; } } } @ Override public void onFailure ( @ NonNull Call < PatientDto > call , @ NonNull Throwable t ) { if ( callbackListener != null ) { callbackListener . onErrorResponse ( t . getMessage ( ) ) ; } } } ) ; } }
Update patient.
Update patient .