private static void TransformBillingProviderLoopTo837(XmlNode billingProviderLoop, Claim claim, TransformBillingProviderHLoopTo837State state) { var nameTypeNode = billingProviderLoop.SelectSingleNode("NM1/NM101"); if (nameTypeNode != null) { switch (nameTypeNode.InnerText) { case "87":if (state.FirstType87 == null) state.FirstType87 = billingProviderLoop;break; case "85": if (state.FirstType85 == null) state.FirstType85 = billingProviderLoop; break; } } }
public void SerializationTest1() { var document = new ClaimDocument(); var claim = new Claim { Type = ClaimTypeEnum.Institutional, PatientControlNumber = "756048Q", TotalClaimChargeAmount = 89.93M }; document.Claims.Add(claim); string xml = document.Serialize(); Trace.Write(xml); }
private static void TransformBillingProviderHLoopTo837(XmlNodeList xmlNodeList, Claim claim) { TransformBillingProviderHLoopTo837State state = new TransformBillingProviderHLoopTo837State(); foreach (XmlNode item in xmlNodeList) { TransformBillingProviderHLoopTo837(item, claim, state); } if (claim.PayToProvider != null ) { if (state.FirstType87 != null) { TransformPayToProvider(state.FirstType87, claim); } else if (state.FirstType85 != null) { TransformPayToProvider(state.FirstType85, claim); } } }
//reverse engineer from https://raw.githubusercontent.com/mmooney/MMDB.DataService/master/ThirdParty/x12parser/trunk/src/OopFactory.X12.Hipaa/Claims/Services/Xsl/X12-837-To-ClaimDocument.xslt private static XmlDocument TransformClaimDocumentTo837(Interchange interchange, Claim claim) { XmlDocument document = new XmlDocument() { PreserveWhitespace = true } ; document.LoadXml(interchange.Serialize()); var claimLoop2300 = document.SelectNodes("//Loop"); for (int i = 0; i < claimLoop2300.Count; i++) { TransformLoopTo837(claimLoop2300[i],claim); } return document; }
private static void TransformBillingProviderHLoopTo837(XmlNode xmlNode, Claim claim, TransformBillingProviderHLoopTo837State state) { var billingProviderLoop= xmlNode.SelectSingleNode("Loop"); TransformBillingProviderLoopTo837(billingProviderLoop, claim,state); }
private static void TransformAMTTo837(XmlNodeList xmlNodeList, Claim claim) { }
private static void TransformSubscriberHLoopTo837(XmlNode hloop, Claim claim) { TransformSBRTo837(hloop.SelectSingleNode("SBR"), claim.SubscriberInformation); }
private static void TransformSubscriberHLoopTo837(XmlNodeList xmlNodeList, Claim claim) { foreach (XmlNode item in xmlNodeList) { TransformSubscriberHLoopTo837(item,claim); } }
private static void TransformPayToProvider(XmlNode billingProvider, Claim claim) { XmlNode name = billingProvider.SelectSingleNode("REF"); XmlNode taxId = null; if (name != null) { XmlNode nameId = name.SelectSingleNode("REF02"); XmlNode nameQualifier = name.SelectSingleNode("REF01"); if (nameId != null && nameQualifier != null) { switch (nameQualifier.InnerText) { case "FI": taxId =nameId; break; case "24": taxId = nameId; ; break; } } } if (taxId != null) taxId.InnerText = claim.PayToProvider.TaxId; else { taxId = GetReferenceId(billingProvider, "EI"); if (taxId == null) taxId = GetReferenceId(billingProvider, "TJ"); } if (taxId != null) taxId.InnerText = claim.PayToProvider.TaxId; }
private static void TransformPatientHLoopTo837(XmlNodeList xmlNodeList, Claim claim) { }
private static void TransformLoopTo837(XmlNode loop, Claim claim) { var loopId = ((XmlElement)loop).GetAttribute("LoopId"); switch (loopId) { case "2300": TransformLoop2300To837(loop, claim);break; case "2010BA": TransformLoop2010BATo837(loop, claim.Subscriber);break; } }
private static void TransformLoop2300To837(XmlNode loop2300, Claim claim) { var parentLoopId = loop2300.SelectSingleNode("../@LoopId"); var parentLoopIdValue= (parentLoopId ==null)?string.Empty:parentLoopId.Value; XmlNode transactionCode; if (parentLoopIdValue == "2000B") { transactionCode = loop2300.SelectSingleNode("../../../ST/ST02"); } else transactionCode = loop2300.SelectSingleNode("../../../../ST/ST02"); transactionCode.InnerText= claim.TransactionCode; var claimNumber = loop2300.SelectSingleNode("REF[REF01 = 'D9'] / REF02"); claimNumber.InnerText = claim.ClaimNumber; var patientControlNumber= loop2300.SelectSingleNode("CLM/CLM01"); patientControlNumber.InnerText = claim.PatientControlNumber; var totalClaimChargeAmount= loop2300.SelectSingleNode("CLM/CLM02"); totalClaimChargeAmount.InnerText = claim.TotalClaimChargeAmount.ToString(); if (!string.IsNullOrWhiteSpace(claim.ProviderSignatureOnFile)) { var providerSignatureOnFile = loop2300.SelectSingleNode("CLM/CLM06"); providerSignatureOnFile.InnerText = claim.ProviderSignatureOnFile; } if (!string.IsNullOrWhiteSpace(claim.MedicalRecordNumber)) { var medicalRecordNumber = loop2300.SelectSingleNode("REF[REF01 = 'EA'] / REF02"); medicalRecordNumber.InnerText = claim.MedicalRecordNumber; } if(!string.IsNullOrWhiteSpace(claim.PriorAuthorizationNumber)) { var priorAuthorizationNumber = loop2300.SelectSingleNode("REF[REF01 = 'G1'] / REF02"); priorAuthorizationNumber.Value = claim.PriorAuthorizationNumber; } if (parentLoopIdValue == "2000B") { TransformBillingProviderHLoopTo837(loop2300.SelectNodes("../../."), claim); TransformSubscriberHLoopTo837(loop2300.SelectNodes("../."), claim); } else if (parentLoopIdValue == "2000C") { TransformBillingProviderHLoopTo837(loop2300.SelectNodes("../../../."), claim); TransformSubscriberHLoopTo837(loop2300.SelectNodes("../../."), claim); TransformPatientHLoopTo837(loop2300.SelectNodes("../."), claim); } TransformPWKTo837(loop2300.SelectNodes("PWK"), claim); TransformDTPTo837(loop2300.SelectNodes("DTP"), claim); TransformAMTTo837(loop2300.SelectNodes("AMT"), claim); TransformREFTo837(loop2300.SelectNodes("REF"), claim); TransformNTETo837(loop2300.SelectNodes("NTE"), claim); TransformHITo837(loop2300.SelectNodes("HI"), claim); TransformLoopTo837(loop2300.SelectNodes("Loop"), claim); }