Example #1
0
        ///<summary>Clears the procedurecode table.  Does not truncate as to not let the PKs repeat.</summary>
        public static void ClearProcedureCodeTable()
        {
            string command = "DELETE FROM procedurecode";

            DataCore.NonQ(command);
            ProcedureCodes.RefreshCache();
        }
Example #2
0
        public static string FreshFromDump()
        {
            SetDbConnection("mysql", "localhost");           //Must connect to the mysql database so we can drop and recreate the test database.
            string command = "DROP DATABASE IF EXISTS canadatest";

            try{
                DataCore.NonQ(command);
            }
            catch {
                throw new Exception("Database could not be dropped.  Please remove any remaining text files and try again.");
            }
            command = "CREATE DATABASE canadatest";
            DataCore.NonQ(command);
            SetDbConnection("canadatest");
            command = Properties.Resources.dumpcanada;
            DataCore.NonQ(command);
            Cache.ClearAllCache();
            string toVersion = Assembly.GetAssembly(typeof(OpenDental.PrefL)).GetName().Version.ToString();

            //MessageBox.Show(Application.ProductVersion+" - "+
            if (!PrefL.ConvertDB(true, toVersion))
            {
                throw new Exception("Wrong version.");
            }
            ProcedureCodes.TcodesClear();
            AutoCodes.SetToDefaultCanada();
            Prefs.UpdateDateT(PrefName.BackupReminderLastDateRun, DateTime.MaxValue.AddYears(-1));           //We do not need backup reminders while testing.
            return("Fresh database loaded from sql dump.\r\n");
        }
Example #3
0
        protected static void FeeTestSetup()
        {
            //Some unit tests cannot handle duplicate procedure codes being present within the database.
            //This is acceptable because that scenario should be impossible (we block the user via the UI layer).
            //Delete all duplicate procedure codes.
            Dictionary <string, ProcedureCode> dictProcCodes = ProcedureCodes.GetAllCodes().GroupBy(x => x.ProcCode).ToDictionary(x => x.Key, x => x.First());

            ProcedureCodeT.ClearProcedureCodeTable();
            foreach (ProcedureCode procedureCode in dictProcCodes.Values)
            {
                ProcedureCodes.Insert(procedureCode);
            }
            ProcedureCodes.RefreshCache();
            _listProcCodes    = ProcedureCodes.GetAllCodes();       //Just in case the PKs matter to some tests.
            _listProcCodesOld = _listProcCodes.Select(x => x.Copy()).ToList();
            if (Fees.GetCountByFeeSchedNum(_standardFeeSchedNum) <= 0)
            {
                List <Fee> listFees = new List <Fee>();
                foreach (ProcedureCode procCode in _listProcCodes)
                {
                    listFees.Add(new Fee()
                    {
                        FeeSched  = _standardFeeSchedNum,
                        CodeNum   = procCode.CodeNum,
                        Amount    = _defaultFeeAmt * _rand.NextDouble(),
                        ClinicNum = 0,
                        ProvNum   = 0
                    });                     //create the default fee schedule fee
                }
                Fees.InsertMany(listFees);
            }
        }
Example #4
0
        ///<summary></summary>
        public static RecallType CreateRecallType(string description       = "Cleaning", string procedures = "D1110,D0150", string timePattern = "///X///",
                                                  Interval defaultInterval = default(Interval))
        {
            RecallType recallType = new RecallType();

            if (defaultInterval == default(Interval))
            {
                recallType.DefaultInterval = new Interval(1, 0, 6, 0);
            }
            else
            {
                recallType.DefaultInterval = defaultInterval;
            }
            recallType.Description = description;
            recallType.Procedures  = procedures;
            recallType.TimePattern = timePattern;
            RecallTypes.Insert(recallType);
            RecallTypes.RefreshCache();
            foreach (string procStr in procedures.Split(','))
            {
                RecallTriggers.Insert(new RecallTrigger {
                    CodeNum       = ProcedureCodes.GetOne(procStr).CodeNum,
                    RecallTypeNum = recallType.RecallTypeNum
                });
            }
            return(recallType);
        }
Example #5
0
        ///<summary>Creates a procedure and computes estimates for a patient where the secondary insurance has a COB rule of Medicaid.</summary>
        private void ComputeEstimatesMedicaidCOB(string suffix, double procFee, double priAllowed, double secAllowed, int priPercentCovered,
                                                 int secPercentCovered, Action <ClaimProc /*Primary*/, ClaimProc /*Secondary*/, Procedure> assertAct)
        {
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum);
            long medicaidFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", medicaidFeeSchedNum, 2, cobRule: EnumCobRule.SecondaryMedicaid);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            InsPlan        priPlan      = InsPlanT.GetPlanForPriSecMed(PriSecMed.Primary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateCategoryPercent(priPlan.PlanNum, EbenefitCategory.Diagnostic, priPercentCovered);
            InsPlan secPlan = InsPlanT.GetPlanForPriSecMed(PriSecMed.Secondary, listPatPlans, listPlans, listSubs);

            BenefitT.CreateCategoryPercent(secPlan.PlanNum, EbenefitCategory.Diagnostic, secPercentCovered);
            List <Benefit> listBens = Benefits.Refresh(listPatPlans, listSubs);
            string         procStr  = "D0150";
            Procedure      proc     = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ProcedureCode  procCode = ProcedureCodes.GetProcCode(procStr);

            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, priAllowed);
            FeeT.CreateFee(medicaidFeeSchedNum, procCode.CodeNum, secAllowed);
            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), false, listPlans, listPatPlans, listBens, pat.Age, listSubs);
            List <ClaimProc> listClaimProcs = ClaimProcs.Refresh(pat.PatNum);

            assertAct(listClaimProcs.FirstOrDefault(x => x.PlanNum == priPlan.PlanNum), listClaimProcs.FirstOrDefault(x => x.PlanNum == secPlan.PlanNum), proc);
        }
