示例#1
0
        public void ShouldAddToHl7List()
        {
            Object list = new LISTImpl <ST, String>(typeof(STImpl)).BareValue;

            ListElementUtil.AddElement(list, new STImpl("Betty"));
            Assert.AreEqual(1, ListElementUtil.Count(list), "count");
        }
示例#2
0
        public void ShouldGetElementFromHl7List()
        {
            IList <String> list = new LISTImpl <ST, String>(typeof(STImpl)).RawList();

            list.Add("Fred");
            list.Add("Barney");
            list.Add("Wilma");

            Assert.AreEqual("Barney", ListElementUtil.GetElement(list, 1), "element");
        }
示例#3
0
        public void ShouldNotLogInfoMessageForUseOfIgnoredNonStructuralAttributeWhenListIsEmpty()
        {
            LIST <II, Identifier> idList       = new LISTImpl <II, Identifier>(typeof(IIImpl));
            Relationship          relationship = CreateNonStructuralRelationship();

            relationship.Conformance = ConformanceLevel.IGNORED;

            ExerciseVisitorOverInteractionWithAttribute(idList, relationship);

            Assert.IsFalse(StringUtils.Contains(this.visitor.ToXml().GetXmlMessage(), "Attribute is ignored and will not be used"));
        }
示例#4
0
        public virtual void ShouldAdaptListCorrectly()
        {
            IIImpl ii = new IIImpl(new Identifier("1", "2"));
            LIST <IIImpl, Identifier> list = new LISTImpl <IIImpl, Identifier>(typeof(IIImpl));

            list.Value.Add(ii);
            BareANY adapted = this.adapter.Adapt("II", list);

            Assert.IsTrue(adapted is II);
            Assert.IsTrue(adapted == ii);
        }
示例#5
0
        public void ShouldAddToHl7RawList()
        {
            IList <String> list = new LISTImpl <ST, String>(typeof(STImpl)).RawList();

            list.Add("Fred");
            list.Add("Barney");
            list.Add("Wilma");

            ListElementUtil.AddElement(list, "Betty");
            Assert.AreEqual(4, list.Count, "count");
            Assert.IsTrue(list.Contains("Betty"));
        }
示例#6
0
        public virtual void ShouldAdaptListCorrectly()
        {
            LIST <ST, string> list = new LISTImpl <ST, string>(typeof(STImpl));

            list.RawList().Add("text1");
            list.RawList().Add("text2");
            BareANY adapted = this.adapter.Adapt("SET<TN>", list);

            Assert.IsTrue(adapted is SET <TNImpl, TrivialName>, "type");
            LinkedSet <TNImpl> set = (LinkedSet <TNImpl>)adapted.BareValue;

            Assert.AreEqual(2, set.Count, "size");
            Assert.IsTrue(EveryItemTN(set), "all TNs");
            Assert.IsTrue(HasItemWithValue(set, "text1"));
            Assert.IsTrue(HasItemWithValue(set, "text2"));
        }
示例#7
0
        public virtual void TestFormatValueNonNull()
        {
            string result = new BagR2PropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                          (new ModelToXmlResult(), null, "telecom", "BAG<TEL>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality
                                                                                          .Create("1-4"), false, SpecificationVersion.R02_04_03, null, null, null, false), (BareANY)LISTImpl <ANY <object>, object> .
                                                                                      Create <TEL, TelecommunicationAddress>(typeof(TELImpl), CreateTelecommunicationAddressList()));

            AssertXml("non null", "<telecom value=\"+1-519-555-2345;ext=12345\"/>" + "<telecom value=\"+1-416-555-2345;ext=12345\"/>"
                      , result);
        }
