private void updateRounds(final Patients p) {
    final Dialog in_d = new Dialog(getActivity());
    in_d.setTitle("Update Hospital Details");
    in_d.setContentView(R.layout.input_rounds_schedule);

    Calendar c = Calendar.getInstance();
    final EditText h_name = (EditText) in_d.findViewById(R.id.hospital_name_next);
    final EditText h_room = (EditText) in_d.findViewById(R.id.hospital_room_next);
    TimePicker timePicker = (TimePicker) in_d.findViewById(R.id.round_schedule);
    final View amPmView = ((ViewGroup) timePicker.getChildAt(0)).getChildAt(3);
    Button add_rounds_setup = (Button) in_d.findViewById(R.id.save_rounds_setup);
    Button cancel_rounds_setup = (Button) in_d.findViewById(R.id.cancel_rounds_setup);

    c.setTimeInMillis(p.getTime());
    h_name.setText(p.getHosp_name());
    h_room.setText(p.getHosp_room());
    timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(c.get(Calendar.MINUTE));

    mHour = timePicker.getCurrentHour();
    mMin = timePicker.getCurrentMinute();

    timePicker.setOnTimeChangedListener(
        new TimePicker.OnTimeChangedListener() {

          public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            mHour = hourOfDay;
            mMin = minute;
          }
        });

    add_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // Temporary Workaround bug on timepicker
            if (amPmView instanceof NumberPicker) {
              if (((NumberPicker) amPmView).getValue() == 1) {
                if (mHour >= 12) mHour = mHour - 12;
                mHour = mHour + 12;
              }

              if (((NumberPicker) amPmView).getValue() == 0) {
                if (mHour >= 12) mHour = mHour - 12;
              }
            }

            // Toast.makeText(getActivity(), "Time of this record is: "+formatTime(timeInMills),
            // Toast.LENGTH_LONG).show();
            Time time = new Time();
            time.hour = mHour;
            time.minute = mMin;
            timeInMills = time.toMillis(false);

            Patients patients = p;

            patients.setHosp_name(h_name.getText().toString());
            patients.setHosp_room(h_room.getText().toString());

            patients.setLocation(h_name.getText().toString() + " - " + h_room.getText().toString());
            patients.setTime(timeInMills);

            Toast.makeText(getActivity(), "Rounds Schedule Updated!", Toast.LENGTH_SHORT).show();
            help.update(patients, Helper.UPDATE_SCHEDULE);
            loadPatientMasterList();
            loadPatientList(1);
            in_d.cancel();
          }
        });

    cancel_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            in_d.cancel();
          }
        });

    in_d.show();
  }
  private void updateRounds(final Patients p) {
    final Dialog in_d = new Dialog(getActivity());
    in_d.setTitle("Update Hospital Details");
    in_d.setContentView(R.layout.input_rounds_schedule);

    Calendar c = Calendar.getInstance();
    final EditText h_name = (EditText) in_d.findViewById(R.id.hospital_name_next);
    final EditText h_room = (EditText) in_d.findViewById(R.id.hospital_room_next);
    TimePicker timePicker = (TimePicker) in_d.findViewById(R.id.round_schedule);
    final View amPmView = ((ViewGroup) timePicker.getChildAt(0)).getChildAt(3);
    save = (Button) in_d.findViewById(R.id.save_rounds_setup);
    Button cancel_rounds_setup = (Button) in_d.findViewById(R.id.cancel_rounds_setup);
    save.setEnabled(false);

    c.setTimeInMillis(p.getTime());
    h_name.setText(p.getHosp_name());
    h_room.setText(p.getHosp_room());
    timePicker.setCurrentHour(c.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(c.get(Calendar.MINUTE));

    mHour = timePicker.getCurrentHour();
    mMin = timePicker.getCurrentMinute();

    timePicker.setOnTimeChangedListener(
        new TimePicker.OnTimeChangedListener() {

          public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            mHour = hourOfDay;
            mMin = minute;
            save.setEnabled(true);
          }
        });

    h_name.addTextChangedListener(this);
    h_room.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) {
                    // Temporary Workaround bug on timepicker
                    if (amPmView instanceof NumberPicker) {
                      if (((NumberPicker) amPmView).getValue() == 1) {
                        if (mHour >= 12) mHour = mHour - 12;
                        mHour = mHour + 12;
                      }

                      if (((NumberPicker) amPmView).getValue() == 0) {
                        if (mHour >= 12) mHour = mHour - 12;
                      }
                    }

                    // Toast.makeText(getActivity(), "Time of this record is:
                    // "+formatTime(timeInMills), Toast.LENGTH_LONG).show();

                    Time time = new Time();
                    time.hour = mHour;
                    time.minute = mMin;
                    time.second = 0;
                    timeInMills = time.toMillis(false);

                    Patients patients = p;

                    patients.setHosp_name(h_name.getText().toString());
                    patients.setHosp_room(h_room.getText().toString());

                    patients.setLocation(
                        h_name.getText().toString() + " - " + h_room.getText().toString());
                    patients.setTime(timeInMills);

                    Toast.makeText(getActivity(), "Rounds Schedule Updated!", Toast.LENGTH_SHORT)
                        .show();
                    help.update(patients, Helper.UPDATE_SCHEDULE);
                    // Helper.scheduleRepeatingAlarm(getActivity(), patients,
                    // patients.getRequestCode(), patients.getTime());
                    loadPatientMasterList();
                    loadPatientList(1);
                    in_d.cancel();
                  }
                });
            build.setNegativeButton(
                "No",
                new DialogInterface.OnClickListener() {

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

            AlertDialog alert = build.create();
            alert.show();
          }
        });

    cancel_rounds_setup.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            in_d.cancel();
          }
        });

    in_d.show();
  }