Exemple #1
0
        public virtual void TestIvlTsConstraintsInvalid()
        {
            XmlToModelResult    result      = new XmlToModelResult();
            XmlNode             node        = CreateNode("<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>");
            ConstrainedDatatype constraints = new ConstrainedDatatype("ivl", "IVL<TS>");

            constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0")));
            constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0")));
            ParseContext context = ParseContextImpl.Create("IVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), constraints, true);
            BareANY                 parseResult         = this.parser.Parse(context, Arrays.AsList(node), result);
            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> expectedIvl         = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsFalse(result.IsValid());
            Assert.AreEqual(2, result.GetHl7Errors().Count);
            Assert.IsTrue(parseResult is IVLTSCDAR1);
            DateInterval ivl = (DateInterval)parseResult.BareValue;

            Assert.AreEqual(expectedIvl, ivl.Interval);
        }
Exemple #2
0
        public virtual void TestIvlTsWithConstraintsInValid()
        {
            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);
            ConstrainedDatatype constraints  = new ConstrainedDatatype("ivl", "IVL<TS>");

            constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0")));
            constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0")));
            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, constraints, true);
            string xml = this.formatter.Format(formatContext, dataType);

            Assert.IsFalse(result.IsValid());
            Assert.AreEqual(2, result.GetHl7Errors().Count);
            string expected = "<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>";

            AssertXml("ivl output", expected, xml, true);
        }
Exemple #3
0
        private ConstrainedDatatype CreateConstraints(bool referenceMandatory)
        {
            //        <relationship name="reference" attribute="false" cardinality="1"/>
            //        <relationship name="reference.value" attribute="false" cardinality="1"/>
            //
            //        <relationship name="reference" attribute="false" cardinality="0-1"/>
            //        <relationship name="reference.value" attribute="false" cardinality="1"/>
            //
            //        <relationship name="mediaType" attribute="false" cardinality="1" fixedValue="application/dicom"/>
            //        <relationship name="reference" attribute="false" cardinality="1"/>
            ConstrainedDatatype constraints = new ConstrainedDatatype("MessagePart.relationshipName", "ED");

            constraints.SetRestriction();
            Relationship referenceConstraint = new Relationship("reference", null, Cardinality.Create(referenceMandatory ? "1" : "0-1"
                                                                                                      ));

            constraints.Relationships.Add(referenceConstraint);
            Relationship referenceValueConstraint = new Relationship("reference.value", null, Cardinality.Create("1"));

            constraints.Relationships.Add(referenceValueConstraint);
            Relationship mediaTypeConstraint = new Relationship("mediaType", null, Cardinality.Create("1"));

            mediaTypeConstraint.FixedValue = "application/dicom";
            constraints.Relationships.Add(mediaTypeConstraint);
            return(constraints);
        }
Exemple #4
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\" " + "xmlns:cda=\"urn:hl7-org:v3\" xmlns:sdtc=\"urn:hl7-org:sdtc\">"
                                      + "<effectiveTime xsi:type=\"IVL_TS\"><low value=\"20120512\"/><high value=\"20120512\"/></effectiveTime>" + "<effectiveTime xsi:type=\"PIVL_TS\" institutionSpecified=\"true\" operator=\"A\"><period value=\"1\" unit=\"h\"/></effectiveTime>"
                                      + "</top>");
            ParseContext parseContext = ParseContextImpl.Create("LIST<SXCM<TS>>", null, SpecificationVersion.CCDA_R1_1, null, null, null
                                                                , Cardinality.Create("0-4"), null, true);
            BareANY result = new ListR2ElementParser(this.parserR2Registry).Parse(parseContext, AsList(node.ChildNodes), this.xmlResult
                                                                                  );

            Assert.IsTrue(this.xmlResult.IsValid());
            IList <MbDate> list = ((LIST <SXCM_R2 <MbDate>, MbDate>)result).RawList();

            Assert.IsNotNull(list, "null");
            Assert.AreEqual(2, list.Count, "size");
            DateInterval firstValue = (DateInterval)list[0];

            AssertDateEquals("low", "yyyyMMdd", ParseDate("2012-05-12"), firstValue.Interval.Low);
            AssertDateEquals("high", "yyyyMMdd", ParseDate("2012-05-12"), firstValue.Interval.High);
            PeriodicIntervalTimeR2 secondValue = (PeriodicIntervalTimeR2)list[1];

            Assert.AreEqual(true, secondValue.InstitutionSpecified);
            Assert.AreEqual(new BigDecimal("1"), secondValue.Period.Quantity);
            Assert.AreEqual("h", secondValue.Period.Unit.CodeValue);
        }
