コード例 #1
0
        ///<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;
        }
コード例 #2
0
        ///<summary>Creates a single recall appointment. If it's from a double click, then it will end up on that spot in the Appts module.  If not, it will end up on the pinboard with StringDateJumpTo as due date to jump to.  ListAptNumsSelected will contain the AptNum of the new appointment.</summary>
        public void MakeRecallAppointment()
        {
            List <InsSub>  listInsSubs  = InsSubs.RefreshForFam(_famCur);
            List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs);
            Appointment    apt          = null;
            DateTime       dateTimeApt  = DateTime.MinValue;

            if (this.IsInitialDoubleClick)
            {
                dateTimeApt = DateTimeClicked;
            }
            try{
                apt = AppointmentL.CreateRecallApt(_patCur, listInsPlans, -1, listInsSubs, dateTimeApt);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            DateTime datePrevious = apt.DateTStamp;

            ListAptNumsSelected.Add(apt.AptNum);
            if (IsInitialDoubleClick)
            {
                Appointment oldApt = apt.Copy();
                if (_patCur.AskToArriveEarly > 0)
                {
                    apt.DateTimeAskedToArrive = apt.AptDateTime.AddMinutes(-_patCur.AskToArriveEarly);
                    MessageBox.Show(Lan.g(this, "Ask patient to arrive") + " " + _patCur.AskToArriveEarly
                                    + " " + Lan.g(this, "minutes early at") + " " + apt.DateTimeAskedToArrive.ToShortTimeString() + ".");
                }
                apt.AptStatus = ApptStatus.Scheduled;
                apt.ClinicNum = _patCur.ClinicNum;
                apt.Op        = OpNumClicked;
                apt           = Appointments.AssignFieldsForOperatory(apt);
                //Use apt.ClinicNum because it was just set based on Op.ClinicNum in AssignFieldsForOperatory().
                if (!AppointmentL.IsSpecialtyMismatchAllowed(_patCur.PatNum, apt.ClinicNum))
                {
                    return;
                }
                Appointments.Update(apt, oldApt);
                _otherResult = OtherResult.CreateNew;
                SecurityLogs.MakeLogEntry(Permissions.AppointmentCreate, apt.PatNum, apt.AptDateTime.ToString(), apt.AptNum, datePrevious);
                //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined
                if (HL7Defs.IsExistingHL7Enabled())
                {
                    //S12 - New Appt Booking event
                    MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(_patCur, _famCur.GetPatient(_patCur.Guarantor), EventTypeHL7.S12, apt);
                    //Will be null if there is no outbound SIU message defined, so do nothing
                    if (messageHL7 != null)
                    {
                        HL7Msg hl7Msg = new HL7Msg();
                        hl7Msg.AptNum    = apt.AptNum;
                        hl7Msg.HL7Status = HL7MessageStatus.OutPending;                      //it will be marked outSent by the HL7 service.
                        hl7Msg.MsgText   = messageHL7.ToString();
                        hl7Msg.PatNum    = _patCur.PatNum;
                        HL7Msgs.Insert(hl7Msg);
#if DEBUG
                        MessageBox.Show(this, messageHL7.ToString());
#endif
                    }
                }
                DialogResult = DialogResult.OK;
                return;
            }
            //not initialClick
            _otherResult = OtherResult.PinboardAndSearch;
            Recall recall = Recalls.GetRecallProphyOrPerio(_patCur.PatNum);          //shouldn't return null.
            if (recall.DateDue < DateTime.Today)
            {
                StringDateJumpTo = DateTime.Today.ToShortDateString();              //they are overdue
            }
            else
            {
                StringDateJumpTo = recall.DateDue.ToShortDateString();
            }
            //no securitylog entry needed here.  That will happen when it's dragged off pinboard.
            DialogResult = DialogResult.OK;
        }