public void setUpCheckBoxLogic(final ViewHolder holder, final Patient patient) {
    if (new PatientDAO().userDoesNotExist(patient.getUuid())) {
      holder.mAvailableOfflineCheckbox.setChecked(false);
      holder.mAvailableOfflineCheckbox.setVisibility(View.VISIBLE);
      holder.mAvailableOfflineCheckbox.setText(
          mContext.getString(R.string.find_patients_row_checkbox_download_label));
      holder.mAvailableOfflineCheckbox.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (((CheckBox) v).isChecked()) {
                long patientId = new PatientDAO().savePatient(patient);
                ((ACBaseActivity) mContext).showProgressDialog(R.string.save_patient_data_dialog);
                new VisitsManager()
                    .findVisitsByPatientUUID(
                        VisitsHelper.createVisitsByPatientUUIDListener(
                            patient.getUuid(), patientId, (ACBaseActivity) mContext));
                disableCheckBox(holder);

                if (mContext instanceof FindPatientsActivity) {
                  FragmentManager fm =
                      ((FindPatientsActivity) mContext).getSupportFragmentManager();
                  FindPatientInDatabaseFragment fragment =
                      (FindPatientInDatabaseFragment)
                          fm.getFragments().get(FindPatientsActivity.TabHost.DOWNLOADED_TAB_POS);

                  fragment.updatePatientsInDatabaseList();
                }
              }
            }
          });
    } else {
      disableCheckBox(holder);
    }
  }
 private void startCaptureVitals() {
   try {
     Intent intent = new Intent(this, FormEntryActivity.class);
     Uri formURI =
         new FormsDAO(this.getContentResolver())
             .getFormURI(ApplicationConstants.FormNames.VITALS_XFORM);
     intent.setData(formURI);
     intent.putExtra(ApplicationConstants.BundleKeys.PATIENT_UUID_BUNDLE, mPatient.getUuid());
     this.startActivityForResult(intent, CAPTURE_VITALS_REQUEST_CODE);
   } catch (Exception e) {
     ToastUtil.showLongToast(this, ToastUtil.ToastType.ERROR, R.string.failed_to_open_vitals_form);
     OpenMRS.getInstance().getOpenMRSLogger().d(e.toString());
   }
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   switch (resultCode) {
     case RESULT_OK:
       String path = data.getData().toString();
       String instanceID = path.substring(path.lastIndexOf('/') + 1);
       FormManagerBundle bundle =
           FormsHelper.createBundle(
               new FormsDAO(getContentResolver())
                   .getSurveysSubmissionDataFromFormInstanceId(instanceID)
                   .getFormInstanceFilePath(),
               mPatient.getUuid(),
               mPatient.getId(),
               mVisit.getUuid());
       mFormsManager.uploadXFormWithMultiPartRequest(
           FormsHelper.createUploadXFormWithMultiPartRequestListener(bundle, this));
       break;
     case RESULT_CANCELED:
       finish();
     default:
       break;
   }
 }