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

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

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

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

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

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

                    case "7":                            //TreatmentArea.ToothRange:
                        //strLine+=table.Rows[j][13].ToString()+" ";//don't show range
                        break;
                    }
                    procDescOne         += procTable.Rows[j]["AbbrDesc"].ToString();
                    newApt.ProcDescript += procDescOne;
                    //Color and previous date are determined by ProcApptColor object
                    ProcApptColor        pac    = ProcApptColors.GetMatch(procCode);
                    System.Drawing.Color pColor = System.Drawing.Color.Black;
                    string prevDateString       = "";
                    if (pac != null)
                    {
                        pColor = pac.ColorText;
                        if (pac.ShowPreviousDate)
                        {
                            prevDateString = Procedures.GetRecentProcDateString(newApt.PatNum, newApt.AptDateTime, pac.CodeRange);
                            if (prevDateString != "")
                            {
                                prevDateString = " (" + prevDateString + ")";
                            }
                        }
                    }
                    newApt.ProcsColored += "<span color=\"" + pColor.ToArgb().ToString() + "\">" + procDescOne + prevDateString + "</span>";
                    count++;
                }
                Appointments.Update(newApt, aptList[i]);
            }
            #endregion
            Cursor = Cursors.Default;
            MsgBox.Show(this, "Done. Please refresh Appt module to see the changes.");
        }
