/// <summary>Search predicate returns true if code matches.</summary> private bool EB03MatchesCode(EB03 eb03val) { if (Segment.Get(3) == eb03val.Code) { return(true); } return(false); }
/// <summary>Search predicate returns true if code matches.</summary> private bool EB03MatchesCode(EB03 eb03val) { if(Segment.Get(3)==eb03val.Code) { return true; } return false; }
public EB271(X12Segment segment, bool isInNetwork, bool isCoinsuranceInverted, X12Segment segHsd = null) { if (eb01 == null) { FillDictionaries(); } Segment = segment; SupplementalSegments = new List <X12Segment>(); //start pattern matching to generate closest Benefit EB01 eb01val = eb01.Find(EB01MatchesCode); EB02 eb02val = eb02.Find(EB02MatchesCode); EB03 eb03val = eb03.Find(EB03MatchesCode); EB06 eb06val = eb06.Find(EB06MatchesCode); EB09 eb09val = eb09.Find(EB09MatchesCode); ProcedureCode proccode = null; if (ProcedureCodes.IsValidCode(Segment.Get(13, 2))) { proccode = ProcedureCodes.GetProcCode(Segment.Get(13, 2)); } if (!eb01val.IsSupported || (eb02val != null && !eb02val.IsSupported) || (eb03val != null && !eb03val.IsSupported) || (eb06val != null && !eb06val.IsSupported) || (eb09val != null && !eb09val.IsSupported)) { Benefitt = null; return; } if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && Segment.Get(3) == "30") { Benefitt = null; return; } if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && proccode != null) { //A code is covered. Informational only. Benefitt = null; return; } if (Segment.Get(8) != "") //if percentage //must have either a category or a proc code { if (proccode == null) //if no proc code is specified { if (eb03val == null || eb03val.ServiceType == EbenefitCategory.None || eb03val.ServiceType == EbenefitCategory.General) //and no category specified { Benefitt = null; return; } } } //coinsurance amounts are handled with fee schedules rather than benefits if (eb01val.BenefitType == InsBenefitType.CoPayment || eb01val.BenefitType == InsBenefitType.CoInsurance) { if (Segment.Get(7) != "") //and a monetary amount specified { Benefitt = null; return; } } //a limitation without an amount is meaningless if (eb01val.BenefitType == InsBenefitType.Limitations && segHsd == null) //Some benefits do not have monetary value but limit service in a time period. Originally done for customer 27936. { if (Segment.Get(7) == "") //no monetary amount specified { Benefitt = null; return; } } if (isInNetwork && (Segment.Get(12) == "N" || Segment.Get(12) == "U")) { Benefitt = null; return; } if (!isInNetwork && Segment.Get(12) == "Y") { Benefitt = null; return; } //if only a quantity is specified with no qualifier, it's meaningless if (Segment.Get(10) != "" && eb09val == null) { Benefitt = null; return; } //if only a qualifier is specified with no quantity, it's meaningless if (eb09val != null && Segment.Get(10) == "") { Benefitt = null; return; } Benefitt = new Benefit(); //1 Benefitt.BenefitType = eb01val.BenefitType; //2 if (eb02val != null) { Benefitt.CoverageLevel = eb02val.CoverageLevel; } //3 if (eb03val != null) { Benefitt.CovCatNum = CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum; } //4-Insurance type - we ignore. //5-Plan description - we ignore. //6 if (eb06val != null) { Benefitt.TimePeriod = eb06val.TimePeriod; } //7 if (Segment.Get(7) != "") { Benefitt.MonetaryAmt = PIn.Double(Segment.Get(7)); //Monetary amount. Situational } //8 if (Segment.Get(8) != "") { if (isCoinsuranceInverted && Benefitt.BenefitType == InsBenefitType.CoInsurance) //Some carriers incorrectly send insurance percentage. { Benefitt.Percent = (int)(PIn.Double(Segment.Get(8)) * 100); //Percent. Came to us inverted, do Not Invert. } else { //OD shows the percentage paid by Insurance by default. //Some carriers submit 271s to us showing percentage paid by Patient, so we need to invert this case to match OD expectations. Benefitt.Percent = 100 - (int)(PIn.Double(Segment.Get(8)) * 100); //Percent. Invert. } Benefitt.CoverageLevel = BenefitCoverageLevel.None; } //9-Quantity qualifier if (eb09val != null) { Benefitt.QuantityQualifier = eb09val.QuantityQualifier; } //10-Quantity if (Segment.Get(10) != "") { Benefitt.Quantity = (byte)PIn.Double(Segment.Get(10)); //Example: "19.0" with Quantity qualifier "S7" (age). } //11-Authorization. Ignored. //12-In network. Ignored. //13-proc if (proccode != null) { Benefitt.CodeNum = proccode.CodeNum; //element 13,2 } if (Benefitt.BenefitType == InsBenefitType.Limitations && proccode != null && //Valid ADA code. segHsd != null) { if (segHsd.Elements.Length < 6 || segHsd.Elements[2] == "" || segHsd.Elements[5] == "") { Benefitt = null; return; } Benefitt.Quantity = PIn.Byte(segHsd.Elements[2]); //HSD02: Quantity. Benefitt.TimePeriod = eb06.FirstOrDefault(x => x.Code == segHsd.Elements[5]).TimePeriod; //HSD05: Frequency. } }
///<summary>The most human-readable description possible for a single element.</summary> public string GetDescript(int elementPos, bool isMessageMode, bool isCoinsurancePatPays = true) { string elementCode = Segment.Get(elementPos); if (elementCode == "") { return(""); } switch (elementPos) { case 1: //This is a required element, but we still won't assume it's found EB01 eb01val = eb01.Find(EB01MatchesCode); if (eb01val == null) { return(""); } if (eb01val.Code == "D" && isMessageMode) //D is for benefit description, which is already obvious { return(""); } return(eb01val.Descript); case 2: EB02 eb02val = eb02.Find(EB02MatchesCode); if (eb02val == null) { return(""); } return(eb02val.Descript); case 3: EB03 eb03val = eb03.Find(EB03MatchesCode); if (eb03val == null) { return(""); } return(eb03val.Descript); case 4: if (!EB04.ContainsKey(elementCode)) { return(""); } return(EB04[elementCode]); case 5: return(Segment.Get(5)); case 6: EB06 eb06val = eb06.Find(EB06MatchesCode); if (eb06val == null) { return(""); } return(eb06val.Descript); case 7: return(PIn.Double(elementCode).ToString("c")); //Monetary amount. Situational case 8: if (isMessageMode) //delta sends 80% instead of 20% like they should { return((PIn.Double(elementCode) * 100).ToString() + "%"); //Percent. } else { string leadingStr = "Patient pays "; if (!isCoinsurancePatPays) { leadingStr = "Insurance pays "; } return(leadingStr + (PIn.Double(elementCode) * 100).ToString() + "%"); //Percent. Situational } case 9: //Quantity qualifier. Situational EB09 eb09val = eb09.Find(EB09MatchesCode); if (eb09val == null) { return(""); } return(eb09val.Descript); case 10: return(elementCode); //Quantity. Situational case 11: return("Authorization Required-" + elementCode); //Situational. case 12: //Situational. if (elementCode == "Y") { return("In network"); } else if (elementCode == "N") { return("Out of network"); } else //elementCode=="U" { return("Unknown if in network"); } case 13: string procStr = Segment.Get(13, 2); if (procStr == "") { return(""); } ProcedureCode procCode = ProcedureCodes.GetProcCode(procStr); return(procStr + " - " + procCode.AbbrDesc); //ProcedureCodes.GetLaymanTerm(procCode.CodeNum); //Even though we don't make requests about specific procedure codes, some ins co's will send back codes. default: return(""); } }
public EB271(X12Segment segment, bool isInNetwork) { if (eb01 == null) { FillDictionaries(); } Segment = segment; SupplementalSegments = new List <X12Segment>(); //start pattern matching to generate closest Benefit EB01 eb01val = eb01.Find(EB01MatchesCode); EB02 eb02val = eb02.Find(EB02MatchesCode); EB03 eb03val = eb03.Find(EB03MatchesCode); EB06 eb06val = eb06.Find(EB06MatchesCode); EB09 eb09val = eb09.Find(EB09MatchesCode); ProcedureCode proccode = null; if (ProcedureCodes.IsValidCode(Segment.Get(13, 2))) { proccode = ProcedureCodes.GetProcCode(Segment.Get(13, 2)); } if (!eb01val.IsSupported || (eb02val != null && !eb02val.IsSupported) || (eb03val != null && !eb03val.IsSupported) || (eb06val != null && !eb06val.IsSupported) || (eb09val != null && !eb09val.IsSupported)) { Benefitt = null; return; } if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && Segment.Get(3) == "30") { Benefitt = null; return; } if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && proccode != null) { //A code is covered. Informational only. Benefitt = null; return; } if (Segment.Get(8) != "") //if percentage //must have either a category or a proc code { if (proccode == null) //if no proc code is specified { if (eb03val == null || eb03val.ServiceType == EbenefitCategory.None || eb03val.ServiceType == EbenefitCategory.General) //and no category specified { Benefitt = null; return; } } } //coinsurance amounts are handled with fee schedules rather than benefits if (eb01val.BenefitType == InsBenefitType.CoPayment || eb01val.BenefitType == InsBenefitType.CoInsurance) { if (Segment.Get(7) != "") //and a monetary amount specified { Benefitt = null; return; } } //a limitation without an amount is meaningless if (eb01val.BenefitType == InsBenefitType.Limitations) { if (Segment.Get(7) == "") //no monetary amount specified { Benefitt = null; return; } } if (isInNetwork && Segment.Get(12) == "N") { Benefitt = null; return; } if (!isInNetwork && Segment.Get(12) == "Y") { Benefitt = null; return; } //if only a quantity is specified with no qualifier, it's meaningless if (Segment.Get(10) != "" && eb09val == null) { Benefitt = null; return; } //if only a qualifier is specified with no quantity, it's meaningless if (eb09val != null && Segment.Get(10) == "") { Benefitt = null; return; } Benefitt = new Benefit(); //1 Benefitt.BenefitType = eb01val.BenefitType; //2 if (eb02val != null) { Benefitt.CoverageLevel = eb02val.CoverageLevel; } //3 if (eb03val != null) { Benefitt.CovCatNum = CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum; } //4-Insurance type - we ignore. //5-Plan description - we ignore. //6 if (eb06val != null) { Benefitt.TimePeriod = eb06val.TimePeriod; } //7 if (Segment.Get(7) != "") { Benefitt.MonetaryAmt = PIn.Double(Segment.Get(7)); //Monetary amount. Situational } //8 if (Segment.Get(8) != "") { Benefitt.Percent = 100 - (int)(PIn.Double(Segment.Get(8)) * 100); //Percent. Situational Benefitt.CoverageLevel = BenefitCoverageLevel.None; } //9-Quantity qualifier if (eb09val != null) { Benefitt.QuantityQualifier = eb09val.QuantityQualifier; } //10-Quantity if (Segment.Get(10) != "") { Benefitt.Quantity = (byte)PIn.Double(Segment.Get(10)); //Example: "19.0" with Quantity qualifier "S7" (age). } //11-Authorization. Ignored. //12-In network. Ignored. //13-proc if (proccode != null) { Benefitt.CodeNum = proccode.CodeNum; //element 13,2 } }