///<summary>Offers to use unscheduled appt. Shows ApptEdit window. Sets Prospective, if necessary. Fires Automation triggers. ListAptNumsSelected will contain the AptNum of the new appointment.</summary> public void MakeAppointment() { //Check to see if the patient has any unscheduled appointments and inform the user. List <Appointment> listUnschedAppts = Appointments.GetUnschedApptsForPat(_patCur.PatNum); //Per Nathan, pinboard appointments will not be considered unscheduled for this logic. listUnschedAppts.RemoveAll(x => x.AptNum.In(_listPinboardApptNums)); FormApptEdit formApptEdit = null; long aptNum = 0; bool isSchedulingUnscheduled = false; if (listUnschedAppts.Count > 0 && MsgBox.Show(this, MsgBoxButtons.YesNo, "This patient has an unscheduled appointment, would you like to use an existing unscheduled appointment?")) { if (listUnschedAppts.Count == 1) { aptNum = listUnschedAppts[0].AptNum; } else //Multiple unscheduled appointments, let the user pick which one to use. { FormUnschedListPatient formUnschedListPatient = new FormUnschedListPatient(_patCur); if (formUnschedListPatient.ShowDialog() != DialogResult.OK) { return; } //Use the appointment the user selected. aptNum = formUnschedListPatient.SelectedAppt.AptNum; } isSchedulingUnscheduled = true; } formApptEdit = new FormApptEdit(aptNum, patNum: _patCur.PatNum, useApptDrawingSettings: IsInitialDoubleClick, patient: _patCur, dateTNew: DateTNew, opNumNew: OpNumNew); formApptEdit.IsNew = (aptNum == 0); formApptEdit.IsSchedulingUnscheduledAppt = isSchedulingUnscheduled; formApptEdit.ShowDialog(); if (formApptEdit.DialogResult != DialogResult.OK) { return; } Appointment aptCur = formApptEdit.GetAppointmentCur(); if (IsInitialDoubleClick) { if (isSchedulingUnscheduled) //User double clicked in Appointment Module, intending to schedule appointment at a specific time/op/etc. { Appointment aptOld = aptCur.Copy(); aptCur.AptDateTime = DateTimeClicked; aptCur.Op = OpNumClicked; if (_patCur != null && _patCur.AskToArriveEarly > 0) { aptCur.DateTimeAskedToArrive = aptCur.AptDateTime.AddMinutes(-_patCur.AskToArriveEarly); } aptCur = Appointments.AssignFieldsForOperatory(aptCur); aptCur.AptStatus = ApptStatus.Scheduled; Appointments.Update(aptCur, aptOld); } //Change PatStatus to Prospective or from Prospective. Operatory opCur = Operatories.GetOperatory(aptCur.Op); if (opCur != null) { if (opCur.SetProspective && _patCur.PatStatus != PatientStatus.Prospective) //Don't need to prompt if patient is already prospective. { if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Patient's status will be set to Prospective.")) { Patient patOld = _patCur.Copy(); _patCur.PatStatus = PatientStatus.Prospective; Patients.Update(_patCur, patOld); } } else if (!opCur.SetProspective && _patCur.PatStatus == PatientStatus.Prospective) { if (MsgBox.Show(this, MsgBoxButtons.OKCancel, "Patient's status will change from Prospective to Patient.")) { Patient patOld = _patCur.Copy(); _patCur.PatStatus = PatientStatus.Patient; Patients.Update(_patCur, patOld); } } } } ListAptNumsSelected.Add(aptCur.AptNum); if (IsInitialDoubleClick) { _otherResult = OtherResult.CreateNew; } else { _otherResult = OtherResult.NewToPinBoard; } if (aptCur.IsNewPatient) { AutomationL.Trigger(AutomationTrigger.CreateApptNewPat, null, aptCur.PatNum, aptCur.AptNum); } AutomationL.Trigger(AutomationTrigger.CreateAppt, null, aptCur.PatNum, aptCur.AptNum); DialogResult = DialogResult.OK; }
private void FormPatientUnschedList_Load(object sender, EventArgs e) { this.Text = " " + _patCur.GetNameLF(); _listUnschedApptsForPat = Appointments.GetUnschedApptsForPat(_patCur.PatNum); FillGrid(); }