Example #6
0
        ///<summary>Creates a procedure and returns its procedure fee.</summary>
        private double GetProcFee(string suffix, bool doUseMedicalCode)
        {
            Prefs.UpdateBool(PrefName.InsPpoAlwaysUseUcrFee, true);
            Prefs.UpdateBool(PrefName.MedicalFeeUsedForNewProcs, doUseMedicalCode);
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR " + suffix);

            FeeSchedT.UpdateUCRFeeSched(pat, ucrFeeSchedNum);
            long ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO " + suffix);

            InsuranceT.AddInsurance(pat, suffix, "p", ppoFeeSchedNum, 1, true);
            List <InsSub>  listSubs     = InsSubT.GetInsSubs(pat);
            List <InsPlan> listPlans    = InsPlans.RefreshForSubList(listSubs);
            List <PatPlan> listPatPlans = PatPlans.Refresh(pat.PatNum);
            string         procStr      = "D0150";
            string         procStrMed   = "D0120";
            ProcedureCode  procCode     = ProcedureCodes.GetProcCode(procStr);
            ProcedureCode  procCodeMed  = ProcedureCodes.GetProcCode(procStrMed);

            procCode.MedicalCode = procCodeMed.ProcCode;
            FeeT.CreateFee(ucrFeeSchedNum, procCode.CodeNum, 300);
            FeeT.CreateFee(ppoFeeSchedNum, procCode.CodeNum, 120);
            FeeT.CreateFee(ucrFeeSchedNum, procCodeMed.CodeNum, 175);
            FeeT.CreateFee(ppoFeeSchedNum, procCodeMed.CodeNum, 85);
            Procedure proc = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", 300);

            return(Procedures.GetProcFee(pat, listPatPlans, listSubs, listPlans, procCode.CodeNum, proc.ProvNum, proc.ClinicNum, procCode.MedicalCode));
        }
Example #7
0
        public void RepeatCharges_RunRepeatingCharges_ChangeRepeatChargeStartDate()
        {
            Patient pat = CreatePatForRepeatCharge("RepeatCharge", 15);
            //add a repeat charge with start 01/15/2017
            RepeatCharge rc = new RepeatCharge();

            rc.ChargeAmt       = 99;
            rc.PatNum          = pat.PatNum;
            rc.ProcCode        = "D2750";
            rc.IsEnabled       = true;
            rc.DateStart       = new DateTime(2017, 01, pat.BillingCycleDay);
            rc.RepeatChargeNum = RepeatCharges.Insert(rc);
            //add a procedures with procdate 01/15/2017
            Procedure p = new Procedure();

            p.PatNum          = pat.PatNum;
            p.ProcStatus      = ProcStat.C;
            p.ProcDate        = new DateTime(2017, 01, pat.BillingCycleDay);
            p.ProcFee         = 99;
            p.CodeNum         = ProcedureCodes.GetCodeNum("D2750");
            p.RepeatChargeNum = rc.RepeatChargeNum;
            Procedures.Insert(p);
            //add a procedures with procdate 02/15/2017
            p                 = new Procedure();
            p.PatNum          = pat.PatNum;
            p.ProcStatus      = ProcStat.C;
            p.ProcDate        = new DateTime(2017, 02, pat.BillingCycleDay);
            p.ProcFee         = 99;
            p.CodeNum         = ProcedureCodes.GetCodeNum("D2750");
            p.RepeatChargeNum = rc.RepeatChargeNum;
            Procedures.Insert(p);
            //add a procedures with procdate 03/15/2017
            p                 = new Procedure();
            p.PatNum          = pat.PatNum;
            p.ProcStatus      = ProcStat.C;
            p.ProcDate        = new DateTime(2017, 03, pat.BillingCycleDay);
            p.ProcFee         = 99;
            p.CodeNum         = ProcedureCodes.GetCodeNum("D2750");
            p.RepeatChargeNum = rc.RepeatChargeNum;
            Procedures.Insert(p);
            //add a procedures with procdate 04/15/2017
            p                 = new Procedure();
            p.PatNum          = pat.PatNum;
            p.ProcStatus      = ProcStat.C;
            p.ProcDate        = new DateTime(2017, 04, pat.BillingCycleDay);
            p.ProcFee         = 99;
            p.CodeNum         = ProcedureCodes.GetCodeNum("D2750");
            p.RepeatChargeNum = rc.RepeatChargeNum;
            Procedures.Insert(p);
            //change the repeatcharge start date to 05/15/2017
            rc.DateStart = new DateTime(2017, 05, pat.BillingCycleDay);
            RepeatCharges.Update(rc);
            DateTime dateRun = new DateTime(2017, 05, pat.BillingCycleDay);

            RepeatCharges.RunRepeatingCharges(dateRun);
            List <Procedure> listProcs = Procedures.Refresh(pat.PatNum);

            Assert.AreEqual(5, listProcs.Count);
        }
