コード例 #1
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);
        }
コード例 #2
0
        public virtual void TestParseValidFull()
        {
            XmlNode node = CreateNode("<something code=\"FRED\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\">"
                                      + "  <originalText>some original text</originalText>" + "  <qualifier inverted=\"true\"><name code=\"cm\" codeSystem=\"1.2.3.4\"/><value code=\"normal\" codeSystem=\"2.16.840.1.113883.5.14\"/></qualifier>"
                                      + "  <qualifier inverted=\"true\"><name code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\"/><value code=\"ACT\" codeSystem=\"2.16.840.1.113883.5.6\"/></qualifier>"
                                      + "  <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />" + "  <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />"
                                      + "</something>");
            CD_R2 <MockCharacters> cd = (CD_R2 <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("CD", typeof(MockCharacters),
                                                                                                           SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node
                                                                                   , this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid(), "valid");
            Assert.AreEqual(MockEnum.FRED, cd.Value.Code, "enum found properly");
            Assert.AreEqual("aCsName", cd.Value.CodeSystemName);
            Assert.AreEqual("aCsVersion", cd.Value.CodeSystemVersion);
            Assert.AreEqual("aDisplayName", cd.Value.DisplayName);
            Assert.AreEqual("some original text", cd.Value.OriginalText.Content);
            Assert.AreEqual(2, cd.Value.Translation.Count);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeValue, cd.Value.Translation[0
                            ].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeSystem, cd.Value.Translation[
                                0].Code.CodeSystem);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeValue, cd.Value.Translation
                            [1].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, cd.Value.Translation
                            [1].Code.CodeSystem);
            Assert.AreEqual(2, cd.Value.Qualifier.Count);
            Assert.IsTrue(cd.Value.Qualifier[0].Inverted);
            Assert.IsTrue(cd.Value.Qualifier[1].Inverted);
            Assert.AreEqual("cm", cd.Value.Qualifier[0].Name.GetCodeValue());
            Assert.AreEqual("M", cd.Value.Qualifier[1].Name.GetCodeValue());
            Assert.AreEqual("normal", cd.Value.Qualifier[0].Value.GetCodeValue());
            Assert.AreEqual("ACT", cd.Value.Qualifier[1].Value.GetCodeValue());
        }
コード例 #3
0
 private void HandleTranslation(XmlElement element, CodedTypeR2 <Code> codedType, ParseContext context, XmlToModelResult result
                                )
 {
     if (TranslationAllowed())
     {
         // we have no knowledge of what domain the translation may belong to (I imagine code system could allow for a reverse lookup at some point)
         ParseContext newContext   = ParseContextImpl.Create("CD", typeof(Code), context);
         XmlNodeList  translations = element.GetElementsByTagName("translation");
         for (int i = 0, length = translations.Count; i < length; i++)
         {
             XmlElement translationElement = (XmlElement)translations.Item(i);
             // only want direct child node translations
             if (translationElement.ParentNode.Equals(element))
             {
                 CodedTypeR2 <Code> parsedTranslation = ParseTranslation(translationElement, newContext, result);
                 if (parsedTranslation != null)
                 {
                     codedType.Translation.Add(parsedTranslation);
                 }
             }
         }
     }
     else
     {
         ValidateUnallowedChildNode(context.Type, element, result, "translation");
     }
 }
