public void EV_1101_DefaultSerializationLegacy() { String expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ClinicalDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" classCode=\"DOCCLIN\" moodCode=\"EVN\" xmlns=\"urn:hl7-org:v3\"><author nullFlavor=\"NI\" xsi:nil=\"true\" /></ClinicalDocument>"; ClinicalDocument document = new ClinicalDocument(); Author a = new Author(); a.Time = DateTime.Now; a.AssignedAuthor = new AssignedAuthor(SET <II> .CreateSET(Guid.NewGuid())); document.Author.Add(a); a.NullFlavor = NullFlavor.NoInformation; XmlIts1Formatter formatter = new XmlIts1Formatter(); formatter.GraphAides.Add(new ClinicalDocumentDatatypeFormatter()); formatter.ValidateConformance = false; formatter.Settings = SettingsType.DefaultLegacy; StringWriter sw = new StringWriter(); using (XmlWriter xw = XmlWriter.Create(sw)) { formatter.Graph(xw, document); xw.Flush(); String data = sw.ToString(); R2SerializationHelper.XmlIsEquivalent(expected, data); } }
public void R2EDContentBinSerializationTest() { String expectedXml = String.Format(@"<test xmlns=""urn:hl7-org:v3"" mediaType=""bin/plain""><data>{0}</data></test>", Convert.ToBase64String(UTF8Encoding.UTF8.GetBytes("This is binary"))); String actualXml = R2SerializationHelper.SerializeAsString(new ED(System.Text.Encoding.UTF8.GetBytes("This is binary"), "bin/plain")); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void EV_1101_SuppressXsiNilMultiprocessor() { String expected = "<?xml version=\"1.0\" encoding=\"utf-16\"?><ClinicalDocument xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" classCode=\"DOCCLIN\" moodCode=\"EVN\" xmlns=\"urn:hl7-org:v3\"><author typeCode=\"AUT\" nullFlavor=\"NI\" contextControlCode=\"OP\"><time value=\"20140116103733.292-0500\" /><assignedAuthor classCode=\"ASSIGNED\"><id root=\"2BCF1373-9199-4574-A254-0E7558DE9825\" /></assignedAuthor></author></ClinicalDocument>"; ClinicalDocument document = new ClinicalDocument(); Author a = new Author(); a.Time = (TS)"20140116103733.292-0500"; a.AssignedAuthor = new AssignedAuthor(SET <II> .CreateSET(Guid.Parse("2BCF1373-9199-4574-A254-0E7558DE9825"))); document.Author.Add(a); a.NullFlavor = NullFlavor.NoInformation; XmlIts1Formatter formatter = new XmlIts1Formatter(); formatter.Settings = SettingsType.DefaultMultiprocessor; formatter.Settings |= SettingsType.SuppressXsiNil | SettingsType.SuppressNullEnforcement; formatter.GraphAides.Add(new ClinicalDocumentDatatypeFormatter()); formatter.ValidateConformance = false; StringWriter sw = new StringWriter(); using (XmlWriter xw = XmlWriter.Create(sw)) { var results = formatter.Graph(xw, document); xw.Flush(); String data = sw.ToString(); R2SerializationHelper.XmlIsEquivalent(expected, data); } }
public void R2TELParseTest2() { TEL telType = new TEL("tel:+15556755745", new CS <TelecommunicationAddressUse>[] { TelecommunicationAddressUse.Home, TelecommunicationAddressUse.WorkPlace }); telType.Capabilities = new SET <CS <TelecommunicationCabability> >() { TelecommunicationCabability.Voice, TelecommunicationCabability.Fax }; telType.ValidTimeLow = null; telType.ValidTimeHigh = null; telType.NullFlavor = null; telType.UpdateMode = null; telType.UseablePeriod = null; var actualXml = R2SerializationHelper.SerializeAsString(telType); var set2 = R2SerializationHelper.ParseString <TEL>(actualXml); Assert.AreEqual(telType, set2); }
public void EIVLSerializationTest01() { // construct eivl EIVL <TS> eivl = new EIVL <TS>( DomainTimingEventType.Dinner, new IVL <PQ>( new PQ(30, "min"), // low new PQ(30, "min") // high ) ); eivl.Offset.HighClosed = true; eivl.Offset.LowClosed = true; eivl.ValidTimeHigh = null; eivl.ValidTimeLow = null; eivl.ControlActRoot = null; eivl.ControlActExt = null; eivl.NullFlavor = null; eivl.UpdateMode = null; eivl.OriginalText = null; Assert.IsTrue(eivl.Validate()); var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" event=""CV"" ><offset lowClosed=""true"" highClosed=""true""><low value=""30"" unit=""min""/><high value=""30"" unit=""min""/></offset></test>"; var actualXml = R2SerializationHelper.SerializeAsString(eivl); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2BLNullFlavorNullParseTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" nullFlavor=""NI""/>"; BL parsed = R2SerializationHelper.ParseString <BL>(expectedXml); Assert.AreEqual(NullFlavor.NoInformation, (NullFlavor)parsed.NullFlavor); }
public void R2BLTrueSerializationTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" value=""true""/>"; String actualXml = R2SerializationHelper.SerializeAsString(new BL(true)); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2BLTrueParseTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" value=""true""/>"; BL parsed = R2SerializationHelper.ParseString <BL>(expectedXml); Assert.AreEqual(true, parsed.Value); }
public void PQRParseTest04() { PQR pqr = new PQR(3, "[ft_i]", "2.16.840.1.113883.6.8"); pqr.ValidTimeLow = new TS(new DateTime(2012, 01, 01), DatePrecision.Day); pqr.ValidTimeHigh = new TS(new DateTime(2012, 12, 31), DatePrecision.Day); pqr.ControlActRoot = null; pqr.ControlActExt = null; pqr.NullFlavor = null; pqr.UpdateMode = null; pqr.CodeSystemName = null; pqr.CodeSystemVersion = null; pqr.ValueSet = null; pqr.ValueSetVersion = null; pqr.DisplayName = null; pqr.OriginalText = null; Console.WriteLine("Value: {0} | Code: {1} | Codesystem: {2}", pqr.Value, pqr.Code, pqr.CodeSystem); Assert.IsTrue(pqr.Validate()); // serialize and parse pivl var actualXml = R2SerializationHelper.SerializeAsString(pqr); var pqr2 = R2SerializationHelper.ParseString <PQR>(actualXml); Assert.AreEqual(pqr, pqr2); }
public void R2CDQualifierNestedCodeSerializationTest() { string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" code=""64572001:{116676008=72704001,363698007=(12611008:272741003=7771000)}"" codeSystem=""2.16.840.1.113883.6.96"" codeSystemName=""Snomed-CT""><originalText value=""Some original text""/></test>"; var cdi = new CD <String>("64572001", "2.16.840.1.113883.6.96", "Snomed-CT", null, new ST("disease"), new ED("Some original text")); cdi.Qualifier = new LIST <CR <string> >(); cdi.Qualifier.Add(new CR <string>( new CV <String>("116676008", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "associated morphology", null), new CD <String>("72704001", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "fracture", null) )); cdi.Qualifier.Add(new CR <String>( new CV <String>("363698007", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "finding site", null), new CD <String>("12611008", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "bone structure of tibia", null) { Qualifier = LIST <CR <String> > .CreateList( new CR <String>( new CV <String>("272741003", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "laterality", null), new CD <String>("7771000", "2.16.840.1.113883.6.96", "SNOMED-CT", null, "left", null) ) ) } )); string actualXml = R2SerializationHelper.SerializeAsString(cdi); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2EDContentTextSerializationTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3"" value=""this is my test""/>"; String actualXml = R2SerializationHelper.SerializeAsString(new ED("this is my test")); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void PQRSerializationTest01() { PQR pqr = new PQR(3, "[ft_i]", "2.16.840.1.113883.6.8"); pqr.ValidTimeLow = null; pqr.ValidTimeHigh = null; pqr.ControlActRoot = null; pqr.ControlActExt = null; pqr.NullFlavor = null; pqr.UpdateMode = null; pqr.CodeSystemName = null; pqr.CodeSystemVersion = null; pqr.ValueSet = null; pqr.ValueSetVersion = null; pqr.DisplayName = null; pqr.OriginalText = null; Console.WriteLine("Value: {0} | Code: {1} | Codesystem: {2}", pqr.Value, pqr.Code, pqr.CodeSystem); Assert.IsTrue(pqr.Validate()); var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" value=""3"" code=""[ft_i]"" codeSystem=""2.16.840.1.113883.6.8""></test>"; var actualXml = R2SerializationHelper.SerializeAsString(pqr); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2CDQualifierNestedCodeParseTest() { var cdi = new CD <String>("64572001", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, new ED("Some original text")); cdi.Qualifier = new LIST <CR <string> >(); cdi.Qualifier.Add(new CR <string>( new CV <String>("116676008", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null), new CD <String>("72704001", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null) )); cdi.Qualifier.Add(new CR <String>( new CV <String>("363698007", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null), new CD <String>("12611008", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null) { Qualifier = LIST <CR <String> > .CreateList( new CR <String>( new CV <String>("272741003", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null), new CD <String>("7771000", "2.16.840.1.113883.6.96", "SNOMED-CT", null, null, null) ) ) } )); string actualXml = R2SerializationHelper.SerializeAsString(cdi); var cd2 = R2SerializationHelper.ParseString <CD <String> >(actualXml); Assert.AreEqual(cdi, cd2); }
public void R2TELUseablePeriodParseTest() { var tel = new TEL("tel:+190555525485"); // This PIVL<TS> selects the week of Aug 15 2011 - Aug 19 2011 var weekdays = new PIVL <TS>( new IVL <TS>(DateTime.Parse("08-15-2011"), DateTime.Parse("08-19-2011")), new PQ(1, "wk") ); // This PIVL<TS> selects the hours of 9-5 var nineToFive = new PIVL <TS>( new IVL <TS>(DateTime.Parse("08-15-2011 09:00 AM"), DateTime.Parse("08-15-2011 05:00 PM")), new PQ(1, "d") ); // We set the usable period to a set of // 1. All weekdays // 2. intersect with times from 9-5 daily tel.UseablePeriod = new GTS(QSI <TS> .CreateQSI( weekdays, nineToFive )); var actualXml = R2SerializationHelper.SerializeAsString(tel); var inti = R2SerializationHelper.ParseString <TEL>(actualXml); Assert.AreEqual(tel, inti); }
public void R2TELSerializationTest2() { TEL telType = new TEL("tel:+15556755745", new CS <TelecommunicationAddressUse>[] { TelecommunicationAddressUse.Home, TelecommunicationAddressUse.WorkPlace }); telType.Capabilities = new SET <CS <TelecommunicationCabability> >() { TelecommunicationCabability.Voice, TelecommunicationCabability.Fax }; telType.ValidTimeLow = null; telType.ValidTimeHigh = null; telType.NullFlavor = null; telType.UpdateMode = null; telType.UseablePeriod = null; var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" value=""tel:+15556755745"" use=""H WP"" capabilities=""voice fax""/>"; var actualXml = R2SerializationHelper.SerializeAsString(telType); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2ADBasicPartTypesSerializationTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3""><part type=""AL"" value=""1050 Wishard Blvd""/><part type=""AL"" value=""RG 5th Floor""/><part type=""STA"" value=""Ontario""/></test>"; String actualXml = R2SerializationHelper.SerializeAsString(AD.CreateAD(new ADXP("1050 Wishard Blvd", AddressPartType.AddressLine), new ADXP("RG 5th Floor", AddressPartType.AddressLine), new ADXP("Ontario", AddressPartType.State))); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2ADBasicSerializationTest() { String expectedXml = @"<test xmlns=""urn:hl7-org:v3""><part value=""1050 Wishard Blvd""/><part type=""DEL""/></test>"; String actualXml = R2SerializationHelper.SerializeAsString(AD.CreateAD(new ADXP("1050 Wishard Blvd"), new ADXP(null, AddressPartType.Delimiter))); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void EIVLSerializationTest03() { // construct eivl EIVL <TS> eivl = new EIVL <TS>( DomainTimingEventType.Breakfast, new IVL <PQ>( new PQ(-1, "h"), // low new PQ(-50, "min") // high ) ); eivl.Offset.HighClosed = true; eivl.Offset.LowClosed = true; eivl.ValidTimeLow = new TS(new DateTime(2012, 01, 01), DatePrecision.Day); eivl.ValidTimeHigh = new TS(new DateTime(2012, 12, 31), DatePrecision.Day); eivl.NullFlavor = null; eivl.UpdateMode = UpdateMode.Add; eivl.OriginalText = "One hour before breakfast for 10 minutes"; Assert.IsTrue(eivl.Validate()); var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" event=""CM"" validTimeHigh=""20121231"" validTimeLow=""20120101"" updateMode=""A"" ><originalText value=""One hour before breakfast for 10 minutes"" language=""en-US"" /><offset lowClosed=""true"" highClosed=""true""><low value=""-1"" unit=""h""/><high value=""-50"" unit=""min""/></offset></test>"; var actualXml = R2SerializationHelper.SerializeAsString(eivl); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2PNQualifierSerializationTest() { PN inti = new PN( EntityNameUse.Legal, new ENXP[] { new ENXP("Sir", EntityNamePartType.Prefix) { Qualifier = new SET <CS <EntityNamePartQualifier> >(EntityNamePartQualifier.Nobility) }, new ENXP("Dr", EntityNamePartType.Prefix) { Qualifier = new SET <CS <EntityNamePartQualifier> >(EntityNamePartQualifier.Academic) }, new ENXP("John", EntityNamePartType.Given), new ENXP("Jacob", EntityNamePartType.Given), new ENXP("Jingleheimer", EntityNamePartType.Family), new ENXP("-", EntityNamePartType.Delimiter), new ENXP("Schmidt", EntityNamePartType.Family), new ENXP("III", EntityNamePartType.Suffix) } ); inti.Use.Add(EntityNameUse.OfficialRecord); string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" use=""L OR"" flavorId=""EN.PN""><part type=""TITLE"" value=""Sir"" qualifier=""NB PFX""/><part type=""TITLE"" value=""Dr"" qualifier=""AC PFX""/><part type=""GIV"" value=""John""/><part type=""GIV"" value=""Jacob""/><part type=""FAM"" value=""Jingleheimer""/><part type=""DEL"" value=""-""/><part type=""FAM"" value=""Schmidt""/><part qualifier=""SFX"" value=""III""/></test>"; string actualXml = R2SerializationHelper.SerializeAsString(inti); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void IVL_PQSerializationTest03() { PQ low = new PQ(1, "s"); low.CodingRationale = new SET <CodingRationale>( CodingRationale.Required ); PQ high = new PQ(10, "s"); high.CodingRationale = new SET <CodingRationale>( CodingRationale.Required ); IVL <PQ> ivl = new IVL <PQ>( low, high ); ivl.ValidTimeLow = new TS(new DateTime(2008, 01, 01), DatePrecision.Day); ivl.ValidTimeHigh = new TS(new DateTime(2008, 01, 31), DatePrecision.Day); ivl.UpdateMode = UpdateMode.Add; ivl.Width = null; ivl.LowClosed = true; ivl.HighClosed = true; ivl.NullFlavor = null; ivl.OriginalText = "Test"; Assert.IsTrue(ivl.Validate()); var expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" lowClosed=""true"" highClosed=""true"" validTimeLow=""20080101"" validTimeHigh=""20080131"" updateMode=""A"" ><originalText language=""en-US"" value=""Test"" /><low value=""1"" unit=""s"" codingRationale=""Required""/><high value=""10"" unit=""s"" codingRationale=""Required""/></test>"; var actualXml = R2SerializationHelper.SerializeAsString(ivl); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2RTOUncertainRangeParseTest() { RTO <IQuantity, IQuantity> inti = new RTO <IQuantity, IQuantity>(); inti.UncertainRange = new IVL <MARC.Everest.DataTypes.Interfaces.IQuantity>( new RTO <PQ, PQ>( new PQ(1, "d") { Translation = new SET <PQR>( new PQR(24, "hr", "UCUM") ) }, new PQ(2, "d") ), new RTO <PQ, PQ>( new PQ(3, "d"), new PQ(4, "d") ) ); //string expectedXml = @"<test xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""urn:hl7-org:v3""><uncertainRange><low xsi:type=""RTO""><numerator xsi:type=""MO"" value=""1.23"" currency=""CAD""/><denominator xsi:type=""PQ"" value=""1"" unit=""hr""/></low><high xsi:type=""RTO""><numerator xsi:type=""MO"" value=""2.23"" currency=""CAD""/><denominator xsi:type=""PQ"" value=""1"" unit=""hr""/></high></uncertainRange></test>"; var actualXml = R2SerializationHelper.SerializeAsString(inti); var int2 = R2SerializationHelper.ParseString <RTO <IQuantity, IQuantity> >(actualXml); Assert.AreEqual(inti, int2); }
/// <summary> /// PArse of an invalid RTO without an XSI type on one of the numerator /// or denominator /// </summary> public void R2RTOInvalidParseTest() { string xml = @"<test xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""urn:hl7-org:v3""><numerator xsi:type=""MO"" value=""12.30"" currency=""CAD""/><denominator value=""1"" unit=""hr""/></test>"; var ret = R2SerializationHelper.ParseString <RTO <IQuantity, IQuantity> >(xml); Assert.IsNull(ret); }
public void R2PNQualifierParseTest() { PN inti = new PN( EntityNameUse.Legal, new ENXP[] { new ENXP("Sir", EntityNamePartType.Title) { Qualifier = new SET <CS <EntityNamePartQualifier> >(new EntityNamePartQualifier[] { EntityNamePartQualifier.Nobility, EntityNamePartQualifier.Acquired }) }, new ENXP("Dr", EntityNamePartType.Title) { Qualifier = new SET <CS <EntityNamePartQualifier> >(EntityNamePartQualifier.Academic) }, new ENXP("John", EntityNamePartType.Given), new ENXP("Jacob", EntityNamePartType.Given), new ENXP("Jingleheimer", EntityNamePartType.Family), new ENXP("-", EntityNamePartType.Delimiter), new ENXP("Schmidt", EntityNamePartType.Family), new ENXP("III") } ) { Flavor = "EN.PN" }; string actualXml = R2SerializationHelper.SerializeAsString(inti); var int2 = R2SerializationHelper.ParseString <PN>(actualXml); Assert.AreEqual(inti, int2); }
public void R2TNQualifierSerializationTest() { TN inti = new TN("Sir Dr. John Jacob Jingleheimer-Schmidt III"); string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" flavorId=""EN.TN""><part value=""Sir Dr. John Jacob Jingleheimer-Schmidt III""/></test>"; string actualXml = R2SerializationHelper.SerializeAsString(inti); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2MOBasicSerializationTest() { MO inti = new MO((decimal)1.304, "CAD"); string expectedXml = @"<test xmlns=""urn:hl7-org:v3"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" currency=""CAD"" value=""1.304""/>"; string actualXml = R2SerializationHelper.SerializeAsString(inti); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2REALBasicSerializationTest() { REAL inti = 8.24; string expectedXml = @"<test xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" value=""8.24"" xmlns=""urn:hl7-org:v3""/>"; var actualXml = R2SerializationHelper.SerializeAsString(inti); R2SerializationHelper.XmlIsEquivalent(expectedXml, actualXml); }
public void R2INTBasicParseTest() { INT inti = 8; var actualXml = R2SerializationHelper.SerializeAsString(inti); var int2 = R2SerializationHelper.ParseString <INT>(actualXml); Assert.AreEqual(inti, int2); }
public void R2ADBasicPartTypesParseTest() { var adi = AD.CreateAD(new ADXP("1050 Wishard Blvd", AddressPartType.AddressLine), new ADXP("RG 5th Floor", AddressPartType.AddressLine), new ADXP("Ontario", AddressPartType.State)); String actualXml = R2SerializationHelper.SerializeAsString(adi); var ad2 = R2SerializationHelper.ParseString <AD>(actualXml); Assert.AreEqual(adi, ad2); }
public void R2EDContentBinParseTest() { var ved = new ED(System.Text.Encoding.UTF8.GetBytes("This is binary"), "bin/plain"); String actualXml = R2SerializationHelper.SerializeAsString(ved); var ved2 = R2SerializationHelper.ParseString <ED>(actualXml); Assert.AreEqual(ved, ved2); }
public void R2ADBasicParseTest() { var adi = AD.CreateAD(new ADXP("1050 Wishard Blvd"), new ADXP(null, AddressPartType.Delimiter)); String actualXml = R2SerializationHelper.SerializeAsString(adi); var ad2 = R2SerializationHelper.ParseString <AD>(actualXml); Assert.AreEqual(adi, ad2); }