Exemple #5
0
        public virtual void TestPivlPhasePeriod()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><period unit=\"d\" value=\"1\"/><phase><low value=\"20120503\"/><high value=\"20120708\"/></phase></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult    = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedPeriod = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                   .DAY);
            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> expectedPhase       = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedPeriod.Quantity, pivl.Period.Quantity);
            Assert.AreEqual(expectedPeriod.Unit.CodeValue, pivl.Period.Unit.CodeValue);
            Assert.AreEqual(expectedPhase, pivl.Phase);
            Assert.IsNull(pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.FrequencyQuantity);
        }
Exemple #6
0
        public virtual void ShouldHandleInlinedPropertiesWithMapByPartTypeAndWithout()
        {
            RelationshipSorter sorter = RelationshipSorter.Create(string.Empty, new MockMultiplyCompoundNestedMappedMessagePartBean()
                                                                  );
            Relationship organizationInMapByPartTypeRelationship = new Relationship("representedOrganization", "COCT_MT090102CA.Organization"
                                                                                    , Cardinality.Create("1"));
            Relationship organizationNotInMapByPartTypeRelationship = new Relationship("representedOrganization", "MOCK_MT090102CA.Organization"
                                                                                       , Cardinality.Create("1"));
            Relationship assignedOrganizationInMapByPartTypeRelationship = new Relationship("assignedOrganization", "COCT_MT260030CA.Organization"
                                                                                            , Cardinality.Create("1"));
            Relationship nameRelationship    = new Relationship("name", "ST", Cardinality.Create("1"));
            Relationship idRelationship      = new Relationship("id", "II", Cardinality.Create("1"));
            Relationship otherIdRelationship = new Relationship("otherId", "II", Cardinality.Create("1"));
            // >>>>>>>>>>>>>>>>>>
            object @object = sorter.Get(organizationInMapByPartTypeRelationship);

            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            RelationshipSorter innerSorter = (RelationshipSorter)@object;

            @object = innerSorter.Get(nameRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "assignedOrganizationName", @object);
            @object = innerSorter.Get(idRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property id", "organizationIdentifier", @object);
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNull(@object, "type does not exists");
            // >>>>>>>>>>>>>>>>>>
            @object = sorter.Get(organizationNotInMapByPartTypeRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            innerSorter = (RelationshipSorter)@object;
            @object     = innerSorter.Get(nameRelationship);
            Assert.IsNull(@object, "type does not exist");
            @object = innerSorter.Get(idRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property id", "organizationIdentifier", @object);
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNull(@object, "type does not exist");
            // >>>>>>>>>>>>>>>>>>
            @object = sorter.Get(assignedOrganizationInMapByPartTypeRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            innerSorter = (RelationshipSorter)@object;
            @object     = innerSorter.Get(nameRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "assignedOrganizationName", @object);
            @object = innerSorter.Get(idRelationship);
            Assert.IsNull(@object, "type should not exist");
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("other property id", "otherOrganizationIdentifier", @object);
        }
Exemple #7
0
        public virtual void ShouldWriteMultipleCardinalityAttribute()
        {
            BeanBPrime  beanB   = new BeanBPrime();
            BeanWrapper wrapper = new BeanWrapper(beanB);

            wrapper.Write(new Relationship("text", "ST", Cardinality.Create("0-10")), "This is my text");
            Assert.AreEqual("This is my text", beanB.Text[0], "text");
        }
Exemple #8
0
        public virtual void ShouldWriteSimpleAttribute()
        {
            BeanB       beanB   = new BeanB();
            BeanWrapper wrapper = new BeanWrapper(beanB);

            wrapper.Write(new Relationship("text", "ST", Cardinality.Create("0-1")), "This is my text");
            Assert.AreEqual("This is my text", beanB.Text, "text");
        }
Exemple #9
0
        private PhysicalQuantity ParseDenominator(ParseContext context, XmlElement numerator, XmlToModelResult xmlToModelResult)
        {
            ElementParser parser     = ParserRegistry.GetInstance().Get("PQ.TIME");
            ParseContext  subContext = ParseContextImpl.Create("PQ.TIME", typeof(PhysicalQuantity), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                               .MANDATORY, Cardinality.Create("1"), context);

            return((PhysicalQuantity)parser.Parse(subContext, Arrays.AsList((XmlNode)numerator), xmlToModelResult).BareValue);
        }
Exemple #10
0
        private Int32?ParseNumerator(ParseContext context, XmlElement numerator, XmlToModelResult xmlToModelResult)
        {
            ElementParser parser     = ParserRegistry.GetInstance().Get("INT.NONNEG");
            ParseContext  subContext = ParseContextImpl.Create("INT.NONNEG", typeof(Int32?), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                               .MANDATORY, Cardinality.Create("1"), context);

            return((Int32?)parser.Parse(subContext, Arrays.AsList((XmlNode)numerator), xmlToModelResult).BareValue);
        }
Exemple #11
0
        public virtual void ShouldWriteSimpleAssociation()
        {
            BeanB       beanB   = new BeanB();
            BeanC       beanC   = new BeanC();
            BeanWrapper wrapper = new BeanWrapper(beanC);

            wrapper.Write(new Relationship("textHolder", "ABCD_IN123456CA.BeanB", Cardinality.Create("0-1")), beanB);
            Assert.IsNotNull(beanC.BeanB, "bean b");
        }
Exemple #12
0
        private PeriodicIntervalTime ParseFrequency(ParseContext context, XmlToModelResult xmlToModelResult, XmlElement durationElement
                                                    )
        {
            ParseContext subContext = ParseContextImpl.Create("PIVL<TS.DATETIME>", typeof(PeriodicIntervalTime), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                              .MANDATORY, Cardinality.Create("1"), context);

            return((PeriodicIntervalTime)ParserRegistry.GetInstance().Get("PIVL<TS.DATETIME>").Parse(subContext, Arrays.AsList((XmlNode
                                                                                                                                )durationElement), xmlToModelResult).BareValue);
        }
Exemple #13
0
        private Interval <PlatformDate> ParseDuration(ParseContext context, XmlToModelResult xmlResult, XmlElement durationElement
                                                      )
        {
            ParseContext subContext = ParseContextImpl.Create("IVL<TS.FULLDATE>", typeof(Interval <object>), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                              .MANDATORY, Cardinality.Create("1"), context);

            return((Interval <PlatformDate>)ParserRegistry.GetInstance().Get("IVL<TS.FULLDATE>").Parse(subContext, Arrays.AsList((XmlNode
                                                                                                                                  )durationElement), xmlResult).BareValue);
        }
Exemple #14
0
        private Interval <PhysicalQuantity> ParseDenominatorSk(ParseContext context, XmlElement numerator, XmlToModelResult xmlToModelResult
                                                               )
        {
            // TM - Unsure if SK is allowed to send in any kind of PQ, or only specific ones. Picked PQ.BASIC to cover most scenarios.
            ElementParser parser     = ParserRegistry.GetInstance().Get("IVL<PQ.BASIC>");
            ParseContext  subContext = ParseContextImpl.Create("IVL<PQ.BASIC>", typeof(PhysicalQuantity), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                               .MANDATORY, Cardinality.Create("1"), context);

            return((Interval <PhysicalQuantity>)parser.Parse(subContext, Arrays.AsList((XmlNode)numerator), xmlToModelResult).BareValue);
        }
Exemple #15
0
        public virtual void ShouldCopyOriginalTextFromCVImplObjectToBean()
        {
            BeanD       beanD   = new BeanD();
            BeanWrapper wrapper = new BeanWrapper(beanD);
            CVImpl      cvImpl  = new CVImpl(CodeResolverRegistry.Lookup <IntoleranceValue>("CODE"));

            cvImpl.OriginalText = ORIGINAL_TEXT;
            wrapper.Write(new Relationship("value", "CV", Cardinality.Create("0-1")), cvImpl);
            Assert.AreEqual(ORIGINAL_TEXT, ((CV)beanD.GetField("someCode")).OriginalText, "originalText");
        }
Exemple #16
0
        private ConstrainedDatatype CreateLowHighConstraints()
        {
            ConstrainedDatatype constraints = new ConstrainedDatatype("MessagePart.relationshipName", "IVL<TS>");

            constraints.SetRestriction();
            Relationship lowConstraint  = new Relationship("low", null, Cardinality.Create("1"));
            Relationship highConstraint = new Relationship("high", null, Cardinality.Create("1"));

            constraints.Relationships.Add(lowConstraint);
            constraints.Relationships.Add(highConstraint);
            return(constraints);
        }
Exemple #17
0
        public virtual void TestSxcmTs()
        {
            PlatformDate expectedDate = DateUtil.GetDate(2012, 4, 3);
            XmlNode      node         = CreateNode("<date operator=\"E\" value=\"20120503\"/>");
            ParseContext context      = ParseContextImpl.Create("SXCMTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY parseResult = this.parser.Parse(context, Arrays.AsList(node), this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsTrue(parseResult is SXCMTSCDAR1);
            Assert.IsTrue(parseResult.BareValue is MbDate);
            Assert.AreEqual(expectedDate, ((MbDate)parseResult.BareValue).Value);
        }
Exemple #18
0
        private ConstrainedDatatype CreateConstraints(bool isTemplateId)
        {
            string name = (isTemplateId ? "MessagePart.templateId" : "MessagePart.relationshipName");
            ConstrainedDatatype constraints = new ConstrainedDatatype(name, "II");

            constraints.SetRestriction();
            Relationship rootConstraint = new Relationship("root", null, Cardinality.Create("1"));

            rootConstraint.FixedValue = "1.2.3.4";
            Relationship extensionConstraint = new Relationship("extension", null, Cardinality.Create("1"));

            extensionConstraint.FixedValue = "1234";
            constraints.Relationships.Add(rootConstraint);
            constraints.Relationships.Add(extensionConstraint);
            return(constraints);
        }
Exemple #19
0
        /// <summary>
        /// Wrapper for Convert.ChangeType, to get around the issue of the said method not supporting
        /// Nullable types. This method simple extracts the unerlying type if it's Nullable based and
        /// then pass through to Convert.ChangeType.
        /// </summary>
        /// <param name="value">Value to be converted</param>
        /// <param name="conversionType">Type to convert to</param>
        /// <returns></returns>
        public static object ChangeType(object o, Type conversionType)
        {
            if (conversionType == null)
            {
                throw new ArgumentNullException("conversionType");
            }

            if (o == null)
            {
                return(null);
            }
            else if (conversionType.IsEnum)
            {
                string s = (string)o;
                return(System.Enum.Parse(conversionType, s));
            }
            else if (conversionType.Equals(typeof(Cardinality)))
            {
                string s = (string)o;
                return(Cardinality.Create(s));
            }
            else if (conversionType.IsSubclassOf(typeof(EnumPattern)))
            {
                return(EnumPattern.ValueOf <EnumPattern>(conversionType, (string)o));
            }
            else
            //
            // If it's not a nullable type, just pass through the parameters to Convert.ChangeType.
            //
            if (conversionType.IsGenericType &&
                conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable <>)))
            {
                if (o == null)
                {
                    return(null);
                }

                conversionType = Nullable.GetUnderlyingType(conversionType);
            }

            return(Convert.ChangeType(o, conversionType));
        }
Exemple #20
0
        public virtual void ShouldHandleCollapsedTypesWithOuterMultipleCardinality()
        {
            MessagePart partB = new MessagePart("ABCE_MT123456CA.BeanB");

            partB.Relationships.Add(new Relationship("text", "ST", Cardinality.Create("1")));
            MessagePart elidedPart = new MessagePart("ABCE_MT123456CA.ElidedPart");

            elidedPart.Relationships.Add(new Relationship("issue", "ABCE_MT123456CA.BeanB", Cardinality.Create("1")));
            mockService.AddPart(elidedPart.Name, elidedPart);
            mockService.AddPart(partB.Name, partB);
            BeanA bean = new BeanA();

            bean.Issues.Add(new BeanB());
            bean.Issues.Add(new BeanB());
            MessagePart  part = new MessagePart();
            Relationship subjectOfRelationship = new Relationship("subjectOf", "ABCE_MT123456CA.ElidedPart", Cardinality.Create("0-50"
                                                                                                                                ));

            Assert.IsTrue(subjectOfRelationship.Association, "association");
            part.Relationships.Add(subjectOfRelationship);
            PartBridge bridge = new BridgeFactoryImpl(this.mockService, VERSION).CreatePartBridgeFromBean("controlAct", bean, new Interaction
                                                                                                              (), new MessagePartHolder(part));

            Assert.AreEqual(1, bridge.GetRelationshipBridges().Count, "size");
            Assert.AreEqual("subjectOf", bridge.GetRelationshipBridges()[0].GetRelationship().Name, "name of relationship");
            BaseRelationshipBridge relationship = bridge.GetRelationshipBridges()[0];

            Assert.IsTrue(relationship.IsAssociation(), "association relationship");
            ICollection <PartBridge> values = ((AssociationBridge)relationship).GetAssociationValues();

            Assert.AreEqual(2, values.Count, "number of values");
            foreach (PartBridge partBridge in values)
            {
                IList <BaseRelationshipBridge> relationshipBridges = partBridge.GetRelationshipBridges();
                Assert.AreEqual(1, relationshipBridges.Count, "inner relationships");
                BaseRelationshipBridge   temp        = relationshipBridges[0];
                AssociationBridge        association = (AssociationBridge)temp;
                ICollection <PartBridge> innerValues = association.GetAssociationValues();
                Assert.IsFalse(innerValues.IsEmpty(), "has value");
            }
        }
Exemple #21
0
        public virtual void TestPivlFrequency()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><frequency><numerator value=\"4\"/><denominator unit=\"d\" value=\"1\"/></frequency></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedFrequencyQuantity = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                              .DAY);

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedFrequencyQuantity.Quantity, pivl.FrequencyQuantity.Quantity);
            Assert.AreEqual(expectedFrequencyQuantity.Unit.CodeValue, pivl.FrequencyQuantity.Unit.CodeValue);
            Assert.AreEqual((Int32?)4, pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.Period);
            Assert.IsNull(pivl.Phase);
        }
Exemple #22
0
        public virtual void ShouldProcessInteraction()
        {
            Interaction interaction = new Interaction();

            interaction.Name          = "ABCD_IN123456CA.SimpleInteraction";
            interaction.SuperTypeName = "ABCD_MT123456CA.MessageBean";
            MessagePart partB = new MessagePart("ABCD_MT123456CA.BeanB");

            partB.Relationships.Add(new Relationship("text", "ST", Cardinality.Create("1")));
            MessagePart message = new MessagePart("ABCD_MT123456CA.MessageBean");

            message.Relationships.Add(new Relationship("bean", "ABCD_MT123456CA.BeanB", Cardinality.Create("1")));
            mockService.AddPart("ABCD_MT123456CA.MessageBean", message);
            mockService.AddPart("ABCD_MT123456CA.BeanB", partB);
            mockService.AddInteraction("ABCD_IN123456CA.SimpleInteraction", interaction);
            SimpleInteraction interactionBean = new SimpleInteraction();

            interactionBean.Bean = new BeanB();
            PartBridge bridge = new BridgeFactoryImpl(this.mockService, VERSION).CreateInteractionBridge(interactionBean);

            Assert.IsNotNull(bridge, "bridge");
        }
Exemple #23
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top>" + "<targetSiteCode code=\"416949008\" codeSystem=\"2.16.840.1.113883.6.96\" codeSystemName=\"SNOMED CT\" displayName=\"Abdomen and pelvis\"/>"
                                      + "</top>");
            Type         expectedReturnType = typeof(ObservationValue);
            ParseContext parseContext       = ParseContextImpl.Create("LIST<CD>", expectedReturnType, SpecificationVersion.CCDA_R1_1, null,
                                                                      null, null, Cardinality.Create("0-4"), null, true);
            BareANY result = new ListR2ElementParser(this.parserR2Registry).Parse(parseContext, AsList(node.ChildNodes), this.xmlResult
                                                                                  );

            Assert.IsTrue(this.xmlResult.IsValid());
            IList <CodedTypeR2 <ObservationValue> > list = ((LIST <CD_R2 <ObservationValue>, CodedTypeR2 <ObservationValue> >)result).RawList
                                                               ();

            Assert.IsNotNull(list, "null");
            Assert.AreEqual(1, list.Count, "size");
            CodedTypeR2 <ObservationValue> firstValue = list[0];

            Assert.AreEqual("416949008", firstValue.GetCodeValue());
            Assert.AreEqual("2.16.840.1.113883.6.96", firstValue.GetCodeSystem());
            Assert.AreEqual("SNOMED CT", firstValue.CodeSystemName);
            Assert.AreEqual("Abdomen and pelvis", firstValue.DisplayName);
        }
