///<summary>Returns true if the commlog was able to save to the database. Otherwise returns false. ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary> public bool SaveCommItem(bool showMsg) { Commlog commlog; if (!_view.TryGetCommItem(showMsg, out commlog)) { return(false); } if (IsNew || IsPersistent) { _view.SetCommlogNum(Commlogs.Insert(commlog)); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, "Insert"); //Post insert persistent user preferences. if (IsPersistent) { if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString)) { _view.ClearNote(); } if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString)) { _view.ClearDateTimeEnd(); } ODException.SwallowAnyException(() => { FormOpenDental.S_RefreshCurrentModule(); }); } } else { Commlogs.Update(commlog); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, commlog.PatNum, ""); } return(true); }
///<summary>Returns true if the commlog was able to save to the database. Otherwise returns false. ///Set showMsg to true to show a meaningful message when the commlog cannot be saved.</summary> private bool SaveCommItem(bool showMsg) { if (!SyncCommlogWithUI(showMsg)) { return(false); } if (_isPersistent && string.IsNullOrWhiteSpace(_commlogCur.Note)) //in persistent mode, we don't want to save empty commlogs { return(false); } if (_commlogOld.IsNew || _isPersistent) { Commlogs.Insert(_commlogCur); _commlogCur.IsNew = false; _commlogOld = _commlogCur.Copy(); textCommlogNum.Text = _commlogCur.CommlogNum.ToString(); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, "Insert"); //Post insert persistent user preferences. if (_isPersistent) { if (_userOdPrefClearNote == null || PIn.Bool(_userOdPrefClearNote.ValueString)) { ClearNote(); } if (_userOdPrefEndDate == null || PIn.Bool(_userOdPrefEndDate.ValueString)) { ClearDateTimeEnd(); } ODException.SwallowAnyException(() => { FormOpenDental.S_RefreshCurrentModule(); }); } } else { Commlogs.Update(_commlogCur); SecurityLogs.MakeLogEntry(Permissions.CommlogEdit, _commlogCur.PatNum, ""); } return(true); }
///<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); }