Example #8
0
 ///<summary>After running FeeTestSetup() this can be called to
 ///set procs in _listProcCodes back to their original state via _listProcCodesOld.</summary>
 protected static void FeeTestTearDown()
 {
     foreach (ProcedureCode procCode in _listProcCodesOld)             //Reset
     {
         ProcedureCodes.Update(procCode);
     }
     ProcedureCodes.RefreshCache();
 }
Example #9
0
        public static Benefit CreateFrequencyLimitation(string procCode, byte quantity, BenefitQuantity quantityQualifier, long planNum,
                                                        BenefitTimePeriod timePeriod)
        {
            Benefit ben = Benefits.CreateFrequencyBenefit(ProcedureCodes.GetCodeNum(procCode), quantity, quantityQualifier, planNum, timePeriod);

            Benefits.Insert(ben);
            return(ben);
        }
Example #10
0
        public static string ClearDb()
        {
            string command = @"
				DELETE FROM carrier;
				DELETE FROM claim;
				DELETE FROM claimproc;
				DELETE FROM fee;
				DELETE FROM feesched WHERE FeeSchedNum !=53; /*because this is the default fee schedule for providers*/
				DELETE FROM insplan;
				DELETE FROM patient;
				DELETE FROM patplan;
				DELETE FROM procedurelog;
				DELETE FROM etrans;
				"                ;

            DataCore.NonQ(command);
            ProcedureCodes.RefreshCache();
            ProcedureCode procCode;

            if (!ProcedureCodes.IsValidCode("99222"))
            {
                procCode               = new ProcedureCode();
                procCode.ProcCode      = "99222";
                procCode.Descript      = "Lab2";
                procCode.AbbrDesc      = "Lab2";
                procCode.IsCanadianLab = true;
                procCode.ProcCat       = 256;
                procCode.ProcTime      = "/X/";
                procCode.TreatArea     = TreatmentArea.Mouth;
                ProcedureCodes.Insert(procCode);
                ProcedureCodes.RefreshCache();
            }
            procCode = ProcedureCodes.GetProcCode("99111");
            procCode.IsCanadianLab = true;
            ProcedureCodes.Update(procCode);
            ProcedureCodes.RefreshCache();
            if (!ProcedureCodes.IsValidCode("27213"))
            {
                procCode           = new ProcedureCode();
                procCode.ProcCode  = "27213";
                procCode.Descript  = "Crown";
                procCode.AbbrDesc  = "Crn";
                procCode.ProcCat   = 250;
                procCode.ProcTime  = "/X/";
                procCode.TreatArea = TreatmentArea.Tooth;
                procCode.PaintType = ToothPaintingType.CrownLight;
                ProcedureCodes.Insert(procCode);
                ProcedureCodes.RefreshCache();
            }
            procCode           = ProcedureCodes.GetProcCode("67211");
            procCode.TreatArea = TreatmentArea.Quad;
            ProcedureCodes.Update(procCode);
            ProcedureCodes.RefreshCache();



            return("Database cleared of old data.\r\n");
        }