Exemple #24
0
        private ConstrainedDatatype CreateConstraints(bool qualifierMandatory)
        {
            //        <relationship name="qualifier" attribute="false" cardinality="0-1"/>
            //        <relationship name="qualifier" attribute="false" cardinality="1"/>
            //        <relationship name="qualifier.name" attribute="false" cardinality="1"/>
            //        <relationship name="qualifier.name.code" attribute="false" cardinality="1" fixedValue="121139"/>
            //        <relationship name="qualifier.name.codeSystem" attribute="false" cardinality="1" fixedValue="1.2.840.10008.2.16.4"/>
            //        <relationship name="qualifier.value" attribute="false" cardinality="1"/>
            //        <relationship name="qualifier.value.code" attribute="false" domainType="TargetSiteQualifiers" domainSource="VALUE_SET" cardinality="0-1"/>
            //        <relationship name="codeSystem" attribute="false" cardinality="1" fixedValue="1.2.840.10008.2.6.1"/>
            ConstrainedDatatype constraints = new ConstrainedDatatype("MessagePart.relationshipName", "CD");

            constraints.SetRestriction();
            Relationship qualifierConstraint = new Relationship("qualifier", null, Cardinality.Create(qualifierMandatory ? "1" : "0-1"
                                                                                                      ));
            Relationship qualifierNameConstraint     = new Relationship("qualifier.name", null, Cardinality.Create("1"));
            Relationship qualifierNameCodeConstraint = new Relationship("qualifier.name.code", null, Cardinality.Create("1"));

            qualifierNameCodeConstraint.FixedValue = "121139";
            Relationship qualifierNameCodeSystemConstraint = new Relationship("qualifier.name.codeSystem", null, Cardinality.Create("1"
                                                                                                                                    ));

            qualifierNameCodeSystemConstraint.FixedValue = "1.2.840.10008.2.16.4";
            Relationship qualifierValueConstraint     = new Relationship("qualifier.value", null, Cardinality.Create("1"));
            Relationship qualifierValueCodeConstraint = new Relationship("qualifier.value.code", null, Cardinality.Create("1"));
            Relationship codeSystemConstraint         = new Relationship("codeSystem", null, Cardinality.Create("1"));

            codeSystemConstraint.FixedValue = "1.2.840.10008.2.6.1";
            constraints.Relationships.Add(qualifierConstraint);
            constraints.Relationships.Add(qualifierNameConstraint);
            constraints.Relationships.Add(qualifierNameCodeConstraint);
            constraints.Relationships.Add(qualifierNameCodeSystemConstraint);
            constraints.Relationships.Add(qualifierValueConstraint);
            constraints.Relationships.Add(qualifierValueCodeConstraint);
            constraints.Relationships.Add(codeSystemConstraint);
            return(constraints);
        }
