コード例 #1
0
		private void comboStatus_SelectionChangeCommitted(object sender, System.EventArgs e) {
			if(grid.SelectedIndices.Length==0){
				return;//because user could never initiate this action.
			}
			Appointment apt;
			Cursor=Cursors.WaitCursor;
			long[] selectedApts=new long[grid.SelectedIndices.Length];
			for(int i=0;i<grid.SelectedIndices.Length;i++){
				selectedApts[i]=PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString());
			}
			for(int i=0;i<grid.SelectedIndices.Length;i++){
				apt=Appointments.GetOneApt(PIn.Long(Table.Rows[grid.SelectedIndices[i]]["AptNum"].ToString()));
				Appointment aptOld=apt.Clone();
				int selectedI=comboStatus.SelectedIndex;
				apt.Confirmed=DefC.Short[(int)DefCat.ApptConfirmed][selectedI].DefNum;
				try{
					Appointments.Update(apt,aptOld);
				}
				catch(ApplicationException ex){
					Cursor=Cursors.Default;
					MessageBox.Show(ex.Message);
					return;
				}
			}
			FillMain();
			//reselect all the apts
			for(int i=0;i<Table.Rows.Count;i++){
				for(int j=0;j<selectedApts.Length;j++){
					if(PIn.Long(Table.Rows[i]["AptNum"].ToString())==selectedApts[j]){
						grid.SetSelected(i,true);
					}
				}
			}
			SetFamilyColors();
			comboStatus.SelectedIndex=-1;
			Cursor=Cursors.Default;
		}
