public void WhenHealthVaultCdaToFhirToHealthVault_ThenValuesEqual()
        {
            string inputCdaXmlRaw = SampleUtil.GetSampleContent("CDA.xml");

            XPathDocument xpDoc = DocumentReferenceHelper.GetXPathDocumentFromXml(inputCdaXmlRaw);

            CDA inputCda = new CDA();

            inputCda.TypeSpecificData = xpDoc;

            var documentReference = inputCda.ToFhir() as DocumentReference;

            var cda = documentReference.ToHealthVault() as CDA;

            XPathDocument cdaXPathDoc = DocumentReferenceHelper.GetXPathDocumentFromXml(inputCdaXmlRaw) ?? throw new Exception("Invalid XML");

            // XML gets generated using a common method in order to use in Assert.AreEqual
            string inputCdaXml = DocumentReferenceHelper.GetXmlFromXPathNavigator(cdaXPathDoc.CreateNavigator());

            Assert.IsNotNull(cda);
            Assert.IsNotNull(cda.TypeSpecificData);

            string cdaXml = DocumentReferenceHelper.GetXmlFromXPathNavigator(cda.TypeSpecificData.CreateNavigator());

            Assert.AreEqual(inputCdaXml, cdaXml);
        }
示例#2
0
        public void WhenHealthVaultCdaTransformedToFhir_ThenValuesEqual()
        {
            string cdaXmlRaw = SampleUtil.GetSampleContent("CDA.xml");

            XPathDocument xpDoc = DocumentReferenceHelper.GetXPathDocumentFromXml(cdaXmlRaw);

            Assert.IsNotNull(xpDoc);

            CDA cda = new CDA();

            cda.TypeSpecificData = xpDoc;

            var documentReference = cda.ToFhir() as DocumentReference;

            Assert.IsNotNull(documentReference);
            Assert.IsNotNull(documentReference.Type);
            Assert.AreEqual(documentReference.Content.Count, 1);
            Assert.IsNotNull(documentReference.Content[0].Attachment);
            Assert.IsNotNull(documentReference.Content[0].Attachment.Data);
            Assert.IsNotNull(documentReference.Content[0].Attachment.ContentType, "application/xml");

            string cdaXml = DocumentReferenceHelper.GetXmlFromXPathNavigator(cda.TypeSpecificData.CreateNavigator());
            string cdaContentBase64Encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(cdaXml));

            string fhirXmlRaw = Encoding.UTF8.GetString(documentReference.Content[0].Attachment.Data);

            XPathDocument fhirXPathDoc;

            using (TextReader txtReader = new StringReader(fhirXmlRaw))
            {
                fhirXPathDoc = new XPathDocument(txtReader);
            }

            string fhirXml = DocumentReferenceHelper.GetXmlFromXPathNavigator(xpDoc.CreateNavigator());
            string fhirAttachmentDataBase64Encoded = Convert.ToBase64String(documentReference.Content[0].Attachment.Data);

            Assert.AreEqual(fhirAttachmentDataBase64Encoded, cdaContentBase64Encoded);
        }