nus-yam/ex-repair huggingface dataset:
Program: 168318
Project: 168318
Buggy source:
/** 
 * Called after a device has been registered.
 * @param appContext        Application's context.
 * @param registrationToken The registration id returned by the Push Notifications service.
 */
@Override protected void onRegistered(@NotNull Context appContext,@NotNull String registrationToken){
  OpenPushHelper.notifyRegistrationEnd(new ProviderRegistrationResult(NokiaPushProvider.NAME,registrationToken));
}

Fixed version (ground truth):
/** 
 * Called after a device has been registered.
 * @param appContext        Application's context.
 * @param registrationToken The registration id returned by the Push Notifications service.
 */
@Override protected void onRegistered(@NotNull Context appContext,@NotNull String registrationToken){
  OpenPushHelper.notifyRegistrationEnd(new RegistrationResult(NokiaPushProvider.NAME,registrationToken));
}
Program: 168319
Project: 168319
Buggy source:
public synchronized void init(@NotNull Context context,@NotNull Options options){
  if (mInitStatus == INIT_NOT_STARTED || mInitStatus == INIT_ERROR) {
    mInitStatus=INIT_IN_PROGRESS;
    mOptions=options;
    mAppContext=context.getApplicationContext();
    PushProvider provider=getLastProvider();
    if (provider != null && provider.isAvailable()) {
      mCurrentProvider=provider;
    }
 else {
      provider=getNextCandidate(null);
    }
    if (provider != null) {
      provider.register();
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}

Fixed version (ground truth):
public synchronized void init(@NotNull Options options){
  if (mInitStatus == INIT_NOT_STARTED || mInitStatus == INIT_ERROR) {
    mInitStatus=INIT_IN_PROGRESS;
    mOptions=options;
    PushProvider provider=getNextCandidate(null);
    if (provider != null) {
      provider.register();
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str");
  }
}
Program: 168320
Project: 168320
Buggy source:
private OpenPushHelper(@NotNull Context context){
  mAppContext=context.getApplicationContext();
}

Fixed version (ground truth):
private OpenPushHelper(@NotNull Context context){
  mAppContext=context.getApplicationContext();
  sListener=new OpenPushListener(mAppContext);
  mInitStatus=getSavedInitStatus();
  PushProvider provider=getLastProvider();
  if (provider != null && provider.isAvailable() && mInitStatus == INIT_SUCCESS) {
    mCurrentProvider=provider;
  }
}
Program: 168321
Project: 168321
Buggy source:
private void onRegistrationResult(@NotNull final ProviderRegistrationResult e){
  if (e.getErrorCode() == OpenPushConstants.NO_ERROR) {
    mRetryNumber=0;
    mCurrentProvider=getProviderByName(e.getProviderName());
    saveProvider(mCurrentProvider);
  }
 else {
    final PushProvider lastProvider=getProviderByName(e.getProviderName());
    if (mOptions.getRetryPolice() != null && mRetryNumber < mOptions.getRetryPolice().tryCount()) {
      sHandler.postDelayed(new RetryRegistrationRunnable(lastProvider),mOptions.getRetryPolice().getDelay(mRetryNumber));
      mRetryNumber++;
    }
 else {
      PushProvider provider=getNextCandidate(lastProvider);
      if (provider != null) {
        provider.register();
      }
 else {
        mInitStatus=INIT_ERROR;
      }
    }
  }
}

Fixed version (ground truth):
private void onRegistrationResult(@NotNull final ProviderRegistrationResult result){
  final PushProvider provider=getProviderByName(result.getProviderName());
  Assert.assertNotNull(provider);
  if (result.isSuccess()) {
    mInitStatus=INIT_SUCCESS;
    saveInitStatus(INIT_SUCCESS);
    mRetryNumber=0;
    mCurrentProvider=provider;
    saveProvider(mCurrentProvider);
    sListener.onRegistered(result.getProviderName(),result.getRegistrationId());
  }
 else {
    if (result.isRecoverableError() && mOptions.getRetryPolice() != null && mRetryNumber < mOptions.getRetryPolice().tryCount()) {
      sHandler.postDelayed(new RetryRegistrationRunnable(provider),mOptions.getRetryPolice().getDelay(mRetryNumber));
      mRetryNumber++;
    }
 else {
      sListener.onRegistrationError(provider.getName(),result.getErrorCode());
      mRetryNumber=0;
      PushProvider nextProvider=getNextCandidate(provider);
      if (nextProvider != null) {
        nextProvider.register();
      }
 else {
        mInitStatus=INIT_ERROR;
        sListener.onNoAvailableProvider();
      }
    }
  }
}
Program: 168322
Project: 168322
Buggy source:
/** 
 * Gets the registration id.
 */
String getRegistrationId();

Fixed version (ground truth):
/** 
 * Gets the registration id.
 */
@Nullable String getRegistrationId();
Program: 168323
Project: 168323
Buggy source:
@Override public String getRegistrationId(){
  return mAdm.getRegistrationId();
}

Fixed version (ground truth):
@Override @Nullable public String getRegistrationId(){
  return mAdm.getRegistrationId();
}
Program: 168324
Project: 168324
Buggy source:
/** 
 * Called each time ADM delivers a message to an instance of your app.
 * @param intent An intent containing the message and associated data.You extract the message content from the set of extras attached to the  {@code com.amazon.device.messaging.intent.RECEIVE intent}. For an example of defining the behavior of the onMessage() callback, see SampleADMMessageHandler.java in the ADMMessenger sample app.
 */
@Override protected void onMessage(@NotNull Intent intent){
  OpenPushHelper.sendMessage(this,ADMProvider.NAME,intent.getExtras());
}

Fixed version (ground truth):
/** 
 * Called each time ADM delivers a message to an instance of your app.
 * @param intent An intent containing the message and associated data.You extract the message content from the set of extras attached to the  {@code com.amazon.device.messaging.intent.RECEIVE intent}. For an example of defining the behavior of the onMessage() callback, see SampleADMMessageHandler.java in the ADMMessenger sample app.
 */
@Override protected void onMessage(@NotNull Intent intent){
  OpenPushHelper.getListener().onMessage(ADMProvider.NAME,intent.getExtras());
}
Program: 168325
Project: 168325
Buggy source:
/** 
 * Called when a registration request succeeds. ADM may call this message in response to your app calling startRegister() or if ADM has updated the registration ID for this app instance.
 * @param registrationId The new registration ID for the instance of your app.Pass this value to your components that are using ADM to send messages. The  {@link com.amazon.device.messaging.ADM#getRegistrationId()}method also obtains the registration ID for an instance of your app.
 */
@Override protected void onRegistered(@NotNull String registrationId){
  OpenPushHelper.notifyRegistrationEnd(new ProviderRegistrationResult(ADMProvider.NAME,registrationId));
  OpenPushHelper.sendRegistered(this,ADMProvider.NAME,registrationId);
}

Fixed version (ground truth):
/** 
 * Called when a registration request succeeds. ADM may call this message in response to your app calling startRegister() or if ADM has updated the registration ID for this app instance.
 * @param registrationId The new registration ID for the instance of your app.Pass this value to your components that are using ADM to send messages. The  {@link com.amazon.device.messaging.ADM#getRegistrationId()}method also obtains the registration ID for an instance of your app.
 */
@Override protected void onRegistered(@NotNull String registrationId){
  OpenPushHelper.notifyRegistrationEnd(new ProviderRegistrationResult(ADMProvider.NAME,registrationId));
}
Program: 168326
Project: 168326
Buggy source:
/** 
 * Called on successful unregistration. This method may be called in response to your app calling startUnregister() or if ADM has unregistered the app for some reason (typically because the device has lost its association with a user's Amazon account). If this message is called, your app should notify your components that are using ADM to send messages, so that they know this instance of your app is no longer a valid recipient.
 * @param registrationId The registration ID for the instance of your app that is now unregistered.This ID is no longer a valid destination for messages. Calling  {@link com.amazon.device.messaging.ADM#getRegistrationId()}will show the registration ID for an unregistered app as   {@code null}.
 */
@Override protected void onUnregistered(@NotNull String registrationId){
  OpenPushHelper.sendUnregistered(this,ADMProvider.NAME,registrationId);
}

Fixed version (ground truth):
/** 
 * Called on successful unregistration. This method may be called in response to your app calling startUnregister() or if ADM has unregistered the app for some reason (typically because the device has lost its association with a user's Amazon account). If this message is called, your app should notify your components that are using ADM to send messages, so that they know this instance of your app is no longer a valid recipient.
 * @param registrationId The registration ID for the instance of your app that is now unregistered.This ID is no longer a valid destination for messages. Calling  {@link com.amazon.device.messaging.ADM#getRegistrationId()}will show the registration ID for an unregistered app as   {@code null}.
 */
@Override protected void onUnregistered(@NotNull String registrationId){
  OpenPushHelper.getListener().onUnregistered(ADMProvider.NAME,registrationId);
}
Program: 168327
Project: 168327
Buggy source:
@Override public void onClick(DialogInterface dialogInterface,int i){
  String filename=OpenMRS.getInstance().getOpenMRSDir() + File.separator + mOpenMRSLogger.getLogFilename();
  Intent email=new Intent(Intent.ACTION_SEND);
  email.putExtra(Intent.EXTRA_SUBJECT,"String_Node_Str");
  email.putExtra(Intent.EXTRA_TEXT,error);
  email.putExtra(Intent.EXTRA_STREAM,Uri.parse("String_Node_Str" + filename));
  email.setType("String_Node_Str");
  startActivity(Intent.createChooser(email,"String_Node_Str"));
}

Fixed version (ground truth):
@Override public void onClick(DialogInterface dialogInterface,int i){
  String filename=OpenMRS.getInstance().getOpenMRSDir() + File.separator + mOpenMRSLogger.getLogFilename();
  Intent email=new Intent(Intent.ACTION_SEND);
  email.putExtra(Intent.EXTRA_SUBJECT,R.string.error_email_subject_app_crashed);
  email.putExtra(Intent.EXTRA_TEXT,error);
  email.putExtra(Intent.EXTRA_STREAM,Uri.parse("String_Node_Str" + filename));
  email.setType("String_Node_Str");
  startActivity(Intent.createChooser(email,getString(R.string.choose_a_email_client)));
}
Program: 168328
Project: 168328
Buggy source:
public void showAppCrashDialog(String error){
  AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(this);
  alertDialogBuilder.setTitle(R.string.crash_dialog_title);
  alertDialogBuilder.setMessage(R.string.crash_dialog_message).setCancelable(false).setPositiveButton(R.string.crash_dialog_positive_button,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
).setNegativeButton(R.string.crash_dialog_negative_button,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      finishAffinity();
    }
  }
).setNeutralButton(R.string.crash_dialog_neutral_button,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      String filename=OpenMRS.getInstance().getOpenMRSDir() + File.separator + mOpenMRSLogger.getLogFilename();
      Intent email=new Intent(Intent.ACTION_SEND);
      email.putExtra(Intent.EXTRA_SUBJECT,"String_Node_Str");
      email.putExtra(Intent.EXTRA_TEXT,error);
      email.putExtra(Intent.EXTRA_STREAM,Uri.parse("String_Node_Str" + filename));
      email.setType("String_Node_Str");
      startActivity(Intent.createChooser(email,"String_Node_Str"));
    }
  }
);
  AlertDialog alertDialog=alertDialogBuilder.create();
  alertDialog.show();
}