コード例 #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;
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: AutomationL.cs プロジェクト: ChemBrain/OpenDental
        public static bool Trigger <T>(AutomationTrigger trigger, List <string> procCodes, long patNum, long aptNum = 0, T triggerObj = default(T))
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            List <Automation> listAutomations = Automations.GetDeepCopy();
            bool automationHappened           = false;

            for (int i = 0; i < listAutomations.Count; i++)
            {
                if (listAutomations[i].Autotrigger != trigger)
                {
                    continue;
                }
                if (trigger == AutomationTrigger.CompleteProcedure || trigger == AutomationTrigger.ScheduleProcedure)
                {
                    if (procCodes == null || procCodes.Count == 0)
                    {
                        continue;                        //fail silently
                    }
                    string[] arrayCodes = listAutomations[i].ProcCodes.Split(',');
                    if (procCodes.All(x => !arrayCodes.Contains(x)))
                    {
                        continue;
                    }
                }
                //matching automation item has been found
                //Get possible list of conditions that exist for this automation item
                List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(listAutomations[i].AutomationNum);
                if (autoConditionsList.Count > 0 && !CheckAutomationConditions(autoConditionsList, patNum, triggerObj))
                {
                    continue;
                }
                SheetDef          sheetDef;
                Sheet             sheet;
                FormSheetFillEdit FormSF;
                Appointment       aptNew;
                Appointment       aptOld;
                switch (listAutomations[i].AutoAction)
                {
                case AutomationAction.CreateCommlog:
                    if (Plugins.HookMethod(null, "AutomationL.Trigger_CreateCommlog_start", patNum, aptNum, listAutomations[i].CommType,
                                           listAutomations[i].MessageContent, trigger))
                    {
                        automationHappened = true;
                        continue;
                    }
                    Commlog commlogCur = new Commlog();
                    commlogCur.PatNum       = patNum;
                    commlogCur.CommDateTime = DateTime.Now;
                    commlogCur.CommType     = listAutomations[i].CommType;
                    commlogCur.Note         = listAutomations[i].MessageContent;
                    commlogCur.Mode_        = CommItemMode.None;
                    commlogCur.UserNum      = Security.CurUser.UserNum;
                    commlogCur.IsNew        = true;
                    FormCommItem commItemView = new FormCommItem(commlogCur);
                    commItemView.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUp:
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUpThenDisable10Min:
                    Plugins.HookAddCode(null, "AutomationL.Trigger_PopUpThenDisable10Min_begin", listAutomations[i], procCodes, patNum);
                    long automationNum      = listAutomations[i].AutomationNum;
                    bool hasAutomationBlock = FormOpenDental.DicBlockedAutomations.ContainsKey(automationNum);
                    if (hasAutomationBlock && FormOpenDental.DicBlockedAutomations[automationNum].ContainsKey(patNum))                             //Automation block exist for current patient.
                    {
                        continue;
                    }
                    if (hasAutomationBlock)
                    {
                        FormOpenDental.DicBlockedAutomations[automationNum].Add(patNum, DateTime.Now.AddMinutes(10)); //Disable for 10 minutes.
                    }
                    else                                                                                              //Add automationNum to higher level dictionary .
                    {
                        FormOpenDental.DicBlockedAutomations.Add(automationNum,
                                                                 new Dictionary <long, DateTime>()
                        {
                            { patNum, DateTime.Now.AddMinutes(10) }                                           //Disable for 10 minutes.
                        });
                    }
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintPatientLetter:
                case AutomationAction.ShowExamSheet:
                case AutomationAction.ShowConsentForm:
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintReferralLetter:
                    long referralNum = RefAttaches.GetReferralNum(patNum);
                    if (referralNum == 0)
                    {
                        MsgBox.Show("Automations", "This patient has no referral source entered.");
                        automationHappened = true;
                        continue;
                    }
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetParameter.SetParameter(sheet, "ReferralNum", referralNum);
                    //Don't fill these params if the sheet doesn't use them.
                    if (sheetDef.SheetFieldDefs.Any(x =>
                                                    (x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted") ||
                                                    (x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart")))
                    {
                        List <Procedure> listProcs = Procedures.GetCompletedForDateRange(DateTime.Today, DateTime.Today
                                                                                         , listPatNums: new List <long>()
                        {
                            patNum
                        }
                                                                                         , includeNote: true
                                                                                         , includeGroupNote: true
                                                                                         );
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted"))
                        {
                            SheetParameter.SetParameter(sheet, "CompletedProcs", listProcs);
                        }
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart"))
                        {
                            SheetParameter.SetParameter(sheet, "toothChartImg", SheetPrinting.GetToothChartHelper(patNum, false, listProceduresFilteredOverride: listProcs));
                        }
                    }
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.SetApptASAP:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld          = aptNew.Copy();
                    aptNew.Priority = ApptPriority.ASAP;
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.SetApptType:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld = aptNew.Copy();
                    aptNew.AppointmentTypeNum = listAutomations[i].AppointmentTypeNum;
                    AppointmentType aptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == aptNew.AppointmentTypeNum);
                    if (aptTypeCur != null)
                    {
                        aptNew.ColorOverride = aptTypeCur.AppointmentTypeColor;
                        aptNew.Pattern       = AppointmentTypes.GetTimePatternForAppointmentType(aptTypeCur);
                        List <Procedure> listProcs = Appointments.ApptTypeMissingProcHelper(aptNew, aptTypeCur, new List <Procedure>());
                        Procedures.UpdateAptNums(listProcs.Select(x => x.ProcNum).ToList(), aptNew.AptNum, aptNew.AptStatus == ApptStatus.Planned);
                    }
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.PatRestrictApptSchedTrue:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to restrict patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.Upsert(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PatRestrictApptSchedFalse:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to allow patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.RemovePatRestriction(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintRxInstruction:
                    List <RxPat> listRx = (List <RxPat>)(object) triggerObj;
                    if (listRx == null)
                    {
                        //Got here via a pre-existing trigger that doesn't pass in triggerObj.  We now block creation of automation triggers that could get
                        //here via code that does not pass in triggerObj.
                        continue;
                    }
                    //We go through each new Rx where the patient note isn't blank.
                    //There should only usually be one new rx, but we'll loop just in case.
                    foreach (RxPat rx in listRx.Where(x => !string.IsNullOrWhiteSpace(x.PatientInstruction)))
                    {
                        //This logic is an exact copy of FormRxManage.butPrintSelect_Click()'s logic when 1 Rx is selected.
                        //If this is updated, that method needs to be updated as well.
                        sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                        sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                        SheetParameter.SetParameter(sheet, "RxNum", rx.RxNum);
                        SheetFiller.FillFields(sheet);
                        SheetUtil.CalculateHeights(sheet);
                        FormSF = new FormSheetFillEdit(sheet);
                        FormSF.ShowDialog();
                        automationHappened = true;
                    }
                    continue;

                case AutomationAction.ChangePatStatus:
                    Patient pat    = Patients.GetPat(patNum);
                    Patient patOld = pat.Copy();
                    pat.PatStatus = listAutomations[i].PatStatus;
                    //Don't allow changing status from Archived if this is a merged patient.
                    if (patOld.PatStatus != pat.PatStatus &&
                        patOld.PatStatus == PatientStatus.Archived &&
                        PatientLinks.WasPatientMerged(patOld.PatNum))
                    {
                        MsgBox.Show("FormPatientEdit", "Not allowed to change the status of a merged patient.");
                        continue;
                    }
                    switch (pat.PatStatus)
                    {
                    case PatientStatus.Deceased:
                        if (patOld.PatStatus != PatientStatus.Deceased)
                        {
                            List <Appointment> listFutureAppts = Appointments.GetFutureSchedApts(pat.PatNum);
                            if (listFutureAppts.Count > 0)
                            {
                                string apptDates = string.Join("\r\n", listFutureAppts.Take(10).Select(x => x.AptDateTime.ToString()));
                                if (listFutureAppts.Count > 10)
                                {
                                    apptDates += "(...)";
                                }
                                if (MessageBox.Show(
                                        Lan.g("FormPatientEdit", "This patient has scheduled appointments in the future") + ":\r\n" + apptDates + "\r\n"
                                        + Lan.g("FormPatientEdit", "Would you like to delete them and set the patient to Deceased?"),
                                        Lan.g("FormPatientEdit", "Delete future appointments?"),
                                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                                {
                                    foreach (Appointment appt in listFutureAppts)
                                    {
                                        Appointments.Delete(appt.AptNum, true);
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        break;
                    }
                    //Re-activate or disable recalls depending on the the status that the patient is changing to.
                    Patients.UpdateRecalls(pat, patOld, "ChangePatStatus automation");
                    if (Patients.Update(pat, patOld))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientEdit, patNum, "Patient status changed from " + patOld.PatStatus.GetDescription() +
                                                  " to " + listAutomations[i].PatStatus.GetDescription() + " through ChangePatStatus automation.");
                    }
                    automationHappened = true;
                    continue;
                }
            }
            return(automationHappened);
        }
コード例 #5
0
        public static bool Trigger <T>(AutomationTrigger trigger, List <string> procCodes, long patNum, long aptNum = 0, T triggerObj = default(T))
        {
            if (patNum == 0)           //Could happen for OpenPatient trigger
            {
                return(false);
            }
            List <Automation> listAutomations = Automations.GetDeepCopy();
            bool automationHappened           = false;

            for (int i = 0; i < listAutomations.Count; i++)
            {
                if (listAutomations[i].Autotrigger != trigger)
                {
                    continue;
                }
                if (trigger == AutomationTrigger.CompleteProcedure || trigger == AutomationTrigger.ScheduleProcedure)
                {
                    if (procCodes == null || procCodes.Count == 0)
                    {
                        continue;                        //fail silently
                    }
                    string[] arrayCodes = listAutomations[i].ProcCodes.Split(',');
                    if (procCodes.All(x => !arrayCodes.Contains(x)))
                    {
                        continue;
                    }
                }
                //matching automation item has been found
                //Get possible list of conditions that exist for this automation item
                List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(listAutomations[i].AutomationNum);
                if (autoConditionsList.Count > 0 && !CheckAutomationConditions(autoConditionsList, patNum, triggerObj))
                {
                    continue;
                }
                SheetDef          sheetDef;
                Sheet             sheet;
                FormSheetFillEdit FormSF;
                Appointment       aptNew;
                Appointment       aptOld;
                switch (listAutomations[i].AutoAction)
                {
                case AutomationAction.CreateCommlog:
                    if (Plugins.HookMethod(null, "AutomationL.Trigger_CreateCommlog_start", patNum, aptNum, listAutomations[i].CommType,
                                           listAutomations[i].MessageContent))
                    {
                        automationHappened = true;
                        continue;
                    }
                    Commlog commlogCur = new Commlog();
                    commlogCur.PatNum       = patNum;
                    commlogCur.CommDateTime = DateTime.Now;
                    commlogCur.CommType     = listAutomations[i].CommType;
                    commlogCur.Note         = listAutomations[i].MessageContent;
                    commlogCur.Mode_        = CommItemMode.None;
                    commlogCur.UserNum      = Security.CurUser.UserNum;
                    FormCommItem commItemView = new FormCommItem();
                    commItemView.ShowDialog(new CommItemModel()
                    {
                        CommlogCur = commlogCur
                    }, new CommItemController(commItemView)
                    {
                        IsNew = true
                    });
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUp:
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PopUpThenDisable10Min:
                    long automationNum      = listAutomations[i].AutomationNum;
                    bool hasAutomationBlock = FormOpenDental.DicBlockedAutomations.ContainsKey(automationNum);
                    if (hasAutomationBlock && FormOpenDental.DicBlockedAutomations[automationNum].ContainsKey(patNum))                             //Automation block exist for current patient.
                    {
                        continue;
                    }
                    if (hasAutomationBlock)
                    {
                        FormOpenDental.DicBlockedAutomations[automationNum].Add(patNum, DateTime.Now.AddMinutes(10)); //Disable for 10 minutes.
                    }
                    else                                                                                              //Add automationNum to higher level dictionary .
                    {
                        FormOpenDental.DicBlockedAutomations.Add(automationNum,
                                                                 new Dictionary <long, DateTime>()
                        {
                            { patNum, DateTime.Now.AddMinutes(10) }                                           //Disable for 10 minutes.
                        });
                    }
                    MessageBox.Show(listAutomations[i].MessageContent);
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintPatientLetter:
                case AutomationAction.ShowExamSheet:
                case AutomationAction.ShowConsentForm:
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.PrintReferralLetter:
                    long referralNum = RefAttaches.GetReferralNum(patNum);
                    if (referralNum == 0)
                    {
                        MsgBox.Show("Automations", "This patient has no referral source entered.");
                        automationHappened = true;
                        continue;
                    }
                    sheetDef = SheetDefs.GetSheetDef(listAutomations[i].SheetDefNum);
                    sheet    = SheetUtil.CreateSheet(sheetDef, patNum);
                    SheetParameter.SetParameter(sheet, "PatNum", patNum);
                    SheetParameter.SetParameter(sheet, "ReferralNum", referralNum);
                    //Don't fill these params if the sheet doesn't use them.
                    if (sheetDef.SheetFieldDefs.Any(x =>
                                                    (x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted") ||
                                                    (x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart")))
                    {
                        List <Procedure> listProcs = Procedures.GetCompletedForDateRange(DateTime.Today, DateTime.Today
                                                                                         , listPatNums: new List <long>()
                        {
                            patNum
                        }
                                                                                         , includeNote: true
                                                                                         , includeGroupNote: true
                                                                                         );
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Grid && x.FieldName == "ReferralLetterProceduresCompleted"))
                        {
                            SheetParameter.SetParameter(sheet, "CompletedProcs", listProcs);
                        }
                        if (sheetDef.SheetFieldDefs.Any(x => x.FieldType == SheetFieldType.Special && x.FieldName == "toothChart"))
                        {
                            SheetParameter.SetParameter(sheet, "toothChartImg", SheetPrinting.GetToothChartHelper(patNum, false, listProceduresFilteredOverride: listProcs));
                        }
                    }
                    SheetFiller.FillFields(sheet);
                    SheetUtil.CalculateHeights(sheet);
                    FormSF = new FormSheetFillEdit(sheet);
                    FormSF.ShowDialog();
                    automationHappened = true;
                    continue;

                case AutomationAction.SetApptASAP:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld          = aptNew.Copy();
                    aptNew.Priority = ApptPriority.ASAP;
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.SetApptType:
                    aptNew = Appointments.GetOneApt(aptNum);
                    if (aptNew == null)
                    {
                        MsgBox.Show("Automations", "Invalid appointment for automation.");
                        automationHappened = true;
                        continue;
                    }
                    aptOld = aptNew.Copy();
                    aptNew.AppointmentTypeNum = listAutomations[i].AppointmentTypeNum;
                    AppointmentType aptTypeCur = AppointmentTypes.GetFirstOrDefault(x => x.AppointmentTypeNum == aptNew.AppointmentTypeNum);
                    if (aptTypeCur != null)
                    {
                        aptNew.ColorOverride = aptTypeCur.AppointmentTypeColor;
                    }
                    Appointments.Update(aptNew, aptOld);                           //Appointments S-Class handles Signalods
                    continue;

                case AutomationAction.PatRestrictApptSchedTrue:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to restrict patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.Upsert(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;

                case AutomationAction.PatRestrictApptSchedFalse:
                    if (!Security.IsAuthorized(Permissions.PatientApptRestrict, true))
                    {
                        SecurityLogs.MakeLogEntry(Permissions.PatientApptRestrict, patNum, "Attempt to allow patient scheduling was blocked due to lack of user permission.");
                        continue;
                    }
                    PatRestrictions.RemovePatRestriction(patNum, PatRestrict.ApptSchedule);
                    automationHappened = true;
                    continue;
                }
            }
            return(automationHappened);
        }
コード例 #6
0
        private void butApptProcs_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will fix procedure descriptions in the Appt module that aren't correctly showing tooth numbers.\r\nContinue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            //The ApptProcDescript region is also in FormProcEdit.SaveAndClose() and FormApptEdit.UpdateToDB()  Make any changes there as well.
            #region ApptProcDescript
            List <long>   aptNums = new List <long>();
            Appointment[] aptList = Appointments.GetForPeriod(DateTime.Now.Date.AddMonths(-6), DateTime.MaxValue.AddDays(-10));
            for (int i = 0; i < aptList.Length; i++)
            {
                aptNums.Add(aptList[i].AptNum);
            }
            for (int i = 0; i < aptList.Length; i++)
            {
                //This gets the list of procedures in the correct order.
                DataTable   procTable = Appointments.GetProcTable(aptList[i].PatNum.ToString(), aptList[i].AptNum.ToString(), ((int)aptList[i].AptStatus).ToString(), aptList[i].AptDateTime.ToString());
                Appointment newApt    = aptList[i].Clone();
                newApt.ProcDescript = "";
                newApt.ProcsColored = "";
                int count = 0;
                for (int j = 0; j < procTable.Rows.Count; j++)
                {
                    if (procTable.Rows[j]["attached"].ToString() != "1")
                    {
                        continue;
                    }
                    string procDescOne = "";
                    string procCode    = procTable.Rows[j]["ProcCode"].ToString();
                    if (count > 0)
                    {
                        newApt.ProcDescript += ", ";
                    }
                    switch (procTable.Rows[j]["TreatArea"].ToString())
                    {
                    case "1":                                                        //TreatmentArea.Surf:
                        procDescOne += "#" + Tooth.GetToothLabel(procTable.Rows[j]["ToothNum"].ToString()) + "-"
                                       + procTable.Rows[j]["Surf"].ToString() + "-"; //""#12-MOD-"
                        break;

                    case "2":                                                                                     //TreatmentArea.Tooth:
                        procDescOne += "#" + Tooth.GetToothLabel(procTable.Rows[j]["ToothNum"].ToString()) + "-"; //"#12-"
                        break;

                    default:                            //area 3 or 0 (mouth)
                        break;

                    case "4":                                                      //TreatmentArea.Quad:
                        procDescOne += procTable.Rows[j]["Surf"].ToString() + "-"; //"UL-"
                        break;

                    case "5":                                                            //TreatmentArea.Sextant:
                        procDescOne += "S" + procTable.Rows[j]["Surf"].ToString() + "-"; //"S2-"
                        break;

                    case "6":                                                      //TreatmentArea.Arch:
                        procDescOne += procTable.Rows[j]["Surf"].ToString() + "-"; //"U-"
                        break;

                    case "7":                            //TreatmentArea.ToothRange:
                        //strLine+=table.Rows[j][13].ToString()+" ";//don't show range
                        break;
                    }
                    procDescOne         += procTable.Rows[j]["AbbrDesc"].ToString();
                    newApt.ProcDescript += procDescOne;
                    //Color and previous date are determined by ProcApptColor object
                    ProcApptColor        pac    = ProcApptColors.GetMatch(procCode);
                    System.Drawing.Color pColor = System.Drawing.Color.Black;
                    string prevDateString       = "";
                    if (pac != null)
                    {
                        pColor = pac.ColorText;
                        if (pac.ShowPreviousDate)
                        {
                            prevDateString = Procedures.GetRecentProcDateString(newApt.PatNum, newApt.AptDateTime, pac.CodeRange);
                            if (prevDateString != "")
                            {
                                prevDateString = " (" + prevDateString + ")";
                            }
                        }
                    }
                    newApt.ProcsColored += "<span color=\"" + pColor.ToArgb().ToString() + "\">" + procDescOne + prevDateString + "</span>";
                    count++;
                }
                Appointments.Update(newApt, aptList[i]);
            }
            #endregion
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Done. Please refresh Appt module to see the changes.");
        }
コード例 #7
0
ファイル: AppointmentL.cs プロジェクト: royedwards/DRDNet
        ///<summary></summary>
        public static PlannedApptStatus CreatePlannedAppt(Patient pat, int itemOrder, List <long> listPreSelectedProcNums = null)
        {
            if (!Security.IsAuthorized(Permissions.AppointmentCreate))
            {
                return(PlannedApptStatus.Failure);
            }
            if (PatRestrictionL.IsRestricted(pat.PatNum, PatRestrict.ApptSchedule))
            {
                return(PlannedApptStatus.Failure);
            }
            if (PromptForMerge(pat, out pat))
            {
                FormOpenDental.S_Contr_PatientSelected(pat, true, false);
            }
            if (pat.PatStatus.In(PatientStatus.Archived, PatientStatus.Deceased))
            {
                MsgBox.Show("Appointments", "Appointments cannot be scheduled for " + pat.PatStatus.ToString().ToLower() + " patients.");
                return(PlannedApptStatus.Failure);
            }
            Appointment AptCur = new Appointment();

            AptCur.PatNum      = pat.PatNum;
            AptCur.ProvNum     = pat.PriProv;
            AptCur.ClinicNum   = pat.ClinicNum;
            AptCur.AptStatus   = ApptStatus.Planned;
            AptCur.AptDateTime = DateTimeOD.Today;
            List <Procedure> listProcs = Procedures.GetManyProc(listPreSelectedProcNums, false);        //Returns empty list if null.

            //If listProcs is empty then AptCur.Pattern defaults to PrefName.AppointmentWithoutProcsDefaultLength value.
            //See Appointments.GetApptTimePatternForNoProcs().
            AptCur.Pattern    = Appointments.CalculatePattern(pat, AptCur.ProvNum, AptCur.ProvHyg, listProcs, isMake5Minute: true);
            AptCur.TimeLocked = PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
            Appointments.Insert(AptCur);
            PlannedAppt plannedAppt = new PlannedAppt();

            plannedAppt.AptNum    = AptCur.AptNum;
            plannedAppt.PatNum    = pat.PatNum;
            plannedAppt.ItemOrder = itemOrder;
            PlannedAppts.Insert(plannedAppt);
            Procedures.UpdateAptNums(listPreSelectedProcNums, plannedAppt.AptNum, true);          //Simply returns if listPreSelectedProcNums is null
            FormApptEdit FormApptEdit = new FormApptEdit(AptCur.AptNum);

            FormApptEdit.IsNew = true;
            FormApptEdit.ShowDialog();
            if (FormApptEdit.DialogResult != DialogResult.OK)
            {
                Procedures.UpdateAptNums(listPreSelectedProcNums, 0, true);              //Simply returns if listPreSelectedProcNums is null
                return(PlannedApptStatus.FillGridNeeded);
            }
            //Only set the appointment hygienist to this patient's secondary provider if one was not manually set within the edit window.
            if (AptCur.ProvHyg < 1)
            {
                List <Procedure> myProcList  = Procedures.GetProcsForSingle(AptCur.AptNum, true);
                bool             allProcsHyg = (myProcList.Count > 0 && myProcList.Select(x => ProcedureCodes.GetProcCode(x.CodeNum)).ToList().All(x => x.IsHygiene));
                //Automatically set the appointments hygienist to the secondary provider of the patient if one is set.
                if (allProcsHyg && pat.SecProv != 0)
                {
                    Appointment aptOld = AptCur.Copy();
                    AptCur.ProvNum = pat.SecProv;
                    Appointments.Update(AptCur, aptOld);
                }
            }
            Patient patOld = pat.Copy();

            pat.PlannedIsDone = false;
            Patients.Update(pat, patOld);
            FormOpenDental.S_RefreshCurrentModule(isClinicRefresh: false);           //if procs were added in appt, then this will display them
            return(PlannedApptStatus.Success);
        }
コード例 #8
0
        private void butApptProcs_Click(object sender, EventArgs e)
        {
            if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "This will fix procedure descriptions in the Appt module that aren't correctly showing tooth numbers.\r\nContinue?"))
            {
                return;
            }
            Cursor = Cursors.WaitCursor;
            //The ApptProcDescript region is also in FormProcEdit.SaveAndClose() and FormDatabaseMaintenance.butApptProcs_Click()  Make any changes there as well.
            #region ApptProcDescript
            List <long>   aptNums = new List <long>();
            Appointment[] aptList = Appointments.GetForPeriod(DateTime.Now.Date.AddMonths(-6), DateTime.MaxValue.AddDays(-10));
            for (int i = 0; i < aptList.Length; i++)
            {
                aptNums.Add(aptList[i].AptNum);
            }
            List <Procedure> procsMultApts = Procedures.GetProcsMultApts(aptNums);
            for (int i = 0; i < aptList.Length; i++)
            {
                Appointment newApt = aptList[i].Clone();
                newApt.ProcDescript = "";
                Procedure[] procsForOne  = Procedures.GetProcsOneApt(aptList[i].AptNum, procsMultApts);
                string      procDescript = "";
                for (int j = 0; j < procsForOne.Length; j++)
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCodeFromDb(procsForOne[j].CodeNum);
                    if (j > 0)
                    {
                        procDescript += ", ";
                    }
                    switch (procCode.TreatArea)
                    {
                    case TreatmentArea.Surf:
                        procDescript += "#" + Tooth.GetToothLabel(procsForOne[j].ToothNum) + "-"
                                        + procsForOne[j].Surf + "-";             //""#12-MOD-"
                        break;

                    case TreatmentArea.Tooth:
                        procDescript += "#" + Tooth.GetToothLabel(procsForOne[j].ToothNum) + "-";                          //"#12-"
                        break;

                    case TreatmentArea.Quad:
                        procDescript += procsForOne[j].Surf + "-";                            //"UL-"
                        break;

                    case TreatmentArea.Sextant:
                        procDescript += "S" + procsForOne[j].Surf + "-";                          //"S2-"
                        break;

                    case TreatmentArea.Arch:
                        procDescript += procsForOne[j].Surf + "-";                            //"U-"
                        break;

                    case TreatmentArea.ToothRange:
                        break;

                    default:                            //area 3 or 0 (mouth)
                        break;
                    }
                    procDescript += procCode.AbbrDesc;
                }
                newApt.ProcDescript = procDescript;
                Appointments.Update(newApt, aptList[i]);
            }
            #endregion
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Done. Please refresh Appt module to see the changes.");
        }