private void butPrint_Click(object sender, System.EventArgs e) { if (textBody.Text == "") { MsgBox.Show(this, "Letter not allowed to be blank."); return; } pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.OriginAtMargins = true; if (!Printers.SetPrinter(pd2, PrintSituation.Default)) { return; } try{ pd2.Print(); } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } Commlog CommlogCur = new Commlog(); CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = CommItemType.Misc; CommlogCur.PatNum = PatCur.PatNum; CommlogCur.Note = "Letter sent"; if (LetterCur != null) { CommlogCur.Note += ": " + LetterCur.Description + ". "; } FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; FormCI.ShowDialog(); //this window now closes regardless of whether the user saved the comm item. DialogResult = DialogResult.OK; }
private void phoneSmall_GoToChanged(object sender,EventArgs e) { if(phoneSmall.GotoPatNum==0) { return; } CurPatNum=phoneSmall.GotoPatNum; Patient pat=Patients.GetPat(CurPatNum); RefreshCurrentModule(); FillPatientButton(pat); Commlog commlog=Commlogs.GetIncompleteEntry(Security.CurUser.UserNum,CurPatNum); PhoneEmpDefault ped=PhoneEmpDefaults.GetByExtAndEmp(phoneSmall.Extension,Security.CurUser.EmployeeNum); if(ped!=null && ped.IsTriageOperator) { if(Plugins.HookMethod(this,"FormOpenDental.phoneSmall_GoToChanged_IsTriage",pat,phoneSmall.Extension)) { return; } Task task=new Task(); task.TaskListNum=-1;//don't show it in any list yet. Tasks.Insert(task); Task taskOld=task.Copy(); task.KeyNum=CurPatNum; task.ObjectType=TaskObjectType.Patient; task.TaskListNum=1697;//Hardcoded for internal Triage task list. task.UserNum=Security.CurUser.UserNum; task.Descript=Phones.GetPhoneForExtension(Phones.GetPhoneList(),phoneSmall.Extension).CustomerNumberRaw+" ";//Prefill description with customers number. FormTaskEdit FormTE=new FormTaskEdit(task,taskOld); FormTE.IsNew=true; FormTE.Show(); } else {//Not a triage operator. if(Plugins.HookMethod(this,"FormOpenDental.phoneSmall_GoToChanged_NotTriage",pat)) { return; } if(commlog==null) { commlog = new Commlog(); commlog.PatNum = CurPatNum; commlog.CommDateTime = DateTime.Now; commlog.CommType =Commlogs.GetTypeAuto(CommItemTypeAuto.MISC); commlog.Mode_=CommItemMode.Phone; commlog.SentOrReceived=CommSentOrReceived.Received; commlog.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(commlog); FormCI.IsNew = true; FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { RefreshCurrentModule(); } } else { FormCommItem FormCI=new FormCommItem(commlog); FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { RefreshCurrentModule(); } } } }
private void OnBreak_Click() { if(!PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment) && PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType)==0) { MsgBox.Show(this,"Broken appointment adjustment type is not setup yet. Please go to Setup | Modules to fix this."); return; } int thisI=GetIndex(ContrApptSingle.SelectedAptNum); if(thisI==-1) {//selected appt is on a different day MsgBox.Show(this,"Please select an appointment first."); return; } Appointment apt = Appointments.GetOneApt(ContrApptSingle.SelectedAptNum); Patient pat=Patients.GetPat(PIn.Long(ContrApptSingle3[thisI].DataRoww["PatNum"].ToString())); if(!Security.IsAuthorized(Permissions.AppointmentEdit)) { return; } if(apt.AptStatus == ApptStatus.PtNote || apt.AptStatus == ApptStatus.PtNoteCompleted) { MsgBox.Show(this,"Only appointments may be broken, not notes."); return; } if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { if(!MsgBox.Show(this,true,"Break appointment?")) { return; } } Appointments.SetAptStatus(ContrApptSingle.SelectedAptNum,ApptStatus.Broken); SecurityLogs.MakeLogEntry(Permissions.AppointmentMove,pat.PatNum, ContrApptSingle3[thisI].DataRoww["procs"].ToString()+", "+ContrApptSingle3[thisI].DataRoww["AptDateTime"].ToString()+", Broken from the Appts module.", PIn.Long(ContrApptSingle3[thisI].DataRoww["AptNum"].ToString())); //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if(HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7=MessageConstructor.GenerateSIU(pat,Patients.GetPat(pat.Guarantor),EventTypeHL7.S15,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=pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show(this,messageHL7.ToString()); #endif } } long provNum=PIn.Long(ContrApptSingle3[thisI].DataRoww["ProvNum"].ToString());//remember before ModuleSelected ProcedureCode procCodeBrokenApt=ProcedureCodes.GetProcCode("D9986"); if(procCodeBrokenApt.CodeNum!=0) {//ADA proc code D9986 exists Procedure procedureCur=new Procedure(); procedureCur.PatNum=pat.PatNum; procedureCur.ProvNum=provNum; procedureCur.ProcFee=0; procedureCur.CodeNum=procCodeBrokenApt.CodeNum; procedureCur.ProcDate=DateTime.Today; procedureCur.DateEntryC=DateTime.Now; procedureCur.ProcStatus=ProcStat.C; procedureCur.ClinicNum=pat.ClinicNum; procedureCur.Note=Lan.g(this,"Appt BROKEN for ")+apt.ProcDescript+" "+apt.AptDateTime.ToString(); Procedures.Insert(procedureCur); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List<InsSub> listInsSubs=InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List<InsPlan> listInsPlans=InsPlans.RefreshForSubList(listInsSubs); List<PatPlan> listPatPlans=PatPlans.Refresh(pat.PatNum); List<Benefit> listBenefits=Benefits.Refresh(listPatPlans,listInsSubs); List<ClaimProc> listClaimProcsForProc=ClaimProcs.RefreshForProc(procedureCur.ProcNum); Procedures.ComputeEstimates(procedureCur,pat.PatNum,listClaimProcsForProc,false,listInsPlans,listPatPlans,listBenefits,pat.Age,listInsSubs); FormProcEdit formP=new FormProcEdit(procedureCur,pat,Patients.GetFamily(pat.PatNum)); formP.IsNew=false; formP.ShowDialog(); if(PrefC.GetBool(PrefName.BrokenApptCommLogWithProcedure)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+apt.ProcDescript+" "+apt.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } } else {//No D9986 present if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+apt.ProcDescript+" "+apt.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } else { Adjustment AdjustmentCur=new Adjustment(); AdjustmentCur.DateEntry=DateTime.Today; AdjustmentCur.AdjDate=DateTime.Today; AdjustmentCur.ProcDate=DateTime.Today; AdjustmentCur.ProvNum=provNum; AdjustmentCur.PatNum=pat.PatNum; AdjustmentCur.AdjType=PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum=pat.ClinicNum; FormAdjust FormA=new FormAdjust(pat,AdjustmentCur); FormA.IsNew=true; FormA.ShowDialog(); } } ModuleSelected(pat.PatNum);//Must be ran after the "D9986" break logic due to the addition of a completed procedure. SetInvalid(); AutomationL.Trigger(AutomationTrigger.BreakAppointment,null,pat.PatNum); Recalls.SynchScheduledApptFull(apt.PatNum); }
private void OnCommlog_Click() { Commlog CommlogCur = new Commlog(); CommlogCur.PatNum = CurPatNum; CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType =Commlogs.GetTypeAuto(CommItemTypeAuto.MISC); if(PrefC.GetBool(PrefName.DistributorKey)) {//for OD HQ CommlogCur.Mode_=CommItemMode.None; CommlogCur.SentOrReceived=CommSentOrReceived.Neither; } else { CommlogCur.Mode_=CommItemMode.Phone; CommlogCur.SentOrReceived=CommSentOrReceived.Received; } CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; FormCI.ShowDialog(); if(FormCI.DialogResult == DialogResult.OK) { RefreshCurrentModule(); } }
private void butAddComm_Click(object sender,EventArgs e) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=AptCur.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); DS.Tables.Remove("Comm"); DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["Comm"].Copy()); //AppointmentL.GetApptEditComm(AptCur.AptNum)); FillComm(); }
private void OnBreak_Click() { if(!PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment) && PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType)==0) { MsgBox.Show(this,"Broken appointment adjustment type is not setup yet. Please go to Setup | Modules to fix this."); return; } int thisI=GetIndex(ContrApptSingle.SelectedAptNum); if(thisI==-1) {//selected appt is on a different day MsgBox.Show(this,"Please select an appointment first."); return; } Appointment apt = Appointments.GetOneApt(ContrApptSingle.SelectedAptNum); Patient pat=Patients.GetPat(PIn.Long(ContrApptSingle3[thisI].DataRoww["PatNum"].ToString())); if(!Security.IsAuthorized(Permissions.AppointmentEdit)) { return; } if(apt.AptStatus == ApptStatus.PtNote || apt.AptStatus == ApptStatus.PtNoteCompleted) { MsgBox.Show(this,"Only appointments may be broken, not notes."); return; } if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { if(!MsgBox.Show(this,true,"Break appointment?")) { return; } } Appointments.SetAptStatus(ContrApptSingle.SelectedAptNum,ApptStatus.Broken); SecurityLogs.MakeLogEntry(Permissions.AppointmentMove,pat.PatNum, ContrApptSingle3[thisI].DataRoww["procs"].ToString()+", "+ContrApptSingle3[thisI].DataRoww["AptDateTime"].ToString()+", Broken from the Appts module.", PIn.Long(ContrApptSingle3[thisI].DataRoww["AptNum"].ToString())); long provNum=PIn.Long(ContrApptSingle3[thisI].DataRoww["ProvNum"].ToString());//remember before ModuleSelected ModuleSelected(pat.PatNum); SetInvalid(); if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+apt.ProcDescript+" "+apt.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } else { Adjustment AdjustmentCur=new Adjustment(); AdjustmentCur.DateEntry=DateTime.Today; AdjustmentCur.AdjDate=DateTime.Today; AdjustmentCur.ProcDate=DateTime.Today; AdjustmentCur.ProvNum=provNum; AdjustmentCur.PatNum=pat.PatNum; AdjustmentCur.AdjType=PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum=pat.ClinicNum; FormAdjust FormA=new FormAdjust(pat,AdjustmentCur); FormA.IsNew=true; FormA.ShowDialog(); } AutomationL.Trigger(AutomationTrigger.BreakAppointment,null,pat.PatNum); Recalls.SynchScheduledApptFull(apt.PatNum); }
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); }
private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) { SelectedPatNum=PIn.Long(table.Rows[e.Row]["PatNum"].ToString()); Recall recall=Recalls.GetRecall(PIn.Long(table.Rows[e.Row]["RecallNum"].ToString())); FormRecallEdit FormR=new FormRecallEdit(); FormR.RecallCur=recall.Copy(); FormR.ShowDialog(); if(FormR.DialogResult!=DialogResult.OK) { return; } if(recall.RecallStatus!=FormR.RecallCur.RecallStatus//if the status has changed || (recall.IsDisabled != FormR.RecallCur.IsDisabled)//or any of the three disabled fields was changed || (recall.DisableUntilDate != FormR.RecallCur.DisableUntilDate) || (recall.DisableUntilBalance != FormR.RecallCur.DisableUntilBalance) || (recall.Note != FormR.RecallCur.Note))//or a note was added { //make a commlog entry //unless there is an existing recall commlog entry for today bool recallEntryToday=false; List<Commlog> CommlogList=Commlogs.Refresh(SelectedPatNum); for(int i=0;i<CommlogList.Count;i++) { if(CommlogList[i].CommDateTime.Date==DateTime.Today && CommlogList[i].CommType==Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL)) { recallEntryToday=true; } } if(!recallEntryToday) { Commlog CommlogCur=new Commlog(); CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL); CommlogCur.PatNum=SelectedPatNum; CommlogCur.Note=""; if(recall.RecallStatus!=FormR.RecallCur.RecallStatus) { if(FormR.RecallCur.RecallStatus==0) { CommlogCur.Note+=Lan.g(this,"Status None"); } else { CommlogCur.Note+=DefC.GetName(DefCat.RecallUnschedStatus,FormR.RecallCur.RecallStatus); } } if(recall.DisableUntilDate!=FormR.RecallCur.DisableUntilDate && FormR.RecallCur.DisableUntilDate.Year>1880) { if(CommlogCur.Note!="") { CommlogCur.Note+=", "; } CommlogCur.Note+=Lan.g(this,"Disabled until ")+FormR.RecallCur.DisableUntilDate.ToShortDateString(); } if(recall.DisableUntilBalance!=FormR.RecallCur.DisableUntilBalance && FormR.RecallCur.DisableUntilBalance>0) { if(CommlogCur.Note!="") { CommlogCur.Note+=", "; } CommlogCur.Note+=Lan.g(this,"Disabled until balance below ")+FormR.RecallCur.DisableUntilBalance.ToString("c"); } if(recall.Note!=FormR.RecallCur.Note) { if(CommlogCur.Note!="") { CommlogCur.Note+=", "; } CommlogCur.Note+=FormR.RecallCur.Note; } CommlogCur.Note+=". "; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; //forces user to at least consider a commlog entry FormCI.ShowDialog();//typically saved in this window. } } FillMain(null); for(int i=0;i<gridMain.Rows.Count;i++) { if(PIn.Long(table.Rows[i]["PatNum"].ToString())==SelectedPatNum){ gridMain.SetSelected(i,true); } } SetFamilyColors(); }
///<summary>Called from butOK_Click and butPin_Click</summary> private bool UpdateToDB(){ DateTime dateTimeAskedToArrive=DateTime.MinValue; if((AptOld.AptStatus==ApptStatus.Complete && comboStatus.SelectedIndex!=1) || (AptOld.AptStatus==ApptStatus.Broken && comboStatus.SelectedIndex!=4)) //Un-completing or un-breaking the appt. We must use selectedindex due to AptCur gets updated later UpdateDB() { //If the insurance plans have changed since this appt was completed, warn the user that the historical data will be neutralized. List<PatPlan> listPatPlans=PatPlans.Refresh(pat.PatNum); InsSub sub1=InsSubs.GetSub(PatPlans.GetInsSubNum(listPatPlans,PatPlans.GetOrdinal(PriSecMed.Primary,listPatPlans,PlanList,SubList)),SubList); InsSub sub2=InsSubs.GetSub(PatPlans.GetInsSubNum(listPatPlans,PatPlans.GetOrdinal(PriSecMed.Secondary,listPatPlans,PlanList,SubList)),SubList); if(sub1.PlanNum!=AptCur.InsPlan1 || sub2.PlanNum!=AptCur.InsPlan2) { if(!MsgBox.Show(this,MsgBoxButtons.OKCancel,"The current insurance plans for this patient are different than the plans associated to this appointment. They will be updated to the patient's current insurance plans. Continue?")) { return false; } //Update the ins plans associated to this appointment so that they're the most accurate at this time. AptCur.InsPlan1=sub1.PlanNum; AptCur.InsPlan2=sub2.PlanNum; } } if(textTimeAskedToArrive.Text!=""){ try{ dateTimeAskedToArrive=AptCur.AptDateTime.Date+DateTime.Parse(textTimeAskedToArrive.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Asked To Arrive invalid."); return false; } } DateTime dateTimeArrived=AptCur.AptDateTime.Date; if(textTimeArrived.Text!=""){ try{ dateTimeArrived=AptCur.AptDateTime.Date+DateTime.Parse(textTimeArrived.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Arrived invalid."); return false; } } DateTime dateTimeSeated=AptCur.AptDateTime.Date; if(textTimeSeated.Text!=""){ try{ dateTimeSeated=AptCur.AptDateTime.Date+DateTime.Parse(textTimeSeated.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Seated invalid."); return false; } } DateTime dateTimeDismissed=AptCur.AptDateTime.Date; if(textTimeDismissed.Text!=""){ try{ dateTimeDismissed=AptCur.AptDateTime.Date+DateTime.Parse(textTimeDismissed.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Arrived invalid."); return false; } } //This change was just slightly too risky to make to 6.9, so 7.0 only if(AptCur.AptStatus!=ApptStatus.Complete//was not originally complete && AptCur.AptStatus!=ApptStatus.PtNote && AptCur.AptStatus!=ApptStatus.PtNoteCompleted && comboStatus.SelectedIndex==1 //making it complete && AptCur.AptDateTime.Date > DateTime.Today)//and future appt { MsgBox.Show(this,"Not allowed to set complete future appointments."); return false; } string aptPattern=Appointments.ConvertPatternTo5(strBTime.ToString()); //Only run appt overlap check if editing an appt not in unscheduled list and in chart module and eCW program link not enabled. if((IsInChartModule || IsInViewPatAppts) && !Programs.UsingEcwTightOrFullMode() && AptCur.AptStatus!=ApptStatus.UnschedList) { //==Travis 04/06/2015: This call was added on 04/23/2014 and backported to 14.1. It is not storing the return value and does not look to be // doing anything so it has been commented out. //Appointments.RefreshPeriod(AptCur.AptDateTime,AptCur.AptDateTime); List<Appointment> apptList=Appointments.GetForPeriodList(AptCur.AptDateTime,AptCur.AptDateTime); if(DoesOverlap(aptPattern,apptList)) { MsgBox.Show(this,"Appointment is too long and would overlap another appointment. Automatically shortened to fit."); do { aptPattern=aptPattern.Substring(0,aptPattern.Length-1); if(aptPattern.Length==1) { break; } } while(DoesOverlap(aptPattern,apptList)); } } if(AptCur.AptStatus == ApptStatus.Planned) { ; } else if(comboStatus.SelectedIndex==-1) { AptCur.AptStatus=ApptStatus.Scheduled; } else if (AptCur.AptStatus == ApptStatus.PtNote | AptCur.AptStatus == ApptStatus.PtNoteCompleted){ AptCur.AptStatus = (ApptStatus)comboStatus.SelectedIndex + 7; } else { AptCur.AptStatus=(ApptStatus)comboStatus.SelectedIndex+1; } //set procs complete was moved further down //convert from current increment into 5 minute increment //MessageBox.Show(strBTime.ToString()); AptCur.Pattern=aptPattern; if(comboUnschedStatus.SelectedIndex==0){//none AptCur.UnschedStatus=0; } else{ AptCur.UnschedStatus=DefC.Short[(int)DefCat.RecallUnschedStatus][comboUnschedStatus.SelectedIndex-1].DefNum; } if(comboConfirmed.SelectedIndex!=-1){ AptCur.Confirmed=DefC.Short[(int)DefCat.ApptConfirmed][comboConfirmed.SelectedIndex].DefNum; } AptCur.TimeLocked=checkTimeLocked.Checked; AptCur.ColorOverride=butColor.BackColor; AptCur.Note=textNote.Text; if(comboClinic.SelectedIndex==0) {//none AptCur.ClinicNum=0; } else { AptCur.ClinicNum=Clinics.List[comboClinic.SelectedIndex-1].ClinicNum; } //there should always be a non-hidden primary provider for an appt. if(comboProvNum.SelectedIndex==-1) { AptCur.ProvNum=ProviderC.ListShort[0].ProvNum; } else { AptCur.ProvNum=ProviderC.ListShort[comboProvNum.SelectedIndex].ProvNum; } if(comboProvHyg.SelectedIndex==0) {//none AptCur.ProvHyg=0; } else { AptCur.ProvHyg=ProviderC.ListShort[comboProvHyg.SelectedIndex-1].ProvNum; } AptCur.IsHygiene=checkIsHygiene.Checked; if(comboAssistant.SelectedIndex==0) {//none AptCur.Assistant=0; } else { AptCur.Assistant=Employees.ListShort[comboAssistant.SelectedIndex-1].EmployeeNum; } AptCur.IsNewPatient=checkIsNewPatient.Checked; AptCur.DateTimeAskedToArrive=dateTimeAskedToArrive; AptCur.DateTimeArrived=dateTimeArrived; AptCur.DateTimeSeated=dateTimeSeated; AptCur.DateTimeDismissed=dateTimeDismissed; //AptCur.InsPlan1 and InsPlan2 already handled //The ApptProcDescript region is also in FormProcEdit.SaveAndClose() and FormDatabaseMaintenance.butApptProcs_Click() Make any changes there as well. #region ApptProcDescript AptCur.ProcDescript=""; AptCur.ProcsColored=""; for(int i=0;i<gridProc.SelectedIndices.Length;i++) { string procDescOne=""; string procCode=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ProcCode"].ToString(); if(i>0){ AptCur.ProcDescript+=", "; } switch(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["TreatArea"].ToString()) { case "1"://TreatmentArea.Surf: procDescOne+="#"+Tooth.GetToothLabel(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ToothNum"].ToString())+"-" +DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//""#12-MOD-" break; case "2"://TreatmentArea.Tooth: procDescOne+="#"+Tooth.GetToothLabel(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ToothNum"].ToString())+"-";//"#12-" break; default://area 3 or 0 (mouth) break; case "4"://TreatmentArea.Quad: procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"UL-" break; case "5"://TreatmentArea.Sextant: procDescOne+="S"+DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"S2-" break; case "6"://TreatmentArea.Arch: procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"U-" break; case "7"://TreatmentArea.ToothRange: //strLine+=table.Rows[j][13].ToString()+" ";//don't show range break; } procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["AbbrDesc"].ToString(); AptCur.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(AptCur.PatNum,AptCur.AptDateTime,pac.CodeRange); if(prevDateString!="") { prevDateString=" ("+prevDateString+")"; } } } AptCur.ProcsColored+="<span color=\""+pColor.ToArgb().ToString()+"\">"+procDescOne+prevDateString+"</span>"; } #endregion bool isPlanned=AptCur.AptStatus==ApptStatus.Planned; if(comboApptType.SelectedIndex==0) {//0 index = none. AptCur.AppointmentTypeNum=0; } else { AptCur.AppointmentTypeNum=_listAppointmentType[comboApptType.SelectedIndex-1].AppointmentTypeNum; } try { Appointments.Update(AptCur,AptOld); //Appointments.UpdateAttached(AptCur.AptNum,procNums,isPlanned); } catch(ApplicationException ex) { MessageBox.Show(ex.Message); return false; } //if appointment is marked complete and any procedures are not, //then set the remaining procedures complete if(AptCur.AptStatus==ApptStatus.Complete) { bool allProcsComplete=true; for(int i=0;i<gridProc.SelectedIndices.Length;i++){ if(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ProcStatus"].ToString()!="2") {//Complete allProcsComplete=false; break; } } if(!allProcsComplete) { if(!Security.IsAuthorized(Permissions.ProcComplCreate,AptCur.AptDateTime)) { return false; } List <PatPlan> PatPlanList=PatPlans.Refresh(AptCur.PatNum); ProcedureL.SetCompleteInAppt(AptCur,PlanList,PatPlanList,pat.SiteNum,pat.Age,SubList); SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit,pat.PatNum, AptCur.AptDateTime.ToShortDateString()+", "+AptCur.ProcDescript+", Procedures automatically set complete due to appt being set complete",AptCur.AptNum); } } else{ Procedures.SetProvidersInAppointment(AptCur,Procedures.GetProcsForSingle(AptCur.AptNum,false)); } //Do the appointment "break" automation for appointments that were just broken. if(AptCur.AptStatus==ApptStatus.Broken && AptOld.AptStatus!=ApptStatus.Broken) { SecurityLogs.MakeLogEntry(Permissions.AppointmentMove,pat.PatNum,AptCur.ProcDescript+", "+AptCur.AptDateTime.ToString() +", Broken by changing the Status in the Edit Appointment window.",AptCur.AptNum); //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if(HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7=MessageConstructor.GenerateSIU(pat,fam.GetPatient(pat.Guarantor),EventTypeHL7.S15,AptCur); //Will be null if there is no outbound SIU message defined, so do nothing if(messageHL7!=null) { HL7Msg hl7Msg=new HL7Msg(); hl7Msg.AptNum=AptCur.AptNum; hl7Msg.HL7Status=HL7MessageStatus.OutPending;//it will be marked outSent by the HL7 service. hl7Msg.MsgText=messageHL7.ToString(); hl7Msg.PatNum=pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show(this,messageHL7.ToString()); #endif } } ProcedureCode procCodeBrokenApt=ProcedureCodes.GetProcCode("D9986"); if(procCodeBrokenApt.CodeNum!=0) {//ADA proc code D9986 exists Procedure procedureCur=new Procedure(); procedureCur.PatNum=pat.PatNum; procedureCur.ProvNum=AptCur.ProvNum; procedureCur.ProcFee=0; procedureCur.CodeNum=procCodeBrokenApt.CodeNum; procedureCur.ProcDate=DateTime.Today; procedureCur.DateEntryC=DateTime.Now; procedureCur.ProcStatus=ProcStat.C; procedureCur.ClinicNum=pat.ClinicNum; procedureCur.Note=Lan.g(this,"Appt BROKEN for ")+AptCur.ProcDescript+" "+AptCur.AptDateTime.ToString(); Procedures.Insert(procedureCur); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List<InsSub> listInsSubs=InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List<InsPlan> listInsPlans=InsPlans.RefreshForSubList(listInsSubs); List<PatPlan> listPatPlans=PatPlans.Refresh(pat.PatNum); List<Benefit> listBenefits=Benefits.Refresh(listPatPlans,listInsSubs); List<ClaimProc> listClaimProcsForProc=ClaimProcs.RefreshForProc(procedureCur.ProcNum); Procedures.ComputeEstimates(procedureCur,pat.PatNum,listClaimProcsForProc,false,listInsPlans,listPatPlans,listBenefits,pat.Age,listInsSubs); FormProcEdit FormP=new FormProcEdit(procedureCur,pat,Patients.GetFamily(pat.PatNum)); FormP.IsNew=false; FormP.ShowDialog(); if(PrefC.GetBool(PrefName.BrokenApptCommLogWithProcedure)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+AptCur.ProcDescript+" "+AptCur.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } } else {//No D9986 present if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+AptCur.ProcDescript+" "+AptCur.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } else { Adjustment AdjustmentCur=new Adjustment(); AdjustmentCur.DateEntry=DateTime.Today; AdjustmentCur.AdjDate=DateTime.Today; AdjustmentCur.ProcDate=DateTime.Today; AdjustmentCur.ProvNum=AptCur.ProvNum; AdjustmentCur.PatNum=pat.PatNum; AdjustmentCur.AdjType=PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum=pat.ClinicNum; FormAdjust FormA=new FormAdjust(pat,AdjustmentCur); FormA.IsNew=true; FormA.ShowDialog(); } } AutomationL.Trigger(AutomationTrigger.BreakAppointment,null,pat.PatNum); } return true; }
private void gridProg_CellDoubleClick(object sender,ODGridClickEventArgs e) { //Chartscrollval = gridProg.ScrollValue; DataRow row = (DataRow)gridProg.Rows[e.Row].Tag; if(row["ProcNum"].ToString() != "0") { if(checkAudit.Checked) { MsgBox.Show(this,"Not allowed to edit procedures when in audit mode."); return; } Procedure proc = Procedures.GetOneProc(PIn.Long(row["ProcNum"].ToString()),true); FormProcEdit FormP = new FormProcEdit(proc,PatCur,FamCur); FormP.ShowDialog(); if(FormP.DialogResult != DialogResult.OK) { return; } } else if(row["CommlogNum"].ToString() != "0") { Commlog comm = Commlogs.GetOne(PIn.Long(row["CommlogNum"].ToString())); FormCommItem FormC = new FormCommItem(comm); FormC.ShowDialog(); if(FormC.DialogResult != DialogResult.OK) { return; } } else if(row["RxNum"].ToString() != "0") { RxPat rx = RxPats.GetRx(PIn.Long(row["RxNum"].ToString())); FormRxEdit FormRxE = new FormRxEdit(PatCur,rx); FormRxE.ShowDialog(); if(FormRxE.DialogResult != DialogResult.OK) { return; } } else if(row["LabCaseNum"].ToString() != "0") { LabCase lab = LabCases.GetOne(PIn.Long(row["LabCaseNum"].ToString())); FormLabCaseEdit FormL = new FormLabCaseEdit(); FormL.CaseCur = lab; FormL.ShowDialog(); } else if(row["TaskNum"].ToString() != "0") { Task task = Tasks.GetOne(PIn.Long(row["TaskNum"].ToString())); FormTaskEdit FormT = new FormTaskEdit(task,task.Copy()); FormT.Closing+=new CancelEventHandler(TaskGoToEvent); FormT.Show();//non-modal } else if(row["AptNum"].ToString() != "0") { //Appointment apt=Appointments.GetOneApt( FormApptEdit FormA = new FormApptEdit(PIn.Long(row["AptNum"].ToString())); //PinIsVisible=false FormA.ShowDialog(); if(FormA.DialogResult != DialogResult.OK) { return; } } else if(row["EmailMessageNum"].ToString() != "0") { EmailMessage msg = EmailMessages.GetOne(PIn.Long(row["EmailMessageNum"].ToString())); FormEmailMessageEdit FormE = new FormEmailMessageEdit(msg); FormE.ShowDialog(); if(FormE.DialogResult != DialogResult.OK) { return; } } ModuleSelected(PatCur.PatNum); }
private void gridComm_CellDoubleClick(object sender,OpenDental.UI.ODGridClickEventArgs e) { //TODO: transition this to checking the Tag object. int row=e.Row; if(!this.checkShowFamilyComm.Checked) {//if only showing entries for one patient instead of intermingled family entries int i; for(row=0,i=0;row<DataSetMain.Tables["Commlog"].Rows.Count;row++) { //Matching FName is not perfect because children can have the same names as parents. //But it does currently match the logic for display, so it will at least select the right row when double clicked. if(DataSetMain.Tables["Commlog"].Rows[row]["patName"].ToString()==PatCur.FName || DataSetMain.Tables["Commlog"].Rows[row]["patName"].ToString()=="") { if(i==e.Row) { break; } i++; } } } if(DataSetMain.Tables["Commlog"].Rows[row]["CommlogNum"].ToString()!="0") { Commlog CommlogCur= Commlogs.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["CommlogNum"].ToString())); FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else if(DataSetMain.Tables["Commlog"].Rows[row]["EmailMessageNum"].ToString()!="0") { EmailMessage email= EmailMessages.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["EmailMessageNum"].ToString())); FormEmailMessageEdit FormE=new FormEmailMessageEdit(email); FormE.ShowDialog(); if(FormE.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else if(DataSetMain.Tables["Commlog"].Rows[row]["FormPatNum"].ToString()!="0") { FormPat form=FormPats.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["FormPatNum"].ToString())); FormFormPatEdit FormP=new FormFormPatEdit(); FormP.FormPatCur=form; FormP.ShowDialog(); if(FormP.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else if(DataSetMain.Tables["Commlog"].Rows[row]["SheetNum"].ToString()!="0") { Sheet sheet=Sheets.GetSheet(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["SheetNum"].ToString())); FormSheetFillEdit FormSFE=new FormSheetFillEdit(sheet); FormSFE.ShowDialog(); if(FormSFE.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } }
private void butAddComm_Click(object sender, System.EventArgs e) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=CommItemType.ApptRelated; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); FillComm(); }
private void tbCommlog_CellDoubleClicked(object sender, CellEventArgs e){ FormCommItem FormCI=new FormCommItem((Commlog)ALCommItems[e.Row]); FormCI.ShowDialog(); FillComm(); }
private void gridComm_CellDoubleClick(object sender,OpenDental.UI.ODGridClickEventArgs e) { int row=(int)gridComm.Rows[e.Row].Tag; if(DataSetMain.Tables["Commlog"].Rows[row]["CommlogNum"].ToString()!="0") { Commlog CommlogCur= Commlogs.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["CommlogNum"].ToString())); FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else if(DataSetMain.Tables["Commlog"].Rows[row]["EmailMessageNum"].ToString()!="0") { EmailMessage email= EmailMessages.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["EmailMessageNum"].ToString())); if(email.SentOrReceived==EmailSentOrReceived.WebMailReceived || email.SentOrReceived==EmailSentOrReceived.WebMailRecdRead || email.SentOrReceived==EmailSentOrReceived.WebMailSent || email.SentOrReceived==EmailSentOrReceived.WebMailSentRead) { //web mail uses special secure messaging portal FormWebMailMessageEdit FormWMME=new FormWebMailMessageEdit(PatCur.PatNum,email.EmailMessageNum); if(FormWMME.ShowDialog()==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else { FormEmailMessageEdit FormE=new FormEmailMessageEdit(email); FormE.ShowDialog(); if(FormE.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } } else if(DataSetMain.Tables["Commlog"].Rows[row]["FormPatNum"].ToString()!="0") { FormPat form=FormPats.GetOne(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["FormPatNum"].ToString())); FormFormPatEdit FormP=new FormFormPatEdit(); FormP.FormPatCur=form; FormP.ShowDialog(); if(FormP.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } else if(DataSetMain.Tables["Commlog"].Rows[row]["SheetNum"].ToString()!="0") { Sheet sheet=Sheets.GetSheet(PIn.Long(DataSetMain.Tables["Commlog"].Rows[row]["SheetNum"].ToString())); FormSheetFillEdit FormSFE=new FormSheetFillEdit(sheet); FormSFE.ShowDialog(); if(FormSFE.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum); } } }
private void butSetStatus_Click(object sender, System.EventArgs e) { if(gridMain.SelectedIndices.Length==0) { MsgBox.Show(this,"Please select a patient first."); return; } //bool makeCommEntries=MsgBox.Show(this,MsgBoxButtons.OKCancel,"Add Commlog (reminder) entries for each patient?"); long newStatus=0; if(comboStatus.SelectedIndex>0) { newStatus=DefC.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex-1].DefNum; } for(int i=0;i<gridMain.SelectedIndices.Length;i++){ Recalls.UpdateStatus(PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["RecallNum"].ToString()),newStatus); } //show the first one, and then make all the others very similar Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString()); CommlogCur.CommDateTime=DateTime.Now; CommlogCur.SentOrReceived=CommSentOrReceived.Sent; CommlogCur.Mode_=CommItemMode.Phone;//user can change this, of course. CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL); CommlogCur.UserNum=Security.CurUser.UserNum; CommlogCur.Note=Lan.g(this,"Recall reminder."); if(comboStatus.SelectedIndex>0) { CommlogCur.Note+=" "+DefC.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex-1].ItemName; } else{ CommlogCur.Note+=" "+Lan.g(this,"Status None"); } FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); if(FormCI.DialogResult!=DialogResult.OK) {//if user cancels, then the other comm entries won't go in either FillMain(null); return; } for(int i=1;i<gridMain.SelectedIndices.Length;i++) { CommlogCur.PatNum=PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString()); Commlogs.Insert(CommlogCur); } FillMain(null); }
private void butCommlog_Click(object sender,EventArgs e) { if(gridMain.SelectedIndices.Length==0) { MsgBox.Show(this,"Please select a patient first."); return; } //show the first one, and then make all the others very similar Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=PIn.Long(table.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString()); CommlogCur.CommDateTime=DateTime.Now; CommlogCur.SentOrReceived=CommSentOrReceived.Sent; CommlogCur.Mode_=CommItemMode.Phone;//user can change this, of course. CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.RECALL); CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); if(FormCI.DialogResult!=DialogResult.OK) { return; } for(int i=1;i<gridMain.SelectedIndices.Length;i++) { CommlogCur.PatNum=PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString()); Commlogs.Insert(CommlogCur); } FillMain(null); }
///<summary>Only used for eCW tight. Everyone else has the commlog button up in the main toolbar.</summary> private void Tool_Commlog_Click() { Commlog CommlogCur = new Commlog(); CommlogCur.PatNum = PatCur.PatNum; CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType =Commlogs.GetTypeAuto(CommItemTypeAuto.MISC); CommlogCur.Mode_=CommItemMode.Phone; CommlogCur.SentOrReceived=CommSentOrReceived.Received; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; FormCI.ShowDialog(); if(FormCI.DialogResult == DialogResult.OK) { ModuleSelected(PatCur.PatNum); } }
///<summary>ProcCodes will be null unless trigger is CompleteProcedure. This routine will generally fail silently. Will return true if a trigger happened.</summary> public static bool Trigger(AutomationTrigger trigger,List<string> procCodes,long patNum) { if(patNum==0) {//Could happen for OpenPatient trigger return false; } bool automationHappened=false; for(int i=0;i<Automations.Listt.Count;i++) { if(Automations.Listt[i].Autotrigger!=trigger) { continue; } if(trigger==AutomationTrigger.CompleteProcedure) { if(procCodes==null) { continue;//fail silently } bool codeFound=false; string[] arrayCodes=Automations.Listt[i].ProcCodes.Split(','); for(int p=0;p<procCodes.Count;p++) { for(int a=0;a<arrayCodes.Length;a++) { if(arrayCodes[a]==procCodes[p]) { codeFound=true; break; } } } if(!codeFound) { continue; } } //matching automation item has been found //Get possible list of conditions that exist for this automation item List<AutomationCondition> autoConditionsList=AutomationConditions.GetListByAutomationNum(Automations.Listt[i].AutomationNum); if(Automations.Listt[i].AutoAction==AutomationAction.CreateCommlog) { if(autoConditionsList.Count>0) { if(!CheckAutomationConditions(autoConditionsList,patNum)) { continue; } } Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=patNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Automations.Listt[i].CommType; CommlogCur.Note=Automations.Listt[i].MessageContent; CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); automationHappened=true; } else if(Automations.Listt[i].AutoAction==AutomationAction.PopUp) { if(autoConditionsList.Count>0) { if(!CheckAutomationConditions(autoConditionsList,patNum)) { continue; } } MessageBox.Show(Automations.Listt[i].MessageContent); automationHappened=true; } else if(Automations.Listt[i].AutoAction==AutomationAction.PrintPatientLetter) { if(autoConditionsList.Count>0) { if(!CheckAutomationConditions(autoConditionsList,patNum)) { continue; } } SheetDef sheetDef=SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet=SheetUtil.CreateSheet(sheetDef,patNum); SheetParameter.SetParameter(sheet,"PatNum",patNum); //SheetParameter.SetParameter(sheet,"ReferralNum",referral.ReferralNum); SheetFiller.FillFields(sheet); using(Bitmap bmp=new Bitmap(100,100)) {//a dummy bitmap for the graphics object using(Graphics g=Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet,g); } } FormSheetFillEdit FormSF=new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened=true; } else if(Automations.Listt[i].AutoAction==AutomationAction.PrintReferralLetter) { if(autoConditionsList.Count>0) { if(!CheckAutomationConditions(autoConditionsList,patNum)) { continue; } } long referralNum=RefAttaches.GetReferralNum(patNum); if(referralNum==0) { MsgBox.Show("Automations","This patient has no referral source entered."); automationHappened=true; continue; } SheetDef sheetDef=SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet=SheetUtil.CreateSheet(sheetDef,patNum); SheetParameter.SetParameter(sheet,"PatNum",patNum); SheetParameter.SetParameter(sheet,"ReferralNum",referralNum); SheetFiller.FillFields(sheet); using(Bitmap bmp=new Bitmap(100,100)) {//a dummy bitmap for the graphics object using(Graphics g=Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet,g); } } FormSheetFillEdit FormSF=new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened=true; } else if(Automations.Listt[i].AutoAction==AutomationAction.ShowExamSheet) { if(autoConditionsList.Count>0) { if(!CheckAutomationConditions(autoConditionsList,patNum)) { continue; } } SheetDef sheetDef=SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet=SheetUtil.CreateSheet(sheetDef,patNum); SheetParameter.SetParameter(sheet,"PatNum",patNum); SheetFiller.FillFields(sheet); using(Bitmap bmp=new Bitmap(100,100)) {//a dummy bitmap for the graphics object using(Graphics g=Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet,g); } } FormSheetFillEdit FormSF=new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened=true; } } return automationHappened; }
private void gridProg_CellDoubleClick(object sender,ODGridClickEventArgs e) { Chartscrollval=gridProg.ScrollValue; DataRow row=(DataRow)gridProg.Rows[e.Row].Tag; if(row["ProcNum"].ToString()!="0"){ if(checkAudit.Checked){ MsgBox.Show(this,"Not allowed to edit procedures when in audit mode."); return; } Procedure proc=Procedures.GetOneProc(PIn.Long(row["ProcNum"].ToString()),true); if(ProcedureCodes.GetStringProcCode(proc.CodeNum)==ProcedureCodes.GroupProcCode){ FormProcGroup FormP=new FormProcGroup(); List<ProcGroupItem> groupItemList=ProcGroupItems.GetForGroup(proc.ProcNum); List<Procedure> procList=new List<Procedure>(); for(int i=0;i<groupItemList.Count;i++){ procList.Add(Procedures.GetOneProc(groupItemList[i].ProcNum,false)); } FormP.GroupCur=proc; FormP.GroupItemList=groupItemList; FormP.ProcList=procList; FormP.ShowDialog(); if(FormP.DialogResult==DialogResult.OK){ ModuleSelected(PatCur.PatNum); FillProgNotes(); } return; } else{ FormProcEdit FormP=new FormProcEdit(proc,PatCur,FamCur); Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_proc", proc, FormP); if(!FormP.IsDisposed) { //Form might be disposed by the above hook. FormP.ShowDialog(); } Plugins.HookAddCode(this, "ContrChart.gridProg_CellDoubleClick_proc2", proc, FormP); if(FormP.DialogResult!=DialogResult.OK) { return; } } } else if(row["CommlogNum"].ToString()!="0"){ Commlog comm=Commlogs.GetOne(PIn.Long(row["CommlogNum"].ToString())); FormCommItem FormC=new FormCommItem(comm); FormC.ShowDialog(); if(FormC.DialogResult!=DialogResult.OK){ return; } } else if(row["RxNum"].ToString()!="0") { RxPat rx=RxPats.GetRx(PIn.Long(row["RxNum"].ToString())); FormRxEdit FormRxE=new FormRxEdit(PatCur,rx); FormRxE.ShowDialog(); if(FormRxE.DialogResult!=DialogResult.OK){ return; } } else if(row["LabCaseNum"].ToString()!="0") { LabCase lab=LabCases.GetOne(PIn.Long(row["LabCaseNum"].ToString())); FormLabCaseEdit FormL=new FormLabCaseEdit(); FormL.CaseCur=lab; FormL.ShowDialog(); //needs to always refresh due to complex ok/cancel } else if(row["TaskNum"].ToString()!="0") { Task task=Tasks.GetOne(PIn.Long(row["TaskNum"].ToString())); if(task==null) { MsgBox.Show(this,"This task has been deleted by another user."); } else { FormTaskEdit FormT=new FormTaskEdit(task,task.Copy()); FormT.Closing+=new CancelEventHandler(TaskGoToEvent); FormT.Show();//non-modal } } else if(row["AptNum"].ToString()!="0") { //Appointment apt=Appointments.GetOneApt( FormApptEdit FormA=new FormApptEdit(PIn.Long(row["AptNum"].ToString())); //PinIsVisible=false FormA.IsInChartModule=true; FormA.ShowDialog(); if(FormA.CloseOD) { ((Form)this.Parent).Close(); return; } if(FormA.DialogResult!=DialogResult.OK) { return; } } else if(row["EmailMessageNum"].ToString()!="0") { EmailMessage msg=EmailMessages.GetOne(PIn.Long(row["EmailMessageNum"].ToString())); if(msg.SentOrReceived==EmailSentOrReceived.WebMailReceived || msg.SentOrReceived==EmailSentOrReceived.WebMailRecdRead || msg.SentOrReceived==EmailSentOrReceived.WebMailSent || msg.SentOrReceived==EmailSentOrReceived.WebMailSentRead) { //web mail uses special secure messaging portal FormWebMailMessageEdit FormWMME=new FormWebMailMessageEdit(PatCur.PatNum,msg.EmailMessageNum); if(FormWMME.ShowDialog()!=DialogResult.OK) { return; } } else { FormEmailMessageEdit FormE=new FormEmailMessageEdit(msg); FormE.ShowDialog(); if(FormE.DialogResult!=DialogResult.OK) { return; } } } else if(row["SheetNum"].ToString()!="0") { Sheet sheet=Sheets.GetSheet(PIn.Long(row["SheetNum"].ToString())); FormSheetFillEdit FormSFE=new FormSheetFillEdit(sheet); FormSFE.ShowDialog(); if(FormSFE.DialogResult!=DialogResult.OK) { return; } } else if(row["FormPatNum"].ToString()!="0"){ FormPat form=FormPats.GetOne(PIn.Long(row["FormPatNum"].ToString())); FormFormPatEdit FormP=new FormFormPatEdit(); FormP.FormPatCur=form; FormP.ShowDialog(); if(FormP.DialogResult==DialogResult.OK) { ModuleSelected(PatCur.PatNum);//Why is this called here and down 3 lines? Do we need the Allocator, or should we return here? } } ModuleSelected(PatCur.PatNum); Reporting.Allocators.MyAllocator1_ProviderPayment.AllocateWithToolCheck(this.PatCur.Guarantor); }
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); }
///<summary>Sets given appt.AptStatus to broken. ///Provide procCode that should be charted, can be null but will not chart a broken procedure. ///Also considers various broken procedure based prefs. ///Makes its own securitylog entries.</summary> public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode) { //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed. DateTime datePrevious = appt.DateTStamp; bool suppressHistory = false; if (procCode != null) { suppressHistory = (procCode.ProcCode.In("D9986", "D9987")); } Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods if (appt.AptStatus != ApptStatus.Complete) //seperate log entry for completed appointments. { SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } else { SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } #region HL7 //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if (HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt); //Will be null if there is no outbound SIU message defined, so do nothing if (messageHL7 != null) { HL7Msg hl7Msg = new HL7Msg(); hl7Msg.AptNum = appt.AptNum; hl7Msg.HL7Status = HL7MessageStatus.OutPending; //it will be marked outSent by the HL7 service. hl7Msg.MsgText = messageHL7.ToString(); hl7Msg.PatNum = pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show("Appointments", messageHL7.ToString()); #endif } } #endregion List <Procedure> listProcedures = new List <Procedure>(); //splits should only exist on procs if they are using tp pre-payments List <PaySplit> listSplitsForApptProcs = new List <PaySplit>(); bool isNonRefundable = false; double brokenProcAmount = 0; Procedure brokenProcedure = new Procedure(); bool wasBrokenProcDeleted = false; if (PrefC.GetYN(PrefName.PrePayAllowedForTpProcs)) { listProcedures = Procedures.GetProcsForSingle(appt.AptNum, false); if (listProcedures.Count > 0) { listSplitsForApptProcs = PaySplits.GetPaySplitsFromProcs(listProcedures.Select(x => x.ProcNum).ToList()); } } #region Charting the proc if (procCode != null) { switch (procCode.ProcCode) { case "D9986": //Missed HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed); break; case "D9987": //Cancelled HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled); break; } brokenProcedure.PatNum = pat.PatNum; brokenProcedure.ProvNum = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum); brokenProcedure.CodeNum = procCode.CodeNum; brokenProcedure.ProcDate = DateTime.Today; brokenProcedure.DateEntryC = DateTime.Now; brokenProcedure.ProcStatus = ProcStat.C; brokenProcedure.ClinicNum = appt.ClinicNum; brokenProcedure.UserNum = Security.CurUser.UserNum; brokenProcedure.Note = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); brokenProcedure.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. List <InsSub> listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan insPlanPrimary = null; InsSub insSubPrimary = null; if (listPatPlans.Count > 0) { insSubPrimary = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans); } double procFee; long feeSch; if (insPlanPrimary == null || procCode.NoBillIns) { feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, brokenProcedure.ProvNum); } else //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns { feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, brokenProcedure.ProvNum); } procFee = Fees.GetAmount0(brokenProcedure.CodeNum, feeSch, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical) //PPO { double provFee = Fees.GetAmount0(brokenProcedure.CodeNum, Providers.GetProv(brokenProcedure.ProvNum).FeeSched, brokenProcedure.ClinicNum, brokenProcedure.ProvNum); brokenProcedure.ProcFee = Math.Max(provFee, procFee); } else if (listSplitsForApptProcs.Count > 0 && PrefC.GetBool(PrefName.TpPrePayIsNonRefundable) && procCode.ProcCode == "D9986") { //if there are pre-payments, non-refundable pre-payments is turned on, and the broken appointment is a missed code then auto-fill //the window with the sum of the procs for the appointment. Transfer money below after broken procedure is confirmed by the user. brokenProcedure.ProcFee = listSplitsForApptProcs.Sum(x => x.SplitAmt); isNonRefundable = true; } else { brokenProcedure.ProcFee = procFee; } if (!PrefC.GetBool(PrefName.EasyHidePublicHealth)) { brokenProcedure.SiteNum = pat.SiteNum; } Procedures.Insert(brokenProcedure); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(brokenProcedure.ProcNum); Procedures.ComputeEstimates(brokenProcedure, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs); FormProcBroken FormPB = new FormProcBroken(brokenProcedure, isNonRefundable); FormPB.IsNew = true; FormPB.ShowDialog(); brokenProcAmount = FormPB.AmountTotal; wasBrokenProcDeleted = FormPB.IsProcDeleted; } #endregion #region BrokenApptAdjustment if (PrefC.GetBool(PrefName.BrokenApptAdjustment)) { Adjustment AdjustmentCur = new Adjustment(); AdjustmentCur.DateEntry = DateTime.Today; AdjustmentCur.AdjDate = DateTime.Today; AdjustmentCur.ProcDate = DateTime.Today; AdjustmentCur.ProvNum = appt.ProvNum; AdjustmentCur.PatNum = pat.PatNum; AdjustmentCur.AdjType = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum = appt.ClinicNum; FormAdjust FormA = new FormAdjust(pat, AdjustmentCur); FormA.IsNew = true; FormA.ShowDialog(); } #endregion #region BrokenApptCommLog if (PrefC.GetBool(PrefName.BrokenApptCommLog)) { Commlog commlogCur = new Commlog(); commlogCur.PatNum = pat.PatNum; commlogCur.CommDateTime = DateTime.Now; commlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); commlogCur.Note = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); commlogCur.Mode_ = CommItemMode.None; commlogCur.UserNum = Security.CurUser.UserNum; commlogCur.IsNew = true; FormCommItem FormCI = new FormCommItem(commlogCur); FormCI.ShowDialog(); } #endregion #region Transfer money from TP Procedures if necessary //Note this MUST come after FormProcBroken since clicking cancel in that window will delete the procedure. if (isNonRefundable && !wasBrokenProcDeleted && listSplitsForApptProcs.Count > 0) { //transfer what the user specified in the broken appointment window. //transfer up to the amount specified by the user foreach (Procedure proc in listProcedures) { if (brokenProcAmount == 0) { break; } List <PaySplit> listSplitsForAppointmentProcedure = listSplitsForApptProcs.FindAll(x => x.ProcNum == proc.ProcNum); foreach (PaySplit split in listSplitsForAppointmentProcedure) { if (brokenProcAmount == 0) { break; } double amt = Math.Min(brokenProcAmount, split.SplitAmt); Payments.CreateTransferForTpProcs(proc, new List <PaySplit> { split }, brokenProcedure, amt); double amtPaidOnApt = listSplitsForApptProcs.Sum(x => x.SplitAmt); if (amtPaidOnApt > amt) { //If the original prepayment amount is greater than the amt being specified for the appointment break, transfer //the difference to an Unallocated Unearned Paysplit on the account. double remainingAmt = amtPaidOnApt - amt; //We have to create a new transfer payment here to correlate to the split. Payment txfrPayment = new Payment(); txfrPayment.PayAmt = 0; txfrPayment.PayDate = DateTime.Today; txfrPayment.ClinicNum = split.ClinicNum; txfrPayment.PayNote = "Automatic transfer from treatment planned procedure prepayment."; txfrPayment.PatNum = split.PatNum; //ultimately where the payment ends up. txfrPayment.PayType = 0; Payments.Insert(txfrPayment); PaymentEdit.IncomeTransferData transferData = PaymentEdit.IncomeTransferData.CreateTransfer(split, txfrPayment.PayNum, true, remainingAmt); PaySplit offset = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum != 0); long offsetSplitNum = PaySplits.Insert(offset); //Get the FSplitNum from the offset PaySplit allocation = transferData.ListSplitsCur.FirstOrDefault(x => x.FSplitNum == 0); allocation.FSplitNum = offsetSplitNum; PaySplits.Insert(allocation); //Insert so the split is now up to date SecurityLogs.MakeLogEntry(Permissions.PaymentCreate, txfrPayment.PatNum, "Automatic transfer of funds for treatment plan procedure pre-payments."); } brokenProcAmount -= amt; } } } //if broken appointment procedure was deleted (user cancelled out of the window) just keep money on the original procedure. #endregion AppointmentEvent.Fire(ODEventType.AppointmentEdited, appt); AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum); Recalls.SynchScheduledApptFull(appt.PatNum); }
private void gridComm_CellDoubleClick(object sender,ODGridClickEventArgs e) { Commlog item=Commlogs.GetOne(PIn.Long(DS.Tables["Comm"].Rows[e.Row]["CommlogNum"].ToString())); FormCommItem FormCI=new FormCommItem(item); FormCI.ShowDialog(); DS.Tables.Remove("Comm"); DS.Tables.Add(Appointments.GetApptEdit(AptCur.AptNum).Tables["Comm"].Copy()); //AppointmentL.GetApptEditComm(AptCur.AptNum)); FillComm(); }
///<summary>Sets given appt.AptStatus to broken. ///Provide procCode that should be charted, can be null but will not chart a broken procedure. ///Also considers various broken procedure based prefs. ///Makes its own securitylog entries.</summary> public static void BreakApptHelper(Appointment appt, Patient pat, ProcedureCode procCode) { //suppressHistory is true due to below logic creating a log with a specific HistAppointmentAction instead of the generic changed. DateTime datePrevious = appt.DateTStamp; bool suppressHistory = false; if (procCode != null) { suppressHistory = (procCode.ProcCode.In("D9986", "D9987")); } Appointments.SetAptStatus(appt, ApptStatus.Broken, suppressHistory); //Appointments S-Class handles Signalods if (appt.AptStatus != ApptStatus.Complete) //seperate log entry for completed appointments. { SecurityLogs.MakeLogEntry(Permissions.AppointmentEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } else { SecurityLogs.MakeLogEntry(Permissions.AppointmentCompleteEdit, pat.PatNum, appt.ProcDescript + ", " + appt.AptDateTime.ToString() + ", Broken from the Appts module.", appt.AptNum, datePrevious); } #region HL7 //If there is an existing HL7 def enabled, send a SIU message if there is an outbound SIU message defined if (HL7Defs.IsExistingHL7Enabled()) { //S15 - Appt Cancellation event MessageHL7 messageHL7 = MessageConstructor.GenerateSIU(pat, Patients.GetPat(pat.Guarantor), EventTypeHL7.S15, appt); //Will be null if there is no outbound SIU message defined, so do nothing if (messageHL7 != null) { HL7Msg hl7Msg = new HL7Msg(); hl7Msg.AptNum = appt.AptNum; hl7Msg.HL7Status = HL7MessageStatus.OutPending; //it will be marked outSent by the HL7 service. hl7Msg.MsgText = messageHL7.ToString(); hl7Msg.PatNum = pat.PatNum; HL7Msgs.Insert(hl7Msg); #if DEBUG MessageBox.Show("Appointments", messageHL7.ToString()); #endif } } #endregion #region Charting the proc if (procCode != null) { switch (procCode.ProcCode) { case "D9986": //Missed HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Missed); break; case "D9987": //Cancelled HistAppointments.CreateHistoryEntry(appt.AptNum, HistAppointmentAction.Cancelled); break; } Procedure procedureCur = new Procedure(); procedureCur.PatNum = pat.PatNum; procedureCur.ProvNum = (procCode.ProvNumDefault > 0 ? procCode.ProvNumDefault : appt.ProvNum); procedureCur.CodeNum = procCode.CodeNum; procedureCur.ProcDate = DateTime.Today; procedureCur.DateEntryC = DateTime.Now; procedureCur.ProcStatus = ProcStat.C; procedureCur.ClinicNum = appt.ClinicNum; procedureCur.UserNum = Security.CurUser.UserNum; procedureCur.Note = Lans.g("AppointmentEdit", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); procedureCur.PlaceService = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService); //Default proc place of service for the Practice is used. List <InsSub> listInsSubs = InsSubs.RefreshForFam(Patients.GetFamily(pat.PatNum)); List <InsPlan> listInsPlans = InsPlans.RefreshForSubList(listInsSubs); List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum); InsPlan insPlanPrimary = null; InsSub insSubPrimary = null; if (listPatPlans.Count > 0) { insSubPrimary = InsSubs.GetSub(listPatPlans[0].InsSubNum, listInsSubs); insPlanPrimary = InsPlans.GetPlan(insSubPrimary.PlanNum, listInsPlans); } double procFee; long feeSch; if (insPlanPrimary == null || procCode.NoBillIns) { feeSch = FeeScheds.GetFeeSched(0, pat.FeeSched, procedureCur.ProvNum); } else //Only take into account the patient's insurance fee schedule if the D9986 procedure is not marked as NoBillIns { feeSch = FeeScheds.GetFeeSched(insPlanPrimary.FeeSched, pat.FeeSched, procedureCur.ProvNum); } procFee = Fees.GetAmount0(procedureCur.CodeNum, feeSch, procedureCur.ClinicNum, procedureCur.ProvNum); if (insPlanPrimary != null && insPlanPrimary.PlanType == "p" && !insPlanPrimary.IsMedical) //PPO { double provFee = Fees.GetAmount0(procedureCur.CodeNum, Providers.GetProv(procedureCur.ProvNum).FeeSched, procedureCur.ClinicNum, procedureCur.ProvNum); procedureCur.ProcFee = Math.Max(provFee, procFee); } else { procedureCur.ProcFee = procFee; } if (!PrefC.GetBool(PrefName.EasyHidePublicHealth)) { procedureCur.SiteNum = pat.SiteNum; } Procedures.Insert(procedureCur); //Now make a claimproc if the patient has insurance. We do this now for consistency because a claimproc could get created in the future. List <Benefit> listBenefits = Benefits.Refresh(listPatPlans, listInsSubs); List <ClaimProc> listClaimProcsForProc = ClaimProcs.RefreshForProc(procedureCur.ProcNum); Procedures.ComputeEstimates(procedureCur, pat.PatNum, listClaimProcsForProc, false, listInsPlans, listPatPlans, listBenefits, pat.Age, listInsSubs); FormProcBroken FormPB = new FormProcBroken(procedureCur); FormPB.IsNew = true; FormPB.ShowDialog(); } #endregion #region BrokenApptAdjustment if (PrefC.GetBool(PrefName.BrokenApptAdjustment)) { Adjustment AdjustmentCur = new Adjustment(); AdjustmentCur.DateEntry = DateTime.Today; AdjustmentCur.AdjDate = DateTime.Today; AdjustmentCur.ProcDate = DateTime.Today; AdjustmentCur.ProvNum = appt.ProvNum; AdjustmentCur.PatNum = pat.PatNum; AdjustmentCur.AdjType = PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum = appt.ClinicNum; FormAdjust FormA = new FormAdjust(pat, AdjustmentCur); FormA.IsNew = true; FormA.ShowDialog(); } #endregion #region BrokenApptCommLog if (PrefC.GetBool(PrefName.BrokenApptCommLog)) { Commlog CommlogCur = new Commlog(); CommlogCur.PatNum = pat.PatNum; CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note = Lan.g("Appointment", "Appt BROKEN for") + " " + appt.ProcDescript + " " + appt.AptDateTime.ToString(); CommlogCur.Mode_ = CommItemMode.None; CommlogCur.UserNum = Security.CurUser.UserNum; FormCommItem FormCI = new FormCommItem(); FormCI.ShowDialog(new CommItemModel() { CommlogCur = CommlogCur }, new CommItemController(FormCI) { IsNew = true }); } #endregion AutomationL.Trigger(AutomationTrigger.BreakAppointment, null, pat.PatNum); Recalls.SynchScheduledApptFull(appt.PatNum); }
///<summary>Called from butOK_Click and butPin_Click</summary> private bool UpdateToDB(){ DateTime dateTimeAskedToArrive=DateTime.MinValue; if(textTimeAskedToArrive.Text!=""){ try{ dateTimeAskedToArrive=AptCur.AptDateTime.Date+DateTime.Parse(textTimeAskedToArrive.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Asked To Arrive invalid."); return false; } } DateTime dateTimeArrived=AptCur.AptDateTime.Date; if(textTimeArrived.Text!=""){ try{ dateTimeArrived=AptCur.AptDateTime.Date+DateTime.Parse(textTimeArrived.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Arrived invalid."); return false; } } DateTime dateTimeSeated=AptCur.AptDateTime.Date; if(textTimeSeated.Text!=""){ try{ dateTimeSeated=AptCur.AptDateTime.Date+DateTime.Parse(textTimeSeated.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Seated invalid."); return false; } } DateTime dateTimeDismissed=AptCur.AptDateTime.Date; if(textTimeDismissed.Text!=""){ try{ dateTimeDismissed=AptCur.AptDateTime.Date+DateTime.Parse(textTimeDismissed.Text).TimeOfDay; } catch{ MsgBox.Show(this,"Time Arrived invalid."); return false; } } //This change was just slightly too risky to make to 6.9, so 7.0 only if(AptCur.AptStatus!=ApptStatus.Complete//was not originally complete && AptCur.AptStatus!=ApptStatus.PtNote && AptCur.AptStatus!=ApptStatus.PtNoteCompleted && comboStatus.SelectedIndex==1 //making it complete && AptCur.AptDateTime.Date > DateTime.Today)//and future appt { MsgBox.Show(this,"Not allowed to set complete future appointments."); return false; } string aptPattern=Appointments.ConvertPatternTo5(strBTime.ToString()); //Only run appt overlap check if editing an appt from the chart module and eCW program link not enabled. if(IsInChartModule && !Programs.UsingEcwTightOrFullMode()) { List<Appointment> apptList=Appointments.GetForPeriodList(AptCur.AptDateTime,AptCur.AptDateTime); if(DoesOverlap(aptPattern,apptList)) { MsgBox.Show(this,"Appointment is too long and would overlap another appointment. Automatically shortened to fit."); do { aptPattern=aptPattern.Substring(0,aptPattern.Length-1); if(aptPattern.Length==1) { break; } } while(DoesOverlap(aptPattern,apptList)); } } if(AptCur.AptStatus == ApptStatus.Planned) { ; } else if(comboStatus.SelectedIndex==-1) { AptCur.AptStatus=ApptStatus.Scheduled; } else if (AptCur.AptStatus == ApptStatus.PtNote | AptCur.AptStatus == ApptStatus.PtNoteCompleted){ AptCur.AptStatus = (ApptStatus)comboStatus.SelectedIndex + 7; } else { AptCur.AptStatus=(ApptStatus)comboStatus.SelectedIndex+1; } //set procs complete was moved further down //convert from current increment into 5 minute increment //MessageBox.Show(strBTime.ToString()); AptCur.Pattern=aptPattern; if(comboUnschedStatus.SelectedIndex==0){//none AptCur.UnschedStatus=0; } else{ AptCur.UnschedStatus=DefC.Short[(int)DefCat.RecallUnschedStatus][comboUnschedStatus.SelectedIndex-1].DefNum; } if(comboConfirmed.SelectedIndex!=-1){ AptCur.Confirmed=DefC.Short[(int)DefCat.ApptConfirmed][comboConfirmed.SelectedIndex].DefNum; } AptCur.TimeLocked=checkTimeLocked.Checked; AptCur.ColorOverride=butColor.BackColor; AptCur.Note=textNote.Text; if(comboClinic.SelectedIndex==0) {//none AptCur.ClinicNum=0; } else { AptCur.ClinicNum=Clinics.List[comboClinic.SelectedIndex-1].ClinicNum; } //there should always be a non-hidden primary provider for an appt. if(comboProvNum.SelectedIndex==-1) { AptCur.ProvNum=ProviderC.ListShort[0].ProvNum; } else { AptCur.ProvNum=ProviderC.ListShort[comboProvNum.SelectedIndex].ProvNum; } if(comboProvHyg.SelectedIndex==0) {//none AptCur.ProvHyg=0; } else { AptCur.ProvHyg=ProviderC.ListShort[comboProvHyg.SelectedIndex-1].ProvNum; } AptCur.IsHygiene=checkIsHygiene.Checked; if(comboAssistant.SelectedIndex==0) {//none AptCur.Assistant=0; } else { AptCur.Assistant=Employees.ListShort[comboAssistant.SelectedIndex-1].EmployeeNum; } AptCur.IsNewPatient=checkIsNewPatient.Checked; AptCur.DateTimeAskedToArrive=dateTimeAskedToArrive; AptCur.DateTimeArrived=dateTimeArrived; AptCur.DateTimeSeated=dateTimeSeated; AptCur.DateTimeDismissed=dateTimeDismissed; //AptCur.InsPlan1 and InsPlan2 already handled //The ApptProcDescript region is also in FormProcEdit.SaveAndClose() and FormDatabaseMaintenance.butApptProcs_Click() Make any changes there as well. #region ApptProcDescript AptCur.ProcDescript=""; AptCur.ProcsColored=""; for(int i=0;i<gridProc.SelectedIndices.Length;i++) { string procDescOne=""; string procCode=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ProcCode"].ToString(); if(i>0){ AptCur.ProcDescript+=", "; } switch(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["TreatArea"].ToString()) { case "1"://TreatmentArea.Surf: procDescOne+="#"+Tooth.GetToothLabel(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ToothNum"].ToString())+"-" +DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//""#12-MOD-" break; case "2"://TreatmentArea.Tooth: procDescOne+="#"+Tooth.GetToothLabel(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ToothNum"].ToString())+"-";//"#12-" break; default://area 3 or 0 (mouth) break; case "4"://TreatmentArea.Quad: procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"UL-" break; case "5"://TreatmentArea.Sextant: procDescOne+="S"+DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"S2-" break; case "6"://TreatmentArea.Arch: procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["Surf"].ToString()+"-";//"U-" break; case "7"://TreatmentArea.ToothRange: //strLine+=table.Rows[j][13].ToString()+" ";//don't show range break; } procDescOne+=DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["AbbrDesc"].ToString(); AptCur.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(AptCur.PatNum,AptCur.AptDateTime,pac.CodeRange); if(prevDateString!="") { prevDateString=" ("+prevDateString+")"; } } } AptCur.ProcsColored+="<span color=\""+pColor.ToArgb().ToString()+"\">"+procDescOne+prevDateString+"</span>"; } #endregion bool isPlanned=AptCur.AptStatus==ApptStatus.Planned; try { Appointments.Update(AptCur,AptOld); //Appointments.UpdateAttached(AptCur.AptNum,procNums,isPlanned); } catch(ApplicationException ex) { MessageBox.Show(ex.Message); return false; } //if appointment is marked complete and any procedures are not, //then set the remaining procedures complete if(AptCur.AptStatus==ApptStatus.Complete) { bool allProcsComplete=true; for(int i=0;i<gridProc.SelectedIndices.Length;i++){ if(DS.Tables["Procedure"].Rows[gridProc.SelectedIndices[i]]["ProcStatus"].ToString()!="2") {//Complete allProcsComplete=false; break; } } if(!allProcsComplete) { if(!Security.IsAuthorized(Permissions.ProcComplCreate,AptCur.AptDateTime)) { return false; } List <PatPlan> PatPlanList=PatPlans.Refresh(AptCur.PatNum); ProcedureL.SetCompleteInAppt(AptCur,PlanList,PatPlanList,pat.SiteNum,pat.Age,SubList); SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate,pat.PatNum, AptCur.AptDateTime.ToShortDateString()+", "+AptCur.ProcDescript+", Procedures automatically set complete due to appt being set complete",0); } } else{ Procedures.SetProvidersInAppointment(AptCur,Procedures.GetProcsForSingle(AptCur.AptNum,false)); } //Do the appointment "break" automation for appointments that were just broken. if(AptCur.AptStatus==ApptStatus.Broken && AptOld.AptStatus!=ApptStatus.Broken) { SecurityLogs.MakeLogEntry(Permissions.AppointmentMove,pat.PatNum,AptCur.ProcDescript+", "+AptCur.AptDateTime.ToString() +", Broken by changing the Status in the Edit Appointment window.",AptCur.AptNum); if(PrefC.GetBool(PrefName.BrokenApptCommLogNotAdjustment)) { Commlog CommlogCur=new Commlog(); CommlogCur.PatNum=pat.PatNum; CommlogCur.CommDateTime=DateTime.Now; CommlogCur.CommType=Commlogs.GetTypeAuto(CommItemTypeAuto.APPT); CommlogCur.Note=Lan.g(this,"Appt BROKEN for ")+AptCur.ProcDescript+" "+AptCur.AptDateTime.ToString(); CommlogCur.Mode_=CommItemMode.None; CommlogCur.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(CommlogCur); FormCI.IsNew=true; FormCI.ShowDialog(); } else { Adjustment AdjustmentCur=new Adjustment(); AdjustmentCur.DateEntry=DateTime.Today; AdjustmentCur.AdjDate=DateTime.Today; AdjustmentCur.ProcDate=DateTime.Today; AdjustmentCur.ProvNum=AptCur.ProvNum; AdjustmentCur.PatNum=pat.PatNum; AdjustmentCur.AdjType=PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType); AdjustmentCur.ClinicNum=pat.ClinicNum; FormAdjust FormA=new FormAdjust(pat,AdjustmentCur); FormA.IsNew=true; FormA.ShowDialog(); } AutomationL.Trigger(AutomationTrigger.BreakAppointment,null,pat.PatNum); } return true; }
///<summary>Called from Pin_Click and OK_Click.</summary> private void SaveRecall() { int newStatus; if (comboStatus.SelectedIndex == 0) { newStatus = 0; } else { newStatus = DefB.Short[(int)DefCat.RecallUnschedStatus][comboStatus.SelectedIndex - 1].DefNum; } if (newStatus != RecallCur.RecallStatus || //if the status has changed (RecallCur.Note == "" && textNote.Text != "")) //or a note was added { //make a commlog entry //unless there is an existing recall commlog entry for today bool recallEntryToday = false; Commlog[] CommlogList = Commlogs.Refresh(PatCur.PatNum); for (int i = 0; i < CommlogList.Length; i++) { if (CommlogList[i].CommDateTime.Date == DateTime.Today && CommlogList[i].CommType == CommItemType.Recall) { recallEntryToday = true; } } if (!recallEntryToday) { Commlog CommlogCur = new Commlog(); CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = CommItemType.Recall; CommlogCur.PatNum = PatCur.PatNum; if (newStatus != RecallCur.RecallStatus) { //Commlogs.Cur.Note+=Lan.g(this,"Status changed to")+" "; if (newStatus == 0) { CommlogCur.Note += Lan.g(this, "Status None"); } else { CommlogCur.Note += DefB.GetName(DefCat.RecallUnschedStatus, newStatus); } if (RecallCur.Note == "" && textNote.Text != "") { CommlogCur.Note += ", "; } } if (RecallCur.Note == "" && textNote.Text != "") { CommlogCur.Note += textNote.Text; } CommlogCur.Note += ". "; FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; //forces user to at least consider a commlog entry FormCI.ShowDialog(); //typically saved in this window. } } RecallCur.RecallStatus = newStatus; RecallCur.Note = textNote.Text; Recalls.Update(RecallCur); Patient PatOld = PatCur.Copy(); PatCur.WkPhone = textWkPhone.Text; PatCur.WirelessPhone = textWirelessPhone.Text; PatCur.Email = textEmail.Text; PatCur.PreferRecallMethod = (ContactMethod)comboRecallMethod.SelectedIndex; Patients.Update(PatCur, PatOld); Patients.UpdatePhoneAndNoteIfNeeded(textHmPhone.Text, textAddrNotes.Text, PatCur.PatNum); }
private void phoneSmall_GoToChanged(object sender,EventArgs e) { if(phoneSmall.GotoPatNum==0) { return; } CurPatNum=phoneSmall.GotoPatNum; Patient pat=Patients.GetPat(CurPatNum); RefreshCurrentModule(); FillPatientButton(CurPatNum,pat.GetNameLF(),pat.Email!="",pat.ChartNumber,pat.SiteNum); Commlog commlog=Commlogs.GetIncompleteEntry(Security.CurUser.UserNum,CurPatNum); if(commlog==null) { commlog = new Commlog(); commlog.PatNum = CurPatNum; commlog.CommDateTime = DateTime.Now; commlog.CommType =Commlogs.GetTypeAuto(CommItemTypeAuto.MISC);//support call commlog.Mode_=CommItemMode.Phone; commlog.SentOrReceived=CommSentOrReceived.Received; commlog.UserNum=Security.CurUser.UserNum; FormCommItem FormCI=new FormCommItem(commlog); FormCI.IsNew = true; FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { RefreshCurrentModule(); } } else { FormCommItem FormCI=new FormCommItem(commlog); FormCI.ShowDialog(); if(FormCI.DialogResult==DialogResult.OK) { RefreshCurrentModule(); } } }
///<summary>ProcCodes will be null unless trigger is CompleteProcedure. This routine will generally fail silently. Will return true if a trigger happened.</summary> public static bool Trigger(AutomationTrigger trigger, List <string> procCodes, long patNum) { if (patNum == 0) //Could happen for OpenPatient trigger { return(false); } bool automationHappened = false; for (int i = 0; i < Automations.Listt.Count; i++) { if (Automations.Listt[i].Autotrigger != trigger) { continue; } if (trigger == AutomationTrigger.CompleteProcedure) { if (procCodes == null) { continue; //fail silently } bool codeFound = false; string[] arrayCodes = Automations.Listt[i].ProcCodes.Split(','); for (int p = 0; p < procCodes.Count; p++) { for (int a = 0; a < arrayCodes.Length; a++) { if (arrayCodes[a] == procCodes[p]) { codeFound = true; break; } } } if (!codeFound) { continue; } } //matching automation item has been found //Get possible list of conditions that exist for this automation item List <AutomationCondition> autoConditionsList = AutomationConditions.GetListByAutomationNum(Automations.Listt[i].AutomationNum); if (Automations.Listt[i].AutoAction == AutomationAction.CreateCommlog) { if (autoConditionsList.Count > 0) { if (!CheckAutomationConditions(autoConditionsList, patNum)) { continue; } } Commlog CommlogCur = new Commlog(); CommlogCur.PatNum = patNum; CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = Automations.Listt[i].CommType; CommlogCur.Note = Automations.Listt[i].MessageContent; CommlogCur.Mode_ = CommItemMode.None; CommlogCur.UserNum = Security.CurUser.UserNum; FormCommItem FormCI = new FormCommItem(CommlogCur); FormCI.IsNew = true; FormCI.ShowDialog(); automationHappened = true; } else if (Automations.Listt[i].AutoAction == AutomationAction.PopUp) { if (autoConditionsList.Count > 0) { if (!CheckAutomationConditions(autoConditionsList, patNum)) { continue; } } MessageBox.Show(Automations.Listt[i].MessageContent); automationHappened = true; } else if (Automations.Listt[i].AutoAction == AutomationAction.PrintPatientLetter) { if (autoConditionsList.Count > 0) { if (!CheckAutomationConditions(autoConditionsList, patNum)) { continue; } } SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet = SheetUtil.CreateSheet(sheetDef, patNum); SheetParameter.SetParameter(sheet, "PatNum", patNum); //SheetParameter.SetParameter(sheet,"ReferralNum",referral.ReferralNum); SheetFiller.FillFields(sheet); using (Bitmap bmp = new Bitmap(100, 100)) { //a dummy bitmap for the graphics object using (Graphics g = Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet, g); } } FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened = true; } else if (Automations.Listt[i].AutoAction == AutomationAction.PrintReferralLetter) { if (autoConditionsList.Count > 0) { if (!CheckAutomationConditions(autoConditionsList, patNum)) { continue; } } long referralNum = RefAttaches.GetReferralNum(patNum); if (referralNum == 0) { MsgBox.Show("Automations", "This patient has no referral source entered."); automationHappened = true; continue; } SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet = SheetUtil.CreateSheet(sheetDef, patNum); SheetParameter.SetParameter(sheet, "PatNum", patNum); SheetParameter.SetParameter(sheet, "ReferralNum", referralNum); SheetFiller.FillFields(sheet); using (Bitmap bmp = new Bitmap(100, 100)) { //a dummy bitmap for the graphics object using (Graphics g = Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet, g); } } FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened = true; } else if (Automations.Listt[i].AutoAction == AutomationAction.ShowExamSheet) { if (autoConditionsList.Count > 0) { if (!CheckAutomationConditions(autoConditionsList, patNum)) { continue; } } SheetDef sheetDef = SheetDefs.GetSheetDef(Automations.Listt[i].SheetDefNum); Sheet sheet = SheetUtil.CreateSheet(sheetDef, patNum); SheetParameter.SetParameter(sheet, "PatNum", patNum); SheetFiller.FillFields(sheet); using (Bitmap bmp = new Bitmap(100, 100)) { //a dummy bitmap for the graphics object using (Graphics g = Graphics.FromImage(bmp)) { SheetUtil.CalculateHeights(sheet, g); } } FormSheetFillEdit FormSF = new FormSheetFillEdit(sheet); FormSF.ShowDialog(); automationHappened = true; } } return(automationHappened); }