///<summary>Dependencies checked first and throws an exception if any found. So surround by try catch</summary> public static void Delete(TreatPlan tp) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), tp); return; } //check proctp for dependencies string command = "SELECT * FROM proctp WHERE TreatPlanNum =" + POut.Long(tp.TreatPlanNum); DataTable table = Db.GetTable(command); if (table.Rows.Count > 0) { //this should never happen throw new ApplicationException(Lans.g("TreatPlans", "Cannot delete treatment plan because it has ProcTP's attached")); } command = "DELETE from treatplan WHERE TreatPlanNum = '" + POut.Long(tp.TreatPlanNum) + "'"; Db.NonQ(command); if (!tp.TPStatus.In(TreatPlanStatus.Saved)) { return; } List <MobileAppDevice> listPatDevices = MobileAppDevices.GetAll(tp.PatNum); if (listPatDevices.Count > 0) { PushNotificationUtils.CI_RemoveTreatmentPlan(listPatDevices.First().MobileAppDeviceNum, tp); } }
///<summary>Throws Exception. ///Helper method that calls TryInsertPDF(...) for treatment plan PDFs.</summary> public static bool TryInsertTreatPlanPDF(PdfDocument doc, TreatPlan treatPlan, bool hasPracticeSig, string unlockCode , out string errorMsg, out MobileDataByte mobileDataByte) { mobileDataByte = null; if (!MobileAppDevices.IsClinicSignedUpForEClipboard(Clinics.ClinicNum)) { throw new Exception($"This practice or clinic is not signed up for eClipboard.\r\nGo to eServices | Signup Portal to sign up."); } try{ List <string> listTagValues = new List <string>() { treatPlan.Heading, treatPlan.TreatPlanNum.ToString(), hasPracticeSig.ToString(), treatPlan.DateTP.Ticks.ToString() }; TryInsertPDF(doc, treatPlan.PatNum, unlockCode, eActionType.TreatmentPlan , out long mobileDataByteNum, out errorMsg, listTagValues ); if (mobileDataByteNum != -1) { mobileDataByte = GetOne(mobileDataByteNum); } } catch (Exception ex) { errorMsg = ex.Message; } return(errorMsg.IsNullOrEmpty() && mobileDataByte != null); }
///<summary>Called by eClipboard check-in once an appointment has been moved to the waiting room and the patient is ready to fill out forms. ///Returns number of new sheets created and inserted into Sheet table.</summary> public static int CreateSheetsForCheckIn(Appointment appt) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetInt(MethodBase.GetCurrentMethod(), appt)); } if (!MobileAppDevices.IsClinicSignedUpForEClipboard(PrefC.HasClinicsEnabled?appt.ClinicNum:0)) //this clinic isn't signed up for this feature { return(0); } if (!ClinicPrefs.GetBool(PrefName.EClipboardCreateMissingFormsOnCheckIn, appt.ClinicNum)) //This feature is turned off { return(0); } bool useDefault = ClinicPrefs.GetBool(PrefName.EClipboardUseDefaults, appt.ClinicNum); List <EClipboardSheetDef> listSheetsToCreate = EClipboardSheetDefs.GetForClinic(useDefault ? 0 : appt.ClinicNum); if (listSheetsToCreate.Count == 0) //There aren't any sheets to create here { return(0); } List <Sheet> listAlreadyCompleted = Sheets.GetForPatient(appt.PatNum); List <Sheet> listAlreadyInTerminal = Sheets.GetForTerminal(appt.PatNum); //if we already have sheets queued for the patient don't add duplicates if (listAlreadyInTerminal.Count > 0) { listAlreadyCompleted.RemoveAll(x => listAlreadyInTerminal.Select(y => y.SheetNum).Contains(x.SheetNum)); listSheetsToCreate.RemoveAll(x => listAlreadyInTerminal.Select(y => y.SheetDefNum).Contains(x.SheetDefNum)); } byte showInTerminal = GetBiggestShowInTerminal(appt.PatNum); List <Sheet> listNewSheets = new List <Sheet>(); foreach (EClipboardSheetDef sheetInsert in listSheetsToCreate.OrderBy(x => x.ItemOrder)) { //First check if we've already completed this form against our resubmission interval rules DateTime lastCompleted = listAlreadyCompleted .Where(x => x.SheetDefNum == sheetInsert.SheetDefNum) .OrderBy(x => x.DateTimeSheet) .LastOrDefault()?.DateTimeSheet ?? DateTime.MinValue; if (lastCompleted > DateTime.MinValue) { if (sheetInsert.ResubmitInterval.Days == 0) { continue; //If this interval is set to 0 and they've already completed this form once, we never want to create it automatically again } int elapsed = (DateTime.Today - lastCompleted.Date).Days; if (elapsed < sheetInsert.ResubmitInterval.Days) { continue; //The interval hasn't elapsed yet so we don't want to create this sheet } } SheetDef def = SheetDefs.GetSheetDef(sheetInsert.SheetDefNum); Sheet newSheet = CreateSheetFromSheetDef(def, appt.PatNum); SheetParameter.SetParameter(newSheet, "PatNum", appt.PatNum); SheetFiller.FillFields(newSheet); //Counting starts at 1 in this case and we don't want to ovewrite the previous number so increment first newSheet.ShowInTerminal = ++showInTerminal; listNewSheets.Add(newSheet); } SaveNewSheetList(listNewSheets); return(listNewSheets.Count); }