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); }
/// <summary>claimType="P" or "S".</summary> public static Claim CreateClaim(string claimType, List <PatPlan> PatPlanList, List <InsPlan> InsPlanList, List <ClaimProc> ClaimProcList, List <Procedure> procsForPat, Patient pat, List <Procedure> procsForClaim, List <Benefit> benefitList, List <InsSub> SubList) { //Claim ClaimCur=CreateClaim("P",PatPlanList,InsPlanList,ClaimProcList,procsForPat); long claimFormNum = 0; EtransType eFormat = 0; InsPlan PlanCur1 = new InsPlan(); InsSub SubCur1 = new InsSub(); InsPlan PlanCur2 = new InsPlan(); InsSub SubCur2 = new InsSub(); Relat relatOther = Relat.Self; switch (claimType) { case "P": SubCur1 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList); PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList); SubCur2 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList); //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null break; case "S": SubCur1 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 2), SubList); PlanCur1 = InsPlans.GetPlan(SubCur1.PlanNum, InsPlanList); SubCur2 = InsSubs.GetSub(PatPlans.GetInsSubNum(PatPlanList, 1), SubList); //PlanCur2=InsPlans.GetPlan(SubCur.PlanNum,InsPlanList);//can end up null break; } //DataTable table=DataSetMain.Tables["account"]; Procedure proc; //proc=Procedures.GetProcFromList(procsForPat,PIn.Long(table.Rows[gridAccount.SelectedIndices[0]]["ProcNum"].ToString())); //long clinicNum=proc.ClinicNum; ClaimProc[] claimProcs = new ClaimProc[procsForClaim.Count]; //1:1 with procs long procNum; for (int i = 0; i < procsForClaim.Count; i++) //loop through selected procs //and try to find an estimate that can be used { procNum = procsForClaim[i].ProcNum; claimProcs[i] = Procedures.GetClaimProcEstimate(procNum, ClaimProcList, PlanCur1, SubCur1.InsSubNum); } for (int i = 0; i < claimProcs.Length; i++) //loop through each claimProc //and create any missing estimates. This handles claims to 3rd and 4th ins co's. { if (claimProcs[i] == null) { claimProcs[i] = new ClaimProc(); proc = procsForClaim[i]; ClaimProcs.CreateEst(claimProcs[i], proc, PlanCur1, SubCur1); } } Claim claim = new Claim(); Claims.Insert(claim); //to retreive a key for new Claim.ClaimNum claim.PatNum = pat.PatNum; claim.DateService = claimProcs[claimProcs.Length - 1].ProcDate; claim.ClinicNum = procsForClaim[0].ClinicNum; claim.DateSent = DateTime.Today; claim.ClaimStatus = "S"; //datereceived switch (claimType) { case "P": claim.PlanNum = SubCur1.PlanNum; claim.InsSubNum = PatPlans.GetInsSubNum(PatPlanList, 1); claim.PatRelat = PatPlans.GetRelat(PatPlanList, 1); claim.ClaimType = "P"; claim.PlanNum2 = SubCur2.PlanNum; //might be 0 if no sec ins claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 2); claim.PatRelat2 = PatPlans.GetRelat(PatPlanList, 2); break; case "S": claim.PlanNum = SubCur1.PlanNum; claim.InsSubNum = PatPlans.GetInsSubNum(PatPlanList, 2); claim.PatRelat = PatPlans.GetRelat(PatPlanList, 2); claim.ClaimType = "S"; claim.PlanNum2 = SubCur2.PlanNum; claim.InsSubNum2 = PatPlans.GetInsSubNum(PatPlanList, 1); claim.PatRelat2 = PatPlans.GetRelat(PatPlanList, 1); break; } claim.ProvTreat = procsForClaim[0].ProvNum; claim.IsProsthesis = "I"; claim.ProvBill = Providers.GetBillingProvNum(claim.ProvTreat, claim.ClinicNum); claim.EmployRelated = YN.No; //attach procedures Procedure ProcCur; for (int i = 0; i < claimProcs.Length; i++) { ProcCur = procsForClaim[i]; claimProcs[i].ClaimNum = claim.ClaimNum; claimProcs[i].Status = ClaimProcStatus.NotReceived; //status for claims unsent or sent. //writeoff handled in ClaimL.CalculateAndUpdate() claimProcs[i].CodeSent = ProcedureCodes.GetProcCode(ProcCur.CodeNum).ProcCode; if (claimProcs[i].CodeSent.Length > 5 && claimProcs[i].CodeSent.Substring(0, 1) == "D") { claimProcs[i].CodeSent = claimProcs[i].CodeSent.Substring(0, 5); } claimProcs[i].LineNumber = (byte)(i + 1); ClaimProcs.Update(claimProcs[i]); } ClaimProcList = ClaimProcs.Refresh(pat.PatNum); ClaimL.CalculateAndUpdate(procsForPat, InsPlanList, claim, PatPlanList, benefitList, pat.Age, SubList); return(claim); }