Fixed version (ground truth):
public void showAppCrashDialog(String error){
  AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(this);
  alertDialogBuilder.setTitle(R.string.crash_dialog_title);
  alertDialogBuilder.setMessage(R.string.crash_dialog_message).setCancelable(false).setPositiveButton(R.string.crash_dialog_positive_button,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      dialog.cancel();
    }
  }
).setNegativeButton(R.string.crash_dialog_negative_button,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int id){
      finishAffinity();
    }
  }
).setNeutralButton(R.string.crash_dialog_neutral_button,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int i){
      String filename=OpenMRS.getInstance().getOpenMRSDir() + File.separator + mOpenMRSLogger.getLogFilename();
      Intent email=new Intent(Intent.ACTION_SEND);
      email.putExtra(Intent.EXTRA_SUBJECT,R.string.error_email_subject_app_crashed);
      email.putExtra(Intent.EXTRA_TEXT,error);
      email.putExtra(Intent.EXTRA_STREAM,Uri.parse("String_Node_Str" + filename));
      email.setType("String_Node_Str");
      startActivity(Intent.createChooser(email,getString(R.string.choose_a_email_client)));
    }
  }
);
  AlertDialog alertDialog=alertDialogBuilder.create();
  alertDialog.show();
}
Program: 168329
Project: 168329
Buggy source:
private void showNoInternetConnectionSnackbar(){
  Snackbar snackbar=Snackbar.make(findViewById(android.R.id.content),"String_Node_Str",Snackbar.LENGTH_SHORT);
  View sbView=snackbar.getView();
  TextView textView=(TextView)sbView.findViewById(android.support.design.R.id.snackbar_text);
  textView.setTextColor(Color.WHITE);
  snackbar.show();
}

