openmrs-android-sdk/src/main/java/com/openmrs/android_sdk/library/api/repository/AllergyRepository.java
/**
     * Create allergy.
     *
     * @param patientUuid   the patient uuid
     * @param allergyCreate the allergy create
     * @param callback      the callback
     */
Create allergy.
@param patientUuid   the patient uuid
@param allergyCreate the allergy create
@param callback      the callback
Create allergy . @param patientUuid the patient uuid @param allergyCreate the allergy create @param callback the callback
public void createAllergy(String patientUuid, AllergyCreate allergyCreate, DefaultResponseCallback callback) {
        restApi.createAllergy(patientUuid, allergyCreate).enqueue(new Callback<Allergy>() {
            @Override
            public void onResponse(Call<Allergy> call, Response<Allergy> response) {
                if (response.isSuccessful()) {
                    callback.onResponse();
                    allergyRoomDAO.saveAllergy(AppDatabaseHelper.convert(response.body(), patientID));
                } else {
                    callback.onErrorResponse(OpenmrsAndroid.getInstance().getString(R.string.error_creating_allergy));
                }
            }
            @Override
            public void onFailure(Call<Allergy> call, Throwable t) {
                callback.onErrorResponse(t.getMessage());
            }
        });
    }
public void createAllergy ( String patientUuid , AllergyCreate allergyCreate , DefaultResponseCallback callback ) { restApi . createAllergy ( patientUuid , allergyCreate ) . enqueue ( new Callback < Allergy > ( ) { @ Override public void onResponse ( Call < Allergy > call , Response < Allergy > response ) { if ( response . isSuccessful ( ) ) { callback . onResponse ( ) ; allergyRoomDAO . saveAllergy ( AppDatabaseHelper . convert ( response . body ( ) , patientID ) ) ; } else { callback . onErrorResponse ( OpenmrsAndroid . getInstance ( ) . getString ( R . string . error_creating_allergy ) ) ; } } @ Override public void onFailure ( Call < Allergy > call , Throwable t ) { callback . onErrorResponse ( t . getMessage ( ) ) ; } } ) ; }
Create allergy.
Create allergy .