コード例 #1
0
 public void RefreshData(Patient pat, SheetField sheetField)
 {
     _listInsPlans = new List <InsPlan>();
     _listInsSubs  = new List <InsSub>();
     _listPatPlans = new List <PatPlan>();
     _listBenefits = new List <Benefit>();
     _pat          = pat;
     if (_pat == null)
     {
         return;
     }
     _listPatPlans = PatPlans.Refresh(_pat.PatNum);
     _listInsSubs  = InsSubs.RefreshForFam(Patients.GetFamily(_pat.PatNum));
     _listInsPlans = InsPlans.RefreshForSubList(_listInsSubs);
     _listBenefits = Benefits.Refresh(_listPatPlans, _listInsSubs);
 }
コード例 #2
0
ファイル: PatPlans.cs プロジェクト: luisurbinanet/apolloniax
        ///<summary>Deletes the patplan with the specified patPlanNum.  Rearranges the other patplans for the patient to keep the ordinal sequence contiguous.  Then, recomputes all estimates for this patient because their coverage is now different.  Also sets patient.HasIns to the correct value.</summary>
        public static void Delete(int patPlanNum)
        {
            string    command = "SELECT PatNum FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum);
            DataTable table   = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return;
            }
            int patNum = PIn.PInt(table.Rows[0][0].ToString());

            PatPlan[] patPlans    = Refresh(patNum);
            bool      doDecrement = false;

            for (int i = 0; i < patPlans.Length; i++)
            {
                if (doDecrement)                //patPlan has already been deleted, so decrement the rest.
                {
                    command = "UPDATE patplan SET Ordinal=" + POut.PInt(patPlans[i].Ordinal - 1)
                              + " WHERE PatPlanNum=" + POut.PInt(patPlans[i].PatPlanNum);
                    General.NonQ(command);
                    continue;
                }
                if (patPlans[i].PatPlanNum == patPlanNum)
                {
                    command = "DELETE FROM patplan WHERE PatPlanNum=" + POut.PInt(patPlanNum);
                    General.NonQ(command);
                    command = "DELETE FROM benefit WHERE PatPlanNum=" + POut.PInt(patPlanNum);
                    General.NonQ(command);
                    doDecrement = true;
                }
            }
            Family  fam = Patients.GetFamily(patNum);
            Patient pat = fam.GetPatient(patNum);

            ClaimProc[] claimProcs = ClaimProcs.Refresh(patNum);
            Procedure[] procs      = Procedures.Refresh(patNum);
            patPlans = PatPlans.Refresh(patNum);
            InsPlan[] planList = InsPlans.Refresh(fam);
            Benefit[] benList  = Benefits.Refresh(patPlans);
            Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, planList, patPlans, benList);
            Patients.SetHasIns(patNum);
        }
コード例 #3
0
        ///<summary>Used when closing the edit plan window to find all patients using this plan and to update all claimProcs for each patient.  This keeps estimates correct.</summary>
        public static void ComputeEstimatesForPlan(int planNum)
        {
            string    command = "SELECT PatNum FROM patplan WHERE PlanNum=" + POut.PInt(planNum);
            DataTable table   = General.GetTable(command);
            int       patNum  = 0;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                patNum = PIn.PInt(table.Rows[i][0].ToString());
                Family      fam         = Patients.GetFamily(patNum);
                Patient     pat         = fam.GetPatient(patNum);
                ClaimProc[] claimProcs  = ClaimProcs.Refresh(patNum);
                Procedure[] procs       = Procedures.Refresh(patNum);
                InsPlan[]   plans       = InsPlans.Refresh(fam);
                PatPlan[]   patPlans    = PatPlans.Refresh(patNum);
                Benefit[]   benefitList = Benefits.Refresh(patPlans);
                Procedures.ComputeEstimatesForAll(patNum, claimProcs, procs, plans, patPlans, benefitList);
                Patients.SetHasIns(patNum);
            }
        }
コード例 #4
0
        ///<summary>Runs Procedures.ComputeEstimates for given proc and listClaimProcs.
        ///Does not update existing ClaimProcs or insert new ClaimProcs in the database.
        ///Outs new ClaimProcs added by Procedures.ComputeEstimates, listClaimProcs will contain any added claimProcs.</summary>
        private void RecomputeEstimates(Procedure proc, List <ClaimProc> listClaimProcs, out List <ClaimProc> listNewClaimProcs,
                                        OrthoProcLink orthoProcLink, OrthoCase orthoCase, OrthoSchedule orthoSchedule, List <OrthoProcLink> listOrthoProcLinksForOrthoCase)
        {
            List <ClaimProc> listOrigClaimProcs = new List <ClaimProc>(listClaimProcs);
            Patient          pat          = Patients.GetPat(proc.PatNum);
            List <PatPlan>   listPatPlans = PatPlans.GetPatPlansForPat(pat.PatNum);
            List <InsSub>    listInsSubs  = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <InsPlan>   listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Benefit>   listBenefits = Benefits.Refresh(listPatPlans, listInsSubs);      //Same method used in FormProcEdit.Load()->GetLoadData()
            //FormProcEdit uses GetHistList(....,procDate:DateTimeOD.Today,...)
            List <ClaimProcHist> listHist = ClaimProcs.GetHistList(pat.PatNum, listBenefits, listPatPlans, listInsPlans, DateTimeOD.Today, listInsSubs);
            bool isSaveToDb = false;

            //When isSaveToDb is true any estimates that are missing will be inserted into DB and it refreshes listClaimProcs from the Db.
            //Refreshing the list results in losing the changes to ProvNum and ProcDate.
            Procedures.ComputeEstimates(proc, pat.PatNum, ref listClaimProcs, false, listInsPlans, listPatPlans, listBenefits, listHist,
                                        new List <ClaimProcHist> {
            }, isSaveToDb, pat.Age, listInsSubs
                                        , useProcDateOnProc: true,
                                        orthoProcLink: orthoProcLink, orthoCase: orthoCase, orthoSchedule: orthoSchedule, listOrthoProcLinksForOrthoCase: listOrthoProcLinksForOrthoCase);
            listNewClaimProcs = listClaimProcs.Except(listOrigClaimProcs).ToList();
        }
