openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/library/api/services/EncounterService.java
/**
     * Sync encounter.
     *
     * @param encountercreate  the encountercreate
     * @param callbackListener the callback listener
     */
Sync encounter.
@param encountercreate  the encountercreate
@param callbackListener the callback listener
Sync encounter . @param encountercreate the encountercreate @param callbackListener the callback listener
public void syncEncounter(final Encountercreate encountercreate, @Nullable final DefaultResponseCallback callbackListener) {
        if (NetworkUtils.isOnline()) {
            Call<Encounter> call = apiService.createEncounter(encountercreate);
            call.enqueue(new Callback<Encounter>() {
                @Override
                public void onResponse(@NonNull Call<Encounter> call, @NonNull Response<Encounter> response) {
                    if (response.isSuccessful()) {
                        Encounter encounter = response.body();
                        linkvisit(encountercreate.getPatientId(), encountercreate.getFormname(), encounter, encountercreate);
                        encountercreate.setSynced(true);
                        AppDatabase.getDatabase(OpenmrsAndroid.getInstance().getApplicationContext())
                                .encounterCreateRoomDAO()
                                .updateExistingEncounter(encountercreate);
                        new VisitRepository().syncLastVitals(encountercreate.getPatient());
                        if (callbackListener != null) {
                            callbackListener.onResponse();
                        }
                    } else {
                        if (callbackListener != null) {
                            callbackListener.onErrorResponse(response.errorBody().toString());
                        }
                    }
                }
                @Override
                public void onFailure(@NonNull Call<Encounter> call, @NonNull Throwable t) {
                    if (callbackListener != null) {
                        callbackListener.onErrorResponse(t.getLocalizedMessage());
                    }
                }
            });
        } else {
            ToastUtil.error(getString(R.string.form_data_sync_is_off_message));
        }
    }
public void syncEncounter ( final Encountercreate encountercreate , @ Nullable final DefaultResponseCallback callbackListener ) { if ( NetworkUtils . isOnline ( ) ) { Call < Encounter > call = apiService . createEncounter ( encountercreate ) ; call . enqueue ( new Callback < Encounter > ( ) { @ Override public void onResponse ( @ NonNull Call < Encounter > call , @ NonNull Response < Encounter > response ) { if ( response . isSuccessful ( ) ) { Encounter encounter = response . body ( ) ; linkvisit ( encountercreate . getPatientId ( ) , encountercreate . getFormname ( ) , encounter , encountercreate ) ; encountercreate . setSynced ( true ) ; AppDatabase . getDatabase ( OpenmrsAndroid . getInstance ( ) . getApplicationContext ( ) ) . encounterCreateRoomDAO ( ) . updateExistingEncounter ( encountercreate ) ; new VisitRepository ( ) . syncLastVitals ( encountercreate . getPatient ( ) ) ; if ( callbackListener != null ) { callbackListener . onResponse ( ) ; } } else { if ( callbackListener != null ) { callbackListener . onErrorResponse ( response . errorBody ( ) . toString ( ) ) ; } } } @ Override public void onFailure ( @ NonNull Call < Encounter > call , @ NonNull Throwable t ) { if ( callbackListener != null ) { callbackListener . onErrorResponse ( t . getLocalizedMessage ( ) ) ; } } } ) ; } else { ToastUtil . error ( getString ( R . string . form_data_sync_is_off_message ) ) ; } }
Sync encounter.
Sync encounter .