Exemple #1
0
        public virtual void TestGetAttributeNameValuePairsForValidII_PUBLIC()
        {
            Identifier       ii               = new Identifier("11.22.33.44", "extensionString");
            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.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors");
            AssertKeyValuePairInMap(result, "root", "11.22.33.44");
            AssertKeyValuePairInMap(result, "extension", "extensionString");
            AssertKeyValuePairInMap(result, "use", "BUS");
            AssertKeyValuePairInMap(result, "displayable", "true");
        }
Exemple #2
0
        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");
        }
Exemple #3
0
        public virtual void TestGetAttributeNameValuePairsForDateWithPattern()
        {
            // used as expected: a date object is passed in
            PlatformDate    calendar        = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            DateWithPattern dateWithPattern = new DateWithPattern(calendar, "yyyyMM");

            // note that a Date and a DateWithPattern only work for equals() because the
            // Java implementation we are using uses "instanceof" instead of "getClass()" for its preliminary comparison
            Assert.AreEqual(calendar, dateWithPattern, "same dates should be equal");
            ModelToXmlResult             xmlResult = new ModelToXmlResult();
            IDictionary <string, string> result    = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATE", null, null
                                                                                                                                    , false, SpecificationVersion.R02_04_02, null, null, null, false), dateWithPattern, null);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("199904", result.SafeGet("value"), "value as expected");
            Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty());
        }
Exemple #4
0
        public virtual void TestGetAttributeNameValuePairsDateWithOperatorNotAllowed()
        {
            // used as expected: a date object is passed in
            PlatformDate calendar1 = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            TS_R2        ts        = new TS_R2Impl(new MbDate(calendar1));

            ts.Operator = SetOperator.PERIODIC_HULL;
            ModelToXmlResult             xmlResult = new ModelToXmlResult();
            IDictionary <string, string> result    = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS", null, null, false
                                                                                                                                    , SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(calendar1), ts);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            string expectedValue = "19990423101112.0000" + GetCurrentTimeZone(calendar1);

            Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected");
            Assert.IsFalse(xmlResult.IsValid());
            Assert.AreEqual(1, xmlResult.GetHl7Errors().Count);
        }
Exemple #5
0
        public virtual ModelToXmlResult TransformToHl7(VersionNumber version, IInteraction messageBean, TimeZoneInfo dateTimeZone
                                                       , TimeZoneInfo dateTimeTimeZone, GenericCodeResolverRegistry codeResolverRegistryOverride)
        {
            CodeResolverRegistry.SetThreadLocalVersion(version);
            CodeResolverRegistry.SetThreadLocalCodeResolverRegistryOverride(codeResolverRegistryOverride);
            XmlRenderingVisitor visitor = new XmlRenderingVisitor(this.service.IsR2(version), this.service.IsCda(version), version);

            // TODO: Since the two boolean flags are derived from the version, we chould simplify this interface
            new TealBeanRenderWalker(messageBean, version, dateTimeZone, dateTimeTimeZone, this.service).Accept(visitor);
            CodeResolverRegistry.ClearThreadLocalVersion();
            CodeResolverRegistry.ClearThreadLocalCodeResolverRegistryOverride();
            ModelToXmlResult result = visitor.ToXml();

            if (this.service.IsCda(version))
            {
                PerformAdditionalCdaValidation(version, result.GetXmlMessage(), result);
            }
            if (!result.IsValid() && IsStrict())
            {
                throw new InvalidRenderInputException(result.GetHl7Errors());
            }
            return(result);
        }
Exemple #6
0
        public virtual void TestGetAttributeNameValuePairsForValidII_BUS_AND_VER_BUSforCerxWithNewMaxRoot()
        {
            Identifier ii = new Identifier("123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1234567890"
                                           , "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_AND_VER", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false
                                                                                                );
            IDictionary <string, string> result = new IiPropertyFormatterTest.TestableIiPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (context, ii, iiHl7);

            Assert.AreEqual(5, result.Count, "map size");
            Assert.IsTrue(modelToXmlResult.GetHl7Errors().IsEmpty(), "no errors");
            AssertKeyValuePairInMap(result, "root", "123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.1234567890"
                                    );
            AssertKeyValuePairInMap(result, "extension", "extensionString");
            AssertKeyValuePairInMap(result, "use", "BUS");
            AssertKeyValuePairInMap(result, "specializationType", "II.BUS");
            AssertKeyValuePairInMap(result, "xsi:type", "II");
        }