Fixed version (ground truth):
private void showNoInternetConnectionSnackbar(){
  Snackbar snackbar=Snackbar.make(findViewById(android.R.id.content),getString(R.string.no_internet_connection_message),Snackbar.LENGTH_SHORT);
  View sbView=snackbar.getView();
  TextView textView=(TextView)sbView.findViewById(android.support.design.R.id.snackbar_text);
  textView.setTextColor(Color.WHITE);
  snackbar.show();
}
Program: 168331
Project: 168331
Buggy source:
@Override public void attachSnackbarToActivity(){
  Snackbar snackbar=Snackbar.make(getActivity().findViewById(R.id.patientDashboardContentFrame),"String_Node_Str",Snackbar.LENGTH_INDEFINITE);
  View view=snackbar.getView();
  TextView tv=(TextView)view.findViewById(android.support.design.R.id.snackbar_text);
  tv.setTextColor(Color.WHITE);
  snackbar.show();
}

Fixed version (ground truth):
@Override public void attachSnackbarToActivity(){
  Snackbar snackbar=Snackbar.make(getActivity().findViewById(R.id.patientDashboardContentFrame),getString(R.string.snackbar_no_internet_connection),Snackbar.LENGTH_INDEFINITE);
  View view=snackbar.getView();
  TextView tv=(TextView)view.findViewById(android.support.design.R.id.snackbar_text);
  tv.setTextColor(Color.WHITE);
  snackbar.show();
}
Program: 168332
Project: 168332
Buggy source:
@Override public void startFormDisplayActivity(Encounter encounter){
  Form form=encounter.getForm();
  if (form != null) {
    Intent intent=new Intent(getContext(),FormDisplayActivity.class);
    intent.putExtra(ApplicationConstants.BundleKeys.FORM_NAME,form.getName());
    intent.putExtra(ApplicationConstants.BundleKeys.PATIENT_ID_BUNDLE,encounter.getPatient().getId());
    intent.putExtra(ApplicationConstants.BundleKeys.VALUEREFERENCE,form.getValueReference());
    intent.putExtra(ApplicationConstants.BundleKeys.ENCOUNTERTYPE,encounter.getEncounterType().getUuid());
    intent.putParcelableArrayListExtra(ApplicationConstants.BundleKeys.FORM_FIELDS_LIST_BUNDLE,FormFieldsWrapper.create(encounter));
    startActivity(intent);
  }
 else {
    ToastUtil.notify("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void startFormDisplayActivity(Encounter encounter){
  Form form=encounter.getForm();
  if (form != null) {
    Intent intent=new Intent(getContext(),FormDisplayActivity.class);
    intent.putExtra(ApplicationConstants.BundleKeys.FORM_NAME,form.getName());
    intent.putExtra(ApplicationConstants.BundleKeys.PATIENT_ID_BUNDLE,encounter.getPatient().getId());
    intent.putExtra(ApplicationConstants.BundleKeys.VALUEREFERENCE,form.getValueReference());
    intent.putExtra(ApplicationConstants.BundleKeys.ENCOUNTERTYPE,encounter.getEncounterType().getUuid());
    intent.putParcelableArrayListExtra(ApplicationConstants.BundleKeys.FORM_FIELDS_LIST_BUNDLE,FormFieldsWrapper.create(encounter));
    startActivity(intent);
  }
 else {
    ToastUtil.notify(getString(R.string.form_error));
  }
}
Program: 168333
Project: 168333
Buggy source:
@Override protected void onHandleIntent(Intent intent){
  if (NetworkUtils.isOnline()) {
    PatientAndMatchesWrapper patientAndMatchesWrapper=new PatientAndMatchesWrapper();
    List<Patient> patientList=new PatientDAO().getUnsyncedPatients();
    final ListIterator<Patient> it=patientList.listIterator();
    while (it.hasNext()) {
      final Patient patient=it.next();
      fetchSimilarPatients(patient,patientAndMatchesWrapper);
    }
    if (!patientAndMatchesWrapper.getMatchingPatients().isEmpty()) {
      Intent intent1=new Intent(getApplicationContext(),MatchingPatientsActivity.class);
      intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent1.putExtra(ApplicationConstants.BundleKeys.CALCULATED_LOCALLY,calculatedLocally);
      intent1.putExtra(ApplicationConstants.BundleKeys.PATIENTS_AND_MATCHES,patientAndMatchesWrapper);
      startActivity(intent1);
    }
  }
 else {
    ToastUtil.error("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void onHandleIntent(Intent intent){
  if (NetworkUtils.isOnline()) {
    PatientAndMatchesWrapper patientAndMatchesWrapper=new PatientAndMatchesWrapper();
    List<Patient> patientList=new PatientDAO().getUnsyncedPatients();
    final ListIterator<Patient> it=patientList.listIterator();
    while (it.hasNext()) {
      final Patient patient=it.next();
      fetchSimilarPatients(patient,patientAndMatchesWrapper);
    }
    if (!patientAndMatchesWrapper.getMatchingPatients().isEmpty()) {
      Intent intent1=new Intent(getApplicationContext(),MatchingPatientsActivity.class);
      intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent1.putExtra(ApplicationConstants.BundleKeys.CALCULATED_LOCALLY,calculatedLocally);
      intent1.putExtra(ApplicationConstants.BundleKeys.PATIENTS_AND_MATCHES,patientAndMatchesWrapper);
      startActivity(intent1);
    }
  }
 else {
    ToastUtil.error(getString(R.string.activity_no_internet_connection) + getString(R.string.activity_sync_after_connection));
  }
}
Program: 168335
Project: 168335
Buggy source:
public void onDateSet(DatePicker datepicker,int selectedyear,int selectedmonth,int selectedday){
  eddob.setText(selectedday + "String_Node_Str" + selectedmonth+ "String_Node_Str"+ selectedyear);
  birthdate=new LocalDate(selectedyear,selectedmonth,selectedday);
  bdt=birthdate.toDateTimeAtStartOfDay().toDateTime();
}

Fixed version (ground truth):
public void onDateSet(DatePicker datepicker,int selectedyear,int selectedmonth,int selectedday){
  selectedmonth++;
  eddob.setText(selectedday + "String_Node_Str" + selectedmonth+ "String_Node_Str"+ selectedyear);
  birthdate=new LocalDate(selectedyear,selectedmonth,selectedday);
  bdt=birthdate.toDateTimeAtStartOfDay().toDateTime();
}
Program: 168337
Project: 168337
Buggy source:
@Override public void syncVisits(){
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Visit>> call=restApi.findVisitsByPatientUUID(mPatient.getUuid(),"String_Node_Str");
  call.enqueue(new Callback<Results<Visit>>(){
    @Override public void onResponse(    Call<Results<Visit>> call,    Response<Results<Visit>> response){
      if (response.isSuccessful()) {
        List<Visit> visits=response.body().getResults();
        VisitDAO visitDAO=new VisitDAO();
        for (        Visit visit : visits) {
          long visitId=visitDAO.getVisitsIDByUUID(visit.getUuid());
          if (visitId > 0) {
            visitDAO.updateVisit(visit,visitId,mPatient.getId());
          }
 else {
            visitDAO.saveVisit(visit,mPatient.getId());
          }
          mPatientVisitsView.setVisitsToDisplay(visits);
        }
        showStartVisitDialog();
      }
 else {
        ToastUtil.error(response.message());
      }
      mPatientVisitsView.dismissStartVisitDialog();
    }
    @Override public void onFailure(    Call<Results<Visit>> call,    Throwable t){
      ToastUtil.error(t.getMessage());
      mPatientVisitsView.dismissStartVisitDialog();
    }
  }
);
}

Fixed version (ground truth):
@Override public void syncVisits(){
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Visit>> call=restApi.findVisitsByPatientUUID(mPatient.getUuid(),"String_Node_Str");
  call.enqueue(new Callback<Results<Visit>>(){
    @Override public void onResponse(    Call<Results<Visit>> call,    Response<Results<Visit>> response){
      if (response.isSuccessful()) {
        List<Visit> visits=response.body().getResults();
        VisitDAO visitDAO=new VisitDAO();
        for (        Visit visit : visits) {
          long visitId=visitDAO.getVisitsIDByUUID(visit.getUuid());
          if (visitId > 0) {
            visitDAO.updateVisit(visit,visitId,mPatient.getId());
          }
 else {
            visitDAO.saveVisit(visit,mPatient.getId());
          }
          mPatientVisitsView.setVisitsToDisplay(visitDAO.getVisitsByPatientID(mPatient.getId()));
        }
        showStartVisitDialog();
      }
 else {
        ToastUtil.error(response.message());
      }
      mPatientVisitsView.dismissStartVisitDialog();
    }
    @Override public void onFailure(    Call<Results<Visit>> call,    Throwable t){
      ToastUtil.error(t.getMessage());
      mPatientVisitsView.dismissStartVisitDialog();
    }
  }
);
}
Program: 168338
Project: 168338
Buggy source:
public boolean checkfields(){
  boolean emp=true, valid=true;
  for (  InputField field : inputFields) {
    RangeEditText ed=(RangeEditText)getActivity().findViewById(field.getId());
    if (!isEmpty(ed)) {
      emp=false;
      Double inp=Double.parseDouble(ed.getText().toString());
      if (ed.getUpperlimit() != -1.0 && ed.getUpperlimit() != -1.0) {
        if (ed.getUpperlimit() < inp || ed.getLowerlimit() > inp) {
          ToastUtil.error("String_Node_Str" + ed.getName() + "String_Node_Str"+ ed.getLowerlimit()+ "String_Node_Str"+ ed.getUpperlimit());
          ed.setTextColor(ContextCompat.getColor(OpenMRS.getInstance(),R.color.red));
          valid=false;
        }
      }
    }
  }
  if (emp) {
    ToastUtil.error("String_Node_Str");
    return false;
  }
  return valid;
}

Fixed version (ground truth):
public boolean checkfields(){
  boolean emp=true, valid=true;
  for (  InputField field : inputFields) {
    RangeEditText ed=(RangeEditText)getActivity().findViewById(field.getId());
    if (!isEmpty(ed)) {
      emp=false;
      if (ed.getText().toString().charAt(0) != '.') {
        Double inp=Double.parseDouble(ed.getText().toString());
        if (ed.getUpperlimit() != -1.0 && ed.getUpperlimit() != -1.0) {
          if (ed.getUpperlimit() < inp || ed.getLowerlimit() > inp) {
            ToastUtil.error("String_Node_Str" + ed.getName() + "String_Node_Str"+ ed.getLowerlimit()+ "String_Node_Str"+ ed.getUpperlimit());
            ed.setTextColor(ContextCompat.getColor(OpenMRS.getInstance(),R.color.red));
            valid=false;
          }
        }
      }
 else {
        ToastUtil.error("String_Node_Str" + ed.getName() + "String_Node_Str");
        ed.setTextColor(ContextCompat.getColor(OpenMRS.getInstance(),R.color.red));
        valid=false;
      }
    }
  }
  if (emp) {
    ToastUtil.error("String_Node_Str");
    return false;
  }
  return valid;
}
Program: 168340
Project: 168340
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View root=inflater.inflate(R.layout.fragment_form_display,container,false);
  getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
  mParent=(LinearLayout)root.findViewById(R.id.viewholder);
  return root;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View root=inflater.inflate(R.layout.fragment_form_display,container,false);
  getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
  mParent=(LinearLayout)root.findViewById(R.id.sectionContainer);
  return root;
}
Program: 168341
Project: 168341
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionSynchronize:
    mPresenter.synchronizePatient();
case R.id.actionDelete:
  mPresenter.deletePatient();
this.getActivity().finish();
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionSynchronize:
    mPresenter.synchronizePatient();
  break;
case R.id.actionDelete:
mPresenter.deletePatient();
this.getActivity().finish();
break;
}
return super.onOptionsItemSelected(item);
}
Program: 168342
Project: 168342
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionDelete:
    mPresenter.deletePatient();
  this.getActivity().finish();
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionDelete:
    mPresenter.deletePatient();
  this.getActivity().finish();
break;
}
return super.onOptionsItemSelected(item);
}
Program: 168343
Project: 168343
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionStartVisit:
    mPresenter.syncVisits();