Exemple #25
0
        public virtual void ShouldHandleCollapsedTypesWithOuterMultipleCardinalityAndSeveralLevelsOfCollapsing()
        {
            MessagePart partB = new MessagePart("ABCE_MT123456CA.BeanB");

            partB.Relationships.Add(new Relationship("text", "ST", Cardinality.Create("1")));
            MessagePart elidedPart1 = new MessagePart("ABCE_MT123456CA.ElidedPart1");

            elidedPart1.Relationships.Add(new Relationship("component", "ABCE_MT123456CA.ElidedPart2", Cardinality.Create("1")));
            MessagePart elidedPart2 = new MessagePart("ABCE_MT123456CA.ElidedPart2");

            elidedPart2.Relationships.Add(new Relationship("issue", "ABCE_MT123456CA.BeanB", Cardinality.Create("1")));
            mockService.AddPart(elidedPart1.Name, elidedPart1);
            mockService.AddPart(elidedPart2.Name, elidedPart2);
            mockService.AddPart(partB.Name, partB);
            BeanAPrime bean = new BeanAPrime();

            bean.Issues.Add(new BeanB());
            bean.Issues.Add(new BeanB());
            MessagePart  part = new MessagePart();
            Relationship subjectOfRelationship = new Relationship("subjectOf", "ABCE_MT123456CA.ElidedPart1", Cardinality.Create("0-50"
                                                                                                                                 ));

            Assert.IsTrue(subjectOfRelationship.Association, "association");
            part.Relationships.Add(subjectOfRelationship);
            PartBridge bridge = new BridgeFactoryImpl(this.mockService, VERSION).CreatePartBridgeFromBean("controlAct", bean, new Interaction
                                                                                                              (), new MessagePartHolder(part));

            Assert.AreEqual(1, bridge.GetRelationshipBridges().Count, "size");
            Assert.AreEqual("subjectOf", bridge.GetRelationshipBridges()[0].GetRelationship().Name, "name of relationship");
            BaseRelationshipBridge relationship = bridge.GetRelationshipBridges()[0];

            Assert.IsTrue(relationship.IsAssociation(), "association relationship");
            ICollection <PartBridge> values = ((AssociationBridge)relationship).GetAssociationValues();

            Assert.AreEqual(2, values.Count, "number of values");
        }
