/// <summary> /// Transforms document to XML /// </summary> /// <param name="document">Document to be transformed</param> /// <returns>String XML representation of XML document</returns> /// <exception cref="ArgumentNullException">Thrown if document passed is null</exception> public string TransformClaimDocumentToFoXml(ClaimDocument document) { if (document == null) { throw new ArgumentNullException(nameof(document), Resources.InvalidClaimDocumentError); } var form = new FormDocument(); foreach (var claim in document.Claims) { IList <FormPage> pages; switch (claim.Type) { case ClaimType.Professional: pages = this.professionalTransformation.TransformClaimToClaimFormFoXml(claim); form.Pages.AddRange(pages); break; case ClaimType.Institutional: pages = this.institutionalTransformation.TransformClaimToClaimFormFoXml(claim); form.Pages.AddRange(pages); break; case ClaimType.Dental: pages = this.dentalTransformation.TransformClaimToClaimFormFoXml(claim); form.Pages.AddRange(pages); break; default: // If we get here, then something went extremely wrong throw new InvalidOperationException(Resources.InvalidClaimTypeError); } } string xml = form.Serialize(); Stream transformStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("X12.Hipaa.Claims.Services.Xsl.FormDocument-To-FoXml.xslt"); var transform = new XslCompiledTransform(); if (transformStream != null) { transform.Load(XmlReader.Create(transformStream)); } var outputStream = new MemoryStream(); transform.Transform(XmlReader.Create(new StringReader(xml)), new XsltArgumentList(), outputStream); outputStream.Position = 0; return(new StreamReader(outputStream).ReadToEnd()); }
public string TransformClaimDocumentToFoXml(ClaimDocument document) { FormDocument form = TransformClaimDocumentToFormDocument(document); var xml = form.Serialize(); var transformStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Claims.Services.Xsl.FormDocument-To-FoXml.xslt"); var transform = new XslCompiledTransform(); if (transformStream != null) { transform.Load(XmlReader.Create(transformStream)); } var outputStream = new MemoryStream(); transform.Transform(XmlReader.Create(new StringReader(xml)), new XsltArgumentList(), outputStream); outputStream.Position = 0; return(new StreamReader(outputStream).ReadToEnd()); }
public string TransformClaimDocumentToFoXml(ClaimDocument document) { FormDocument form = new FormDocument(); foreach (var claim in document.Claims) { if (claim.Type == ClaimTypeEnum.Professional) { var pages = _professionalTransformation.TransformClaimToClaimFormFoXml(claim); form.Pages.AddRange(pages); } else if (claim.Type == ClaimTypeEnum.Institutional) { var pages = _institutionalTransformation.TransformClaimToClaimFormFoXml(claim); form.Pages.AddRange(pages); } else { form.Pages.AddRange(_dentalTransformation.TransformClaimToClaimFormFoXml(claim)); } } var xml = form.Serialize(); var transformStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OopFactory.X12.Hipaa.Claims.Services.Xsl.FormDocument-To-FoXml.xslt"); var transform = new XslCompiledTransform(); if (transformStream != null) { transform.Load(XmlReader.Create(transformStream)); } var outputStream = new MemoryStream(); transform.Transform(XmlReader.Create(new StringReader(xml)), new XsltArgumentList(), outputStream); outputStream.Position = 0; return(new StreamReader(outputStream).ReadToEnd()); }