Example #11
0
        private static Claim CreatePredetermination(Patient pat, List <Procedure> procList, long provTreat)
        {
            Family           fam           = Patients.GetFamily(pat.PatNum);
            List <InsSub>    subList       = InsSubs.RefreshForFam(fam);
            List <InsPlan>   planList      = InsPlans.RefreshForSubList(subList);
            List <PatPlan>   patPlanList   = PatPlans.Refresh(pat.PatNum);
            List <Benefit>   benefitList   = Benefits.Refresh(patPlanList, subList);
            List <ClaimProc> claimProcList = ClaimProcs.Refresh(pat.PatNum);
            List <Procedure> procsForPat   = Procedures.Refresh(pat.PatNum);
            InsSub           sub           = InsSubs.GetSub(PatPlans.GetInsSubNum(patPlanList, 1), subList);
            InsPlan          insPlan       = InsPlans.GetPlan(sub.PlanNum, planList);
            Claim            claim         = new Claim();

            Claims.Insert(claim);      //to retreive a key for new Claim.ClaimNum
            claim.PatNum      = pat.PatNum;
            claim.DateService = procList[0].ProcDate;
            claim.DateSent    = DateTime.Today;
            claim.ClaimStatus = "W";
            claim.InsSubNum   = PatPlans.GetInsSubNum(patPlanList, 1);
            claim.InsSubNum2  = PatPlans.GetInsSubNum(patPlanList, 2);
            InsSub sub1 = InsSubs.GetSub(claim.InsSubNum, subList);
            InsSub sub2 = InsSubs.GetSub(claim.InsSubNum, subList);

            claim.PlanNum       = sub1.PlanNum;
            claim.PlanNum2      = sub2.PlanNum;
            claim.PatRelat      = PatPlans.GetRelat(patPlanList, 1);
            claim.PatRelat2     = PatPlans.GetRelat(patPlanList, 2);
            claim.ClaimType     = "PreAuth";
            claim.ProvTreat     = provTreat;
            claim.IsProsthesis  = "N";
            claim.ProvBill      = Providers.GetBillingProvNum(claim.ProvTreat, 0);
            claim.EmployRelated = YN.No;
            ClaimProc        cp;
            List <Procedure> procListClaim = new List <Procedure>();  //this list will exclude lab fees

            for (int i = 0; i < procList.Count; i++)
            {
                if (procList[i].ProcNumLab == 0)
                {
                    procListClaim.Add(procList[i]);
                }
            }
            for (int i = 0; i < procListClaim.Count; i++)
            {
                cp = new ClaimProc();
                ClaimProcs.CreateEst(cp, procListClaim[i], insPlan, sub);
                cp.ClaimNum   = claim.ClaimNum;
                cp.Status     = ClaimProcStatus.NotReceived;
                cp.CodeSent   = ProcedureCodes.GetProcCode(procListClaim[i].CodeNum).ProcCode;
                cp.LineNumber = (byte)(i + 1);
                ClaimProcs.Update(cp);
            }
            claimProcList = ClaimProcs.Refresh(pat.PatNum);
            ClaimL.CalculateAndUpdate(procsForPat, planList, claim, patPlanList, benefitList, pat.Age, subList);
            return(claim);
        }
Example #12
0
        public static void SetComplete(Procedure proc, Patient pat, List <InsPlan> planList, List <PatPlan> patPlanList, List <ClaimProc> claimProcList, List <Benefit> benefitList, List <InsSub> subList)
        {
            Procedure     procOld  = proc.Copy();
            ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum);

            proc.DateEntryC = DateTime.Now;
            proc.ProcStatus = ProcStat.C;
            Procedures.Update(proc, procOld);
            Procedures.ComputeEstimates(proc, proc.PatNum, claimProcList, false, planList, patPlanList, benefitList, pat.Age, subList);
        }
Example #13
0
 public static void SetupClass(TestContext testContext)
 {
     //Add anything here that you want to run once before the tests in this class run.
     ProcedureCodeT.AddIfNotPresent("D0120");
     ProcedureCodeT.AddIfNotPresent("D1110");
     ProcedureCodeT.AddIfNotPresent("D0602");
     ProcedureCodeT.AddIfNotPresent("D1206");
     ProcedureCodes.RefreshCache();            //Refresh cache if the codes above were added
     _x271 = new X271(Properties.Resources.x271Test);
 }
Example #14
0
 ///<summary>Returns a procedure code object that utilizes the procCode passed in.
 ///Either returns the pre-existing code from the cache or creates a new one.  Throws an exception if procCode is longer than 15 chars.</summary>
 public static ProcedureCode CreateProcCode(string procCode, bool isCanadianLab = false)
 {
     //The ProcCode column on the procedurecode table is a VARCHAR(15).  MySQL will not throw an exception but will instead truncate the ProcCode.
     //Engineers might not be expecting this and might write an invalid unit test assuming that this method did what they told it to do.
     if (procCode.Length > 15)
     {
         throw new ODException("Invalid procCode passed into ProcedureCodeT.CreateProcCode(); Must be less than 15 characters.");
     }
     AddIfNotPresent(procCode, isCanadianLab);
     return(ProcedureCodes.GetOne(procCode));
 }
Example #15
0
        ///<summary>The tooth number passed in should be in international format.</summary>
        public static void SetExtracted(string toothNumInternat, DateTime procDate, long patNum)
        {
            Procedure proc = new Procedure();

            proc.CodeNum    = ProcedureCodes.GetCodeNum("71101");
            proc.PatNum     = patNum;
            proc.ProcDate   = procDate;
            proc.ToothNum   = Tooth.FromInternat(toothNumInternat);
            proc.ProcStatus = ProcStat.EO;
            Procedures.Insert(proc);
            ToothInitialTC.SetMissing(toothNumInternat, patNum);
        }
Example #16
0
        public static void CreateLimitationProc(long planNum, string procCodeStr, double amt)
        {
            Benefit ben = new Benefit();

            ben.PlanNum       = planNum;
            ben.BenefitType   = InsBenefitType.Limitations;
            ben.CodeNum       = ProcedureCodes.GetCodeNum(procCodeStr);
            ben.CoverageLevel = BenefitCoverageLevel.Individual;
            ben.MonetaryAmt   = amt;
            ben.TimePeriod    = BenefitTimePeriod.CalendarYear;
            Benefits.Insert(ben);
        }