Exemplo n.º 2
0
        /*
         * ///<summary>Only used in GetSearchResults.  All times between start and stop get set to true in provBarSched.</summary>
         * private static void SetProvBarSched(ref bool[] provBarSched,TimeSpan timeStart,TimeSpan timeStop){
         *      int startI=GetProvBarIndex(timeStart);
         *      int stopI=GetProvBarIndex(timeStop);
         *      for(int i=startI;i<=stopI;i++){
         *              provBarSched[i]=true;
         *      }
         * }
         *
         * private static int GetProvBarIndex(TimeSpan time) {
         *      return (int)(((double)time.Hours*(double)60/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement)//aptTimeIncr=minutesPerIncr
         +(double)time.Minutes/(double)PrefC.GetLong(PrefName.AppointmentTimeIncrement))
         *(double)ApptDrawing.LineH*ApptDrawing.RowsPerIncr)
         *              /ApptDrawing.LineH;//rounds down
         * }*/

        ///<summary>Used by UI when it needs a recall appointment placed on the pinboard ready to schedule.  This method creates the appointment and attaches all appropriate procedures.  It's up to the calling class to then place the appointment on the pinboard.  If the appointment doesn't get scheduled, it's important to delete it.  If a recallNum is not 0 or -1, then it will create an appt of that recalltype.</summary>
        public static Appointment CreateRecallApt(Patient patCur, List <Procedure> procList, List <InsPlan> planList, long recallNum, List <InsSub> subList)
        {
            List <Recall> recallList = Recalls.GetList(patCur.PatNum);
            Recall        recallCur  = null;

            if (recallNum > 0)
            {
                recallCur = Recalls.GetRecall(recallNum);
            }
            else
            {
                for (int i = 0; i < recallList.Count; i++)
                {
                    if (recallList[i].RecallTypeNum == RecallTypes.PerioType || recallList[i].RecallTypeNum == RecallTypes.ProphyType)
                    {
                        if (!recallList[i].IsDisabled)
                        {
                            recallCur = recallList[i];
                        }
                        break;
                    }
                }
            }
            if (recallCur == null)                                                                       // || recallCur.DateDue.Year<1880){
            {
                throw new ApplicationException(Lan.g("AppointmentL", "No special type recall is due.")); //Typically never happens because everyone has a recall.  However, it can happen when patients have custom recalls due
            }
            if (recallCur.DateScheduled.Date > DateTime.Today)
            {
                throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString());
            }
            Appointment AptCur = new Appointment();

            AptCur.PatNum    = patCur.PatNum;
            AptCur.AptStatus = ApptStatus.UnschedList;          //In all places where this is used, the unsched status with no aptDateTime will cause the appt to be deleted when the pinboard is cleared.
            if (patCur.PriProv == 0)
            {
                AptCur.ProvNum = PrefC.GetLong(PrefName.PracticeDefaultProv);
            }
            else
            {
                AptCur.ProvNum = patCur.PriProv;
            }
            AptCur.ProvHyg = patCur.SecProv;
            if (AptCur.ProvHyg != 0)
            {
                AptCur.IsHygiene = true;
            }
            AptCur.ClinicNum = patCur.ClinicNum;
            //whether perio or prophy:
            List <string> procs         = RecallTypes.GetProcs(recallCur.RecallTypeNum);
            string        recallPattern = RecallTypes.GetTimePattern(recallCur.RecallTypeNum);

            if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum) &&
                patCur.Birthdate.AddYears(PrefC.GetInt(PrefName.RecallAgeAdult)) > ((recallCur.DateDue > DateTime.Today)?recallCur.DateDue:DateTime.Today))                  //For example, if pt's 12th birthday falls after recall date.
            {
                for (int i = 0; i < RecallTypeC.Listt.Count; i++)
                {
                    if (RecallTypeC.Listt[i].RecallTypeNum == RecallTypes.ChildProphyType)
                    {
                        List <string> childprocs = RecallTypes.GetProcs(RecallTypeC.Listt[i].RecallTypeNum);
                        if (childprocs.Count > 0)
                        {
                            procs = childprocs;                          //overrides adult procs.
                        }
                        string childpattern = RecallTypes.GetTimePattern(RecallTypeC.Listt[i].RecallTypeNum);
                        if (childpattern != "")
                        {
                            recallPattern = childpattern;                          //overrides adult pattern.
                        }
                    }
                }
            }
            //convert time pattern to 5 minute increment
            StringBuilder savePattern = new StringBuilder();

            for (int i = 0; i < recallPattern.Length; i++)
            {
                savePattern.Append(recallPattern.Substring(i, 1));
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 10)
                {
                    savePattern.Append(recallPattern.Substring(i, 1));
                }
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15)
                {
                    savePattern.Append(recallPattern.Substring(i, 1));
                    savePattern.Append(recallPattern.Substring(i, 1));
                }
            }
            if (savePattern.ToString() == "")
            {
                if (PrefC.GetLong(PrefName.AppointmentTimeIncrement) == 15)
                {
                    savePattern.Append("///XXX///");
                }
                else
                {
                    savePattern.Append("//XX//");
                }
            }
            AptCur.Pattern = savePattern.ToString();
            //Add films------------------------------------------------------------------------------------------------------
            if (RecallTypes.IsSpecialRecallType(recallCur.RecallTypeNum))            //if this is a prophy or perio
            {
                for (int i = 0; i < recallList.Count; i++)
                {
                    if (recallCur.RecallNum == recallList[i].RecallNum)
                    {
                        continue;                        //already handled.
                    }
                    if (recallList[i].IsDisabled)
                    {
                        continue;
                    }
                    if (recallList[i].DateDue.Year < 1880)
                    {
                        continue;
                    }
                    if (recallList[i].DateDue > recallCur.DateDue &&              //if film due date is after prophy due date
                        recallList[i].DateDue > DateTime.Today)                         //and not overdue
                    {
                        continue;
                    }
                    //incomplete: exclude manual recall types
                    procs.AddRange(RecallTypes.GetProcs(recallList[i].RecallTypeNum));
                }
            }
            AptCur.ProcDescript = "";
            AptCur.ProcsColored = "";
            for (int i = 0; i < procs.Count; i++)
            {
                string procDescOne = "";
                if (i > 0)
                {
                    AptCur.ProcDescript += ", ";
                }
                procDescOne         += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc;
                AptCur.ProcDescript += procDescOne;
                //Color and previous date are determined by ProcApptColor object
                ProcApptColor        pac    = ProcApptColors.GetMatch(procs[i]);
                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>";
            }
            AptCur.TimeLocked = PrefC.GetBool(PrefName.AppointmentTimeIsLocked);
            Appointments.Insert(AptCur);
            Procedure      ProcCur;
            List <PatPlan> patPlanList = PatPlans.Refresh(patCur.PatNum);
            List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList);
            InsPlan        priplan     = null;
            InsSub         prisub      = null;

            if (patPlanList.Count > 0)
            {
                prisub  = InsSubs.GetSub(patPlanList[0].InsSubNum, subList);
                priplan = InsPlans.GetPlan(prisub.PlanNum, planList);
            }
            double insfee;
            double standardfee;

            for (int i = 0; i < procs.Count; i++)
            {
                ProcCur = new Procedure();              //this will be an insert
                //procnum
                ProcCur.PatNum   = patCur.PatNum;
                ProcCur.AptNum   = AptCur.AptNum;
                ProcCur.CodeNum  = ProcedureCodes.GetCodeNum(procs[i]);
                ProcCur.ProcDate = DateTime.Now;
                ProcCur.DateTP   = DateTime.Now;
                //Check if it's a medical procedure.
                bool isMed = false;
                ProcCur.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.CodeNum).MedicalCode;
                if (ProcCur.MedicalCode != null && ProcCur.MedicalCode != "")
                {
                    isMed = true;
                }
                //Get fee schedule for medical or dental.
                long feeSch;
                if (isMed)
                {
                    feeSch = Fees.GetMedFeeSched(patCur, planList, patPlanList, subList);
                }
                else
                {
                    feeSch = Fees.GetFeeSched(patCur, planList, patPlanList, subList);
                }
                //Get the fee amount for medical or dental.
                if (PrefC.GetBool(PrefName.MedicalFeeUsedForNewProcs) && isMed)
                {
                    insfee = Fees.GetAmount0(ProcedureCodes.GetProcCode(ProcCur.MedicalCode).CodeNum, feeSch);
                }
                else
                {
                    insfee = Fees.GetAmount0(ProcCur.CodeNum, feeSch);
                }
                if (priplan != null && priplan.PlanType == "p")             //PPO
                {
                    standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(patCur)).FeeSched);
                    if (standardfee > insfee)
                    {
                        ProcCur.ProcFee = standardfee;
                    }
                    else
                    {
                        ProcCur.ProcFee = insfee;
                    }
                }
                else
                {
                    ProcCur.ProcFee = insfee;
                }
                //surf
                //toothnum
                //Procedures.Cur.ToothRange="";
                //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.CodeNum).NoBillIns;
                //priority
                ProcCur.ProcStatus = ProcStat.TP;
                ProcCur.Note       = "";
                //Procedures.Cur.PriEstim=
                //Procedures.Cur.SecEstim=
                //claimnum
                ProcCur.ProvNum = patCur.PriProv;
                //Procedures.Cur.Dx=
                ProcCur.ClinicNum = patCur.ClinicNum;
                //nextaptnum
                ProcCur.BaseUnits      = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
                ProcCur.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
                Procedures.Insert(ProcCur);                //no recall synch required
                Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new List <ClaimProc>(), false, planList, patPlanList, benefitList, patCur.Age, subList);
                if (Programs.UsingOrion)
                {
                    FormProcEdit FormP = new FormProcEdit(ProcCur, patCur.Copy(), Patients.GetFamily(patCur.PatNum));
                    FormP.IsNew = true;
                    FormP.ShowDialog();
                    if (FormP.DialogResult == DialogResult.Cancel)
                    {
                        //any created claimprocs are automatically deleted from within procEdit window.
                        try{
                            Procedures.Delete(ProcCur.ProcNum);                            //also deletes the claimprocs
                        }
                        catch (Exception ex) {
                            MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        //Do not synch. Recalls based on ScheduleByDate reports in Orion mode.
                        //Recalls.Synch(PatCur.PatNum);
                    }
                }
            }
            return(AptCur);
        }