/// <summary>For testing only</summary> private static void CreateAppointments(int AppointmentCount) { long[] patNumArray = Patients.GetAllPatNums(); DateTime appdate = DateTime.Now; for (int i = 0; i < patNumArray.Length; i++) { appdate = appdate.AddMinutes(20); for (int j = 0; j < AppointmentCount; j++) { Appointment apt = new Appointment(); appdate = appdate.AddMinutes(20); apt.PatNum = patNumArray[i]; apt.DateTimeArrived = appdate; apt.DateTimeAskedToArrive = appdate; apt.DateTimeDismissed = appdate; apt.DateTimeSeated = appdate; apt.AptDateTime = appdate; apt.Note = "some notenote noten otenotenot enotenot enote" + j; apt.IsNewPatient = true; apt.ProvNum = 3; apt.AptStatus = ApptStatus.Scheduled; apt.AptDateTime = appdate; apt.Op = 2; apt.Pattern = "//XX//////"; apt.ProcDescript = "4-BWX"; apt.ProcsColored = "<span color=\"-16777216\">4-BWX</span>"; Appointments.Insert(apt); } } }
///<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); }
private void butNote_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.AppointmentCreate)) { return; } if (PatRestrictionL.IsRestricted(_patCur.PatNum, PatRestrict.ApptSchedule)) { return; } Appointment aptCur = new Appointment(); aptCur.PatNum = _patCur.PatNum; if (_patCur.DateFirstVisit.Year < 1880 && !Procedures.AreAnyComplete(_patCur.PatNum)) //this only runs if firstVisit blank { aptCur.IsNewPatient = true; } aptCur.Pattern = "/X/"; if (_patCur.PriProv == 0) { aptCur.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv); } else { aptCur.ProvNum = _patCur.PriProv; } aptCur.ProvHyg = _patCur.SecProv; aptCur.AptStatus = ApptStatus.PtNote; aptCur.ClinicNum = _patCur.ClinicNum; aptCur.TimeLocked = PrefC.GetBool(PrefName.AppointmentTimeIsLocked); if (IsInitialDoubleClick) //initially double clicked on appt module { aptCur.AptDateTime = DateTimeClicked; aptCur.Op = OpNumClicked; } else { //new appt will be placed on pinboard instead of specific time } try { if (!AppointmentL.IsSpecialtyMismatchAllowed(_patCur.PatNum, aptCur.ClinicNum)) { return; } Appointments.Insert(aptCur); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } FormApptEdit formApptEdit = new FormApptEdit(aptCur.AptNum); formApptEdit.IsNew = true; formApptEdit.ShowDialog(); if (formApptEdit.DialogResult != DialogResult.OK) { return; } ListAptNumsSelected.Add(aptCur.AptNum); if (IsInitialDoubleClick) { _otherResult = OtherResult.CreateNew; } else { _otherResult = OtherResult.NewToPinBoard; } DialogResult = DialogResult.OK; }
/* * ///<summary>Only used in GetSearchResults. All times between start and stop get set to true in provBarSched.</summary> * private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){ * int startI=GetProvBarIndex(timeStart); * int stopI=GetProvBarIndex(timeStop); * for(int i=startI;i<=stopI;i++){ * provBarSched[i]=true; * } * } * * private static int GetProvBarIndex(TimeSpan time) { * return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr +(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)) *(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr) * /ApptDrawing.LineH;//rounds down * }*/ ///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule. This method creates the appointment and attaches all appropriate procedures. It's up to the calling class to then place the appointment on the pinboard. If the appointment doesn't get scheduled, it's important to delete it. If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary> public static Appointment CreateRecallApt(Patient patCur, List <Procedure> procList, List <InsPlan> planList, long recallNum, List <InsSub> subList) { List <Recall> recallList = Recalls.GetList(patCur.PatNum); Recall recallCur = null; if (recallNum > 0) { recallCur = Recalls.GetRecall(recallNum); } else { for (int i = 0; i < recallList.Count; i++) { if (recallList[i].RecallTypeNum == RecallTypes.PerioType || recallList[i].RecallTypeNum == RecallTypes.ProphyType) { if (!recallList[i].IsDisabled) { recallCur = recallList[i]; } break; } } } if (recallCur == null) // || recallCur.DateDue.Year<1880){ { throw new ApplicationException(Lan.g("AppointmentL", "No recall is due.")); //should never happen because everyone has a recall. } if (recallCur.DateScheduled.Date >= DateTime.Now.Date) { throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString()); } Appointment AptCur = new Appointment(); AptCur.PatNum = patCur.PatNum; AptCur.AptStatus = ApptStatus.UnschedList; //In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared. if (patCur.PriProv == 0) { AptCur.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv); } else { AptCur.ProvNum = patCur.PriProv; } AptCur.ProvHyg = patCur.SecProv; if (AptCur.ProvHyg != 0) { AptCur.IsHygiene = true; } AptCur.ClinicNum = patCur.ClinicNum; //whether perio or prophy: List <string> procs = RecallTypes.GetProcs(recallCur.RecallTypeNum); string recallPattern = RecallTypes.GetTimePattern(recallCur.RecallTypeNum); if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum) && patCur.Birthdate.AddYears(12) > ((recallCur.DateDue > DateTime.Today)?recallCur.DateDue:DateTime.Today)) //if pt's 12th birthday falls after recall date. ie younger than 12. { for (int i = 0; i < RecallTypeC.Listt.Count; i++) { if (RecallTypeC.Listt[i].RecallTypeNum == RecallTypes.ChildProphyType) { List <string> childprocs = RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum); if (childprocs.Count > 0) { procs = childprocs; //overrides adult procs. } string childpattern = RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum); if (childpattern != "") { recallPattern = childpattern; //overrides adult pattern. } } } } //convert time pattern to 5 minute increment StringBuilder savePattern = new StringBuilder(); for (int i = 0; i < recallPattern.Length; i++) { savePattern.Append(recallPattern.Substring(i, 1)); if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 10) { savePattern.Append(recallPattern.Substring(i, 1)); } if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append(recallPattern.Substring(i, 1)); savePattern.Append(recallPattern.Substring(i, 1)); } } if (savePattern.ToString() == "") { if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15) { savePattern.Append("///XXX///"); } else { savePattern.Append("//XX//"); } } AptCur.Pattern = savePattern.ToString(); //Add films------------------------------------------------------------------------------------------------------ if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum)) //if this is a prophy or perio { for (int i = 0; i < recallList.Count; i++) { if (recallCur.RecallNum == recallList[i].RecallNum) { continue; //already handled. } if (recallList[i].IsDisabled) { continue; } if (recallList[i].DateDue.Year < 1880) { continue; } if (recallList[i].DateDue > recallCur.DateDue && //if film due date is after prophy due date recallList[i].DateDue > DateTime.Today) //and not overdue { continue; } //incomplete: exclude manual recall types procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum)); } } AptCur.ProcDescript = ""; for (int i = 0; i < procs.Count; i++) { if (i > 0) { AptCur.ProcDescript += ", "; } AptCur.ProcDescript += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc; } Appointments.Insert(AptCur); Procedure ProcCur; List <PatPlan> patPlanList = PatPlans.Refresh(patCur.PatNum); List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList); InsPlan priplan = null; InsSub prisub = null; if (patPlanList.Count > 0) { prisub = InsSubs.GetSub(patPlanList[0].InsSubNum, subList); priplan = InsPlans.GetPlan(prisub.PlanNum, planList); } double insfee; double standardfee; for (int i = 0; i < procs.Count; i++) { ProcCur = new Procedure(); //this will be an insert //procnum ProcCur.PatNum = patCur.PatNum; ProcCur.AptNum = AptCur.AptNum; ProcCur.CodeNum = ProcedureCodes.GetCodeNum(procs[i]); ProcCur.ProcDate = DateTime.Now; ProcCur.DateTP = DateTime.Now; //Check if it's a medical procedure. bool isMed = false; ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode; if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "") { isMed = true; } //Get fee schedule for medical or dental. long feeSch; if (isMed) { feeSch = Fees.GetMedFeeSched(patCur, planList, patPlanList, subList); } else { feeSch = Fees.GetFeeSched(patCur, planList, patPlanList, subList); } //Get the fee amount for medical or dental. if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed) { insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch); } else { insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch); } if (priplan != null && priplan.PlanType == "p") //PPO { standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched); if (standardfee > insfee) { ProcCur.ProcFee = standardfee; } else { ProcCur.ProcFee = insfee; } } else { ProcCur.ProcFee = insfee; } //surf //toothnum //Procedures.Cur.ToothRange=""; //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns; //priority ProcCur.ProcStatus = ProcStat.TP; ProcCur.Note = ""; //Procedures.Cur.PriEstim= //Procedures.Cur.SecEstim= //claimnum ProcCur.ProvNum = patCur.PriProv; //Procedures.Cur.Dx= ProcCur.ClinicNum = patCur.ClinicNum; //nextaptnum ProcCur.BaseUnits = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits; Procedures.Insert(ProcCur); //no recall synch required Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new List <ClaimProc>(), false, planList, patPlanList, benefitList, patCur.Age, subList); if (Programs.UsingOrion) { FormProcEdit FormP = new FormProcEdit(ProcCur, patCur.Copy(), Patients.GetFamily(patCur.PatNum)); FormP.IsNew = true; FormP.ShowDialog(); if (FormP.DialogResult == DialogResult.Cancel) { //any created claimprocs are automatically deleted from within procEdit window. try{ Procedures.Delete(ProcCur.ProcNum); //also deletes the claimprocs } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { //Do not synch. Recalls based on ScheduleByDate reports in Orion mode. //Recalls.Synch(PatCur.PatNum); } } } return(AptCur); }