Example #17
0
        ///<summary>Financial transaction segment.</summary>
        private void FT1(List <Procedure> listProcs, bool justPDF)
        {
            if (justPDF)
            {
                return;                //FT1 segment is not necessary when sending only a PDF.
            }
            ProcedureCode procCode;

            for (int i = 0; i < listProcs.Count; i++)
            {
                seg = new SegmentHL7(SegmentNameHL7.FT1);
                seg.SetField(0, "FT1");
                seg.SetField(1, (i + 1).ToString());
                seg.SetField(4, listProcs[i].ProcDate.ToString("yyyyMMdd"));
                seg.SetField(5, listProcs[i].ProcDate.ToString("yyyyMMdd"));
                seg.SetField(6, "CG");
                seg.SetField(10, "1.0");
                seg.SetField(16, "");               //location code and description???
                seg.SetField(19, listProcs[i].DiagnosticCode);
                Provider prov = Providers.GetProv(listProcs[i].ProvNum);
                seg.SetField(20, prov.EcwID, prov.LName, prov.FName, prov.MI);            //performed by provider.
                seg.SetField(21, prov.EcwID, prov.LName, prov.FName, prov.MI);            //ordering provider.
                seg.SetField(22, listProcs[i].ProcFee.ToString("F2"));
                procCode = ProcedureCodes.GetProcCode(listProcs[i].CodeNum);
                if (procCode.ProcCode.Length > 5 && procCode.ProcCode.StartsWith("D"))
                {
                    seg.SetField(25, procCode.ProcCode.Substring(0, 5));                  //Remove suffix from all D codes.
                }
                else
                {
                    seg.SetField(25, procCode.ProcCode);
                }
                if (procCode.TreatArea == TreatmentArea.ToothRange)
                {
                    seg.SetField(26, listProcs[i].ToothRange, "");
                }
                else if (procCode.TreatArea == TreatmentArea.Surf)              //probably not necessary
                {
                    seg.SetField(26, Tooth.ToInternat(listProcs[i].ToothNum), Tooth.SurfTidyForClaims(listProcs[i].Surf, listProcs[i].ToothNum));
                }
                //this property will not exist if using Oracle, eCW will never use Oracle
                else if (procCode.TreatArea == TreatmentArea.Quad && ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "IsQuadAsToothNum") == "1")
                {
                    seg.SetField(26, listProcs[i].Surf, "");
                }
                else
                {
                    seg.SetField(26, Tooth.ToInternat(listProcs[i].ToothNum), listProcs[i].Surf);
                }
                msg.Segments.Add(seg);
            }
        }
Example #18
0
 /// <summary>Returns true if a procedureCode was added.</summary>
 public static bool AddIfNotPresent(string procCode, bool isCanadianLab = false)
 {
     if (!ProcedureCodes.GetContainsKey(procCode))
     {
         ProcedureCodes.Insert(new ProcedureCode {
             ProcCode      = procCode,
             IsCanadianLab = isCanadianLab,
         });
         ProcedureCodes.RefreshCache();
         return(true);
     }
     return(false);
 }
Example #19
0
        public void InsPlans_GetAllowed_PPOSubstituteMoreExpensive()
        {
            InsPlan       plan     = GeneratePPOPlan(MethodBase.GetCurrentMethod().Name, false);
            ProcedureCode procCode = _listProcCodes[9];

            procCode.SubstitutionCode = _listProcCodes[10].ProcCode;
            ProcedureCodes.Update(procCode);
            Fee    feeOrig = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 85);
            Fee    feeSubs = FeeT.GetNewFee(plan.FeeSched, ProcedureCodes.GetSubstituteCodeNum(procCode.SubstitutionCode, "", plan.PlanNum), 200);
            double allowed = InsPlans.GetAllowed(procCode.ProcCode, plan.FeeSched, plan.AllowedFeeSched, plan.CodeSubstNone, plan.PlanType, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeOrig.Amount, allowed);
        }
Example #20
0
        public void InsPlans_GetCopay_SubstituteFee()
        {
            ProcedureCode procCode = _listProcCodes[4];

            procCode.SubstitutionCode = _listProcCodes[5].ProcCode;
            ProcedureCodes.Update(procCode);
            InsPlan plan          = GenerateMediFlatInsPlan(MethodBase.GetCurrentMethod().Name, false);
            Fee     feeDefault    = FeeT.GetNewFee(plan.FeeSched, procCode.CodeNum, 100);
            Fee     feeSubstitute = FeeT.GetNewFee(plan.CopayFeeSched, ProcedureCodes.GetSubstituteCodeNum(procCode.ProcCode, "", plan.PlanNum), 45);
            double  amt           = InsPlans.GetCopay(procCode.CodeNum, plan.FeeSched, plan.CopayFeeSched, plan.CodeSubstNone, "", 0, 0, plan.PlanNum);

            Assert.AreEqual(feeSubstitute.Amount, amt);
        }