case R.id.actionDelete:
  mPresenter.deletePatient();
this.getActivity().finish();
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionStartVisit:
    mPresenter.syncVisits();
  break;
case R.id.actionDelete:
mPresenter.deletePatient();
this.getActivity().finish();
break;
}
return super.onOptionsItemSelected(item);
}
Program: 168344
Project: 168344
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionDelete:
    mPresenter.deletePatient();
  this.getActivity().finish();
default :
return super.onOptionsItemSelected(item);
}
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  int id=item.getItemId();
switch (id) {
case R.id.actionDelete:
    mPresenter.deletePatient();
  this.getActivity().finish();
break;
}
return super.onOptionsItemSelected(item);
}
Program: 168345
Project: 168345
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_matching_patients);
  Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
  if (toolbar != null) {
    toolbar.setTitle(getString(R.string.matching_patients_toolbar_tittle));
    setSupportActionBar(toolbar);
  }
  MatchingPatientsFragment matchingPatientsFragment=(MatchingPatientsFragment)getSupportFragmentManager().findFragmentById(R.id.matchingPatientsContentFrame);
  if (matchingPatientsFragment == null) {
    matchingPatientsFragment=MatchingPatientsFragment.newInstance();
  }
  if (!matchingPatientsFragment.isAdded()) {
    addFragmentToActivity(getSupportFragmentManager(),matchingPatientsFragment,R.id.matchingPatientsContentFrame);
  }
  PatientAndMatchesWrapper patientAndMatchesWrapper=(PatientAndMatchesWrapper)getIntent().getSerializableExtra("String_Node_Str");
  new MatchingPatientsPresenter(matchingPatientsFragment,patientAndMatchesWrapper.getMatchingPatients());
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_matching_patients);
  Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
  if (toolbar != null) {
    toolbar.setTitle(getString(R.string.matching_patients_toolbar_tittle));
    setSupportActionBar(toolbar);
  }
  MatchingPatientsFragment matchingPatientsFragment=(MatchingPatientsFragment)getSupportFragmentManager().findFragmentById(R.id.matchingPatientsContentFrame);
  if (matchingPatientsFragment == null) {
    matchingPatientsFragment=MatchingPatientsFragment.newInstance();
  }
  if (!matchingPatientsFragment.isAdded()) {
    addFragmentToActivity(getSupportFragmentManager(),matchingPatientsFragment,R.id.matchingPatientsContentFrame);
  }
  if (getIntent().getExtras().getBoolean(ApplicationConstants.BundleKeys.CALCULATED_LOCALLY,false)) {
    showToast(getString(R.string.registration_core_info));
  }
  PatientAndMatchesWrapper patientAndMatchesWrapper=(PatientAndMatchesWrapper)getIntent().getSerializableExtra(ApplicationConstants.BundleKeys.PATIENTS_AND_MATCHES);
  new MatchingPatientsPresenter(matchingPatientsFragment,patientAndMatchesWrapper.getMatchingPatients());
}
Program: 168347
Project: 168347
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.activity_register_patient);
  Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  }
  RegisterPatientFragment registerPatientFragment=(RegisterPatientFragment)getSupportFragmentManager().findFragmentById(R.id.registerPatientContentFrame);
  if (registerPatientFragment == null) {
    registerPatientFragment=RegisterPatientFragment.newInstance();
  }
  if (!registerPatientFragment.isActive()) {
    addFragmentToActivity(getSupportFragmentManager(),registerPatientFragment,R.id.registerPatientContentFrame);
  }
  mPresenter=new SyncPatientPresenter(registerPatientFragment);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.activity_register_patient);
  Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  }
  RegisterPatientFragment registerPatientFragment=(RegisterPatientFragment)getSupportFragmentManager().findFragmentById(R.id.registerPatientContentFrame);
  if (registerPatientFragment == null) {
    registerPatientFragment=RegisterPatientFragment.newInstance();
  }
  if (!registerPatientFragment.isActive()) {
    addFragmentToActivity(getSupportFragmentManager(),registerPatientFragment,R.id.registerPatientContentFrame);
  }
  mPresenter=new RegisterPatientPresenter(registerPatientFragment);
}
Program: 168348
Project: 168348
Buggy source:
void setProgressBarVisibility(int visibility);