コード例 #5
0
        ///<summary>raised for each page to be printed.  One page per appointment.</summary>
        private void pd_PrintPage(object sender, PrintPageEventArgs ev)
        {
            if (ApptNum != 0)           //just for one appointment
            {
                date = Appointments.DateSelected;
            }
            Graphics   g = ev.Graphics;
            float      y = 50;
            float      x = 0;
            string     str;
            float      sizeW;       //used when measuring text for placement
            Font       fontTitle   = new Font(FontFamily.GenericSansSerif, 11, FontStyle.Bold);
            Font       fontHeading = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold);
            Font       font        = new Font(FontFamily.GenericSansSerif, 8);
            SolidBrush brush       = new SolidBrush(Color.Black);

            //Title----------------------------------------------------------------------------------------------------------
            str   = Lan.g(this, "Routing Slip");
            sizeW = g.MeasureString(str, fontTitle).Width;
            x     = 425 - sizeW / 2;
            g.DrawString(str, fontTitle, brush, x, y);
            y += 35;
            x  = 75;
            //Today's appointment, including procedures-----------------------------------------------------------------------
            Family  fam = Patients.GetFamily(Appts[pagesPrinted].PatNum);
            Patient pat = fam.GetPatient(Appts[pagesPrinted].PatNum);

            str = pat.GetNameFL();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Appts[pagesPrinted].AptDateTime.ToShortTimeString() + "  " + Appts[pagesPrinted].AptDateTime.ToShortDateString();
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = (Appts[pagesPrinted].Pattern.Length * 5).ToString() + " " + Lan.g(this, "minutes");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Providers.GetAbbr(Appts[pagesPrinted].ProvNum);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            if (Appts[pagesPrinted].ProvHyg != 0)
            {
                str = Providers.GetAbbr(Appts[pagesPrinted].ProvHyg);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Procedures:");
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Procedure[] procsAll = Procedures.Refresh(pat.PatNum);
            Procedure[] procsApt = Procedures.GetProcsOneApt(Appts[pagesPrinted].AptNum, procsAll);
            for (int i = 0; i < procsApt.Length; i++)
            {
                str = "   " + Procedures.GetDescription(procsApt[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            str = Lan.g(this, "Note:") + " " + Appts[pagesPrinted].Note;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Patient/Family Info---------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Patient Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "PatNum:") + " " + pat.PatNum.ToString();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Age:") + " ";
            if (pat.Age > 0)
            {
                str += pat.Age.ToString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Date of First Visit:") + " ";
            if (pat.DateFirstVisit.Year < 1880)
            {
                str += "?";
            }
            else if (pat.DateFirstVisit == Appts[pagesPrinted].AptDateTime.Date)
            {
                str += Lan.g(this, "New Patient");
            }
            else
            {
                str += pat.DateFirstVisit.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Billing Type:") + " " + DefB.GetName(DefCat.BillingTypes, pat.BillingType);
            g.DrawString(str, font, brush, x, y);
            y += 15;
            Recall[] recallList = Recalls.GetList(new int[] { pat.PatNum });
            str = Lan.g(this, "Recall Due Date:") + " ";
            if (recallList.Length > 0)
            {
                str += recallList[0].DateDue.ToShortDateString();
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Medical notes:") + " " + pat.MedUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 25;
            //Other Family Members
            str = Lan.g(this, "Other Family Members");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < fam.List.Length; i++)
            {
                if (fam.List[i].PatNum == pat.PatNum)
                {
                    continue;
                }
                str = fam.List[i].GetNameFL();
                if (fam.List[i].Age > 0)
                {
                    str += ",   " + fam.List[i].Age.ToString();
                }
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Insurance Info--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Insurance");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            PatPlan[]   patPlanList   = PatPlans.Refresh(pat.PatNum);
            InsPlan[]   plans         = InsPlans.Refresh(fam);
            ClaimProc[] claimProcList = ClaimProcs.Refresh(pat.PatNum);
            Benefit[]   benefits      = Benefits.Refresh(patPlanList);
            InsPlan     plan;
            Carrier     carrier;
            string      subscriber;
            double      max;
            double      deduct;

            if (patPlanList.Length == 0)
            {
                str = Lan.g(this, "none");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            for (int i = 0; i < patPlanList.Length; i++)
            {
                plan    = InsPlans.GetPlan(patPlanList[i].PlanNum, plans);
                carrier = Carriers.GetCarrier(plan.CarrierNum);
                str     = carrier.CarrierName;
                g.DrawString(str, fontHeading, brush, x, y);
                y         += 18;
                subscriber = fam.GetNameInFamFL(plan.Subscriber);
                if (subscriber == "")               //subscriber from another family
                {
                    subscriber = Patients.GetLim(plan.Subscriber).GetNameLF();
                }
                str = Lan.g(this, "Subscriber:") + " " + subscriber;
                g.DrawString(str, font, brush, x, y);
                y += 15;
                bool isFamMax = Benefits.GetIsFamMax(benefits, plan.PlanNum);
                str = "";
                if (isFamMax)
                {
                    str += Lan.g(this, "Family ");
                }
                str += Lan.g(this, "Annual Max:") + " ";
                max  = Benefits.GetAnnualMax(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (max != -1)
                {
                    str += max.ToString("n0") + " ";
                }
                str += "   ";
                bool isFamDed = Benefits.GetIsFamDed(benefits, plan.PlanNum);
                if (isFamDed)
                {
                    str += Lan.g(this, "Family ");
                }
                str   += Lan.g(this, "Deductible:") + " ";
                deduct = Benefits.GetDeductible(benefits, plan.PlanNum, patPlanList[i].PatPlanNum);
                if (deduct != -1)
                {
                    str += deduct.ToString("n0");
                }
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = "";
                for (int j = 0; j < benefits.Length; j++)
                {
                    if (benefits[j].PlanNum != plan.PlanNum)
                    {
                        continue;
                    }
                    if (benefits[j].BenefitType != InsBenefitType.Percentage)
                    {
                        continue;
                    }
                    if (str != "")
                    {
                        str += ",  ";
                    }
                    str += CovCats.GetDesc(benefits[j].CovCatNum) + " " + benefits[j].Percent.ToString() + "%";
                }
                if (str != "")
                {
                    g.DrawString(str, font, brush, x, y);
                    y += 15;
                }
                double pend = 0;
                double used = 0;
                if (isFamMax || isFamDed)
                {
                    ClaimProc[] claimProcsFam = ClaimProcs.RefreshFam(plan.PlanNum);
                    used = InsPlans.GetInsUsed(claimProcsFam, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits);
                    pend = InsPlans.GetPending(claimProcsFam, date, plan, patPlanList[i].PatPlanNum, -1, benefits);
                }
                else
                {
                    used = InsPlans.GetInsUsed(claimProcList, date, plan.PlanNum, patPlanList[i].PatPlanNum, -1, plans, benefits);
                    pend = InsPlans.GetPending(claimProcList, date, plan, patPlanList[i].PatPlanNum, -1, benefits);
                }
                str = Lan.g(this, "Ins Used:") + " " + used.ToString("n");
                g.DrawString(str, font, brush, x, y);
                y  += 15;
                str = Lan.g(this, "Ins Pending:") + " " + pend.ToString("n");
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            y += 10;
            //Account Info---------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Account Info");
            g.DrawString(str, fontHeading, brush, x, y);
            y  += 18;
            str = Lan.g(this, "Guarantor:") + " " + fam.List[0].GetNameFL();
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Balance:") + (fam.List[0].BalTotal - fam.List[0].InsEst).ToString("c");
            if (fam.List[0].InsEst > .01)
            {
                str += "  (" + fam.List[0].BalTotal.ToString("c") + " - "
                       + fam.List[0].InsEst.ToString("c") + " " + Lan.g(this, "InsEst") + ")";
            }
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Aging:")
                  + "  0-30:" + fam.List[0].Bal_0_30.ToString("c")
                  + "  31-60:" + fam.List[0].Bal_31_60.ToString("c")
                  + "  61-90:" + fam.List[0].Bal_61_90.ToString("c")
                  + "  90+:" + fam.List[0].BalOver90.ToString("c");
            g.DrawString(str, font, brush, x, y);
            y  += 15;
            str = Lan.g(this, "Fam Urgent Fin Note:")
                  + fam.List[0].FamFinUrgNote;
            g.DrawString(str, font, brush, x, y);
            y += 15;
            y += 10;
            //Treatment Plan--------------------------------------------------------------------------------------------------
            g.DrawLine(Pens.Black, 75, y, 775, y);
            str = Lan.g(this, "Treatment Plan");
            g.DrawString(str, fontHeading, brush, x, y);
            y += 18;
            for (int i = 0; i < procsAll.Length; i++)
            {
                if (procsAll[i].ProcStatus != ProcStat.TP)
                {
                    continue;
                }
                str = Procedures.GetDescription(procsAll[i]);
                g.DrawString(str, font, brush, x, y);
                y += 15;
            }
            pagesPrinted++;
            if (pagesPrinted == Appts.Length)
            {
                ev.HasMorePages = false;
                pagesPrinted    = 0;
            }
            else
            {
                ev.HasMorePages = true;
            }
        }
コード例 #6
0
ファイル: FormApptProcs.cs プロジェクト: kjb7749/testImport
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormProcCodes FormP = new FormProcCodes();

            FormP.IsSelectionMode = true;
            FormP.ShowDialog();
            if (FormP.DialogResult != DialogResult.OK)
            {
                return;
            }
            Procedure ProcCur;

            ProcCur         = new Procedure();  //going to be an insert, so no need to set Procedures.CurOld
            ProcCur.CodeNum = FormP.SelectedCodeNum;
            //procnum
            ProcCur.PatNum = AptCur.PatNum;
            //aptnum
            //proccode
            //ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set
            ProcCur.ProcDate = DateTime.Today;
            ProcCur.DateTP   = ProcCur.ProcDate;
            //int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty;
            Family         fam         = Patients.GetFamily(AptCur.PatNum);
            Patient        pat         = fam.GetPatient(AptCur.PatNum);
            List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum);
            ProcedureCode  procCodeCur = ProcedureCodes.GetProcCode(ProcCur.CodeNum);

            ProcCur.MedicalCode = procCodeCur.MedicalCode;
            if (procCodeCur.IsHygiene && pat.SecProv != 0)
            {
                ProcCur.ProvNum = pat.SecProv;
            }
            else
            {
                ProcCur.ProvNum = pat.PriProv;
            }
            ProcCur.ClinicNum = pat.ClinicNum;
            ProcCur.ProcFee   = Procedures.GetProcFee(pat, patPlanList, subList, planList, ProcCur.CodeNum, ProcCur.ProvNum, ProcCur.ClinicNum, ProcCur.MedicalCode);
            //surf
            //ToothNum
            //Procedures.Cur.ToothRange
            //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ProcCode).NoBillIns;
            ProcCur.Priority   = 0;
            ProcCur.ProcStatus = ProcStat.TP;
            ProcCur.Note       = "";
            //dx
            //nextaptnum
            ProcCur.DateEntryC     = DateTime.Now;
            ProcCur.BaseUnits      = procCodeCur.BaseUnits;
            ProcCur.SiteNum        = pat.SiteNum;
            ProcCur.RevCode        = procCodeCur.RevenueCodeDefault;
            ProcCur.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
            ProcCur.PlaceService   = (PlaceOfService)PrefC.GetInt(PrefName.DefaultProcedurePlaceService);        //Default proc place of service for the Practice is used.
            if (Userods.IsUserCpoe(Security.CurUser))
            {
                //This procedure is considered CPOE because the provider is the one that has added it.
                ProcCur.IsCpoe = true;
            }
            Procedures.Insert(ProcCur);
            List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList);

            Procedures.ComputeEstimates(ProcCur, pat.PatNum, new List <ClaimProc>(), true, planList, patPlanList, benefitList, pat.Age, subList);
            FormProcEdit FormPE = new FormProcEdit(ProcCur, pat.Copy(), fam);

            FormPE.IsNew = true;
            FormPE.ShowDialog();
            if (FormPE.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 if (Programs.UsingOrion)
            {
                //No need to synch with Orion mode.
            }
            else
            {
                //Default is set to TP, so Synch is usually not needed.
                if (ProcCur.ProcStatus == ProcStat.C || ProcCur.ProcStatus == ProcStat.EC || ProcCur.ProcStatus == ProcStat.EO)
                {
                    Recalls.Synch(pat.PatNum);
                }
            }
            FillGrid();
        }
コード例 #7
0
ファイル: AppointmentL.cs プロジェクト: royedwards/DRDNet
        ///<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);
        }
コード例 #8
0
        ///<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);
        }
コード例 #9
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormProcCodes FormP = new FormProcCodes();

            FormP.IsSelectionMode = true;
            FormP.ShowDialog();
            if (FormP.DialogResult != DialogResult.OK)
            {
                return;
            }
            Procedure ProcCur;

            ProcCur         = new Procedure();  //going to be an insert, so no need to set Procedures.CurOld
            ProcCur.CodeNum = FormP.SelectedCodeNum;
            //procnum
            ProcCur.PatNum = AptCur.PatNum;
            //aptnum
            //proccode
            //ProcCur.CodeNum=ProcedureCodes.GetProcCode(ProcCur.OldCode).CodeNum;//already set
            ProcCur.ProcDate = DateTime.Today;
            ProcCur.DateTP   = ProcCur.ProcDate;
            //int totUnits = ProcCur.BaseUnits + ProcCur.UnitQty;
            InsPlan        priplan     = null;
            InsSub         prisub      = null;
            Family         fam         = Patients.GetFamily(AptCur.PatNum);
            Patient        pat         = fam.GetPatient(AptCur.PatNum);
            List <InsSub>  subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan> planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan> patPlanList = PatPlans.Refresh(pat.PatNum);

            if (patPlanList.Count > 0)
            {
                prisub  = InsSubs.GetSub(patPlanList[0].InsSubNum, subList);
                priplan = InsPlans.GetPlan(prisub.PlanNum, planList);
            }
            //Check if it's a medical procedure.
            double insfee;
            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(pat, planList, patPlanList, subList);
            }
            else
            {
                feeSch = Fees.GetFeeSched(pat, 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
            {
                double standardfee = Fees.GetAmount0(ProcCur.CodeNum, Providers.GetProv(Patients.GetProvNum(pat)).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.ProcCode).NoBillIns;
            ProcCur.Priority   = 0;
            ProcCur.ProcStatus = ProcStat.TP;
            if (ProcedureCodes.GetProcCode(ProcCur.CodeNum).IsHygiene &&
                pat.SecProv != 0)
            {
                ProcCur.ProvNum = pat.SecProv;
            }
            else
            {
                ProcCur.ProvNum = pat.PriProv;
            }
            ProcCur.Note      = "";
            ProcCur.ClinicNum = pat.ClinicNum;
            //dx
            //nextaptnum
            ProcCur.DateEntryC     = DateTime.Now;
            ProcCur.BaseUnits      = ProcedureCodes.GetProcCode(ProcCur.CodeNum).BaseUnits;
            ProcCur.SiteNum        = pat.SiteNum;
            ProcCur.RevCode        = ProcedureCodes.GetProcCode(ProcCur.CodeNum).RevenueCodeDefault;
            ProcCur.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
            Procedures.Insert(ProcCur);
            List <Benefit> benefitList = Benefits.Refresh(patPlanList, subList);

            Procedures.ComputeEstimates(ProcCur, pat.PatNum, new List <ClaimProc>(), true, planList, patPlanList, benefitList, pat.Age, subList);
            FormProcEdit FormPE = new FormProcEdit(ProcCur, pat.Copy(), fam);

            FormPE.IsNew = true;
            FormPE.ShowDialog();
            if (FormPE.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 if (Programs.UsingOrion)
            {
                //No need to synch with Orion mode.
            }
            else
            {
                //Default is set to TP, so Synch is usually not needed.
                if (ProcCur.ProcStatus == ProcStat.C || ProcCur.ProcStatus == ProcStat.EC || ProcCur.ProcStatus == ProcStat.EO)
                {
                    Recalls.Synch(pat.PatNum);
                }
            }
            FillGrid();
        }
コード例 #10
0
        private void butGenerateClaims_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Count() < 1)
            {
                MsgBox.Show(this, "Please select the rows for which you would like to create procedures and claims.");
                return;
            }
            if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "Are you sure you want to generate claims and procedures for all patients and insurance plans?"))
            {
                return;
            }
            List <long> listPlanNums    = new List <long>();
            List <long> listPatPlanNums = new List <long>();
            List <long> listInsSubNums  = new List <long>();

            for (int i = 0; i < gridMain.SelectedIndices.Count(); i++)
            {
                DataRow rowCur = (DataRow)gridMain.Rows[gridMain.SelectedIndices[i]].Tag;
                listPlanNums.Add(PIn.Long(rowCur["PlanNum"].ToString()));
                listPatPlanNums.Add(PIn.Long(rowCur["PatPlanNum"].ToString()));
                listInsSubNums.Add(PIn.Long(rowCur["InsSubNum"].ToString()));
            }
            List <InsPlan> listSelectedInsPlans = InsPlans.GetPlans(listPlanNums);
            List <PatPlan> listSelectedPatPlans = PatPlans.GetPatPlans(listPatPlanNums);
            List <InsSub>  listSelectedInsSubs  = InsSubs.GetMany(listInsSubNums);
            List <DataRow> rowsSucceeded        = new List <DataRow>();
            int            rowsFailed           = 0;
            List <Benefit> listBenefitsAll      = Benefits.Refresh(listSelectedPatPlans, listSelectedInsSubs);

            for (int i = 0; i < gridMain.SelectedIndices.Count(); i++)
            {
                try {
                    DataRow     rowCur        = (DataRow)gridMain.Rows[gridMain.SelectedIndices[i]].Tag;
                    long        patNumCur     = PIn.Long(rowCur["PatNum"].ToString());
                    Patient     patCur        = Patients.GetPat(patNumCur);
                    PatientNote patNoteCur    = PatientNotes.Refresh(patNumCur, patCur.Guarantor);
                    long        codeNumCur    = PIn.Long(rowCur["AutoCodeNum"].ToString());
                    long        provNumCur    = PIn.Long(rowCur["ProvNum"].ToString());
                    long        clinicNumCur  = PIn.Long(rowCur["ClinicNum"].ToString());
                    long        insPlanNumCur = PIn.Long(rowCur["PlanNum"].ToString());
                    long        patPlanNumCur = PIn.Long(rowCur["PatPlanNum"].ToString());
                    long        insSubNumCur  = PIn.Long(rowCur["InsSubNum"].ToString());
                    int         monthsTreat   = PIn.Int(rowCur["MonthsTreat"].ToString());
                    DateTime    dateDue       = PIn.Date(rowCur["OrthoAutoNextClaimDate"].ToString());
                    //for each selected row
                    //create a procedure
                    //Procedures.CreateProcForPat(patNumCur,codeNumCur,"","",ProcStat.C,provNumCur);
                    Procedure      proc        = Procedures.CreateOrthoAutoProcsForPat(patNumCur, codeNumCur, provNumCur, clinicNumCur, dateDue);
                    InsPlan        insPlanCur  = InsPlans.GetPlan(insPlanNumCur, listSelectedInsPlans);
                    PatPlan        patPlanCur  = listSelectedPatPlans.FirstOrDefault(x => x.PatPlanNum == patPlanNumCur);
                    InsSub         insSubCur   = listSelectedInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNumCur);
                    List <Benefit> benefitList = listBenefitsAll.FindAll(x => x.PatPlanNum == patPlanCur.PatPlanNum || x.PlanNum == insSubCur.PlanNum);
                    //create a claimproc
                    List <ClaimProc> listClaimProcs = new List <ClaimProc>();
                    Procedures.ComputeEstimates(proc, patNumCur, ref listClaimProcs, true, new List <InsPlan> {
                        insPlanCur
                    },
                                                new List <PatPlan> {
                        patPlanCur
                    }, benefitList, null, null, true, patCur.Age, new List <InsSub> {
                        insSubCur
                    }, isForOrtho: true);
                    //make the feebilled == the insplan feebilled or patplan feebilled
                    double feebilled = patPlanCur.OrthoAutoFeeBilledOverride == -1 ? insPlanCur.OrthoAutoFeeBilled : patPlanCur.OrthoAutoFeeBilledOverride;
                    //create a claim with that claimproc
                    string claimType = "";
                    switch (patPlanCur.Ordinal)
                    {
                    case 1:
                        claimType = "P";
                        break;

                    case 2:
                        claimType = "S";
                        break;
                    }
                    DateTimeOD dateTMonthsRem = new DateTimeOD(PIn.Date(rowCur["DateBanding"].ToString()).AddMonths(PIn.Int(rowCur["MonthsTreat"].ToString())), DateTimeOD.Today);
                    Claims.CreateClaimForOrthoProc(claimType, patPlanCur, insPlanCur, insSubCur,
                                                   ClaimProcs.GetForProcWithOrdinal(proc.ProcNum, patPlanCur.Ordinal), proc, feebilled, PIn.Date(rowCur["DateBanding"].ToString()),
                                                   PIn.Int(rowCur["MonthsTreat"].ToString()), ((dateTMonthsRem.YearsDiff * 12) + dateTMonthsRem.MonthsDiff));
                    PatPlans.IncrementOrthoNextClaimDates(patPlanCur, insPlanCur, monthsTreat, patNoteCur);
                    rowsSucceeded.Add(rowCur);
                    SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate, patCur.PatNum
                                              , Lan.g(this, "Automatic ortho procedure and claim generated for") + " " + dateDue.ToShortDateString());
                }
                catch (Exception) {
                    rowsFailed++;
                }
            }
            string message = Lan.g(this, "Done.") + " " + Lan.g(this, "There were") + " " + rowsSucceeded.Count + " "
                             + Lan.g(this, "claim(s) generated and") + " " + rowsFailed + " " + Lan.g(this, "failures") + ".";

            MessageBox.Show(message);
            foreach (DataRow row in rowsSucceeded)
            {
                _tableOutstandingAutoClaims.Rows.Remove(row);
            }
            FillGrid();
        }