コード例 #4
0
        private Interval <PlatformDate> ParseValidTime(XmlElement node, ParseContext context, XmlToModelResult xmlToModelResult)
        {
            Interval <PlatformDate> validTime = null;
            bool        foundValidTime        = false;
            bool        loggedValidTimeError  = false;
            XmlNodeList childNodes            = node.ChildNodes;

            foreach (XmlNode childNode in new XmlNodeListIterable(childNodes))
            {
                string childElementName = NodeUtil.GetLocalOrTagName(childNode);
                bool   isValidTime      = AbstractNameR2ElementParser <V> .VALID_TIME_ELEMENT.Equals(childElementName);

                if (!loggedValidTimeError && foundValidTime)
                {
                    loggedValidTimeError = true;
                    RecordError("Only one validTime is allowed, and it must come after all name parts", (XmlElement)node, xmlToModelResult);
                }
                if (childNode is XmlElement)
                {
                    if (isValidTime)
                    {
                        foundValidTime = true;
                        ParseContext newContext = ParseContextImpl.Create("IVL<TS>", context);
                        BareANY      ivlTsAny   = this.ivlTsParser.Parse(newContext, Arrays.AsList(childNode), xmlToModelResult);
                        if (ivlTsAny != null && ivlTsAny.BareValue != null)
                        {
                            DateInterval dateInterval = (DateInterval)ivlTsAny.BareValue;
                            validTime = dateInterval == null ? null : dateInterval.Interval;
                        }
                    }
                }
            }
            return(validTime);
        }
コード例 #5
0
        public virtual void TestParseValidFull()
        {
            TimeZoneInfo            timeZone = TimeZoneUtil.GetTimeZone("America/Toronto");
            Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate(2006, 11, 25, 11, 12, 13,
                                                                                                             0, timeZone), DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone));
            XmlNode node = CreateNode("<something code=\"FRED\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\">"
                                      + "  <originalText>some original text</originalText>" + "  <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />"
                                      + "  <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />" + "  <validTime><low value=\"20061225121213.0000-0400\"/><high value=\"20070102111112.0000-0400\"/></validTime>"
                                      + "</something>");
            HXIT <MockCharacters> ce = (HXIT <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("HXIT<CE>", typeof(MockCharacters
                                                                                                                            ), SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false),
                                                                                 node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid(), "valid");
            Assert.AreEqual(MockEnum.FRED, ce.Value.Code, "enum found properly");
            Assert.AreEqual("aCsName", ce.Value.CodeSystemName);
            Assert.AreEqual("aCsVersion", ce.Value.CodeSystemVersion);
            Assert.AreEqual("aDisplayName", ce.Value.DisplayName);
            Assert.AreEqual("some original text", ce.Value.OriginalText.Content);
            Assert.AreEqual(2, ce.Value.Translation.Count);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeValue, ce.Value.Translation[0
                            ].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeSystem, ce.Value.Translation[
                                0].Code.CodeSystem);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeValue, ce.Value.Translation
                            [1].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, ce.Value.Translation
                            [1].Code.CodeSystem);
            Assert.AreEqual(interval.Low, ce.Value.ValidTime.Low);
            Assert.AreEqual(interval.High, ce.Value.ValidTime.High);
        }