Fixed version (ground truth):
void setProgressBarVisibility(boolean visibility);
Program: 168349
Project: 168349
Buggy source:
@Override public void showSimilarPatientDialog(List<Patient> patients,Patient newPatient){
  setProgressBarVisibility(View.GONE);
  CustomDialogBundle similarPatientsDialog=new CustomDialogBundle();
  similarPatientsDialog.setTitleViewMessage(getString(R.string.similar_patients_dialog_title));
  similarPatientsDialog.setRightButtonText(getString(R.string.dialog_button_register_new));
  similarPatientsDialog.setRightButtonAction(CustomFragmentDialog.OnClickAction.REGISTER_PATIENT);
  similarPatientsDialog.setLeftButtonText(getString(R.string.dialog_button_cancel));
  similarPatientsDialog.setLeftButtonAction(CustomFragmentDialog.OnClickAction.CANCEL_REGISTERING);
  similarPatientsDialog.setPatientsList(patients);
  similarPatientsDialog.setNewPatient(newPatient);
  ((RegisterPatientActivity)this.getActivity()).createAndShowDialog(similarPatientsDialog,ApplicationConstants.DialogTAG.SIMILAR_PATIENTS_TAG);
}

Fixed version (ground truth):
@Override public void showSimilarPatientDialog(List<Patient> patients,Patient newPatient){
  setProgressBarVisibility(false);
  CustomDialogBundle similarPatientsDialog=new CustomDialogBundle();
  similarPatientsDialog.setTitleViewMessage(getString(R.string.similar_patients_dialog_title));
  similarPatientsDialog.setRightButtonText(getString(R.string.dialog_button_register_new));
  similarPatientsDialog.setRightButtonAction(CustomFragmentDialog.OnClickAction.REGISTER_PATIENT);
  similarPatientsDialog.setLeftButtonText(getString(R.string.dialog_button_cancel));
  similarPatientsDialog.setLeftButtonAction(CustomFragmentDialog.OnClickAction.CANCEL_REGISTERING);
  similarPatientsDialog.setPatientsList(patients);
  similarPatientsDialog.setNewPatient(newPatient);
  ((RegisterPatientActivity)this.getActivity()).createAndShowDialog(similarPatientsDialog,ApplicationConstants.DialogTAG.SIMILAR_PATIENTS_TAG);
}
Program: 168350
Project: 168350
Buggy source:
@Override public void setProgressBarVisibility(int visibility){
  progressBar.setVisibility(visibility);
}

