private void editPatients(final Patients patient) {
    final Dialog d = new Dialog(getActivity());
    d.setTitle("Update Entry");
    d.setContentView(R.layout.input_patient_entry);
    TextView header = (TextView) d.findViewById(R.id.header);
    header.setText("Update Contact Entry");
    final TextView first_name = (TextView) d.findViewById(R.id.fname);
    final TextView middle_name = (TextView) d.findViewById(R.id.mi);
    final TextView last_name = (TextView) d.findViewById(R.id.lname);
    final TextView address = (TextView) d.findViewById(R.id.addr);
    final TextView age = (TextView) d.findViewById(R.id.age);
    final TextView medical_history = (TextView) d.findViewById(R.id.med_hist);
    RadioGroup status_group = (RadioGroup) d.findViewById(R.id.status);
    status_group.setVisibility(RadioGroup.GONE);

    Button save = (Button) d.findViewById(R.id.add);
    Button cancel = (Button) d.findViewById(R.id.cancel);

    save.setText("Update");
    first_name.setText(patient.getFname());
    middle_name.setText(patient.getMi());
    last_name.setText(patient.getLname());
    address.setText(patient.getAddr());
    age.setText(Integer.toString(patient.getAge()));
    medical_history.setText(patient.getMed_history());

    save.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            Patients p = patient;
            p.setFname(first_name.getText().toString());
            p.setMi(middle_name.getText().toString());
            p.setLname(last_name.getText().toString());
            p.setAddr(address.getText().toString());
            p.setAge(Integer.parseInt(age.getText().toString()));
            p.setMed_history(medical_history.getText().toString());
            help.update(p, Helper.NORMAL);
            d.cancel();
            Toast.makeText(getActivity(), "Patient Details Updated!", Toast.LENGTH_SHORT).show();
            loadPatientMasterList();
            loadPatientList(patient.getPat_status());
          }
        });
    cancel.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            d.cancel();
          }
        });

    d.show();
  }
  private void viewPatient(final Patients p) {
    Dialog info = new Dialog(getActivity());
    info.setTitle("Patient Details");
    info.setContentView(R.layout.patient_list_item_details_fragment);

    TextView fname = (TextView) info.findViewById(R.id.first_name_info);
    TextView mname = (TextView) info.findViewById(R.id.middle_name_info);
    TextView lname = (TextView) info.findViewById(R.id.last_name_info);
    TextView age = (TextView) info.findViewById(R.id.age);
    TextView status = (TextView) info.findViewById(R.id.status_info);
    TextView address = (TextView) info.findViewById(R.id.address_info);
    TextView hosp_name = (TextView) info.findViewById(R.id.hosp_name_info);
    TextView hosp_room = (TextView) info.findViewById(R.id.hosp_room_info);

    Button see_diag_info = (Button) info.findViewById(R.id.button1);
    see_diag_info.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            Dialog details = new Dialog(getActivity());
            details.setTitle("Medical History");
            TextView history = new TextView(getActivity());
            history.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
            history.setText(p.getMed_history());
            details.setContentView(history);
            details.show();
          }
        });

    fname.setText(p.getFname());
    mname.setText(p.getMi());
    lname.setText(p.getLname());
    age.setText(Integer.toString(p.getAge()));
    if (p.getPat_status() == 1) {
      status.setText("In-Patient");
      hosp_name.setText(p.getHosp_name());
      hosp_room.setText(p.getHosp_room());
    }

    if (p.getPat_status() == 2) {
      status.setText("Out-Patient");
      hosp_name.setText("None..");
      hosp_room.setText("None..");
      hosp_name.setEnabled(false);
      hosp_room.setEnabled(false);
    }

    address.setText(p.getAddr());
    info.show();
  }
  private void editPatients(final Patients patient) {
    final Dialog d = new Dialog(getActivity());
    d.setTitle("Update Entry");
    d.setContentView(R.layout.input_patient_entry);
    TextView header = (TextView) d.findViewById(R.id.header);
    header.setText("Update Contact Entry");
    final TextView first_name = (TextView) d.findViewById(R.id.fname);
    final TextView middle_name = (TextView) d.findViewById(R.id.mi);
    final TextView last_name = (TextView) d.findViewById(R.id.lname);
    final TextView address = (TextView) d.findViewById(R.id.addr);
    final TextView age = (TextView) d.findViewById(R.id.age);
    final TextView medical_history = (TextView) d.findViewById(R.id.med_hist);
    RadioGroup status_group = (RadioGroup) d.findViewById(R.id.status);
    status_group.setVisibility(RadioGroup.GONE);

    save = (Button) d.findViewById(R.id.add);
    Button cancel = (Button) d.findViewById(R.id.cancel);

    save.setEnabled(false);

    save.setText("Update");
    first_name.setText(patient.getFname());
    middle_name.setText(patient.getMi());
    last_name.setText(patient.getLname());
    address.setText(patient.getAddr());
    age.setText(Integer.toString(patient.getAge()));
    medical_history.setText(patient.getMed_history());

    first_name.addTextChangedListener(this);
    middle_name.addTextChangedListener(this);
    last_name.addTextChangedListener(this);
    address.addTextChangedListener(this);
    age.addTextChangedListener(this);
    medical_history.addTextChangedListener(this);

    save.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
            build.setMessage("Are all edits Correct?");
            build.setCancelable(false);
            build.setPositiveButton(
                "Yes",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    Patients p = patient;
                    p.setFname(first_name.getText().toString());
                    p.setMi(middle_name.getText().toString());
                    p.setLname(last_name.getText().toString());
                    p.setAddr(address.getText().toString());
                    p.setAge(Integer.parseInt(age.getText().toString()));
                    p.setMed_history(medical_history.getText().toString());
                    help.update(p, Helper.NORMAL);
                    d.cancel();
                    Toast.makeText(getActivity(), "Patient Details Updated!", Toast.LENGTH_SHORT)
                        .show();
                    loadPatientMasterList();
                    loadPatientList(patient.getPat_status());
                  }
                });
            build.setNegativeButton(
                "No",
                new DialogInterface.OnClickListener() {

                  public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                  }
                });

            AlertDialog alert = build.create();
            alert.show();
          }
        });
    cancel.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            d.cancel();
          }
        });

    d.show();
  }