コード例 #11
0
ファイル: FormInsRemain.cs プロジェクト: ChemBrain/OpenDental
        private void FillGrid()
        {
            gridRemainTimeUnits.BeginUpdate();
            gridRemainTimeUnits.ListGridRows.Clear();
            List <PatPlan> listPatPlans    = PatPlans.Refresh(_patCur.PatNum);
            List <InsSub>  listInsSubs     = InsSubs.GetMany(listPatPlans.Select(x => x.InsSubNum).ToList());
            List <Benefit> listPatBenefits = Benefits.Refresh(listPatPlans, listInsSubs);

            if (listPatBenefits.IsNullOrEmpty())
            {
                gridRemainTimeUnits.EndUpdate();
                return;
            }
            List <InsPlan> listInsPlans = InsPlans.GetByInsSubs(listInsSubs.Select(x => x.InsSubNum).ToList());
            List <Carrier> listCarriers = Carriers.GetCarriers(listInsPlans.Select(x => x.CarrierNum).ToList());
            //Get the LIM information for all potential subscribers.
            List <Patient> listSubscribers = Patients.GetLimForPats(listInsSubs.Select(x => x.Subscriber).ToList());
            GridRow        gridRow;
            //Get the last year of completed procedures because there is no current TimePeriod for benefits that will care about older procedures.
            //A subset of these procedures will be used for each specific benefit in order to correctly represent the time units remaining.
            List <Procedure> listCompletedProcs = Procedures.GetCompletedForDateRange(
                DateTime.Today.AddYears(-1),
                DateTimeOD.Today,
                listPatNums: new List <long> {
                _patCur.PatNum
            });
            //Get all of the claimprocs associated to the completed procedures in order to link procedures to insurance plans.
            List <ClaimProc> listClaimProcs = ClaimProcs.GetForProcs(listCompletedProcs.Select(x => x.ProcNum).ToList());

            foreach (Benefit benefit in listPatBenefits)
            {
                if (benefit.CovCatNum == 0 ||           //no category
                    benefit.BenefitType != InsBenefitType.Limitations ||                     //benefit type is not limitations
                    (benefit.TimePeriod != BenefitTimePeriod.CalendarYear &&                     //neither calendar year, serviceyear, or 12 months
                     benefit.TimePeriod != BenefitTimePeriod.ServiceYear &&
                     benefit.TimePeriod != BenefitTimePeriod.NumberInLast12Months) ||
                    benefit.Quantity < 0 ||                    //quantity is negative (negatives are allowed in FormBenefitEdit)
                    benefit.QuantityQualifier != BenefitQuantity.NumberOfServices ||                    //qualifier us not the number of services
                    (benefit.CoverageLevel != BenefitCoverageLevel.Family &&                     //neither individual nor family coverage level
                     benefit.CoverageLevel != BenefitCoverageLevel.Individual))
                {
                    continue;
                }
                List <Procedure> listProcs;
                //for calendar year, get completed procs from January.01.CurYear ~ Curdate
                if (benefit.TimePeriod == BenefitTimePeriod.CalendarYear)
                {
                    //01/01/CurYear. is there a better way?
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, 1, 1));
                }
                else if (benefit.TimePeriod == BenefitTimePeriod.NumberInLast12Months)
                {
                    //today - 12 months - 1 day. Procedures exactly 1 year ago are not counted in the range
                    listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= DateTimeOD.Today.AddYears(-1).AddDays(1));
                }
                else                                                                  //if not calendar year, then it must be service year
                {
                    int monthRenew = InsPlans.RefreshOne(benefit.PlanNum).MonthRenew; //monthrenew only stores the month as an int.
                    if (DateTimeOD.Today.Month >= monthRenew)                         //if the the current date is past the renewal month, use the current year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year, monthRenew, 1));
                    }
                    else                       //otherwise use the previous year
                    {
                        listProcs = listCompletedProcs.FindAll(x => x.ProcDate >= new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1));
                    }
                }
                Dictionary <long, List <ClaimProc> > dictClaimProcsPerSub;
                if (benefit.PatPlanNum != 0)
                {
                    //The list of benefits that we are looping through was filled via listPatPlans so this will never fail.
                    //If this line fails then it means that there was a valid PlanNum AND a valid PatPlanNum set on the benefit which is invalid ATM.
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.InsSubNum == listPatPlans.First(y => y.PatPlanNum == benefit.PatPlanNum).InsSubNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                else                  //benefit.PatPlanNum was not set so benefit.PlanNum must be set.
                {
                    dictClaimProcsPerSub = listClaimProcs.FindAll(x => x.PlanNum == benefit.PlanNum)
                                           .GroupBy(x => x.InsSubNum)
                                           .ToDictionary(x => x.Key, x => x.ToList());
                }
                foreach (long insSubNum in dictClaimProcsPerSub.Keys)
                {
                    //The insSubNum should have a corresponding entry within listInsSubs.
                    InsSub insSub = listInsSubs.FirstOrDefault(x => x.InsSubNum == insSubNum);
                    if (insSub == null)
                    {
                        continue;                        //If not found then there are claimprocs associated to an inssub that is associated to a dropped or missing plan.
                    }
                    InsPlan insPlan    = listInsPlans.FirstOrDefault(x => x.PlanNum == insSub.PlanNum);
                    Carrier carrier    = listCarriers.FirstOrDefault(x => x.CarrierNum == insPlan.CarrierNum);
                    Patient subscriber = listSubscribers.FirstOrDefault(x => x.PatNum == insSub.Subscriber);
                    CovCat  category   = CovCats.GetCovCat(benefit.CovCatNum);
                    //Filter out any procedures that are not associated to the insurance plan of the current benefit.
                    List <Procedure> listFilterProcs = listProcs.FindAll(x => x.ProcNum.In(dictClaimProcsPerSub[insSubNum].Select(y => y.ProcNum)));
                    //Calculate the amount used for one benefit.
                    double amtUsed   = CovCats.GetAmtUsedForCat(listFilterProcs, category);
                    double amtRemain = benefit.Quantity - amtUsed;
                    gridRow = new GridRow((carrier == null) ? "Unknown" : carrier.CarrierName,
                                          (subscriber == null) ? "Unknown" : subscriber.GetNameFL(),
                                          category.Description.ToString(),
                                          benefit.Quantity.ToString(),
                                          amtUsed.ToString("F"),
                                          (amtRemain > 0) ? amtRemain.ToString("F") : "0");
                    gridRemainTimeUnits.ListGridRows.Add(gridRow);
                }
            }
            gridRemainTimeUnits.EndUpdate();
        }