示例#8
0
        public virtual void TestFormatWithMissingConstraint()
        {
            Relationship rootConstraint = new Relationship();

            rootConstraint.Name       = "root";
            rootConstraint.FixedValue = "1.22.33.44";
            Relationship extConstraint = new Relationship();

            extConstraint.Name       = "extension";
            extConstraint.FixedValue = "1223344";
            ConstrainedDatatype constraints = new ConstrainedDatatype("iiConstraint", "II");

            constraints.Relationships.Add(rootConstraint);
            constraints.Relationships.Add(extConstraint);
            string result = new ListR2PropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                           (this.result, null, "ids", "LIST<II>", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality.Create
                                                                                               ("0-4"), false, SpecificationVersion.R02_04_03, null, null, null, constraints, false), (BareANY)LISTImpl <ANY <object>, object
                                                                                                                                                                                                         > .Create <II, Identifier>(typeof(IIImpl), CreateIdentifierList()));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual(ErrorLevel.INFO, this.result.GetHl7Errors()[0].GetHl7ErrorLevel());
            Assert.AreEqual(Hl7ErrorCode.CDA_FIXED_CONSTRAINT_PROVIDED, this.result.GetHl7Errors()[0].GetHl7ErrorCode());
            Assert.AreEqual("A fixed constraint was added for compliance: root={1.22.33.44},extension={1223344}", this.result.GetHl7Errors
                                ()[0].GetMessage());
            AssertXml("non null", "<ids extension=\"123\" root=\"1.2.3\"/>" + "<ids extension=\"256\" root=\"2.5.6\"/>" + "<ids extension=\"1223344\" root=\"1.22.33.44\"/>"
                      , result);
        }
示例#9
0
        public virtual void TestFormatValueNonNull()
        {
            string result = new ListR2PropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                           (this.result, null, "ids", "LIST<II>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality.Create("0-4"
                                                                                                                                                                                                              ), false, SpecificationVersion.R02_04_03, null, null, null, false), (BareANY)LISTImpl <ANY <object>, object> .Create <II, Identifier
                                                                                                                                                                                                                                                                                                                                    >(typeof(IIImpl), CreateIdentifierList()));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual(0, this.result.GetHl7Errors().Count);
            AssertXml("non null", "<ids extension=\"123\" root=\"1.2.3\"/>" + "<ids extension=\"256\" root=\"2.5.6\"/>", result);
        }
示例#10
0
        public virtual void TestFormatValueNonNull()
        {
            string result = new ListPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                         (new ModelToXmlResult(), null, "name", "LIST<EN>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality.
                                                                                         Create("0-4"), false, SpecificationVersion.R02_04_02, null, null, null, false), (BareANY)LISTImpl <ANY <object>, object> .Create
                                                                                     <EN <EntityName>, EntityName>(typeof(ENImpl <EntityName>), CreateEntityNameList()));

            Assert.AreEqual("<name xsi:type=\"PN\"><family>Flinstone</family><given>Fred</given></name>" + SystemUtils.LINE_SEPARATOR
                            + "<name xsi:type=\"PN\"><family>Flinstone</family><given>Wilma</given></name>" + SystemUtils.LINE_SEPARATOR, result, "non null"
                            );
        }
示例#11
0
        public virtual void TestConvertToBareANYCollectionType()
        {
            var first  = new CodedTypeR2 <UnitsOfMeasureCaseSensitive>(Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.CUP);
            var second = new CodedTypeR2 <UnitsOfMeasureCaseSensitive>(Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.DECALITRE);
            var third  = new CodedTypeR2 <UnitsOfMeasureCaseSensitive>(Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.GALLON);

            LIST <CD_R2 <UnitsOfMeasureCaseSensitive>, CodedTypeR2 <UnitsOfMeasureCaseSensitive> > list =
                new LISTImpl <CD_R2 <UnitsOfMeasureCaseSensitive>, CodedTypeR2 <UnitsOfMeasureCaseSensitive> >(typeof(CD_R2Impl <UnitsOfMeasureCaseSensitive>));

            list.RawList().Add(first);
            list.RawList().Add(second);
            list.RawList().Add(third);

            ICollection <BareANY> bareANYCollection = GenericClassUtil.ConvertToBareANYCollection(list);
            IEnumerator <BareANY> enumerator        = bareANYCollection.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreSame(first, enumerator.Current.BareValue);
            enumerator.MoveNext();
            Assert.AreSame(second, enumerator.Current.BareValue);
            enumerator.MoveNext();
            Assert.AreSame(third, enumerator.Current.BareValue);
        }