コード例 #6
0
        public virtual void TestParseFull()
        {
            XmlNode node = CreateNode("<something code=\"BARNEY\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\" value=\"1.2\" operator=\"P\">"
                                      + "  some freeform text" + "  <originalText>some original text</originalText>" + "  <qualifier inverted=\"true\"><name code=\"cm\" codeSystem=\"1.2.3.4\"/><value code=\"normal\" codeSystem=\"2.16.840.1.113883.5.14\"/></qualifier>"
                                      + "  <qualifier inverted=\"true\"><name code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\"/><value code=\"ACT\" codeSystem=\"2.16.840.1.113883.5.6\"/></qualifier>"
                                      + "  <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />" + "  <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />"
                                      + "</something>");
            PQR <MockCharacters> pqr = (PQR <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("PQR", typeof(MockCharacters), SpecificationVersion
                                                                                                        .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult);

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(4, this.xmlResult.GetHl7Errors().Count, "error message count");
            Assert.IsNotNull(pqr.Value, "main enum found");
            Assert.AreEqual("BARNEY", pqr.Value.GetCodeValue(), "main code");
            Assert.AreEqual("1.2.3.4.5", pqr.Value.GetCodeSystem(), "main code");
            Assert.AreEqual("aCsName", pqr.Value.CodeSystemName);
            Assert.AreEqual("aCsVersion", pqr.Value.CodeSystemVersion);
            Assert.AreEqual("aDisplayName", pqr.Value.DisplayName);
            Assert.IsNull(pqr.Value.Operator);
            Assert.AreEqual(new BigDecimal("1.2"), pqr.Value.Value);
            Assert.IsNull(pqr.Value.SimpleValue);
            Assert.AreEqual("some original text", pqr.Value.OriginalText.Content);
            Assert.AreEqual(0, pqr.Value.Translation.Count);
            Assert.AreEqual(0, pqr.Value.Qualifier.Count);
        }
コード例 #7
0
 private void HandleOriginalText(XmlElement element, CodedTypeR2 <Code> codedType, ParseContext context, XmlToModelResult result
                                 )
 {
     if (OriginalTextAllowed())
     {
         IList <XmlElement> originalTextElements = GetNamedElements("originalText", element);
         if (originalTextElements.Count > 0)
         {
             if (originalTextElements.Count > 1)
             {
                 RecordError("Only one original text element is allowed.", element, context, result);
             }
             ParseContext newContext         = ParseContextImpl.Create("ED", context);
             BareANY      parsedOriginalText = this.edParser.Parse(newContext, originalTextElements[0], result);
             if (parsedOriginalText != null)
             {
                 codedType.OriginalText = (EncapsulatedData)parsedOriginalText.BareValue;
             }
         }
     }
     else
     {
         ValidateUnallowedChildNode(context.Type, element, result, "originalText");
     }
 }
コード例 #8
0
 private void HandleQualifier(XmlElement element, CodedTypeR2 <Code> codedType, ParseContext context, XmlToModelResult result
                              )
 {
     if (QualifierAllowed())
     {
         ParseContext newContext = ParseContextImpl.Create("CR", typeof(Code), context);
         XmlNodeList  qualifiers = element.GetElementsByTagName("qualifier");
         for (int i = 0, length = qualifiers.Count; i < length; i++)
         {
             XmlElement qualifierElement = (XmlElement)qualifiers.Item(i);
             // only want direct child node qualifiers
             if (qualifierElement.ParentNode.Equals(element))
             {
                 BareANY anyCr = new CrR2ElementParser().Parse(newContext, qualifierElement, result);
                 if (anyCr != null && anyCr.BareValue != null)
                 {
                     codedType.Qualifier.Add((CodeRole)anyCr.BareValue);
                 }
             }
         }
     }
     else
     {
         ValidateUnallowedChildNode(context.Type, element, result, "qualifier");
     }
 }
コード例 #9
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        private Interval <Int32?> Parse(XmlNode node)
        {
            BareANY ivl = this.parser.Parse(ParseContextImpl.Create("IVL<INT>", typeof(Interval <object>), SpecificationVersion.V02R02
                                                                    , null, null, null, null, null, false), Arrays.AsList(node), this.result);

            return((Interval <Int32?>)(ivl.BareValue));
        }
コード例 #10
0
        public virtual void TestParseValidFull()
        {
            XmlNode node = CreateNode("<something code=\"FRED\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\">"
                                      + "  <originalText>some original text</originalText>" + "  <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />"
                                      + "  <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />" + "  <translation nullFlavor=\"OTH\" codeSystem=\"2.16.840.1.113883.5.1\" />"
                                      + "</something>");
            CE_R2 <MockCharacters> ce = (CE_R2 <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("CE", typeof(MockCharacters),
                                                                                                           SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node
                                                                                   , this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid(), "valid");
            Assert.AreEqual(MockEnum.FRED, ce.Value.Code, "enum found properly");
            Assert.AreEqual("aCsName", ce.Value.CodeSystemName);
            Assert.AreEqual("aCsVersion", ce.Value.CodeSystemVersion);
            Assert.AreEqual("aDisplayName", ce.Value.DisplayName);
            Assert.AreEqual("some original text", ce.Value.OriginalText.Content);
            Assert.AreEqual(3, ce.Value.Translation.Count);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeValue, ce.Value.Translation[0
                            ].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeSystem, ce.Value.Translation[
                                0].Code.CodeSystem);
            Assert.IsNull(ce.Value.Translation[0].NullFlavorForTranslationOnly);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeValue, ce.Value.Translation
                            [1].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, ce.Value.Translation
                            [1].Code.CodeSystem);
            Assert.IsNull(ce.Value.Translation[1].NullFlavorForTranslationOnly);
            Assert.IsNull(ce.Value.Translation[2].Code.CodeValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, ce.Value.Translation
                            [2].Code.CodeSystem);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.OTHER, ce.Value.Translation[2].NullFlavorForTranslationOnly
                            );
        }