Example #21
0
        public static void CreateFrequencyProc(long planNum, string procCodeStr, BenefitQuantity quantityQualifier, Byte quantity)
        {
            Benefit ben = new Benefit();

            ben.PlanNum           = planNum;
            ben.BenefitType       = InsBenefitType.Limitations;
            ben.CovCatNum         = 0;
            ben.CodeNum           = ProcedureCodes.GetCodeNum(procCodeStr);
            ben.CoverageLevel     = BenefitCoverageLevel.None;
            ben.TimePeriod        = BenefitTimePeriod.None;
            ben.Quantity          = quantity;
            ben.QuantityQualifier = quantityQualifier;
            Benefits.Insert(ben);
        }
Example #22
0
        /// <summary>Returns the proc</summary>
        public static Procedure CreateProcedure(Patient pat, string procCodeStr, ProcStat procStatus, string toothNum, double procFee)
        {
            Procedure proc = new Procedure();

            proc.CodeNum    = ProcedureCodes.GetCodeNum(procCodeStr);
            proc.PatNum     = pat.PatNum;
            proc.ProcDate   = DateTime.Today;
            proc.ProcStatus = procStatus;
            proc.ProvNum    = pat.PriProv;
            proc.ProcFee    = procFee;
            proc.ToothNum   = toothNum;
            proc.Prosthesis = "I";
            Procedures.Insert(proc);
            return(proc);
        }
Example #23
0
        private static string gProcCode(Procedure proc)
        {
            string        retVal   = "";
            ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum);

            if (procCode.ProcCode.Length > 5 && procCode.ProcCode.StartsWith("D"))
            {
                retVal = procCode.ProcCode.Substring(0, 5);             //Remove suffix from all D codes.
            }
            else
            {
                retVal = procCode.ProcCode;
            }
            return(retVal);
        }