コード例 #12
0
ファイル: FormInsRemain.cs プロジェクト: ChemBrain/OpenDental
        ///<summary>All of the code from this method is copied directly from the account module, ContrAccount.FillSummary().</summary>
        private void FillSummary()
        {
            textFamPriMax.Text = "";
            textFamPriDed.Text = "";
            textFamSecMax.Text = "";
            textFamSecDed.Text = "";
            textPriMax.Text    = "";
            textPriDed.Text    = "";
            textPriDedRem.Text = "";
            textPriUsed.Text   = "";
            textPriPend.Text   = "";
            textPriRem.Text    = "";
            textSecMax.Text    = "";
            textSecDed.Text    = "";
            textSecDedRem.Text = "";
            textSecUsed.Text   = "";
            textSecPend.Text   = "";
            textSecRem.Text    = "";
            if (_patCur == null)
            {
                return;
            }
            double         maxFam = 0;
            double         maxInd = 0;
            double         ded    = 0;
            double         dedFam = 0;
            double         dedRem = 0;
            double         remain = 0;
            double         pend   = 0;
            double         used   = 0;
            InsPlan        PlanCur;
            InsSub         SubCur;
            List <PatPlan> PatPlanList = PatPlans.Refresh(_patCur.PatNum);

            if (!PatPlans.IsPatPlanListValid(PatPlanList))
            {
                //PatPlans had invalid references and need to be refreshed.
                PatPlanList = PatPlans.Refresh(_patCur.PatNum);
            }
            List <InsSub>        subList     = InsSubs.RefreshForFam(_famCur);
            List <InsPlan>       InsPlanList = InsPlans.RefreshForSubList(subList);
            List <Benefit>       BenefitList = Benefits.Refresh(PatPlanList, subList);
            List <Claim>         ClaimList   = Claims.Refresh(_patCur.PatNum);
            List <ClaimProcHist> HistList    = ClaimProcs.GetHistList(_patCur.PatNum, BenefitList, PatPlanList, InsPlanList, DateTimeOD.Today, subList);

            if (PatPlanList.Count > 0)
            {
                SubCur  = InsSubs.GetSub(PatPlanList[0].InsSubNum, subList);
                PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList);
                pend    = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[0].PatPlanNum,
                                                     -1, _patCur.PatNum, PatPlanList[0].InsSubNum, BenefitList);
                used = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum,
                                                  -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[0].InsSubNum);
                textPriPend.Text = pend.ToString("F");
                textPriUsed.Text = used.ToString("F");
                maxFam           = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, true);
                maxInd           = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, false);
                if (maxFam == -1)
                {
                    textFamPriMax.Text = "";
                }
                else
                {
                    textFamPriMax.Text = maxFam.ToString("F");
                }
                if (maxInd == -1)               //if annual max is blank
                {
                    textPriMax.Text = "";
                    textPriRem.Text = "";
                }
                else
                {
                    remain = maxInd - used - pend;
                    if (remain < 0)
                    {
                        remain = 0;
                    }
                    //textFamPriMax.Text=max.ToString("F");
                    textPriMax.Text = maxInd.ToString("F");
                    textPriRem.Text = remain.ToString("F");
                }
                //deductible:
                ded    = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Individual);
                dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[0].PatPlanNum, BenefitCoverageLevel.Family);
                if (ded != -1)
                {
                    textPriDed.Text = ded.ToString("F");
                    dedRem          = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[0].PatPlanNum,
                                                                   -1, InsPlanList, _patCur.PatNum, ded, dedFam);
                    textPriDedRem.Text = dedRem.ToString("F");
                }
                if (dedFam != -1)
                {
                    textFamPriDed.Text = dedFam.ToString("F");
                }
            }
            if (PatPlanList.Count > 1)
            {
                SubCur  = InsSubs.GetSub(PatPlanList[1].InsSubNum, subList);
                PlanCur = InsPlans.GetPlan(SubCur.PlanNum, InsPlanList);
                pend    = InsPlans.GetPendingDisplay(HistList, DateTimeOD.Today, PlanCur, PatPlanList[1].PatPlanNum,
                                                     -1, _patCur.PatNum, PatPlanList[1].InsSubNum, BenefitList);
                textSecPend.Text = pend.ToString("F");
                used             = InsPlans.GetInsUsedDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum,
                                                              -1, InsPlanList, BenefitList, _patCur.PatNum, PatPlanList[1].InsSubNum);
                textSecUsed.Text = used.ToString("F");
                //max=Benefits.GetAnnualMaxDisplay(BenefitList,PlanCur.PlanNum,PatPlanList[1].PatPlanNum);
                maxFam = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, true);
                maxInd = Benefits.GetAnnualMaxDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, false);
                if (maxFam == -1)
                {
                    textFamSecMax.Text = "";
                }
                else
                {
                    textFamSecMax.Text = maxFam.ToString("F");
                }
                if (maxInd == -1)               //if annual max is blank
                {
                    textSecMax.Text = "";
                    textSecRem.Text = "";
                }
                else
                {
                    remain = maxInd - used - pend;
                    if (remain < 0)
                    {
                        remain = 0;
                    }
                    //textFamSecMax.Text=max.ToString("F");
                    textSecMax.Text = maxInd.ToString("F");
                    textSecRem.Text = remain.ToString("F");
                }
                //deductible:
                ded    = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Individual);
                dedFam = Benefits.GetDeductGeneralDisplay(BenefitList, PlanCur.PlanNum, PatPlanList[1].PatPlanNum, BenefitCoverageLevel.Family);
                if (ded != -1)
                {
                    textSecDed.Text = ded.ToString("F");
                    dedRem          = InsPlans.GetDedRemainDisplay(HistList, DateTimeOD.Today, PlanCur.PlanNum, PatPlanList[1].PatPlanNum,
                                                                   -1, InsPlanList, _patCur.PatNum, ded, dedFam);
                    textSecDedRem.Text = dedRem.ToString("F");
                }
                if (dedFam != -1)
                {
                    textFamSecDed.Text = dedFam.ToString("F");
                }
            }
        }