Exemple #26
0
        public virtual void DuplicatesShouldLogValidationError()
        {
            XmlNode node = CreateNode("<top>" + "<something root=\"1.1\" extension=\"fred\" use=\"BUS\"/>" + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />"
                                      + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />" + "</top>");
            BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II.BUS>", null, SpecificationVersion
                                                                                                     .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false),
                                                                             AsList(node.ChildNodes), this.xmlResult);
            ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet();

            Assert.AreEqual(2, rawSet.Count, "size");
            Assert.IsTrue(rawSet.Contains(new Identifier("1.1", "fred")));
            Assert.IsTrue(rawSet.Contains(new Identifier("2.2", "extensionValue")));
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count, "errors");
            Assert.AreEqual("Duplicate value not allowed for SET", this.xmlResult.GetHl7Errors()[0].GetMessage(), "message");
        }
Exemple #27
0
        public virtual void RawValueCanBeAddedToParsedValue()
        {
            XmlNode node = CreateNode("<top>" + "<something root=\"1.1\" extension=\"fred\" use=\"BUS\"/>" + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />"
                                      + "</top>");
            BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II.BUS>", null, SpecificationVersion
                                                                                                     .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false),
                                                                             AsList(node.ChildNodes), null);
            ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet();

            rawSet.Add(new Identifier("3.3", "newExtension"));
            Assert.AreEqual(3, rawSet.Count, "size");
            Assert.IsTrue(rawSet.Contains(new Identifier("3.3", "newExtension")));
        }