コード例 #11
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        private Interval <PlatformDate> Parse(XmlNode node, string type, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel
                                              )
        {
            TimeZoneInfo timeZone     = TimeZoneUtil.GetTimeZone("America/Toronto");
            DateInterval dateInterval = (DateInterval)this.parser.Parse(ParseContextImpl.Create(type, typeof(Interval <object>), SpecificationVersion
                                                                                                .V02R02, timeZone, timeZone, conformanceLevel, null, null, false), Arrays.AsList(node), this.result).BareValue;

            return(dateInterval == null ? null : dateInterval.Interval);
        }
コード例 #12
0
        public virtual void TestParseNoCodeAttributeNode()
        {
            XmlNode node             = CreateNode("<something notvalue=\"\" />");
            PQR <MockCharacters> pqr = (PQR <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("PQR", typeof(MockCharacters), SpecificationVersion
                                                                                                        .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pqr.Value, "node with no code attribute returns null");
        }
コード例 #13
0
        public virtual void TestParseEmptyNode()
        {
            XmlNode node             = CreateNode("<something/>");
            PQR <MockCharacters> pqr = (PQR <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("PQR", typeof(MockCharacters), SpecificationVersion
                                                                                                        .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pqr.Value, "empty node returns null");
        }
コード例 #14
0
        public virtual void TestParseInvalidNullFavorAttributeValue()
        {
            XmlNode node = CreateNode("<something nullFlavor=\"NOT A VALID NULL FAVOR VALUE\"/>");

            this.parser.Parse(ParseContextImpl.Create("CD", typeof(MockCharacters), SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                      .OPTIONAL, null, null, false), node, this.xmlResult);
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count, "warning message count");
        }
コード例 #15
0
        public virtual void TestParseCodeWithNullNodeAndCodeSystem()
        {
            XmlNode node             = CreateNode("<something code=\"BARNEY\" codeSystem=\"1.2.3.4.5\" nullFlavor=\"OTH\"/>");
            PQR <MockCharacters> pqr = (PQR <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("PQR", typeof(MockCharacters), SpecificationVersion
                                                                                                        .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual("BARNEY", pqr.Value.GetCodeValue(), "value");
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.OTHER, pqr.NullFlavor, "null flavor");
        }
コード例 #16
0
        public virtual void TestParseValidWithInvalidNullFavorAttributeValue()
        {
            XmlNode node             = CreateNode("<something code=\"BARNEY\" nullFlavor=\"NOT A VALID NULL FAVOR VALUE\"/>");
            PQR <MockCharacters> pqr = (PQR <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("PQR", typeof(MockCharacters), SpecificationVersion
                                                                                                        .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult);

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual("BARNEY", pqr.Value.GetCodeValue(), "node with no code attribute returns null");
        }
コード例 #17
0
 public override void SetUp()
 {
     base.SetUp();
     this.contextBL = ParseContextImpl.Create("BL", typeof(Boolean?), SpecificationVersion.V02R02, null, null, null, null, null
                                              , false);
     this.contextBN = ParseContextImpl.Create("BN", typeof(Boolean?), SpecificationVersion.R02_04_03, null, null, null, null,
                                              null, false);
     this.result = new XmlToModelResult();
     this.parser = new BlR2ElementParser();
 }
コード例 #18
0
        public virtual void TestParseNullNode()
        {
            XmlNode node             = CreateNode("<something nullFlavor=\"NI\"/>");
            HXIT <MockCharacters> ce = (HXIT <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("HXIT<CE>", typeof(MockCharacters
                                                                                                                            ), SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false),
                                                                                 node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(ce.Value, "value");
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION, ce.NullFlavor, "null flavor");
        }
コード例 #19
0
        public virtual void TestParsePqWithNullFlavor()
        {
            XmlNode node = CreateNode("<something nullFlavor=\"ASKU\" xsi:type=\"PQ\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />"
                                      );
            BareANY pqAny = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.R02_04_03
                                                                                   , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pqAny.BareValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.ASKED_BUT_UNKNOWN, pqAny.NullFlavor);
        }
コード例 #20
0
        public virtual void TestParseOtherNullNode()
        {
            XmlNode node = CreateNode("<something nullFlavor=\"OTH\"/>");
            CD_R2 <MockCharacters> cd = (CD_R2 <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("CD", typeof(MockCharacters),
                                                                                                           SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node
                                                                                   , this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(cd.Value, "value");
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.OTHER, cd.NullFlavor, "null flavor");
        }
コード例 #21
0
        protected override PhysicalQuantity GetDenominatorValue(XmlElement element, string type, ParseContext context, XmlToModelResult
                                                                xmlToModelResult)
        {
            // inner types (numerator and denominator) are guaranteed to be of type MO.x and PQ.x due to the DataTypeHandler annotation; no need to validate this is a MO or PQ
            // create new (mandatory) context
            ParseContext innerContext = ParseContextImpl.Create(type, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality
                                                                .Create("1"), context);

            // this loses any null flavor info; however, since both numerator and denominator are mandatory this is not a problem
            return((PhysicalQuantity)pqParser.Parse(innerContext, (XmlNode)element, xmlToModelResult).BareValue);
        }
コード例 #22
0
        public virtual void TestParseInvalid()
        {
            XmlNode node = CreateNode("<something code=\"ER\" />");
            CD_R2 <MockCharacters> cd = (CD_R2 <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("CD", typeof(MockCharacters),
                                                                                                           SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node
                                                                                   , this.xmlResult);

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.IsNull(cd.Value, "node with no code attribute returns null");
        }
コード例 #23
0
        public virtual void TestParseFullDatePartTimeWithMissingTimezoneForCeRx()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 14, 16, 00, 0);
            string       value          = "200806251416";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            ParseContext context        = ParseContextImpl.Create("TS", typeof(PlatformDate), SpecificationVersion.V01R04_3, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                  .POPULATED, null, null, false);
            MbDate mbDate = (MbDate) new TsR2ElementParser().Parse(context, node, this.xmlResult).BareValue;

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE_TIME, expectedResult, mbDate.Value);
            Assert.AreEqual(0, this.xmlResult.GetHl7Errors().Count, "no timezone missing error");
        }
コード例 #24
0
        protected virtual PhysicalQuantity CreatePeriodType(ParseContext context, XmlElement element, XmlToModelResult xmlToModelResult
                                                            )
        {
            if (element == null)
            {
                return(null);
            }
            ParseContext pqContext = ParseContextImpl.Create("PQ", context);
            BareANY      pqAny     = this.pqParser.Parse(pqContext, element, xmlToModelResult);

            return((PhysicalQuantity)pqAny.BareValue);
        }
コード例 #25
0
        public virtual void TestParseValidFullDateTime()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 14, 16, 10, 0);
            string       value          = "20080625141610" + GetCurrentTimeZone(expectedResult);
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            ParseContext context        = ParseContextImpl.Create("TS", typeof(PlatformDate), SpecificationVersion.R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                  .POPULATED, null, null, false);
            MbDate mbDate = (MbDate) new TsR2ElementParser().Parse(context, node, this.xmlResult).BareValue;

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE_TIME, expectedResult, mbDate.Value);
            Assert.IsTrue(this.xmlResult.GetHl7Errors().IsEmpty(), "no errors");
        }
