public virtual void TestGetAttributeNameValuePairsAllFilledInIncludingSpecializationType() { Identifier ii = new Identifier("11.22.33.44", "extensionString"); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_BUS; Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "name", "II.BUS_AND_VER", null, null, true, SpecificationVersion.R02_04_02, null, null, null , false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(5, result.Count, "map size"); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "specializationType", "II.BUS"); AssertKeyValuePairInMap(result, "use", "BUS"); AssertKeyValuePairInMap(result, "xsi:type", "II"); }
public virtual void TestGetAttributeNameValuePairsIntegerZero() { string integerValue = "0"; Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "name", "INT.POS", null, null, false); Int32?integer = System.Convert.ToInt32(integerValue); IDictionary <string, string> result = new TestableIntPosPropertyFormatter().GetAttributeNameValuePairsForTest(context, integer , new INTImpl(integer)); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual(integerValue, result.SafeGet("value"), "value as expected"); context.GetModelToXmlResult().ClearErrors(); string output = new TestableIntPosPropertyFormatter().Format(context, new INTImpl(integer)); Assert.AreEqual("<name value=\"0\"/>", output.Trim(), "xml output as expected"); Assert.AreEqual(1, context.GetModelToXmlResult().GetHl7Errors().Count, "1 error"); }
public virtual void TestGetAttributeNameValuePairsForValidII_BUSVER() { Identifier ii = new Identifier("11.22.33.44", "extensionString", "a_version_string"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.BUSVER", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false ); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(4, result.Count, "map size"); Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors"); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "version", "a_version_string"); AssertKeyValuePairInMap(result, "use", "BUS"); }
public virtual void TestGetAttributeNameValuePairsIntegerNegative() { string integerValue = "-1"; Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "name", "INT", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.REQUIRED, null, false); Int32?integer = System.Convert.ToInt32(integerValue); IDictionary <string, string> result = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, integer, new INTImpl(integer)); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual(integerValue, result.SafeGet("value"), "value as expected"); context.GetModelToXmlResult().ClearErrors(); string output = new IntR2PropertyFormatterTest.TestableIntR2PropertyFormatter().Format(context, new INTImpl(integer)); Assert.AreEqual("<name value=\"-1\"/>", output.Trim(), "xml output as expected"); Assert.IsTrue(context.GetModelToXmlResult().IsValid()); }
public virtual void TestGetAttributeNameValuePairsForInvalidII_OID_shouldNotHaveExtension() { Identifier ii = new Identifier("11.22.33.44", "shouldNotBeHere"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.OID", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(3, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty()); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("Attribute \"extension\" is not allowed for II.OID", modelToXmlResult.GetHl7Errors()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "shouldNotBeHere"); AssertKeyValuePairInMap(result, "use", "BUS"); }
public virtual void TestGetAttributeNameValuePairsForValidII_VERforCerx() { string uuid = UUID.RandomUUID().ToString(); Identifier ii = new Identifier(uuid); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_VER; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.VER", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(2, result.Count, "map size"); Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors"); AssertKeyValuePairInMap(result, "root", uuid); AssertKeyValuePairInMap(result, "use", "VER"); }
private void HandleTranslation(CodedTypeR2 <Code> codedType, int indentLevel, StringBuilder result, FormatContext context) { // translation (LIST<CD>) if (HasTranslation(codedType)) { if (TranslationAllowed()) { FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("CD", "translation", context); foreach (CodedTypeR2 <Code> translation in codedType.Translation) { CD_R2 <Code> cdAny = new CD_R2Impl <Code>(translation); cdAny.NullFlavor = translation.NullFlavorForTranslationOnly; string transationString = CreateTranslation(translation, cdAny, indentLevel, newContext); result.Append(transationString); } } } }
public virtual void TestGetAttributeNameValuePairsForInvalidII_OID() { UUID randomUUID = UUID.RandomUUID(); Identifier ii = new Identifier(randomUUID.ToString()); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.OID", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(2, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty()); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("The oid, \"" + randomUUID.ToString() + "\" does not appear to be a valid oid", modelToXmlResult.GetHl7Errors ()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", randomUUID.ToString()); AssertKeyValuePairInMap(result, "use", "BUS"); }
public virtual void TestGetAttributeNameValuePairsForInvalidII_OID_rootTooLong() { string tooLongRoot = "12345678900.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789"; Identifier ii = new Identifier(tooLongRoot); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.OID", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(2, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty()); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("root '" + tooLongRoot + "' exceeds maximum allowed length of 200.", modelToXmlResult.GetHl7Errors()[0].GetMessage ()); AssertKeyValuePairInMap(result, "root", tooLongRoot); AssertKeyValuePairInMap(result, "use", "BUS"); }
public virtual void TestGetAttributeNameValuePairsForInvalidIIAsUuid() { UUID randomUUID = UUID.RandomUUID(); string root = randomUUID.ToString() + "_zyx"; Identifier ii = new Identifier(root); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiR2PropertyFormatterTest.TestableIiR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(1, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty()); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("root '" + root + "' must conform to be either a UUID, RUID, or OID.", modelToXmlResult.GetHl7Errors()[0] .GetMessage()); AssertKeyValuePairInMap(result, "root", root); }
public virtual void TestIvlTs() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate dateLow = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPatternLow = new DateWithPattern(dateLow, "yyyyMMdd"); PlatformDate dateHigh = DateUtil.GetDate(2012, 6, 8); DateWithPattern dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd"); Interval <PlatformDate> ivlTs = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh ); DateInterval dateInterval = new DateInterval(ivlTs); BareANY dataType = new IVLTSCDAR1Impl(dateInterval); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "ivl", "IVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion .R02_04_03, null, null, null, null, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsTrue(result.IsValid()); string expected = "<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>"; AssertXml("pivl output", expected, xml, true); }
private void WriteThumbnail(EncapsulatedData encapsulatedData, StringBuilder buffer, int indentLevel, FormatContext context ) { EncapsulatedData thumbnail = encapsulatedData.Thumbnail; if (thumbnail != null) { if (thumbnail.Thumbnail != null) { RecordError("For ED types, the thumbnail property itself cannot also have a thumbnail", context); } ED <EncapsulatedData> thumbnailWrapper = new EDImpl <EncapsulatedData>(thumbnail); FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("ED", "thumbnail", context ); string formattedThumbnail = this.Format(newContext, thumbnailWrapper, indentLevel); if (StringUtils.IsNotBlank(formattedThumbnail)) { buffer.Append(formattedThumbnail); } } }
public virtual void TestGetAttributeNameValuePairsForII_InvalidSpecializationType() { Identifier ii = new Identifier("11.22.33.44", "extensionString"); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_BUS_AND_VER; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(2, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty(), "errors"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("Invalid specializationType (II.BUS_AND_VER). Field being left as II without a specializationType.", modelToXmlResult .GetHl7Errors()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); }
public virtual void TestGetAttributeNameValuePairsForInvalidII_PUBLIC() { Identifier ii = new Identifier("11.22.33.44", "extensionStrngTooLong"); II iiHl7 = new IIImpl(); ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.PUBLIC", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false ); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(4, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty(), "errors"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("extension 'extensionStrngTooLong' exceeds maximum allowed length of 20.", modelToXmlResult.GetHl7Errors( )[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionStrngTooLong"); AssertKeyValuePairInMap(result, "use", "BUS"); AssertKeyValuePairInMap(result, "displayable", "true"); }
public virtual void TestGetAttributeNameValuePairsForII_BUS_UnnecessarySpecializationType() { Identifier ii = new Identifier("11.22.33.44", "extensionString"); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_OID; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.BUS", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(3, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty(), "errors"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count); Assert.AreEqual("A specializationType should not be specified for non-abstract type: II.BUS", modelToXmlResult.GetHl7Errors ()[0].GetMessage()); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "use", "BUS"); }
protected override string FormatNonNullValue(FormatContext context, EntityName value, int indentLevel) { // this code is delegating to the appropriate formatter based on the type of the // object set as the value; specializationType needs to also be set, but we can infer it // (note that this is a bit different from how other formatters treat abstract types) if (value == null || value.GetType().IsAssignableFrom(typeof(EntityName))) { return(base.FormatNonNullValue(context, value, indentLevel)); } else { if (value.GetType().IsAssignableFrom(typeof(TrivialName))) { context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("TN", true, context); return(this.tnPropertyFormatter.Format(context, new TNImpl((TrivialName)value), indentLevel)); } else { if (value.GetType().IsAssignableFrom(typeof(PersonName))) { context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("PN", true, context); return(this.pnPropertyFormatter.Format(context, new PNImpl((PersonName)value), indentLevel)); } else { if (value.GetType().IsAssignableFrom(typeof(OrganizationName))) { context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("ON", true, context); return(this.onPropertyFormatter.Format(context, new ONImpl((OrganizationName)value), indentLevel)); } else { throw new ArgumentException("EN can not handle values of type " + value.GetType()); } } } } }
public virtual void TestPivlPhasePeriod() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate dateLow = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPatternLow = new DateWithPattern(dateLow, "yyyyMMdd"); PlatformDate dateHigh = DateUtil.GetDate(2012, 6, 8); DateWithPattern dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd"); Interval <PlatformDate> phase = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh ); PhysicalQuantity period = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .DAY); PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2(phase, period); BareANY dataType = new PIVLTSCDAR1Impl(pivl); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "pivl", "PIVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion.R02_04_03, null, null, null, null, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsTrue(result.IsValid()); string expected = "<pivl><period unit=\"d\" value=\"1\"/><phase><low value=\"20120503\"/><high value=\"20120708\"/></phase></pivl>"; AssertXml("pivl output", expected, xml, true); }
public virtual void TestGetAttributeNameValuePairsForValidII() { Identifier ii = new Identifier("11.22.33.44", "extensionString"); ii.AssigningAuthorityName = "aaName"; ii.Displayable = "d_true"; II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false); IDictionary <string, string> result = new IiR2PropertyFormatterTest.TestableIiR2PropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(4, result.Count, "map size"); Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors"); AssertKeyValuePairInMap(result, "root", "11.22.33.44"); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "assigningAuthorityName", "aaName"); AssertKeyValuePairInMap(result, "displayable", "d_true"); }
public virtual void TestGetAttributeNameValuePairsForValidII_BUSforCerxWithInvalidRoot() { Identifier ii = new Identifier("123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1" , "extensionString"); II iiHl7 = new IIImpl(); iiHl7.DataType = StandardDataType.II_BUS; ModelToXmlResult modelToXmlResult = new ModelToXmlResult(); Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (modelToXmlResult, null, "name", "II.BUS", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false); IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest (context, ii, iiHl7); Assert.AreEqual(3, result.Count, "map size"); Assert.IsFalse(modelToXmlResult.GetHl7Errors().IsEmpty(), "1 error"); Assert.AreEqual(1, modelToXmlResult.GetHl7Errors().Count, "1 error"); Assert.IsTrue(modelToXmlResult.GetHl7Errors()[0].GetMessage().Contains("200")); AssertKeyValuePairInMap(result, "root", "123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1" ); AssertKeyValuePairInMap(result, "extension", "extensionString"); AssertKeyValuePairInMap(result, "use", "BUS"); }
protected override string FormatNonNullDataType(FormatContext context, BareANY dataType, int indentLevel) { UncertainRange <PhysicalQuantity> value = (UncertainRange <PhysicalQuantity>)dataType.BareValue; // convert URG to an IVL and use IVL formatter (loses any inclusive info; we'll pull that out later) Interval <PhysicalQuantity> convertedInterval = IntervalFactory.CreateFromUncertainRange(value); IVLImpl <PQ, Interval <PhysicalQuantity> > convertedHl7Interval = new IVLImpl <PQ, Interval <PhysicalQuantity> >(convertedInterval ); FormatContext ivlContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(context.Type.Replace ("URG", "IVL"), context.IsSpecializationType(), context); string xml = this.formatter.Format(ivlContext, convertedHl7Interval, indentLevel); xml = ChangeAnyIvlRemnants(xml); xml = AddOriginalText(xml, dataType, indentLevel); // add in inclusive attributes if necessary if (value.LowInclusive != null) { xml = AddInclusiveAttribute(xml, "low", value.LowInclusive); } if (value.HighInclusive != null) { xml = AddInclusiveAttribute(xml, "high", value.HighInclusive); } return(xml); }
private void RenderNonStructuralAttribute(AttributeBridge tealBean, Relationship relationship, ConstrainedDatatype constraints , TimeZoneInfo dateTimeZone, TimeZoneInfo dateTimeTimeZone) { string propertyPath = BuildPropertyPath(); BareANY hl7Value = tealBean.GetHl7Value(); string type = DetermineActualType(relationship, hl7Value, this.result, propertyPath); PropertyFormatter formatter = this.formatterRegistry.Get(type); if (formatter == null) { throw new RenderingException("Cannot support properties of type " + type); } else { string xmlFragment = string.Empty; try { BareANY any = null; bool isMandatoryOrPopulated = ConformanceLevelUtil.IsMandatory(relationship) || ConformanceLevelUtil.IsPopulated(relationship ); if (relationship.HasFixedValue()) { // suppress rendering fixed values for optional or required if (isMandatoryOrPopulated) { any = (BareANY)DataTypeFactory.CreateDataType(relationship.Type, this.isCda && this.isR2); object fixedValue = NonStructuralHl7AttributeRenderer.GetFixedValue(relationship, version, this.isR2, this.result, propertyPath ); ((BareANYImpl)any).BareValue = fixedValue; } } else { any = hl7Value; any = this.adapterProvider.GetAdapter(any != null ? any.GetType() : null, type).Adapt(type, any); } // TODO - CDA - TM - implement default value handling // boolean valueNotProvided = (any.getBareValue() == null && !any.hasNullFlavor()); // if (valueNotProvided && relationship.hasDefaultValue() && isMandatoryOrPopulated) { // // FIXME - CDA - TM - this doesn't work - will have a class cast exception (put Object convert(Object/String?) on ANY, implement trivial in ANYImpl, implement where necessary?) // // any.setBareValue(relationship.getDefaultValue()); // } if (hl7Value != null && Hl7ValueHasContent(hl7Value)) { HandleNotAllowedAndIgnored(relationship, propertyPath); } FormatContext context = Ca.Infoway.Messagebuilder.Marshalling.FormatContextImpl.Create(this.result, propertyPath, relationship , version, dateTimeZone, dateTimeTimeZone, constraints, this.isCda); if (!StringUtils.Equals(type, relationship.Type)) { context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, true, context); } xmlFragment += formatter.Format(context, any, GetIndent()); // if relationship specifies a namespace, need to add it to xml if (StringUtils.IsNotBlank(xmlFragment) & StringUtils.IsNotBlank(relationship.Namespaze)) { xmlFragment = System.Text.RegularExpressions.Regex.Replace(xmlFragment, "<" + relationship.Name + " ", "<" + relationship .Namespaze + ":" + relationship.Name + " "); xmlFragment = System.Text.RegularExpressions.Regex.Replace(xmlFragment, "<" + relationship.Name + ">", "<" + relationship .Namespaze + ":" + relationship.Name + ">"); xmlFragment = System.Text.RegularExpressions.Regex.Replace(xmlFragment, "</" + relationship.Name + ">", "</" + relationship .Namespaze + ":" + relationship.Name + ">"); } } catch (ModelToXmlTransformationException e) { Hl7Error hl7Error = new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, e.Message, propertyPath); this.result.AddHl7Error(hl7Error); } RenderNewErrorsToXml(CurrentBuffer().GetChildBuilder()); CurrentBuffer().GetChildBuilder().Append(xmlFragment); } }