Exemple #28
0
        public virtual void TestParseWithMaximumViolation()
        {
            XmlNode node = CreateNode("<top><telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-519-555-2345;ext=1\"/>" + "<telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-519-555-2345;ext=2\"/>"
                                      + "<telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-519-555-2345;ext=3\"/>" + "<telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-416-555-2345;ext=4\"/></top>"
                                      );
            BareANY result = new ListElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("LIST<TEL.PHONEMAIL>", null, SpecificationVersion
                                                                                                      .V02R02, null, null, null, Cardinality.Create("1-2"), null, false), AsList(node.ChildNodes), this.xmlResult);

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual("Number of elements (4) is more than the specified maximum (2)", this.xmlResult.GetHl7Errors()[0].GetMessage
                                ());
            IList <TelecommunicationAddress> list = ((LIST <TEL, TelecommunicationAddress>)result).RawList();

            Assert.IsNotNull(list, "null");
            Assert.AreEqual(4, list.Count, "size");
            TelecommunicationAddress phone1 = list[0];
            TelecommunicationAddress phone2 = list[1];
            TelecommunicationAddress phone3 = list[2];
            TelecommunicationAddress phone4 = list[3];

            Assert.AreEqual("+1-519-555-2345;ext=1", phone1.Address);
            Assert.AreEqual("+1-519-555-2345;ext=2", phone2.Address);
            Assert.AreEqual("+1-519-555-2345;ext=3", phone3.Address);
            Assert.AreEqual("+1-416-555-2345;ext=4", phone4.Address);
        }
