///<summary>Takes raw text and converts it into an X12Object.</summary> public X12object(string messageText){ messageText=messageText.Replace("\r",""); messageText=messageText.Replace("\n",""); if(messageText.Substring(0,3)!="ISA"){ throw new ApplicationException("ISA not found"); } Separators=new X12Separators(); Separators.Element=messageText.Substring(3,1); Separators.Subelement=messageText.Substring(104,1); Separators.Segment=messageText.Substring(105,1); string[] messageRows=messageText.Split(new string[] {Separators.Segment},StringSplitOptions.None); FunctGroups=new List<X12FunctionalGroup>(); Segments=new List<X12Segment>(); string row; X12Segment segment; for(int i=1;i<messageRows.Length;i++){ row=messageRows[i]; segment=new X12Segment(row,Separators); Segments.Add(segment); if(messageRows[i]=="") { //do nothing } else if(segment.SegmentID=="IEA") {//if end of interchange //do nothing } else if(segment.SegmentID=="GS") {//if new functional group FunctGroups.Add(new X12FunctionalGroup(segment)); } else if(segment.SegmentID=="GE") {//if end of functional group //do nothing } else if(segment.SegmentID=="ST") {//if new transaction set if(LastGroup().Transactions==null) { LastGroup().Transactions=new List<X12Transaction>(); } LastGroup().Transactions.Add(new X12Transaction(segment)); } else if(segment.SegmentID=="SE") {//if end of transaction //do nothing } else if(segment.SegmentID=="TA1") {//This segment can either replace or supplement any GS segments for any ack type (997,999,277). The TA1 will always be before the first GS segment. //Ignore for now. We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105. //This segment is neither mandated or prohibited (see 277.pdf pg. 207). } else {//it must be a detail segment within a transaction. if(LastTransaction().Segments==null) { LastTransaction().Segments=new List<X12Segment>(); } LastTransaction().Segments.Add(segment); } //row=sr.ReadLine(); } }
public X835(string messageText):base(messageText) { segments=FunctGroups[0].Transactions[0].Segments;//The GS segment contains exactly one ST segment below it. segBPR=segments[0];//Always present, because required. segTRN=segments[1];//Always present, because required. segNumsCLP=new List<int>(); segNumsSVC=new List<List<int>>(); List<int> segNumsSVC_cur=new List<int>(); for(int i=0;i<segments.Count;i++) { X12Segment seg=segments[i]; if(seg.SegmentID=="N1" && seg.Get(1)=="PR") { segN1_PR=seg; segN3_PR=segments[i+1]; segN4_PR=segments[i+2]; } else if(seg.SegmentID=="PER" && seg.Get(1)=="BL") { if(segPER_BL==null) {//This segment can repeat. We only care about the first occurrence. segPER_BL=seg; } } else if(seg.SegmentID=="N1" && seg.Get(1)=="PE") { segN1_PE=seg; } else if(seg.SegmentID=="CLP") { //The CLP segment only exists is within the 2100 loop. segNumsCLP.Add(i); segNumsSVC.Add(segNumsSVC_cur); segNumsSVC_cur=new List<int>();//Start a new list of procedures. } else if(seg.SegmentID=="SVC") { //The SVC segment only exists is within the 2100 loop. segNumsSVC_cur.Add(i); } else if(seg.SegmentID=="PLB") { segNumsPLB.Add(i); } } segNumsSVC.Add(segNumsSVC_cur); }
///<summary>Will return "" if unable to determine. But would normally return A=Accepted or R=Rejected or P=Partially accepted if only some of the transactions were accepted.</summary> public string GetBatchAckCode() { if (this.FunctGroups[0].Transactions.Count != 1) { return(""); } X12Segment seg = FunctGroups[0].Transactions[0].GetSegmentByID("AK9"); if (seg == null) { return(""); } string code = seg.Get(1); if (code == "A" || code == "E") //Accepted or accepted with Errors. { return("A"); } if (code == "P") //Partially accepted { return("P"); } return("R"); //rejected }
///<summary>Result will contain strings in the following order: 0 Patient Last Name (NM103), 1 Patient First Name (NM104), 2 Patient Middle Name (NM105), ///3 Claim Status (STC03), 4 Payor's Claim Control Number (REF02), 5 Institutional Type of Bill (REF02), 6 Claim Date Service Start (DTP03), ///7 Claim Date Service End (DTP03), 8 Reason (STC01-2), 9 Amount (STC04)</summary> public string[] GetClaimInfo(string trackingNumber) { string[] result = new string[10]; for (int i = 0; i < result.Length; i++) { result[i] = ""; } for (int i = 0; i < segNumsClaimTrackingNumberTRN.Count; i++) { int segNum = segNumsClaimTrackingNumberTRN[i]; X12Segment seg = segments[segNum]; //TRN segment. if (seg.Get(2) == trackingNumber) //TRN02 //Locate the NM1 segment corresponding to the claim tracking number. One NM1 segment can be shared with multiple TRN segments. //The strategy is to locate the NM1 segment furthest down in the message that is above the TRN segment for the tracking number. { int segNumNM1 = segNumsPatientDetailNM1[segNumsPatientDetailNM1.Count - 1]; //very last NM1 segment for (int j = 0; j < segNumsPatientDetailNM1.Count - 1; j++) { if (segNum > segNumsPatientDetailNM1[j] && segNum < segNumsPatientDetailNM1[j + 1]) { segNumNM1 = segNumsPatientDetailNM1[j]; break; } } seg = segments[segNumNM1]; //NM1 segment. result[0] = seg.Get(3); //NM103 Last Name result[1] = seg.Get(4); //NM104 First Name result[2] = seg.Get(5); //NM105 Middle Name segNum++; seg = segments[segNum]; //STC segment. At least one, maybe multiple, but we only care about the first one. string[] stc01 = seg.Get(1).Split(new string[] { Separators.Subelement }, StringSplitOptions.None); result[3] = GetStringForExternalSourceCode507(stc01[0]); if (stc01.Length > 1) { result[8] = GetStringForExternalSourceCode508(stc01[1]); //STC01-2 } result[9] = seg.Get(4); //Skip the remaining STC segments (if any). segNum++; if (segNum >= segments.Count) { return(result); //End of file } seg = segments[segNum]; while (seg.SegmentID == "STC") { segNum++; seg = segments[segNum]; } while (seg.SegmentID == "REF") { string refIdQualifier = seg.Get(1); if (refIdQualifier == "1K") { result[4] = seg.Get(2); //REF02 Payor's Claim Control Number. } else if (refIdQualifier == "D9") { //REF02 Claim Identifier Number for Clearinghouse and Other Transmission Intermediary from the 837. //When we send this it is the same as the claim identifier/claim tracking number, so we don't use this for now. } else if (refIdQualifier == "BLT") { //REF02 Institutional Type of Bill that was sent in the 837. result[5] = seg.Get(2); } segNum++; if (segNum >= segments.Count) { return(result); //End of file } seg = segments[segNum]; } //The DTP segment for the date of service will not be present when an invalid date was originally sent to the carrier (even though the specifications have it marked as a required segment). if (seg.SegmentID == "DTP") { string dateServiceStr = seg.Get(3); int dateServiceStartYear = PIn.Int(dateServiceStr.Substring(0, 4)); int dateServiceStartMonth = PIn.Int(dateServiceStr.Substring(4, 2)); int dateServiceStartDay = PIn.Int(dateServiceStr.Substring(6, 2)); result[6] = (new DateTime(dateServiceStartYear, dateServiceStartMonth, dateServiceStartDay)).ToShortDateString(); if (dateServiceStr.Length == 17) //Date range. { int dateServiceEndYear = PIn.Int(dateServiceStr.Substring(9, 4)); int dateServiceEndMonth = PIn.Int(dateServiceStr.Substring(13, 2)); int dateServiceEndDay = PIn.Int(dateServiceStr.Substring(15, 2)); result[7] = (new DateTime(dateServiceEndYear, dateServiceEndMonth, dateServiceEndDay)).ToShortDateString(); } } } } return(result); }
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 } }
public X277(string messageText) : base(messageText) { segments = FunctGroups[0].Transactions[0].Segments; //The GS segment contains exactly one ST segment below it. segNumInfoSourceNM101 = -1; segNumInfoReceiverNM101 = -1; segNumsBillingProviderNM1 = new List <int>(); segNumsPatientDetailNM1 = new List <int>(); segNumsClaimTrackingNumberTRN = new List <int>(); for (int i = 0; i < segments.Count; i++) { X12Segment seg = segments[i]; if (seg.SegmentID == "NM1") { string entityIdentifierCode = seg.Get(1); if (entityIdentifierCode == "AY" || entityIdentifierCode == "PR") { segNumInfoSourceNM101 = i; i += 4; } else if (entityIdentifierCode == "41") { segNumInfoReceiverNM101 = i; i += 3; seg = segments[i]; while (seg.SegmentID == "STC") { i++; seg = segments[i]; } i += 4; } else if (entityIdentifierCode == "85") { segNumsBillingProviderNM1.Add(i); } else if (entityIdentifierCode == "QC") { segNumsPatientDetailNM1.Add(i); //Loop 2200D: There can be multiple TRN segments for each NM1*QC. do { i++; segNumsClaimTrackingNumberTRN.Add(i); //a TRN segment is required at this location. i++; seg = segments[i]; //at least one STC segment is required at this location. while (seg.SegmentID == "STC") //there may be multiple STC segments. { i++; if (i >= segments.Count) { return; //End of file } seg = segments[i]; } //Followed by 0 to 3 situational REF segments. for (int j = 0; j < 3 && (seg.SegmentID == "REF"); j++) { i++; if (i >= segments.Count) { return; //End of file } seg = segments[i]; } //Followed by 0 or 1 DTP segments. if (seg.SegmentID == "DTP") { i++; if (i >= segments.Count) { return; //End of file } seg = segments[i]; } //An entire iteration of loop 2200D is now finished. If another iteration is present, it will begin with a TRN segment. } while(seg.SegmentID == "TRN"); } } } }
///<summary>Takes raw text and converts it into an X12Object.</summary> public X12object(string messageText) { messageText = messageText.Replace("\r", ""); messageText = messageText.Replace("\n", ""); if (messageText.Substring(0, 3) != "ISA") { throw new ApplicationException("ISA not found"); } Separators = new X12Separators(); Separators.Element = messageText.Substring(3, 1); Separators.Subelement = messageText.Substring(104, 1); Separators.Segment = messageText.Substring(105, 1); string[] messageRows = messageText.Split(new string[] { Separators.Segment }, StringSplitOptions.None); FunctGroups = new List <X12FunctionalGroup>(); Segments = new List <X12Segment>(); string row; X12Segment segment; for (int i = 1; i < messageRows.Length; i++) { row = messageRows[i]; segment = new X12Segment(row, Separators); Segments.Add(segment); if (messageRows[i] == "") { //do nothing } else if (segment.SegmentID == "IEA") //if end of interchange //do nothing { } else if (segment.SegmentID == "GS") //if new functional group { FunctGroups.Add(new X12FunctionalGroup(segment)); } else if (segment.SegmentID == "GE") //if end of functional group //do nothing { } else if (segment.SegmentID == "ST") //if new transaction set { if (LastGroup().Transactions == null) { LastGroup().Transactions = new List <X12Transaction>(); } LastGroup().Transactions.Add(new X12Transaction(segment)); } else if (segment.SegmentID == "SE") //if end of transaction //do nothing { } else if (segment.SegmentID == "TA1") //This segment can either replace or supplement any GS segments for any ack type (997,999,277). The TA1 will always be before the first GS segment. //Ignore for now. We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105. //This segment is neither mandated or prohibited (see 277.pdf pg. 207). { } else //it must be a detail segment within a transaction. { if (LastTransaction().Segments == null) { LastTransaction().Segments = new List <X12Segment>(); } LastTransaction().Segments.Add(segment); } //row=sr.ReadLine(); } }
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>Returns a copy of this segement</summary> public X12Segment Copy(){ X12Segment retVal=new X12Segment(); retVal.SegmentID=SegmentID; retVal.Elements=(string[])Elements.Clone();//shallow copy is fine since just strings. return retVal; }
///<summary>Supply the functional group header(GS) when creating this object.</summary> public X12FunctionalGroup(X12Segment header) { Header = header.Copy(); }
///<summary>Takes raw text and converts it into an X12Object.</summary> public X12object(string messageText) { messageText = messageText.Replace("\r", ""); messageText = messageText.Replace("\n", ""); if (messageText.Substring(0, 3) != "ISA") { throw new ApplicationException("ISA not found"); } Separators = new X12Separators(); Separators.Element = messageText.Substring(3, 1); Separators.Subelement = messageText.Substring(104, 1); Separators.Segment = messageText.Substring(105, 1); string[] arrayRawSegments = messageText.Split(new string[] { Separators.Segment }, StringSplitOptions.None); FunctGroups = new List <X12FunctionalGroup>(); Segments = new List <X12Segment>(); X12Segment segment; for (int i = 0; i < arrayRawSegments.Length; i++) { segment = new X12Segment(arrayRawSegments[i], Separators); segment.SegmentIndex = i; Segments.Add(segment); if (arrayRawSegments[i] == "") { //do nothing } else if (segment.SegmentID == "ISA") //interchange control header begin //do not add to list of segments { try { DateInterchange = DateTime.ParseExact(segment.Get(9) + segment.Get(10), "yyMMddHHmm", CultureInfo.CurrentCulture.DateTimeFormat); } catch (Exception ex) { ex.DoNothing(); DateInterchange = DateTime.MinValue; } } else if (segment.SegmentID == "IEA") //interchange control header end //do nothing { } else if (segment.SegmentID == "GS") //if new functional group { FunctGroups.Add(new X12FunctionalGroup(segment)); } else if (segment.SegmentID == "GE") //if end of functional group //do nothing { } else if (segment.SegmentID == "ST") //if new transaction set { if (LastGroup().Transactions == null) { LastGroup().Transactions = new List <X12Transaction>(); } LastGroup().Transactions.Add(new X12Transaction(segment)); } else if (segment.SegmentID == "SE") //if end of transaction //do nothing { } else if (segment.SegmentID == "TA1") //This segment can either replace or supplement any GS segments for any ack type (997,999,277). The TA1 will always be before the first GS segment. //Ignore for now. We should eventually match TA101 with the ISA13 of the claim that we sent, so we can report the status to the user using fields TA104 and TA105. //This segment is neither mandated or prohibited (see 277.pdf pg. 207). { } else //it must be a detail segment within a transaction. { if (LastTransaction().Segments == null) { LastTransaction().Segments = new List <X12Segment>(); } LastTransaction().Segments.Add(segment); } //row=sr.ReadLine(); } }
public X12_LS(X12Segment seg) : base(seg) { seg.AssertType("LS"); LoopIdentifierCode = seg.Get(1); }
public X12_ACT(X12Segment seg) : base(seg) { seg.AssertType("ACT"); AccountNumber1 = seg.Get(1); AccountNumber2 = seg.Get(6); }
public X12_AMT(X12Segment seg) : base(seg) { seg.AssertType("AMT"); AmountQualifierCode = seg.Get(1); MonetaryAmount = seg.Get(2); }
public X12_QTY(X12Segment seg) : base(seg) { seg.AssertType("QTY"); QuantityQualifier = seg.Get(1); Quantity = seg.Get(2); }
public X12_REF(X12Segment seg, params string[] arrayElement01Values) : base(seg) { seg.AssertType("REF", arrayElement01Values); ReferenceIdQualifier = seg.Get(1); ReferenceId = seg.Get(2); }
public DTP271(X12Segment segment) { Segment = segment; }
///<summary>Supply the functional group header(GS) when creating this object.</summary> public X12FunctionalGroup(X12Segment header){ Header=header.Copy(); }
public X12_LX(X12Segment seg) : base(seg) { seg.AssertType("LX"); AssignedNumber = seg.Get(1); }
///<summary>Supply the transaction header(ST) when creating this object.</summary> public X12Transaction(X12Segment header){ Header=header.Copy(); }
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 } }
private static string SegmentToString(X12Segment segment) { string retVal=""; string rn="\r\n"; //HL if(segment.SegmentID=="HL"){ retVal+=rn;//insert a blank line before each loop switch(segment.Get(3)){ case "20": retVal+="Information Source:"; break; case "21": retVal+="Information Receiver:"; break; case "19": retVal+="Service Provider:"; break; case "22": retVal+="Subscriber:"; break; case "23": retVal+="Dependent:"; break; } retVal+=rn; } //NM1 else if(segment.SegmentID=="NM1"){ switch(segment.Get(1)){//payer ID code case "PR": retVal="Payer: "; break; case "41": retVal="Submitter: "; break; case "1P": retVal="Provider: "; break; case "IL": retVal="Insured or Subscriber: "; break; case "QC": retVal="Patient: "; break; case "85": retVal="Billing Provider: "; break; } retVal+=segment.Get(3)+", "//LName +segment.Get(4)+" "//Fname +segment.Get(5)+" "//MiddleName +segment.Get(7)+", "//Suffix +"ID code: "+segment.Get(9)+rn;//ID code } //PER else if(segment.SegmentID=="PER"){ retVal="Information Contact: " +segment.Get(2)+" "//Name +GetPERqualifier(segment.Get(3))+" " +segment.Get(4)+" " +GetPERqualifier(segment.Get(5))+" " +segment.Get(6)+" " +GetPERqualifier(segment.Get(7))+" " +segment.Get(8)+rn; } //TRN else if(segment.SegmentID=="TRN"){ retVal="Trace Number: " +segment.Get(2)+rn; } //STC-Status information else if(segment.SegmentID=="STC"){ retVal="ClaimStatus :" //+segment.Get(1,1)+" "//Industry R code +"LOINC:"+segment.Get(1,2)+", "//LOINC code +"DATE: "+ConvertDate(segment.Get(2))+" " +ConvertCurrency(segment.Get(4))+" "//monetary amount +segment.Get(10,2)+" "//LOINC code 2 +segment.Get(11,2)+rn;//LOINC code 3 } //REF else if(segment.SegmentID=="REF"){ switch(segment.Get(1)){ case "EJ": retVal="Patient Account Number: "; break; case "BLT": retVal="Billing Type: "; break; case "EA": retVal="Medical Record ID Number: "; break; case "D9": retVal="Claim Number: "; break; case "FJ": retVal="Line Item Control Number: "; break; case "87": //functional category irrelevant return ""; case "9F": retVal="Referral Number: "; break; case "6R": retVal="Provider Control Number: "; break; case "G5": retVal="Provider Site Number: "; break; case "1B": retVal="Blue Shield Provider Number: "; break; } retVal+=segment.Get(2)+rn; } //DTP(x2)-Date or Time period else if(segment.SegmentID=="DTP"){ switch(segment.Get(1)){ case "434": retVal="Statement date: "; break; case "106": retVal="Required by: "; break; case "472": retVal="Service date: "; break; } if(segment.Get(2)=="D8"){//Date eight char retVal+=ConvertDate(segment.Get(3))+rn; } else if(segment.Get(2)=="RD8"){//Range Date eight char retVal+=ConvertDateRange(segment.Get(3))+rn; } } //PWK-not very useful here //N1 else if(segment.SegmentID=="N1"){ switch(segment.Get(1)){// case "PR": retVal="Payer: "; break; } retVal+=segment.Get(2)+rn; } //N3 else if(segment.SegmentID=="N3"){ retVal=segment.Get(1)+" "//address +segment.Get(2)+rn;//address2 } //N4-CityStateZip else if(segment.SegmentID=="N4"){ retVal=segment.Get(1)+", "//City +segment.Get(2)+" "//State +segment.Get(3)+" ";//Zip if(segment.Get(5)=="B1"){//branch retVal+="Branch "+segment.Get(6); } else if(segment.Get(5)=="DP"){//department retVal+="Department "+segment.Get(6); } retVal+=rn; } //SVC-Service Line Information else if(segment.SegmentID=="SVC"){ retVal=segment.Get(1,2)+" "//procedure code +ConvertCurrency(segment.Get(2))+" "//amount +segment.Get(4)+rn;//national Uniform Billing Code??? on institutional claims. } //SBR-subscriber on 837 //DMG-birthdate,gender on 837 //CLM-claim on 837 //DN2-tooth status on 837 //LX-line counter not needed //SV3-Dental service on 837 //TOO-Tooth info on 837 return retVal; }
public DTP271(X12Segment segment) { Segment=segment; }
///<summary>Supply the transaction header(ST) when creating this object.</summary> public X12Transaction(X12Segment header) { Header = header.Copy(); }
private static string SegmentToString(X12Segment segment) { string retVal = ""; string rn = "\r\n"; //HL if (segment.SegmentID == "HL") { retVal += rn; //insert a blank line before each loop switch (segment.Get(3)) { case "20": retVal += "Information Source:"; break; case "21": retVal += "Information Receiver:"; break; case "19": retVal += "Service Provider:"; break; case "22": retVal += "Subscriber:"; break; case "23": retVal += "Dependent:"; break; } retVal += rn; } //NM1 else if (segment.SegmentID == "NM1") { switch (segment.Get(1)) //payer ID code { case "PR": retVal = "Payer: "; break; case "41": retVal = "Submitter: "; break; case "1P": retVal = "Provider: "; break; case "IL": retVal = "Insured or Subscriber: "; break; case "QC": retVal = "Patient: "; break; case "85": retVal = "Billing Provider: "; break; } retVal += segment.Get(3) + ", " //LName + segment.Get(4) + " " //Fname + segment.Get(5) + " " //MiddleName + segment.Get(7) + ", " //Suffix + "ID code: " + segment.Get(9) + rn; //ID code } //PER else if (segment.SegmentID == "PER") { retVal = "Information Contact: " + segment.Get(2) + " " //Name + GetPERqualifier(segment.Get(3)) + " " + segment.Get(4) + " " + GetPERqualifier(segment.Get(5)) + " " + segment.Get(6) + " " + GetPERqualifier(segment.Get(7)) + " " + segment.Get(8) + rn; } //TRN else if (segment.SegmentID == "TRN") { retVal = "Trace Number: " + segment.Get(2) + rn; } //STC-Status information else if (segment.SegmentID == "STC") { retVal = "ClaimStatus :" //+segment.Get(1,1)+" "//Industry R code + "LOINC:" + segment.Get(1, 2) + ", " //LOINC code + "DATE: " + ConvertDate(segment.Get(2)) + " " + ConvertCurrency(segment.Get(4)) + " " //monetary amount + segment.Get(10, 2) + " " //LOINC code 2 + segment.Get(11, 2) + rn; //LOINC code 3 } //REF else if (segment.SegmentID == "REF") { switch (segment.Get(1)) { case "EJ": retVal = "Patient Account Number: "; break; case "BLT": retVal = "Billing Type: "; break; case "EA": retVal = "Medical Record ID Number: "; break; case "D9": retVal = "Claim Number: "; break; case "FJ": retVal = "Line Item Control Number: "; break; case "87": //functional category irrelevant return(""); case "9F": retVal = "Referral Number: "; break; case "6R": retVal = "Provider Control Number: "; break; case "G5": retVal = "Provider Site Number: "; break; case "1B": retVal = "Blue Shield Provider Number: "; break; } retVal += segment.Get(2) + rn; } //DTP(x2)-Date or Time period else if (segment.SegmentID == "DTP") { switch (segment.Get(1)) { case "434": retVal = "Statement date: "; break; case "106": retVal = "Required by: "; break; case "472": retVal = "Service date: "; break; } if (segment.Get(2) == "D8") //Date eight char { retVal += ConvertDate(segment.Get(3)) + rn; } else if (segment.Get(2) == "RD8") //Range Date eight char { retVal += ConvertDateRange(segment.Get(3)) + rn; } } //PWK-not very useful here //N1 else if (segment.SegmentID == "N1") { switch (segment.Get(1)) // { case "PR": retVal = "Payer: "; break; } retVal += segment.Get(2) + rn; } //N3 else if (segment.SegmentID == "N3") { retVal = segment.Get(1) + " " //address + segment.Get(2) + rn; //address2 } //N4-CityStateZip else if (segment.SegmentID == "N4") { retVal = segment.Get(1) + ", " //City + segment.Get(2) + " " //State + segment.Get(3) + " "; //Zip if (segment.Get(5) == "B1") //branch { retVal += "Branch " + segment.Get(6); } else if (segment.Get(5) == "DP") //department { retVal += "Department " + segment.Get(6); } retVal += rn; } //SVC-Service Line Information else if (segment.SegmentID == "SVC") { retVal = segment.Get(1, 2) + " " //procedure code + ConvertCurrency(segment.Get(2)) + " " //amount + segment.Get(4) + rn; //national Uniform Billing Code??? on institutional claims. } //SBR-subscriber on 837 //DMG-birthdate,gender on 837 //CLM-claim on 837 //DN2-tooth status on 837 //LX-line counter not needed //SV3-Dental service on 837 //TOO-Tooth info on 837 return(retVal); }
public X12_N3(X12Segment seg) : base(seg) { seg.AssertType("N3"); AddressInformation1 = seg.Get(1); AddressInformation2 = seg.Get(2); }
///<summary>Takes raw text and converts it into an X12Object.</summary> public X12object(string messageText) { messageText=messageText.Replace("\r",""); messageText=messageText.Replace("\n",""); if(messageText.Substring(0,3)!="ISA"){ throw new ApplicationException("ISA not found"); } Separators=new X12Separators(); Separators.Element=messageText.Substring(3,1); Separators.Subelement=messageText.Substring(104,1); Separators.Segment=messageText.Substring(105,1); string[] messageRows=messageText.Split(new string[] {Separators.Segment},StringSplitOptions.None); FunctGroups=new List<X12FunctionalGroup>(); Segments=new List<X12Segment>(); string row; X12Segment segment; for(int i=1;i<messageRows.Length;i++){ row=messageRows[i]; segment=new X12Segment(row,Separators); Segments.Add(segment); if(segment.SegmentID=="IEA"){//if end of interchange //do nothing } if(segment.SegmentID=="GS"){//if new functional group FunctGroups.Add(new X12FunctionalGroup(segment)); } else if(segment.SegmentID=="GE"){//if end of functional group //do nothing } else if(segment.SegmentID=="ST"){//if new transaction set if(LastGroup().Transactions==null){ LastGroup().Transactions=new List<X12Transaction>(); } LastGroup().Transactions.Add(new X12Transaction(segment)); } else if(segment.SegmentID=="SE"){//if end of transaction //do nothing } else{//it must be a detail segment within a transaction. if(LastTransaction().Segments==null){ LastTransaction().Segments=new List<X12Segment>(); } LastTransaction().Segments.Add(segment); } //row=sr.ReadLine(); } }