コード例 #13
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 recall is due.")); //should never happen because everyone has a recall.
            }
            if (recallCur.DateScheduled.Date >= DateTime.Now.Date)
            {
                throw new ApplicationException(Lan.g("AppointmentL", "Recall has already been scheduled for ") + recallCur.DateScheduled.ToShortDateString());
            }
            Appointment AptCur = new Appointment();

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

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

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

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

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

            for (int i = 0; i < chargeList.Length; i++)
            {
                if (!chargeList[i].IsEnabled)                 //first make sure it is not disabled
                {
                    continue;
                }
                if (chargeList[i].DateStart > DateTime.Today)              //not started yet
                {
                    continue;
                }
                //if(chargeList[i].DateStop.Year>1880//not blank
                //	&& chargeList[i].DateStop<DateTime.Today)//but already ended
                //{
                //	continue;
                //}
                //get a list dates of all completed procedures with this Code and patNum
                ArrayList ALdates = RepeatCharges.GetDates(ProcedureCodes.GetCodeNum(chargeList[i].ProcCode), chargeList[i].PatNum);
                startDate = chargeList[i].DateStart;
                //This is the repeating date using the old methodology.  It is necessary for checking if the repeating procedure was already added using the old methodology.
                DateTime possibleDateOld = startDate;
                //This is a more accurate repeating date which will allow procedures to be added on the 28th and later.
                DateTime possibleDateNew = startDate;
                int      countMonths     = 0;
                //start looping through possible dates, beginning with the start date of the repeating charge
                while (possibleDateNew <= DateTime.Today)
                {
                    //Only allow back dating up to one month and 20 days.
                    if (possibleDateNew < DateTime.Today.AddDays(-50))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;                        //don't go back more than one month and 20 days
                    }
                    //check to see if the possible date is present in the list
                    if (ALdates.Contains(possibleDateNew) ||
                        ALdates.Contains(possibleDateOld))
                    {
                        possibleDateOld = possibleDateOld.AddMonths(1);
                        countMonths++;
                        possibleDateNew = startDate.AddMonths(countMonths);
                        continue;
                    }
                    if (chargeList[i].DateStop.Year > 1880 &&              //not blank
                        chargeList[i].DateStop < possibleDateNew)                           //but already ended
                    {
                        break;
                    }
                    //otherwise, insert a procedure to db
                    proc                = new Procedure();
                    proc.CodeNum        = ProcedureCodes.GetCodeNum(chargeList[i].ProcCode);
                    proc.DateEntryC     = DateTimeOD.Today;
                    proc.PatNum         = chargeList[i].PatNum;
                    proc.ProcDate       = possibleDateNew;
                    proc.DateTP         = possibleDateNew;
                    proc.ProcFee        = chargeList[i].ChargeAmt;
                    proc.ProcStatus     = ProcStat.C;
                    proc.ProvNum        = PrefC.GetLong(PrefName.PracticeDefaultProv);
                    proc.MedicalCode    = ProcedureCodes.GetProcCode(proc.CodeNum).MedicalCode;
                    proc.BaseUnits      = ProcedureCodes.GetProcCode(proc.CodeNum).BaseUnits;
                    proc.DiagnosticCode = PrefC.GetString(PrefName.ICD9DefaultForNewProcs);
                    //Check if the repeating charge has been flagged to copy it's note into the billing note of the procedure.
                    if (chargeList[i].CopyNoteToProc)
                    {
                        proc.BillingNote = chargeList[i].Note;
                    }
                    Procedures.Insert(proc);                    //no recall synch needed because dental offices don't use this feature
                    countAdded++;
                    possibleDateOld = possibleDateOld.AddMonths(1);
                    countMonths++;
                    possibleDateNew = startDate.AddMonths(countMonths);
                    if (chargeList[i].CreatesClaim && !ProcedureCodes.GetProcCode(chargeList[i].ProcCode).NoBillIns)
                    {
                        List <PatPlan>   patPlanList = PatPlans.Refresh(chargeList[i].PatNum);
                        List <InsSub>    subList     = InsSubs.RefreshForFam(Patients.GetFamily(chargeList[i].PatNum));
                        List <InsPlan>   insPlanList = InsPlans.RefreshForSubList(subList);;
                        List <Benefit>   benefitList = Benefits.Refresh(patPlanList, subList);
                        Claim            claimCur;
                        List <Procedure> procCurList = new List <Procedure>();
                        procCurList.Add(proc);
                        if (patPlanList.Count == 0)                       //no current insurance, do not create a claim
                        {
                            continue;
                        }
                        //create the claimprocs
                        Procedures.ComputeEstimates(proc, proc.PatNum, new List <ClaimProc>(), true, insPlanList, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        //get claimprocs for this proc, may be more than one
                        List <ClaimProc> claimProcList = ClaimProcs.GetForProc(ClaimProcs.Refresh(proc.PatNum), proc.ProcNum);
                        string           claimType     = "P";
                        if (patPlanList.Count == 1 && PatPlans.GetOrdinal(PriSecMed.Medical, patPlanList, insPlanList, subList) > 0)                  //if there's exactly one medical plan
                        {
                            claimType = "Med";
                        }
                        claimCur      = CreateClaim(claimType, patPlanList, insPlanList, claimProcList, proc, subList);
                        claimProcList = ClaimProcs.Refresh(proc.PatNum);
                        if (claimCur.ClaimNum == 0)
                        {
                            continue;
                        }
                        claimsAdded++;
                        ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        if (PatPlans.GetOrdinal(PriSecMed.Secondary, patPlanList, insPlanList, subList) > 0 &&                //if there exists a secondary plan
                            !CultureInfo.CurrentCulture.Name.EndsWith("CA"))                               //and not canada (don't create secondary claim for canada)
                        {
                            claimCur = CreateClaim("S", patPlanList, insPlanList, claimProcList, proc, subList);
                            if (claimCur.ClaimNum == 0)
                            {
                                continue;
                            }
                            claimsAdded++;
                            claimProcList        = ClaimProcs.Refresh(proc.PatNum);
                            claimCur.ClaimStatus = "H";
                            ClaimL.CalculateAndUpdate(procCurList, insPlanList, claimCur, patPlanList, benefitList, Patients.GetPat(proc.PatNum).Age, subList);
                        }
                    }
                }
            }
            //MessageBox.Show(countAdded.ToString()+" "+Lan.g(this,"procedures added."));
            MessageBox.Show(countAdded.ToString() + " " + Lan.g(this, "procedures added.") + "\r\n" + claimsAdded.ToString() + " " + Lan.g(this, "claims added."));
            DialogResult = DialogResult.OK;
        }