Exemple #29
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top>" + "<something root=\"rootValue\" extension=\"fred\" />" + "<something root=\"rootValue2\" extension=\"extensionValue\" />"
                                      + "</top>");
            BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion
                                                                                                     .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false),
                                                                             AsList(node.ChildNodes), new XmlToModelResult());
            ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet();

            Assert.IsNotNull(rawSet, "null");
            Assert.AreEqual(2, rawSet.Count, "size");
            Assert.IsTrue(rawSet.Contains(new Identifier("rootValue", "fred")));
            Assert.IsTrue(rawSet.Contains(new Identifier("rootValue2", "extensionValue")));
        }
Exemple #30
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top><telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-519-555-2345;ext=1\"/>" + "<telecom specializationType=\"TEL.PHONE\" value=\"tel:+1-416-555-2345;ext=2\"/></top>"
                                      );
            BareANY result = new ListElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("LIST<TEL.PHONEMAIL>", null, SpecificationVersion
                                                                                                      .V02R02, null, null, null, Cardinality.Create("0-4"), null, false), AsList(node.ChildNodes), this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            IList <TelecommunicationAddress> list = ((LIST <TEL, TelecommunicationAddress>)result).RawList();

            Assert.IsNotNull(list, "null");
            Assert.AreEqual(2, list.Count, "size");
            TelecommunicationAddress phone1 = list[0];
            TelecommunicationAddress phone2 = list[1];

            Assert.AreEqual("+1-519-555-2345;ext=1", phone1.Address);
            Assert.AreEqual("+1-416-555-2345;ext=2", phone2.Address);
        }