Fixed version (ground truth):
@Override public void setProgressBarVisibility(boolean visibility){
  progressBar.setVisibility(visibility ? View.VISIBLE : View.GONE);
}
Program: 168351
Project: 168351
Buggy source:
private void fetchSimilarPatientsFromServer(Patient patient,PatientAndMatchesWrapper patientAndMatchesWrapper) throws IOException {
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Patient>> patientCall=restApi.getSimilarPatients(patient.toMap());
  Response<Results<Patient>> patientsResp=patientCall.execute();
  if (patientsResp.isSuccessful()) {
    List<Patient> patientList=patientsResp.body().getResults();
    if (!patientList.isEmpty()) {
      patientAndMatchesWrapper.addToList(new PatientAndMatchingPatients(patient,patientList));
    }
 else {
      new PatientApi().syncPatient(patient);
    }
  }
}

Fixed version (ground truth):
private void fetchSimilarPatientsFromServer(Patient patient,PatientAndMatchesWrapper patientAndMatchesWrapper) throws IOException {
  calculatedLocally=false;
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Patient>> patientCall=restApi.getSimilarPatients(patient.toMap());
  Response<Results<Patient>> patientsResp=patientCall.execute();
  if (patientsResp.isSuccessful()) {
    List<Patient> patientList=patientsResp.body().getResults();
    if (!patientList.isEmpty()) {
      patientAndMatchesWrapper.addToList(new PatientAndMatchingPatients(patient,patientList));
    }
 else {
      new PatientApi().syncPatient(patient);
    }
  }
}
Program: 168352
Project: 168352
Buggy source:
private void fetchPatientsAndCalculateLocally(Patient patient,PatientAndMatchesWrapper patientAndMatchesWrapper) throws IOException {
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Patient>> patientCall=restApi.getPatients(patient.getPerson().getName().getGivenName(),ApplicationConstants.API.FULL);
  Response<Results<Patient>> resp=patientCall.execute();
  if (resp.isSuccessful()) {
    List<Patient> similarPatient=new PatientComparator().findSimilarPatient(resp.body().getResults(),patient);
    if (!similarPatient.isEmpty()) {
      patientAndMatchesWrapper.addToList(new PatientAndMatchingPatients(patient,similarPatient));
    }
 else {
      new PatientApi().syncPatient(patient);
    }
  }
  ToastUtil.notifyLong(getApplicationContext().getResources().getString(R.string.registration_core_info));
}