Example #24
0
        ///<summary>Financial transaction segment.</summary>
        private void FT1(long aptNum, bool justPDF)
        {
            if (justPDF)
            {
                return;                //FT1 segment is not necessary when sending only a PDF.
            }
            List <Procedure> procs = Procedures.GetProcsForSingle(aptNum, false);
            ProcedureCode    procCode;

            for (int i = 0; i < procs.Count; i++)
            {
                seg = new SegmentHL7(SegmentNameHL7.FT1);
                seg.SetField(0, "FT1");
                seg.SetField(1, (i + 1).ToString());
                seg.SetField(4, procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
                seg.SetField(5, procs[i].ProcDate.ToString("yyyyMMddHHmmss"));
                seg.SetField(6, "CG");
                seg.SetField(10, "1.0");
                seg.SetField(16, "");               //location code and description???
                seg.SetField(19, procs[i].DiagnosticCode);
                Provider prov = Providers.GetProv(procs[i].ProvNum);
                seg.SetField(20, prov.EcwID, prov.LName, prov.FName, prov.MI);            //performed by provider.
                seg.SetField(21, prov.EcwID, prov.LName, prov.FName, prov.MI);            //ordering provider.
                seg.SetField(22, procs[i].ProcFee.ToString("F2"));
                procCode = ProcedureCodes.GetProcCode(procs[i].CodeNum);
                if (procCode.ProcCode.Length > 5 && procCode.ProcCode.StartsWith("D"))
                {
                    seg.SetField(25, procCode.ProcCode.Substring(0, 5));                  //Remove suffix from all D codes.
                }
                else
                {
                    seg.SetField(25, procCode.ProcCode);
                }
                if (procCode.TreatArea == TreatmentArea.ToothRange)
                {
                    seg.SetField(26, procs[i].ToothRange, "");
                }
                else if (procCode.TreatArea == TreatmentArea.Surf)              //probably not necessary
                {
                    seg.SetField(26, Tooth.ToInternat(procs[i].ToothNum), Tooth.SurfTidyForClaims(procs[i].Surf, procs[i].ToothNum));
                }
                else
                {
                    seg.SetField(26, Tooth.ToInternat(procs[i].ToothNum), procs[i].Surf);
                }
                msg.Segments.Add(seg);
            }
        }
Example #25
0
        public static string FreshFromDump(string serverAddr, string port, string userName, string password, bool isOracle)
        {
            Security.CurUser = Security.CurUser ?? new Userod();
            if (!isOracle)
            {
                string command = "DROP DATABASE IF EXISTS " + TestBase.UnitTestDbName;
                try {
                    DataCore.NonQ(command);
                }
                catch {
                    throw new Exception("Database could not be dropped.  Please remove any remaining text files and try again.");
                }
                command = "CREATE DATABASE " + TestBase.UnitTestDbName;
                DataCore.NonQ(command);
                UnitTestsCore.DatabaseTools.SetDbConnection(TestBase.UnitTestDbName, serverAddr, port, userName, password, false);
                command = Properties.Resources.dump;
                DataCore.NonQ(command);
                string toVersion = Assembly.GetAssembly(typeof(OpenDental.PrefL)).GetName().Version.ToString();
                //MessageBox.Show(Application.ProductVersion+" - "+
                if (!PrefL.ConvertDB(true, toVersion, null))
                {
                    throw new Exception("Wrong version.");
                }
                ProcedureCodes.TcodesClear();
                FormProcCodes.ImportProcCodes("", CDT.Class1.GetADAcodes(), "");              //IF THIS LINE CRASHES:
                //Go to Solution, Configuration Manager.  Exclude UnitTest project from build.
                AutoCodes.SetToDefault();
                ProcButtons.SetToDefault();
                ProcedureCodes.ResetApptProcsQuickAdd();
                //RefreshCache (might be missing a few)  Or, it might make more sense to do this as an entirely separate method when running.
                ProcedureCodes.RefreshCache();
                command = "UPDATE userod SET Password='******' WHERE UserNum=1";              //sets Password to 'pass' for middle tier testing.
                DataCore.NonQ(command);
                AddCdcrecCodes();
            }
            else
            {
                //This stopped working. Might look into it later: for now manually create the unittest db

                //Make sure the command CREATE OR REPLACE DIRECTORY dmpdir AS 'c:\oraclexe\app\tmp'; was run
                //and there is an opendental user with matching username/pass
                //The unittest.dmp was taken from a fresh unittest db created from the code above.  No need to alter it further.
                //string command=@"impdp opendental/opendental DIRECTORY=dmpdir DUMPFILE=unittest.dmp TABLE_EXISTS_ACTION=replace LOGFILE=impschema.log";
                //ExecuteCommand(command);
            }
            return("Fresh database loaded from sql dump.\r\n");
        }
Example #26
0
        public void Claims_CalculateAndUpdate_ProcedureCodeDowngradeHigherFee()
        {
            string  suffix         = "61";
            Patient pat            = PatientT.CreatePatient(suffix);
            long    ucrFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "UCR Fees" + suffix);
            long    ppoFeeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPO Downgrades" + suffix);
            Carrier carrier        = CarrierT.CreateCarrier(suffix);
            InsPlan plan           = InsPlanT.CreateInsPlan(carrier.CarrierNum);
            InsSub  sub            = InsSubT.CreateInsSub(pat.PatNum, plan.PlanNum);
            long    subNum         = sub.InsSubNum;

            BenefitT.CreateCategoryPercent(plan.PlanNum, EbenefitCategory.Restorative, 100);
            PatPlanT.CreatePatPlan(1, pat.PatNum, subNum);
            ProcedureCode originalProcCode  = ProcedureCodes.GetProcCode("D2391");
            ProcedureCode downgradeProcCode = ProcedureCodes.GetProcCode("D2140");

            originalProcCode.SubstitutionCode = "D2140";
            originalProcCode.SubstOnlyIf      = SubstitutionCondition.Always;
            ProcedureCodes.Update(originalProcCode);
            FeeT.CreateFee(ucrFeeSchedNum, originalProcCode.CodeNum, 140);
            FeeT.CreateFee(ucrFeeSchedNum, downgradeProcCode.CodeNum, 120);
            FeeT.CreateFee(ppoFeeSchedNum, originalProcCode.CodeNum, 80);
            FeeT.CreateFee(ppoFeeSchedNum, downgradeProcCode.CodeNum, 100);
            Procedure        proc             = ProcedureT.CreateProcedure(pat, "D2391", ProcStat.C, "1", 140);//Tooth 1
            List <ClaimProc> claimProcs       = ClaimProcs.Refresh(pat.PatNum);
            List <ClaimProc> claimProcListOld = new List <ClaimProc>();
            Family           fam         = Patients.GetFamily(pat.PatNum);
            List <InsSub>    subList     = InsSubs.RefreshForFam(fam);
            List <InsPlan>   planList    = InsPlans.RefreshForSubList(subList);
            List <PatPlan>   patPlans    = PatPlans.Refresh(pat.PatNum);
            List <Benefit>   benefitList = Benefits.Refresh(patPlans, subList);
            List <Procedure> ProcList    = Procedures.Refresh(pat.PatNum);
            InsPlan          insPlan     = planList[0];//Should only be one
            InsPlan          planOld     = insPlan.Copy();

            insPlan.PlanType = "p";
            insPlan.FeeSched = ppoFeeSchedNum;
            InsPlans.Update(insPlan, planOld);
            //Creates the claim in the same manner as the account module, including estimates.
            Claim     claim  = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, ProcList, pat, ProcList, benefitList, subList);
            ClaimProc clProc = ClaimProcs.Refresh(pat.PatNum)[0];          //Should only be one

            Assert.AreEqual(80, clProc.InsEstTotal);
            Assert.AreEqual(60, clProc.WriteOff);
        }
        public void ProcedureCodes_GetProcCodesByTreatmentArea_HiddenCategories()
        {
            string suffix = MethodBase.GetCurrentMethod().Name;
            List <ProcedureCode> listMouthProcCodesOld = ProcedureCodes.GetProcCodesByTreatmentArea(false, TreatmentArea.Mouth, TreatmentArea.None);
            Def defCat = Defs.GetDef(DefCat.ProcCodeCats, listMouthProcCodesOld.FirstOrDefault(x => x.ProcCat > 0 &&
                                                                                               !Defs.GetHidden(DefCat.ProcCodeCats, x.ProcCat)).ProcCat);

            defCat.IsHidden = true;
            Defs.Update(defCat);
            Defs.RefreshCache();
            //ProcedureCodes.RefreshCache();
            List <ProcedureCode> listMouthProcCodesNew = ProcedureCodes.GetProcCodesByTreatmentArea(false, TreatmentArea.Mouth, TreatmentArea.None);

            defCat.IsHidden = false;
            Defs.Update(defCat);
            Defs.RefreshCache();
            Assert.AreNotEqual(listMouthProcCodesOld.Count, listMouthProcCodesNew.Count);
        }
