public void Fees_GetFee_Exact() { Fee expectedFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), true, true); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, expectedFee.ClinicNum, expectedFee.ProvNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void Fees_GetFee_PartialClinicNoProv() { Fee expectedFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), true, false); long provNum = ProviderT.CreateProvider(MethodBase.GetCurrentMethod().Name); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, expectedFee.ClinicNum, provNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void Fees_GetFee_PartialProvDefaultClinic() { Fee expectedFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), false, true); Clinic clinic = ClinicT.CreateClinic(MethodBase.GetCurrentMethod().Name); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, clinic.ClinicNum, expectedFee.ProvNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void Fees_GetFee_PartialNotFound() { string name = MethodBase.GetCurrentMethod().Name; Fee createdFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble()); Clinic clinic = ClinicT.CreateClinic(name); long provNum = ProviderT.CreateProvider(name); Assert.IsNull(Fees.GetFee(_listProcCodes.Last().CodeNum, createdFee.FeeSched, clinic.ClinicNum, provNum)); }
public void Fees_GetFee_PartialDefaultForCode() { string name = MethodBase.GetCurrentMethod().Name; Fee expectedFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble()); Clinic clinic = ClinicT.CreateClinic(name); long provNum = ProviderT.CreateProvider(name); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, clinic.ClinicNum, provNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void Fees_GetFee_GlobalFeeSched() { string name = MethodBase.GetCurrentMethod().Name; Fee expectedFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), false, false, isGlobalFeeSched: true); Fee otherFee1 = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), true, false, expectedFee.FeeSched, expectedFee.CodeNum); Fee otherFee2 = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), false, true, expectedFee.FeeSched, expectedFee.CodeNum); CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), true, true, expectedFee.FeeSched, expectedFee.CodeNum); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, otherFee1.ClinicNum, otherFee2.ProvNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void Fees_GetFee_ManyPossibleMatches() { string name = MethodBase.GetCurrentMethod().Name; Fee expectedFee = CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), true, true); CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), true, false, expectedFee.FeeSched, expectedFee.CodeNum, expectedFee.ClinicNum); CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), false, true, expectedFee.FeeSched, expectedFee.CodeNum, 0, expectedFee.ProvNum); CreateSingleFee(name, _defaultFeeAmt * _rand.NextDouble(), false, false, expectedFee.FeeSched, expectedFee.CodeNum); Fee actualFee = Fees.GetFee(expectedFee.CodeNum, expectedFee.FeeSched, expectedFee.ClinicNum, expectedFee.ProvNum); Assert.IsTrue(AreSimilar(expectedFee, actualFee)); }
public void FeeSchedTools_CopyFeeSched() { //Create two fee schedules; from and to FeeSched fromFeeSched = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_FROM"); FeeSched toFeeSched = FeeSchedT.GetNewFeeSched(FeeScheduleType.Normal, MethodBase.GetCurrentMethod().Name + "_TO"); //Create a single fee and associate it to the "from" fee schedule. long feeCodeNum = _listProcCodes[_rand.Next(_listProcCodes.Count - 1)].CodeNum; FeeT.CreateFee(fromFeeSched.FeeSchedNum, feeCodeNum, _defaultFeeAmt * _rand.NextDouble()); FeeScheds.CopyFeeSchedule(fromFeeSched, 0, 0, toFeeSched, null, 0); //Get the two fees and check that they are the same. Fee fromFee = Fees.GetFee(feeCodeNum, fromFeeSched.FeeSchedNum, 0, 0); Fee toFee = Fees.GetFee(feeCodeNum, toFeeSched.FeeSchedNum, 0, 0); Assert.AreEqual(fromFee.Amount, toFee.Amount); }
public void FeeSchedTools_ImportExport() { FeeTestArgs feeArgs = CreateManyFees(1, 1, 1, MethodBase.GetCurrentMethod().Name); long exportedSched = feeArgs.ListFeeSchedNums[0]; long importedSched = feeArgs.EmptyFeeSchedNum; long clinicNum = feeArgs.ListClinics[0].ClinicNum; string filename = MethodBase.GetCurrentMethod().Name; FeeScheds.ExportFeeSchedule(exportedSched, clinicNum, feeArgs.ListProvNums[0], filename); OpenDental.FeeL.ImportFees(filename, importedSched, clinicNum, feeArgs.ListProvNums[0]); foreach (ProcedureCode procCode in _listProcCodes.Where(x => !string.IsNullOrWhiteSpace(x.ProcCode))) //unable to import without a proccodes { Fee expected = Fees.GetFee(procCode.CodeNum, exportedSched, clinicNum, feeArgs.ListProvNums[0]); Fee actual = Fees.GetFee(procCode.CodeNum, importedSched, clinicNum, feeArgs.ListProvNums[0]); Assert.AreEqual(expected.Amount, actual.Amount); } }
///<summary>Primarily for fee import/copy. Returns true if we can retrieve all of the listActual fees from the db, and all of the fee amounts match those in the list.</summary> protected bool DoAmountsMatch(List <Fee> listActual, long feeSchedNum, long clinicNum, long provNum) { for (int i = 0; i < listActual.Count; i++) { Fee fee = listActual[i]; Fee originalFee = Fees.GetFee(fee.CodeNum, feeSchedNum, fee.ClinicNum, fee.ProvNum); try { if (originalFee.Amount != fee.Amount) { return(false); } } catch (Exception e) { throw new Exception("List check failed for fee at index :" + i + " with CodeNum=" + fee.CodeNum + " Inner:" + e.Message); } } return(true); }
public void Fees_GetFee_ClinicSpecificFees() { Patient pat = PatientT.CreatePatient("58"); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Standard UCR", false); long codeNum = ProcedureCodes.GetCodeNum("D2750"); long clinicNum2 = ClinicT.CreateClinic("2-58").ClinicNum; long clinicNum3 = ClinicT.CreateClinic("3-58").ClinicNum; long clinicNum1 = ClinicT.CreateClinic("1-58").ClinicNum; FeeT.CreateFee(feeSchedNum, codeNum, 65, clinicNum1, 0); FeeT.CreateFee(feeSchedNum, codeNum, 70, clinicNum2, 0); FeeT.CreateFee(feeSchedNum, codeNum, 75, clinicNum3, 0); double fee1 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, 0).Amount; double fee2 = Fees.GetFee(codeNum, feeSchedNum, clinicNum2, 0).Amount; double fee3 = Fees.GetFee(codeNum, feeSchedNum, clinicNum3, 0).Amount; Assert.AreEqual(fee1, 65); Assert.AreEqual(fee2, 70); Assert.AreEqual(fee3, 75); }
public void Fees_GetFee_ProviderSpecificFees() { Patient pat = PatientT.CreatePatient("57"); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "PPOInsPlan1", false); long codeNum = ProcedureCodes.GetCodeNum("D2750"); long provNum1 = ProviderT.CreateProvider("1-57"); long provNum2 = ProviderT.CreateProvider("2-57"); long provNum3 = ProviderT.CreateProvider("3-57"); FeeT.CreateFee(feeSchedNum, codeNum, 50, 0, provNum1); FeeT.CreateFee(feeSchedNum, codeNum, 55, 0, provNum2); FeeT.CreateFee(feeSchedNum, codeNum, 60, 0, provNum3); double fee1 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum1).Amount; double fee2 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum2).Amount; double fee3 = Fees.GetFee(codeNum, feeSchedNum, 0, provNum3).Amount; Assert.AreEqual(50, fee1); Assert.AreEqual(55, fee2); Assert.AreEqual(60, fee3); }
public void FeeSchedTools_Increase() { FeeTestArgs args = CreateManyFees(0, 0, 0, MethodBase.GetCurrentMethod().Name); int percent = 5; List <Fee> listStandardFees = Fees.GetListExact(_standardFeeSchedNum, 0, 0).OrderBy(x => x.FeeNum).ToList(); List <Fee> listIncreasedFees = listStandardFees.Select(x => x.Copy()).ToList(); listIncreasedFees = Fees.IncreaseNew(_standardFeeSchedNum, percent, 2, listIncreasedFees, 0, 0).OrderBy(x => x.FeeNum).ToList(); foreach (Fee fee in listIncreasedFees) { Fee expectedFee = Fees.GetFee(fee.CodeNum, fee.FeeSched, fee.ClinicNum, fee.ProvNum); double amount = fee.Amount / (1 + (double)percent / 100); amount = Math.Round(amount, 2); try { Assert.AreEqual(expectedFee.Amount, amount); } catch (Exception e) { throw new Exception("Failed for fee: " + expectedFee.FeeNum, e); } } }
public void Fees_GetFee_ClinicAndProviderSpecificFees() { Patient pat = PatientT.CreatePatient("59"); long feeSchedNum = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, "Standard", false); long codeNum = ProcedureCodes.GetCodeNum("D2750"); long provNum1 = ProviderT.CreateProvider("1-59"); long provNum2 = ProviderT.CreateProvider("2-59"); long clinicNum1 = ClinicT.CreateClinic("1-59").ClinicNum; long clinicNum2 = ClinicT.CreateClinic("2-59").ClinicNum; FeeT.CreateFee(feeSchedNum, codeNum, 80, clinicNum1, provNum1); FeeT.CreateFee(feeSchedNum, codeNum, 85, clinicNum1, provNum2); FeeT.CreateFee(feeSchedNum, codeNum, 90, clinicNum2, provNum2); double fee1 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, provNum1).Amount; double fee2 = Fees.GetFee(codeNum, feeSchedNum, clinicNum1, provNum2).Amount; double fee3 = Fees.GetFee(codeNum, feeSchedNum, clinicNum2, provNum2).Amount; Assert.AreEqual(fee1, 80); Assert.AreEqual(fee2, 85); Assert.AreEqual(fee3, 90); }
public void Fees_GetFee_ExactNotFound() { Fee createdFee = CreateSingleFee(MethodBase.GetCurrentMethod().Name, _defaultFeeAmt * _rand.NextDouble(), true, true); Assert.IsNull(Fees.GetFee(_listProcCodes.Last().CodeNum, createdFee.FeeSched, createdFee.ClinicNum, createdFee.ProvNum)); }
public void Claims_CalculateAndUpdate_Allowed1Allowed2CompletedProcedures() { string suffix = "8"; Patient pat = PatientT.CreatePatient(suffix); long patNum = pat.PatNum; long feeSchedNum1 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix); long feeSchedNum2 = FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, suffix + "b"); //Standard Fee long codeNum = ProcedureCodes.GetCodeNum("D2750"); Fee fee = Fees.GetFee(codeNum, 53, 0, 0); if (fee == null) { fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = 53; fee.Amount = 1200; Fees.Insert(fee); } else { fee.Amount = 1200; Fees.Update(fee); } //PPO fees fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = feeSchedNum1; fee.Amount = 600; Fees.Insert(fee); fee = new Fee(); fee.CodeNum = codeNum; fee.FeeSched = feeSchedNum2; fee.Amount = 800; Fees.Insert(fee); //Carrier Carrier carrier = CarrierT.CreateCarrier(suffix); long planNum1 = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum1).PlanNum; long planNum2 = InsPlanT.CreateInsPlanPPO(carrier.CarrierNum, feeSchedNum2).PlanNum; InsSub sub1 = InsSubT.CreateInsSub(pat.PatNum, planNum1); long subNum1 = sub1.InsSubNum; InsSub sub2 = InsSubT.CreateInsSub(pat.PatNum, planNum2); long subNum2 = sub2.InsSubNum; BenefitT.CreateCategoryPercent(planNum1, EbenefitCategory.Crowns, 50); BenefitT.CreateCategoryPercent(planNum2, EbenefitCategory.Crowns, 50); BenefitT.CreateAnnualMax(planNum1, 1000); BenefitT.CreateAnnualMax(planNum2, 1000); PatPlanT.CreatePatPlan(1, patNum, subNum1); PatPlanT.CreatePatPlan(2, patNum, subNum2); Procedure proc = ProcedureT.CreateProcedure(pat, "D2750", ProcStat.TP, "8", Fees.GetAmount0(codeNum, 53)); //crown on 8 long procNum = proc.ProcNum; //Lists List <ClaimProc> claimProcs = ClaimProcs.Refresh(patNum); Family fam = Patients.GetFamily(patNum); List <InsSub> subList = InsSubs.RefreshForFam(fam); List <InsPlan> planList = InsPlans.RefreshForSubList(subList); List <PatPlan> patPlans = PatPlans.Refresh(patNum); List <Benefit> benefitList = Benefits.Refresh(patPlans, subList); List <Procedure> procList = Procedures.Refresh(patNum); //Set complete and attach to claim ProcedureT.SetComplete(proc, pat, planList, patPlans, claimProcs, benefitList, subList); claimProcs = ClaimProcs.Refresh(patNum); List <Procedure> procsForClaim = new List <Procedure>(); procsForClaim.Add(proc); Claim claim = ClaimT.CreateClaim("P", patPlans, planList, claimProcs, procList, pat, procsForClaim, benefitList, subList); //Validate Assert.AreEqual(500, claim.WriteOff); }
public void Procedures_GlobalUpdateFees() { string name = MethodBase.GetCurrentMethod().Name; Random rand = new Random(); //set up fees List <Clinic> listClinics = new List <Clinic>(); for (int i = 0; i < 3; i++) { listClinics.Add(ClinicT.CreateClinic(name + "_" + i)); } List <long> listFeeSchedNums = new List <long>(); for (int i = 0; i < 2; i++) { listFeeSchedNums.Add(FeeSchedT.CreateFeeSched(FeeScheduleType.Normal, name + "_" + i, false)); } List <long> listProvNums = new List <long>(); for (int i = 0; i < 2; i++) { long feeSched = listFeeSchedNums[rand.Next(listFeeSchedNums.Count - 1)]; listProvNums.Add(ProviderT.CreateProvider(name + "_" + i, feeSchedNum: feeSched)); } List <ProcedureCode> listProcCodes = ProcedureCodes.GetAllCodes(); List <Fee> listFees = new List <Fee>(); foreach (ProcedureCode procCode in listProcCodes) { foreach (long feeSched in listFeeSchedNums) { foreach (Clinic clinic in listClinics) { foreach (long provNum in listProvNums) { listFees.Add(FeeT.GetNewFee(feeSched, procCode.CodeNum, 50 * rand.NextDouble(), clinic.ClinicNum, provNum)); } } } } //set up patients List <Patient> listPatients = new List <Patient>(); for (int i = 0; i < 3; i++) { listPatients.Add(PatientT.CreatePatient(name + "_" + i, listProvNums[rand.Next(listProvNums.Count - 1)], listClinics[rand.Next(listClinics.Count - 1)].ClinicNum)); } //TP some procedures List <Fee> listTPFees = new List <Fee>(); for (int i = 0; i < 100; i++) { ProcedureCode procCode = listProcCodes[rand.Next(listProcCodes.Count - 1)]; Patient patient = listPatients[rand.Next(listPatients.Count - 1)]; Fee fee = Fees.GetFee(procCode.CodeNum, Providers.GetProv(patient.PriProv).FeeSched, patient.ClinicNum, patient.PriProv); Procedure proc = ProcedureT.CreateProcedure(patient, procCode.ProcCode, ProcStat.TP, "", fee.Amount); listTPFees.Add(fee); } //change some of the fees List <Fee> listTPFeesChanged = listTPFees.OrderBy(x => rand.Next()).Take(50).ToList(); List <Fee> listNonTPFeesChanged = (listFees.Except(listTPFees)).OrderBy(x => rand.Next()).Take(50).ToList(); FeeCache cache = new FeeCache(listTPFeesChanged.Union(listNonTPFeesChanged).ToList()); cache.BeginTransaction(); foreach (Fee fee in listTPFeesChanged) { fee.Amount = 50 * rand.NextDouble(); cache.Update(fee); } foreach (Fee fee in listNonTPFeesChanged) { fee.Amount = 50 * rand.NextDouble(); cache.Update(fee); } cache.SaveToDb(); //Run the global update long updatedCount = 0; cache = new FeeCache(); for (int i = 0; i < listClinics.Count; i++) { updatedCount += Procedures.GlobalUpdateFees(cache.GetFeesForClinics(listClinics.Select(x => x.ClinicNum)), listClinics[i].ClinicNum, listClinics[i].Abbr); } //check the counts are the same List <Fee> listToCount = listTPFees.Where(x => listTPFeesChanged.Select(y => y.FeeNum).Contains(x.FeeNum)).ToList(); Assert.AreEqual(listToCount.Count, updatedCount); }