コード例 #15
0
        ///<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.</summary>
        public static Appointment CreateRecallApt(Patient patCur, Procedure[] procList, Recall recallCur, InsPlan[] planList)
        {
            Appointment AptCur = new Appointment();

            AptCur.PatNum    = patCur.PatNum;
            AptCur.AptStatus = ApptStatus.Scheduled;
            //convert time pattern to 5 minute increment
            StringBuilder savePattern = new StringBuilder();

            for (int i = 0; i < PrefB.GetString("RecallPattern").Length; i++)
            {
                savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1));
                savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1));
                if (PrefB.GetInt("AppointmentTimeIncrement") == 15)
                {
                    savePattern.Append(PrefB.GetString("RecallPattern").Substring(i, 1));
                }
            }
            AptCur.Pattern = savePattern.ToString();
            if (patCur.PriProv == 0)
            {
                AptCur.ProvNum = PrefB.GetInt("PracticeDefaultProv");
            }
            else
            {
                AptCur.ProvNum = patCur.PriProv;
            }
            AptCur.ProvHyg = patCur.SecProv;
            if (AptCur.ProvHyg != 0)
            {
                AptCur.IsHygiene = true;
            }
            AptCur.ClinicNum = patCur.ClinicNum;
            string[] procs = PrefB.GetString("RecallProcedures").Split(',');
            if (PrefB.GetString("RecallBW") != "")          //BWs
            {
                bool dueBW = true;
                //DateTime dueDate=PIn.PDate(listFamily.Items[
                for (int i = 0; i < procList.Length; i++)          //loop through all procedures for this pt.
                //if any BW found within last year, then dueBW=false.
                {
                    if (PrefB.GetString("RecallBW") == procList[i].ADACode &&
                        recallCur.DateDue.Year > 1880 &&
                        procList[i].ProcDate > recallCur.DateDue.AddYears(-1))
                    {
                        dueBW = false;
                    }
                }
                if (dueBW)
                {
                    string[] procs2 = new string[procs.Length + 1];
                    procs.CopyTo(procs2, 0);
                    procs2[procs2.Length - 1] = PrefB.GetString("RecallBW");
                    procs = new string[procs2.Length];
                    procs2.CopyTo(procs, 0);
                }
            }
            AptCur.ProcDescript = "";
            for (int i = 0; i < procs.Length; i++)
            {
                if (i > 0)
                {
                    AptCur.ProcDescript += ", ";
                }
                AptCur.ProcDescript += ProcedureCodes.GetProcCode(procs[i]).AbbrDesc;
            }
            Appointments.InsertOrUpdate(AptCur, null, true);
            Procedure ProcCur;

            PatPlan[] patPlanList = PatPlans.Refresh(patCur.PatNum);
            Benefit[] benefitList = Benefits.Refresh(patPlanList);
            //ClaimProc[] claimProcs=ClaimProcs.Refresh(Patients.Cur.PatNum);
            for (int i = 0; i < procs.Length; i++)
            {
                ProcCur = new Procedure();              //this will be an insert
                //procnum
                ProcCur.PatNum   = patCur.PatNum;
                ProcCur.AptNum   = AptCur.AptNum;
                ProcCur.ADACode  = procs[i];
                ProcCur.ProcDate = DateTime.Now;
                ProcCur.ProcFee  = Fees.GetAmount0(ProcCur.ADACode, Fees.GetFeeSched(patCur, planList, patPlanList));
                //ProcCur.OverridePri=-1;
                //ProcCur.OverrideSec=-1;
                //surf
                //toothnum
                //Procedures.Cur.ToothRange="";
                //ProcCur.NoBillIns=ProcedureCodes.GetProcCode(ProcCur.ADACode).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.MedicalCode = ProcedureCodes.GetProcCode(ProcCur.ADACode).MedicalCode;
                Procedures.Insert(ProcCur);                //no recall synch required
                Procedures.ComputeEstimates(ProcCur, patCur.PatNum, new ClaimProc[0], false, planList, patPlanList, benefitList);
            }
            return(AptCur);
        }