Example #28
0
        public static void SetUp(TestContext context)
        {
            _listProcCodes = ProcedureCodes.GetAllCodes();
            List <Fee> listFees = new List <Fee>();

            foreach (ProcedureCode procCode in _listProcCodes)
            {
                listFees.Add(new Fee()
                {
                    FeeSched  = _standardFeeSchedNum,
                    CodeNum   = procCode.CodeNum,
                    Amount    = _defaultFeeAmt * _rand.NextDouble(),
                    ClinicNum = 0,
                    ProvNum   = 0
                });                 //create the default fee schedule fee
            }
            Fees.InsertMany(listFees);
        }
Example #29
0
        private static string gTreatArea(string componentSep, Procedure proc)
        {
            string        retVal   = "";
            ProcedureCode procCode = ProcedureCodes.GetProcCode(proc.CodeNum);

            if (procCode.TreatArea == TreatmentArea.ToothRange)
            {
                retVal = proc.ToothRange;
            }
            else if (procCode.TreatArea == TreatmentArea.Surf)           //probably not necessary
            {
                retVal = gConcat(componentSep, Tooth.ToInternat(proc.ToothNum), Tooth.SurfTidyForClaims(proc.Surf, proc.ToothNum));
            }
            else
            {
                retVal = gConcat(componentSep, Tooth.ToInternat(proc.ToothNum), proc.Surf);
            }
            return(retVal);
        }
        public void FeeSchedTools_GlobalUpdateWriteoffEstimates()
        {
            string        suffix   = MethodBase.GetCurrentMethod().Name;
            string        procStr  = "D0145";
            double        procFee  = 100;
            ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr);
            //Set up clinic, prov, pat
            Clinic  clinic      = ClinicT.CreateClinic(suffix);
            long    feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.FixedBenefit, suffix);
            long    provNum     = ProviderT.CreateProvider(suffix, feeSchedNum: feeSchedNum);
            Fee     fee         = FeeT.GetNewFee(feeSchedNum, procCode.CodeNum, procFee, clinic.ClinicNum, provNum);
            Patient pat         = PatientT.CreatePatient(suffix, provNum, clinic.ClinicNum);
            //Set up insurance
            InsuranceInfo  info         = InsuranceT.AddInsurance(pat, suffix, "c", feeSchedNum);
            List <InsSub>  listSubs     = info.ListInsSubs;
            List <InsPlan> listPlans    = info.ListInsPlans;
            List <PatPlan> listPatPlans = info.ListPatPlans;
            InsPlan        priPlan      = info.PriInsPlan;
            InsSub         priSub       = info.PriInsSub;

            info.ListBenefits.Add(BenefitT.CreatePercentForProc(priPlan.PlanNum, procCode.CodeNum, 90));
            //Create the procedure and claimproc
            Procedure proc         = ProcedureT.CreateProcedure(pat, procStr, ProcStat.TP, "", procFee);
            ClaimProc priClaimProc = ClaimProcT.CreateClaimProc(pat.PatNum, proc.ProcNum, priPlan.PlanNum, priSub.InsSubNum, DateTime.Today, -1, -1, -1,
                                                                ClaimProcStatus.CapEstimate);

            Procedures.ComputeEstimates(proc, pat.PatNum, new List <ClaimProc>(), true, listPlans, listPatPlans, info.ListBenefits, pat.Age, info.ListInsSubs);
            priClaimProc = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ProcNum == proc.ProcNum);
            Assert.AreEqual(procFee, priClaimProc.WriteOff);
            procFee = 50;
            Procedure procNew = proc.Copy();

            procNew.ProcFee = procFee;
            Procedures.Update(procNew, proc);
            //GlobalUpdate
            long updated = GlobalUpdateWriteoffs(clinic.ClinicNum);

            Assert.AreEqual(1, updated);
            ClaimProc priClaimProcDb = ClaimProcs.Refresh(pat.PatNum).FirstOrDefault(x => x.ClaimProcNum == priClaimProc.ClaimProcNum);

            Assert.AreEqual(procFee, priClaimProcDb.WriteOff);
        }