コード例 #26
0
        public virtual void TestParseWithMissingSpecializationType()
        {
            XmlNode node = CreateNode("<value xsi:type=\"PQ\" value=\"80\" unit=\"pg/mL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"
                                      );
            BareANY result = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY.LAB", typeof(object), null, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                                    .MANDATORY, null, null, false), node, this.xmlResult);

            Assert.IsNotNull(result);
            Assert.IsNull(result.BareValue);
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count, "has error");
            Assert.AreEqual("Cannot support properties of type \"PQ\" for \"ANY.LAB\"", this.xmlResult.GetHl7Errors()[0].GetMessage()
                            , "error message");
        }
コード例 #27
0
        public virtual void ShouldParseStTextNodeAsCdata()
        {
            XmlNode node = CreateNode("<something xsi:type=\"ST\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><![CDATA[<cats think they're > humans & dogs 99% of the time/>]]></something>"
                                      );
            ParseContext context = ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, null, null, false);
            BareANY parseResult = new AnyR2ElementParser().Parse(context, node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(StandardDataType.ST, parseResult.DataType);
            Assert.IsTrue(((ANYMetaData)parseResult).IsCdata, "noted as cdata");
            Assert.AreEqual("<cats think they're > humans & dogs 99% of the time/>", parseResult.BareValue, "proper text returned");
        }