コード例 #16
0
ファイル: FormInsRemain.cs プロジェクト: kjb7749/testImport
        private void FillGrid()
        {
            gridRemainTimeUnits.BeginUpdate();
            gridRemainTimeUnits.Rows.Clear();
            List <Benefit>   listPatBenefits = Benefits.Refresh(PatPlans.Refresh(_patCur.PatNum), InsSubs.GetListForSubscriber(_patCur.PatNum));
            ODGridRow        gridRow;
            List <Procedure> listProcs;
            double           amtUsed;
            int monthRenew;

            if (listPatBenefits.Count > 0)
            {
                for (int i = 0; i < listPatBenefits.Count; i++)
                {
                    if (listPatBenefits[i].CovCatNum == 0 ||               //no category
                        listPatBenefits[i].BenefitType != InsBenefitType.Limitations ||                         //benefit type is not limitations
                        (listPatBenefits[i].TimePeriod != BenefitTimePeriod.CalendarYear &&                         //neither calendar year nor serviceyear
                         listPatBenefits[i].TimePeriod != BenefitTimePeriod.ServiceYear) ||
                        listPatBenefits[i].Quantity < 0 ||                        //quantity is negative (negatives are allowed in FormBenefitEdit)
                        listPatBenefits[i].QuantityQualifier != BenefitQuantity.NumberOfServices ||                        //qualifier us not the number of services
                        (listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Family &&                         //neither individual nor family coverage level
                         listPatBenefits[i].CoverageLevel != BenefitCoverageLevel.Individual))
                    {
                        continue;
                    }
                    //for calendar year, get completed procs from January.01.CurYear ~ Curdate
                    List <long> listPatNums = new List <long> {
                        _patCur.PatNum
                    };                                                                         //for current patient.
                    if (listPatBenefits[i].TimePeriod == BenefitTimePeriod.CalendarYear)
                    {
                        //01/01/CurYear. is there a better way?
                        listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, 1, 1), DateTimeOD.Today, null, listPatNums);
                    }
                    else                                                                         //if not calendar year, then it must be service year
                    {
                        monthRenew = InsPlans.RefreshOne(listPatBenefits[i].PlanNum).MonthRenew; //monthrenew only stores the month as an int.
                        if (DateTimeOD.Today.Month >= monthRenew)                                //if the the current date is past the renewal month, use the current year
                        {
                            listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year, monthRenew, 1), DateTimeOD.Today, null, listPatNums);
                        }
                        else                           //otherwise use the previous year
                        {
                            listProcs = Procedures.GetCompletedForDateRange(new DateTime(DateTimeOD.Today.Year - 1, monthRenew, 1), DateTimeOD.Today, null, listPatNums);
                        }
                    }
                    //Calculate the amount used for one benefit.
                    amtUsed = GetAmtUsedForCat(listProcs, CovCats.GetCovCat(listPatBenefits[i].CovCatNum));
                    gridRow = new ODGridRow();
                    gridRow.Cells.Add(CovCats.GetCovCat(listPatBenefits[i].CovCatNum).EbenefitCat.ToString()); //Coverage Category
                    gridRow.Cells.Add(listPatBenefits[i].Quantity.ToString());                                 //Quantity
                    gridRow.Cells.Add(amtUsed.ToString("F"));                                                  //Used
                    double amtRemain = listPatBenefits[i].Quantity - amtUsed;
                    if (amtRemain > 0)
                    {
                        gridRow.Cells.Add(amtRemain.ToString("F")); //quantity-used.
                    }
                    else                                            //if less then 0, just 0.
                    {
                        gridRow.Cells.Add("0");
                    }
                    gridRemainTimeUnits.Rows.Add(gridRow);
                }
            }
            gridRemainTimeUnits.EndUpdate();
        }