Fixed version (ground truth):
private void fetchPatientsAndCalculateLocally(Patient patient,PatientAndMatchesWrapper patientAndMatchesWrapper) throws IOException {
  calculatedLocally=true;
  RestApi restApi=RestServiceBuilder.createService(RestApi.class);
  Call<Results<Patient>> patientCall=restApi.getPatients(patient.getPerson().getName().getGivenName(),ApplicationConstants.API.FULL);
  Response<Results<Patient>> resp=patientCall.execute();
  if (resp.isSuccessful()) {
    List<Patient> similarPatient=new PatientComparator().findSimilarPatient(resp.body().getResults(),patient);
    if (!similarPatient.isEmpty()) {
      patientAndMatchesWrapper.addToList(new PatientAndMatchingPatients(patient,similarPatient));
    }
 else {
      new PatientApi().syncPatient(patient);
    }
  }
}
Program: 168353
Project: 168353
Buggy source:
@Override protected void onHandleIntent(Intent intent){
  if (NetworkUtils.isOnline()) {
    PatientAndMatchesWrapper patientAndMatchesWrapper=new PatientAndMatchesWrapper();
    List<Patient> patientList=new PatientDAO().getUnsyncedPatients();
    final ListIterator<Patient> it=patientList.listIterator();
    while (it.hasNext()) {
      final Patient patient=it.next();
      fetchSimilarPatients(patient,patientAndMatchesWrapper);
    }
    if (!patientAndMatchesWrapper.getMatchingPatients().isEmpty()) {
      Intent intent1=new Intent(getApplicationContext(),MatchingPatientsActivity.class);
      intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent1.putExtra("String_Node_Str",patientAndMatchesWrapper);
      startActivity(intent1);
    }
  }
 else {
    ToastUtil.error("String_Node_Str" + "String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void onHandleIntent(Intent intent){
  if (NetworkUtils.isOnline()) {
    PatientAndMatchesWrapper patientAndMatchesWrapper=new PatientAndMatchesWrapper();
    List<Patient> patientList=new PatientDAO().getUnsyncedPatients();
    final ListIterator<Patient> it=patientList.listIterator();
    while (it.hasNext()) {
      final Patient patient=it.next();
      fetchSimilarPatients(patient,patientAndMatchesWrapper);
    }
    if (!patientAndMatchesWrapper.getMatchingPatients().isEmpty()) {
      Intent intent1=new Intent(getApplicationContext(),MatchingPatientsActivity.class);
      intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      intent1.putExtra(ApplicationConstants.BundleKeys.CALCULATED_LOCALLY,calculatedLocally);
      intent1.putExtra(ApplicationConstants.BundleKeys.PATIENTS_AND_MATCHES,patientAndMatchesWrapper);
      startActivity(intent1);
    }
  }
 else {
    ToastUtil.error("String_Node_Str" + "String_Node_Str");
  }
}
Program: 168355
Project: 168355
Buggy source:
public static Location findLocationByName(String name){
  Location location=new Location();
  String where=String.format("String_Node_Str",LocationTable.Column.DISPLAY);
  String[] whereArgs=new String[]{name};
  DBOpenHelper helper=OpenMRSDBOpenHelper.getInstance().getDBOpenHelper();
  final Cursor cursor=helper.getReadableDatabase().query(LocationTable.TABLE_NAME,null,where,whereArgs,null,null,null);
  if (null != cursor) {
    try {
      if (cursor.moveToFirst()) {
        location=cursorToLocation(cursor);
      }
    }
  finally {
      cursor.close();
    }
  }
  return location;
}

Fixed version (ground truth):
public static Location findLocationByName(String name){
  if (!StringUtils.notNull(name)) {
    return null;
  }
  Location location=new Location();
  String where=String.format("String_Node_Str",LocationTable.Column.DISPLAY);
  String[] whereArgs=new String[]{name};
  DBOpenHelper helper=OpenMRSDBOpenHelper.getInstance().getDBOpenHelper();
  final Cursor cursor=helper.getReadableDatabase().query(LocationTable.TABLE_NAME,null,where,whereArgs,null,null,null);
  if (null != cursor) {
    try {
      if (cursor.moveToFirst()) {
        location=cursorToLocation(cursor);
      }
    }
  finally {
      cursor.close();
    }
  }
  return location;
}
Program: 168356
Project: 168356
Buggy source:
public long insertVisit(SQLiteDatabase db,Visit visit){
  long visitId;
  SQLiteStatement visitStatement=db.compileStatement(mVisitTable.insertIntoTableDefinition());
  try {
    db.beginTransaction();
    bindString(1,visit.getUuid(),visitStatement);
    bindLong(2,visit.getPatient().getId(),visitStatement);
    bindString(3,visit.getVisitType().getDisplay(),visitStatement);
    bindString(4,visit.getLocation().getDisplay(),visitStatement);
    bindString(5,visit.getStartDatetime(),visitStatement);
    bindString(6,visit.getStopDatetime(),visitStatement);
    visitId=visitStatement.executeInsert();
    visitStatement.clearBindings();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
    visitStatement.close();
  }
  return visitId;
}

Fixed version (ground truth):
public long insertVisit(SQLiteDatabase db,Visit visit){
  long visitId;
  SQLiteStatement visitStatement=db.compileStatement(mVisitTable.insertIntoTableDefinition());
  try {
    db.beginTransaction();
    bindString(1,visit.getUuid(),visitStatement);
    bindLong(2,visit.getPatient().getId(),visitStatement);
    bindString(3,visit.getVisitType().getDisplay(),visitStatement);
    if (visit.getLocation() != null) {
      bindString(4,visit.getLocation().getDisplay(),visitStatement);
    }
    bindString(5,visit.getStartDatetime(),visitStatement);
    bindString(6,visit.getStopDatetime(),visitStatement);
    visitId=visitStatement.executeInsert();
    visitStatement.clearBindings();
    db.setTransactionSuccessful();
  }
  finally {
    db.endTransaction();
    visitStatement.close();
  }
  return visitId;
}
Program: 168357
Project: 168357
Buggy source:
public int updateVisit(SQLiteDatabase db,long visitID,Visit visit){
  ContentValues newValues=new ContentValues();
  newValues.put(VisitTable.Column.UUID,visit.getUuid());
  newValues.put(VisitTable.Column.PATIENT_KEY_ID,visit.getPatient().getId());
  newValues.put(VisitTable.Column.VISIT_TYPE,visit.getVisitType().getDisplay());
  newValues.put(VisitTable.Column.VISIT_PLACE,visit.getLocation().getDisplay());
  newValues.put(VisitTable.Column.START_DATE,visit.getStartDatetime());
  newValues.put(VisitTable.Column.STOP_DATE,visit.getStopDatetime());
  String[] whereArgs=new String[]{String.valueOf(visitID)};
  return db.update(VisitTable.TABLE_NAME,newValues,WHERE_ID_CLAUSE,whereArgs);
}

Fixed version (ground truth):
public int updateVisit(SQLiteDatabase db,long visitID,Visit visit){
  ContentValues newValues=new ContentValues();
  newValues.put(VisitTable.Column.UUID,visit.getUuid());
  newValues.put(VisitTable.Column.PATIENT_KEY_ID,visit.getPatient().getId());
  newValues.put(VisitTable.Column.VISIT_TYPE,visit.getVisitType().getDisplay());
  if (visit.getLocation() != null) {
    newValues.put(VisitTable.Column.VISIT_PLACE,visit.getLocation().getDisplay());
  }
  newValues.put(VisitTable.Column.START_DATE,visit.getStartDatetime());
  newValues.put(VisitTable.Column.STOP_DATE,visit.getStopDatetime());
  String[] whereArgs=new String[]{String.valueOf(visitID)};
  return db.update(VisitTable.TABLE_NAME,newValues,WHERE_ID_CLAUSE,whereArgs);
}
Program: 168358
Project: 168358
Buggy source:
private List<Patient> getPatientsFilteredByQuery(List<Patient> patientList,String query){
  List<Patient> filteredList=new ArrayList<>();
  query=query.toLowerCase();
  for (  Patient patient : patientList) {
    String patientName=patient.getPerson().getNames().get(0).getGivenName().toLowerCase();
    String patientSurname=patient.getPerson().getNames().get(0).getFamilyName().toLowerCase();
    String patientIdentifier=patient.getIdentifier().getIdentifier();
    boolean isPatientNameFitQuery=patientName.length() >= query.length() && patientName.substring(0,query.length()).equals(query);
    boolean isPatientSurnameFitQuery=patientSurname.length() >= query.length() && patientSurname.substring(0,query.length()).equals(query);
    boolean isPatientIdentifierFitQuery=patientIdentifier.length() >= query.length() && patientIdentifier.substring(0,query.length()).equals(query);
    if (isPatientNameFitQuery || isPatientSurnameFitQuery || isPatientIdentifierFitQuery) {
      filteredList.add(patient);
    }
  }
  return filteredList;
}

Fixed version (ground truth):
private List<Patient> getPatientsFilteredByQuery(List<Patient> patientList,String query){
  List<Patient> filteredList=new ArrayList<>();
  query=query.toLowerCase();
  for (  Patient patient : patientList) {
    String patientName=patient.getPerson().getNames().get(0).getGivenName().toLowerCase();
    String patientSurname=patient.getPerson().getNames().get(0).getFamilyName().toLowerCase();
    String patientIdentifier=patient.getIdentifier().getIdentifier();
    boolean isPatientNameFitQuery=patientName.length() >= query.length() && patientName.substring(0,query.length()).equals(query);
    boolean isPatientSurnameFitQuery=patientSurname.length() >= query.length() && patientSurname.substring(0,query.length()).equals(query);
    boolean isPatientIdentifierFitQuery=false;
    if (patientIdentifier != null) {
      isPatientIdentifierFitQuery=patientIdentifier.length() >= query.length() && patientIdentifier.substring(0,query.length()).equals(query);
    }
    if (isPatientNameFitQuery || isPatientSurnameFitQuery || isPatientIdentifierFitQuery) {
      filteredList.add(patient);
    }
  }
  return filteredList;
}
Program: 168359
Project: 168359
Buggy source:
public static boolean isNetworkAvailable(){
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(OpenMRS.getInstance());
  boolean toggle=prefs.getBoolean("String_Node_Str",false);
  if (toggle == true) {
    ConnectivityManager connectivityManager=(ConnectivityManager)OpenMRS.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo=connectivityManager.getActiveNetworkInfo();
    boolean isConnected=activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();
    if (isConnected)     return true;
 else {
      SharedPreferences.Editor editor=prefs.edit();
      editor.putBoolean("String_Node_Str",false);
      editor.commit();
      return false;
    }
  }
 else   return false;
}

Fixed version (ground truth):
public static boolean isNetworkAvailable(){
  final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(OpenMRS.getInstance());
  boolean toggle=prefs.getBoolean("String_Node_Str",false);
  if (toggle) {
    ConnectivityManager connectivityManager=(ConnectivityManager)OpenMRS.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo=connectivityManager.getActiveNetworkInfo();
    boolean isConnected=activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();
    if (isConnected)     return true;
 else {
      SharedPreferences.Editor editor=prefs.edit();
      editor.putBoolean("String_Node_Str",false);
      editor.commit();
      return false;
    }
  }
 else   return false;
}