コード例 #28
0
        protected virtual Interval <PlatformDate> CreatePhaseType(ParseContext context, XmlElement element, XmlToModelResult xmlToModelResult
                                                                  )
        {
            if (element == null)
            {
                return(null);
            }
            ParseContext ivlTsContext = ParseContextImpl.Create("IVL<TS>", context);
            BareANY      periodAny    = this.ivlTsParser.Parse(ivlTsContext, Arrays.AsList((XmlNode)element), xmlToModelResult);
            DateInterval dateInterval = (DateInterval)periodAny.BareValue;

            return(dateInterval == null ? null : dateInterval.Interval);
        }
コード例 #29
0
        public virtual void DateShouldBeAffectedByDateTimeZone()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 24, 23, 0, 0, 0, TimeZoneUtil.GetTimeZone("America/New_York"));
            string       value          = "20080625";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            ParseContext context        = ParseContextImpl.Create("TS", typeof(PlatformDate), SpecificationVersion.R02_04_02, TimeZoneUtil.GetTimeZone
                                                                      ("GMT-3"), TimeZoneUtil.GetTimeZone("GMT-3"), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, null
                                                                  , null, false);
            MbDate mbDate = (MbDate) new TsR2ElementParser().Parse(context, node, this.xmlResult).BareValue;

            AssertDateEquals("should not be different even though different time zone", MarshallingTestCase.FULL_DATE, expectedResult
                             , mbDate.Value);
        }
コード例 #30
0
        public virtual void TestParseValueAttributeValidWithDefaultOperator()
        {
            ParseContext context = ParseContextImpl.Create("SXCM<TS>", typeof(PlatformDate), SpecificationVersion.R02_04_02, null, null
                                                           , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, false);
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 0, 0, 0, 0);
            string       value          = "20080625";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            BareANY      tsAny          = new TsR2ElementParser().Parse(context, node, this.xmlResult);
            MbDate       mbDate         = (MbDate)tsAny.BareValue;

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE, expectedResult, mbDate.Value);
            Assert.IsTrue(this.xmlResult.IsValid(), "no errors");
            Assert.AreEqual(SetOperator.INCLUDE, ((ANYMetaData)tsAny).Operator, "operator");
        }