Exemple #1
0
        public virtual void TestParseAll()
        {
            XmlNode node = CreateNode("<something value=\"http://www.fred.ca\" use=\"HP CONF TMP\">\n" + "<useablePeriod value=\"19990303101112\"/>"
                                      + "<useablePeriod operator=\"E\" value=\"20050303101112\"/>" + "</something>");
            TelecommunicationAddress address = (TelecommunicationAddress) new TelR2ElementParser().Parse(CreateContext("TEL", SpecificationVersion
                                                                                                                       .R02_04_03), node, this.xmlResult).BareValue;

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual("www.fred.ca", address.Address, "correct address returned");
            Assert.AreEqual(CeRxDomainTestValues.HTTP.CodeValue, address.UrlScheme.CodeValue, "correct urlscheme returned");
            Assert.AreEqual(3, address.AddressUses.Count, "correct address uses");
            Assert.IsTrue(address.AddressUses.Contains(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.PRIMARY_HOME
                                                       ));
            Assert.IsTrue(address.AddressUses.Contains(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.CONFIDENTIAL
                                                       ));
            Assert.IsTrue(address.AddressUses.Contains(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.TEMPORARY
                                                       ));
            Assert.AreEqual(2, address.UseablePeriods.Count, "correct number of useable periods");
            IEnumerator <KeyValuePair <PlatformDate, SetOperator> > iterator = address.UseablePeriods.GetEnumerator();
            KeyValuePair <PlatformDate, SetOperator> firstPeriod             = iterator.MoveNext() ? iterator.Current : (KeyValuePair <PlatformDate
                                                                                                                                       , SetOperator>)(object) null;
            KeyValuePair <PlatformDate, SetOperator> secondPeriod = iterator.MoveNext() ? iterator.Current : (KeyValuePair <PlatformDate
                                                                                                                            , SetOperator>)(object) null;

            Assert.AreEqual(DateUtil.GetDate(1999, 2, 3, 10, 11, 12, 0), firstPeriod.Key, "first period");
            Assert.AreEqual(SetOperator.INCLUDE, firstPeriod.Value, "first operator");
            Assert.AreEqual(DateUtil.GetDate(2005, 2, 3, 10, 11, 12, 0), secondPeriod.Key, "second period");
            Assert.AreEqual(SetOperator.EXCLUDE, secondPeriod.Value, "second operator");
        }
Exemple #2
0
        private void ValidateTelecomAddressUses(TelecommunicationAddress telecomAddress, string type, VersionNumber version, XmlElement
                                                element, string propertyPath, Hl7Errors errors)
        {
            int  numUses = telecomAddress.AddressUses.Count;
            bool isUri   = StandardDataType.TEL_URI.Type.Equals(type);

            if (isUri && numUses > 0)
            {
                // error if > 0 and URI
                CreateError("TelecomAddressUses are not allowed for TEL.URI", element, propertyPath, errors);
            }
            else
            {
                if (numUses > MAX_USES)
                {
                    // error if more than 3 uses
                    CreateError("A maximum of 3 TelecomAddressUses are allowed (number found: " + numUses + ")", element, propertyPath, errors
                                );
                }
            }
            if (!isUri)
            {
                foreach (Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse telecomAddressUse in telecomAddress.AddressUses)
                {
                    if (!IsAllowableUse(type, telecomAddressUse, version))
                    {
                        CreateError("TelecomAddressUse is not valid: " + (telecomAddressUse == null ? "null" : telecomAddressUse.CodeValue), element
                                    , propertyPath, errors);
                    }
                }
            }
        }
Exemple #3
0
        private static TelecommunicationAddress CreateTelecommunicationAddress(string formattedPhoneNumber)
        {
            TelecommunicationAddress telecom = new TelecommunicationAddress();

            telecom.Address = formattedPhoneNumber;
            return(telecom);
        }
Exemple #4
0
        public virtual void HandleConstraints(ConstrainedDatatype constraints, EncapsulatedData ed, ErrorLogger logger)
        {
            if (ed == null || constraints == null)
            {
                return;
            }
            TelecommunicationAddress reference = ed.ReferenceObj;

            // ignoring any fixed value returned from reference constraints checking
            this.constraintsHandler.ValidateConstraint("reference", reference == null ? null : "reference", constraints, logger);
            // just checks if reference provided
            if (reference != null)
            {
                // only check this constraint if a reference has been provided (whether the reference was mandatory or not)
                string referenceValue = reference.ToString();
                this.constraintsHandler.ValidateConstraint("reference.value", referenceValue, constraints, logger);
            }
            // checks for actual value
            string mediaType    = ed.MediaType == null ? null : ed.MediaType.CodeValue;
            string newMediaType = this.constraintsHandler.ValidateConstraint("mediaType", mediaType, constraints, logger);

            if (!StringUtils.Equals(mediaType, newMediaType))
            {
                x_DocumentMediaType newMediaTypeEnum = Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.Get(newMediaType);
                if (newMediaTypeEnum != null)
                {
                    ed.MediaType = newMediaTypeEnum;
                }
            }
        }
Exemple #5
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 #6
0
        public virtual void TestCeRxDatatypeDetermination()
        {
            TelecommunicationAddress telecomAddress = new TelecommunicationAddress();
            string        type    = "TEL.PHONEMAIL";
            VersionNumber version = SpecificationVersion.V01R04_3;
            Hl7Errors     errors  = this.xmlResult;

            telecomAddress.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            Assert.AreEqual("TEL.PHONE", new TelValidationUtils().DetermineActualType(telecomAddress, type, null, version, null, null
                                                                                      , errors, true));
            Assert.IsTrue(this.xmlResult.IsValid());
            telecomAddress.UrlScheme = CeRxDomainTestValues.FAX;
            Assert.AreEqual("TEL.PHONE", new TelValidationUtils().DetermineActualType(telecomAddress, type, null, version, null, null
                                                                                      , errors, true));
            Assert.IsTrue(this.xmlResult.IsValid());
            telecomAddress.UrlScheme = CeRxDomainTestValues.MAILTO;
            Assert.AreEqual("TEL.EMAIL", new TelValidationUtils().DetermineActualType(telecomAddress, type, null, version, null, null
                                                                                      , errors, true));
            Assert.IsTrue(this.xmlResult.IsValid());
            telecomAddress.UrlScheme = CeRxDomainTestValues.FTP;
            // this error will be caught elsewhere
            Assert.AreEqual("TEL.PHONE", new TelValidationUtils().DetermineActualType(telecomAddress, type, null, version, null, null
                                                                                      , errors, true));
            Assert.IsTrue(this.xmlResult.IsValid());
        }
Exemple #7
0
        public virtual void TestGetAttributeNameValuePairsIncludeUses()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "value";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONE"), address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:value", result.SafeGet("value"), "value as expected");
            Assert.IsTrue(result.ContainsKey("use"), "use key as expected");
            Assert.AreEqual("H", result.SafeGet("use"), "use as expected");
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest(
                CreateContext("TEL.PHONE"), address, new TELImpl());
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("use"), "use key as expected");
            ICollection <string> uses = FormatterAssert.ToSet(result.SafeGet("use"));

            FormatterAssert.AssertContainsSame("uses", FormatterAssert.ToSet("H MC"), uses);
        }
Exemple #8
0
        public virtual void ValidateTelecommunicationAddress(TelecommunicationAddress telecomAddress, string type, string specializationType
                                                             , VersionNumber version, XmlElement element, string propertyPath, Hl7Errors errors)
        {
            string actualType = DetermineActualType(telecomAddress, type, specializationType, version, element, propertyPath, errors,
                                                    true);

            ValidateTelecomAddressUses(telecomAddress, actualType, version, element, propertyPath, errors);
            ValidateTelecomAddressScheme(telecomAddress, actualType, version.GetBaseVersion(), element, propertyPath, errors);
            ValidateTelecomAddressValue(telecomAddress, actualType, version, element, propertyPath, errors);
        }
Exemple #9
0
        private IList <TelecommunicationAddress> CreateTelecommunicationAddressList()
        {
            List <TelecommunicationAddress> result = new List <TelecommunicationAddress>();
            TelecommunicationAddress        phone1 = CreateTelecommunicationAddress("+1-519-555-2345;ext=12345");
            TelecommunicationAddress        phone2 = CreateTelecommunicationAddress("+1-416-555-2345;ext=12345");

            result.Add(phone1);
            result.Add(phone2);
            return(result);
        }
Exemple #10
0
        public virtual void TestParseValueAttributeValidPlusExtraAttribute()
        {
            XmlNode node = CreateNode("<something extra=\"extra\" value=\"mailto://monkey@monkey\" />");
            TelecommunicationAddress address = (TelecommunicationAddress) new TelR2ElementParser().Parse(CreateContext("TEL", SpecificationVersion
                                                                                                                       .V02R02), node, this.xmlResult).BareValue;

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual("monkey@monkey", address.Address, "correct address returned");
            Assert.AreEqual(CeRxDomainTestValues.MAILTO.CodeValue, address.UrlScheme.CodeValue, "correct urlscheme returned");
        }
Exemple #11
0
        public virtual string DetermineActualType(TelecommunicationAddress telecomAddress, string type, string specializationType
                                                  , VersionNumber version, XmlElement element, string propertyPath, Hl7Errors errors, bool logErrors)
        {
            string actualType     = type;
            bool   isTelAll       = StandardDataType.TEL_ALL.Type.Equals(type);
            bool   isTelPhonemail = StandardDataType.TEL_PHONEMAIL.Type.Equals(type);

            if (isTelAll || isTelPhonemail)
            {
                if (IsCeRxOrNewfoundland(version))
                {
                    Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme = telecomAddress.UrlScheme;
                    if ("mailto".Equals(urlScheme == null ? null : urlScheme.CodeValue))
                    {
                        actualType = "TEL.EMAIL";
                    }
                    else
                    {
                        actualType = "TEL.PHONE";
                    }
                }
                else
                {
                    if (StringUtils.IsBlank(specializationType))
                    {
                        if (logErrors)
                        {
                            string errorMessage = System.String.Format("No specialization type provided. Specialization type of TEL.PHONE/TEL.EMAIL{0} must be specified for abstract data type {1}. Assuming TEL.PHONE"
                                                                       , isTelAll ? "/TEL.URI" : string.Empty, type);
                            CreateError(errorMessage, element, propertyPath, errors);
                        }
                        actualType = "TEL.PHONE";
                    }
                    else
                    {
                        if (!StandardDataType.TEL_PHONE.Type.Equals(specializationType) && !StandardDataType.TEL_EMAIL.Type.Equals(specializationType
                                                                                                                                   ) && !(StandardDataType.TEL_URI.Type.Equals(specializationType) && isTelAll))
                        {
                            if (logErrors)
                            {
                                string errorMessage = System.String.Format("Invalid specialization type provided. Specialization type of TEL.PHONE/TEL.EMAIL{0} must be specified for abstract data type {1}. Assuming TEL.PHONE"
                                                                           , isTelAll ? "/TEL.URI" : string.Empty, type);
                                CreateError(errorMessage, element, propertyPath, errors);
                            }
                            actualType = "TEL.PHONE";
                        }
                        else
                        {
                            actualType = specializationType;
                        }
                    }
                }
            }
            return(actualType);
        }
Exemple #12
0
        public virtual void TestTelEmail()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.MAILTO;
            address.Address   = "1234567890123456789012345678901234567890123";
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name value=\"mailto:1234567890123456789012345678901234567890123\"/>", result);
        }
Exemple #13
0
        /// <exception cref="System.Exception"></exception>
        private void AssertValidValueAttribute(string type, string value, string address, Ca.Infoway.Messagebuilder.Domainvalue.URLScheme
                                               urlScheme)
        {
            XmlNode node = CreateNode("<something value=\"" + value + "\" />");
            TelecommunicationAddress telecommunicationAddress = (TelecommunicationAddress) new TelR2ElementParser().Parse(CreateContext
                                                                                                                              (type, SpecificationVersion.V02R02), node, this.xmlResult).BareValue;

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(address, telecommunicationAddress.Address, "correct address returned");
            Assert.AreEqual(urlScheme.CodeValue, telecommunicationAddress.UrlScheme.CodeValue, "correct urlscheme returned");
        }
Exemple #14
0
        public virtual void TestGetAttributeNameValuePairsTelUriInvalidUse()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FILE;
            address.Address   = "value";
            address.AddressUses.Add(Ca.Infoway.Messagebuilder.Domainvalue.Basic.TelecommunicationAddressUse.HOME);
            new TestableTelUriPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext(), address, new TELImpl());
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
        }
Exemple #15
0
        public virtual void TestTelPhoneValid()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "aValue";
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name value=\"tel:aValue\"/>", result);
        }
Exemple #16
0
        internal static void AssertInvalidUrlScheme(TestableAbstractValueNullFlavorPropertyFormatter <TelecommunicationAddress> formatter
                                                    , Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme, FormatContext context)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = urlScheme;
            address.Address   = "sometext";
            formatter.GetAttributeNameValuePairsForTest(context, address, new TELImpl());
            Assert.IsFalse(context.GetModelToXmlResult().IsValid());
            Assert.AreEqual(1, context.GetModelToXmlResult().GetHl7Errors().Count);
            Assert.IsTrue(context.GetModelToXmlResult().GetHl7Errors()[0].GetMessage().Contains("Scheme " + urlScheme.CodeValue + " is not valid"
                                                                                                ), "expected message");
        }
Exemple #17
0
        /// <exception cref="System.Exception"></exception>
        internal static void AssertValidUrlScheme(TestableAbstractValueNullFlavorPropertyFormatter <TelecommunicationAddress> formatter
                                                  , Ca.Infoway.Messagebuilder.Domainvalue.URLScheme urlScheme, FormatContext context, string expected)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = urlScheme;
            address.Address   = "someAddress";
            IDictionary <string, string> result = formatter.GetAttributeNameValuePairsForTest(context, address, new TELImpl());

            Assert.IsTrue(context.GetModelToXmlResult().IsValid());
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual(expected + address.Address, result.SafeGet("value"), "value as expected");
        }
Exemple #18
0
        public virtual void TestGetAttributeNameValuePairsTelPhonemailValid()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "value";
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("TEL.PHONE"), address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:value", result.SafeGet("value"), "value as expected");
        }
Exemple #19
0
        private void AssertInvalidAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse addressUse)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FAX;
            address.Address   = "4167620032";
            address.AddAddressUse(addressUse);
            this.xmlResult.ClearErrors();
            new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext
                                                                                                                                ("TEL.PHONE"), address, new TELImpl());
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual("TelecomAddressUse is not valid: " + addressUse.CodeValue, this.xmlResult.GetHl7Errors()[0].GetMessage(),
                            "expected message");
        }
Exemple #20
0
        public virtual void TestTelPhoneForMr2007WithValidMaxLength()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            // tel: + 21 = 25 (max)
            address.Address = "123456789012345678901";
            IDictionary <string, string> result = new TestableTelUriPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext
                                                                                                                              ("TEL.PHONE", SpecificationVersion.V02R02), address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("tel:" + address.Address, result.SafeGet("value"), "value as expected");
        }
Exemple #21
0
        public virtual void TestTelEmailWithValidMaxLength()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.MAILTO;
            // mailto: + 43 = 50 (max)
            address.Address = "1234567890123456789012345678901234567890123";
            IDictionary <string, string> result = new TestableTelUriPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext
                                                                                                                              ("TEL.EMAIL"), address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("mailto:" + address.Address, result.SafeGet("value"), "value as expected");
        }
Exemple #22
0
        private void ValidateTelecomAddressValue(TelecommunicationAddress telecomAddress, string type, VersionNumber version, XmlElement
                                                 element, string propertyPath, Hl7Errors errors)
        {
            Hl7BaseVersion baseVersion             = version.GetBaseVersion();
            string         address                 = telecomAddress.Address;
            int            schemePlusAddressLength = telecomAddress.ToString().Length;

            if (StringUtils.IsBlank(address))
            {
                CreateError("TelecomAddress must have a value for the actual address", element, propertyPath, errors);
            }
            else
            {
                if (StandardDataType.TEL_EMAIL.Type.Equals(type) && schemePlusAddressLength > MAX_VALUE_LENGTH_EMAIL)
                {
                    CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_EMAIL, type, baseVersion, element, propertyPath, errors);
                }
                else
                {
                    if (StandardDataType.TEL_URI.Type.Equals(type) && schemePlusAddressLength > MAX_VALUE_LENGTH_URI)
                    {
                        CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_URI, type, baseVersion, element, propertyPath, errors);
                    }
                    else
                    {
                        if (StandardDataType.TEL_PHONE.Type.Equals(type))
                        {
                            if (IsMr2007(baseVersion) || IsCeRxOrNewfoundland(version))
                            {
                                if (schemePlusAddressLength > MAX_VALUE_LENGTH_PHONE_MR2007_CERX)
                                {
                                    CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_PHONE_MR2007_CERX, type, baseVersion, element, propertyPath
                                                         , errors);
                                }
                            }
                            else
                            {
                                if (schemePlusAddressLength > MAX_VALUE_LENGTH_PHONE_MR2009)
                                {
                                    CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_PHONE_MR2009, type, baseVersion, element, propertyPath, errors
                                                         );
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #23
0
        public virtual void TestIncludeUses()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "aValue";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H\" value=\"tel:aValue\"/>", result);
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));
            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H MC\" value=\"tel:aValue\"/>", result);
        }
Exemple #24
0
        public virtual void TestTextContent()
        {
            TelecommunicationAddress reference = new TelecommunicationAddress();

            reference.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            reference.Address   = "aValue";
            reference.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            EncapsulatedData data   = CreateEd(reference, "some content &amp; that will <b>not</b> be escaped");
            string           result = new EdPropertyFormatter(this.telFormatter, true).Format(GetContext("text", "ED"), new EDImpl <EncapsulatedData
                                                                                                                                    >(data));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("something in text node", "<text compression=\"ZL\" integrityCheck=\"c29tZXRoaW5nIHRvIGVuY29kZQ==\" integrityCheckAlgorithm=\"SHA-256\" language=\"en-CA\" mediaType=\"text/plain\" representation=\"TXT\">"
                      + "<reference use=\"H\" value=\"tel:aValue\"/>" + "some content &amp; that will <b>not</b> be escaped" + "</text>", result
                      , true);
        }
Exemple #25
0
        public virtual void TestTelUriWithInvalidMaxLength()
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FILE;
            // file:// + 249 = 256 (1 over max)
            address.Address = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
            IDictionary <string, string> result = new TestableTelUriPropertyFormatter().GetAttributeNameValuePairsForTest(CreateContext
                                                                                                                              (), address, new TELImpl());

            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("file://" + address.Address, result.SafeGet("value"), "value as expected");
        }
Exemple #26
0
        public virtual void TestInvalidTextContent()
        {
            TelecommunicationAddress reference = new TelecommunicationAddress();

            reference.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            reference.Address   = "aValue";
            reference.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            try
            {
                CreateEd(reference, "some content & that will <b>not</b> be escaped");
                Assert.Fail("Should not get here due to unescaped content");
            }
            catch (SAXException)
            {
            }
        }
Exemple #27
0
        /// <exception cref="System.Exception"></exception>
        private void AssertValidAddressUse(Ca.Infoway.Messagebuilder.Domainvalue.TelecommunicationAddressUse addressUse)
        {
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.FAX;
            address.AddAddressUse(addressUse);
            address.Address = "someAddress";
            this.xmlResult.ClearErrors();
            Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl context = CreateContext("TEL.PHONE");
            IDictionary <string, string> result = new TelPhonemailPropertyFormatterTest.TestableTelPhonemailPropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (context, address, new TELImpl());

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("use"), "key as expected");
            Assert.AreEqual(addressUse.CodeValue, result.SafeGet("use"), "value as expected");
        }
Exemple #28
0
        /// <exception cref="System.Exception"></exception>
        private EncapsulatedData CreateEd(TelecommunicationAddress reference, string content)
        {
            EncapsulatedData data = new EncapsulatedData();

            data.Compression             = Compression.ZLIB;
            data.IntegrityCheck          = Base64.EncodeBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("something to encode"));
            data.IntegrityCheckAlgorithm = IntegrityCheckAlgorithm.SHA_256;
            data.Language       = "en-CA";
            data.MediaType      = Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.PLAIN_TEXT;
            data.ReferenceObj   = reference;
            data.Representation = EdRepresentation.TXT;
            if (content != null)
            {
                data.Content = content;
            }
            return(data);
        }
Exemple #29
0
        protected void SetTransportWrapperValues <CAE>(HL7Message <CAE> message)
        {
            // Fill in transport wrapper portion

            Identifier ii = new Identifier(System.Guid.NewGuid().ToString());

            message.Id = ii;

            DateTime now      = DateTime.Now;
            DateTime dateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, 12);

            message.CreationTime = new Ca.Infoway.Messagebuilder.PlatformDate(dateTime);

            message.ProcessingModeCode = ProcessingMode.CURRENT_PROCESSING;

            Identifier profileId   = new Identifier("2.16.840.1.113883.2.20.2", "R02.04.02");
            Identifier abProfileId = new Identifier("2.16.840.1.113883.3.19.3.163.8", "AB-EHR");

            message.ProfileId.Add(profileId);
            message.ProfileId.Add(abProfileId);

            message.ProcessingCode   = ProcessingID.PRODUCTION;
            message.AcceptAckCode    = AcknowledgementCondition.ALWAYS;
            message.ResponseModeCode = ResponseMode.IMMEDIATE;

            // Set Receiver (system that this query is addressed to)
            Receiver receiver = new Receiver();

            message.Receiver  = receiver;
            receiver.DeviceId = new Identifier("2.16.840.1.113883.3.19.3.163.8", "EHR");
            receiver.Telecom  = new TelecommunicationAddress(URLScheme.HTTP, "www.ehr.ca/ehr");
            receiver.DeviceAgentAgentOrganizationId = null;

            // Set Sender
            message.Sender          = new Sender();
            message.Sender.DeviceId = new Identifier("2.16.840.1.113883.3.19.3.163.8", "DR-BLACK-EMR");
            message.Sender.DeviceManufacturerModelName = "5.0";
            message.Sender.DeviceSoftwareName          = "Infoway EMR";
            TelecommunicationAddress tel = new TelecommunicationAddress();

            tel.Address            = "www.infoway-inforoute.ca/emr";
            tel.UrlScheme          = URLScheme.HTTP;
            message.Sender.Telecom = tel;
            message.Sender.DeviceAgentAgentOrganizationId = null;
        }
Exemple #30
0
        public virtual void TestIncludeUsesAndUseablePeriods()
        {
            PlatformDate             date1   = DateUtil.GetDate(2004, 5, 10, 9, 42, 43, 123);
            PlatformDate             date2   = DateUtil.GetDate(2006, 6, 11, 11, 31, 32, 444);
            TelecommunicationAddress address = new TelecommunicationAddress();

            address.UrlScheme = CeRxDomainTestValues.TELEPHONE;
            address.Address   = "aValue";
            address.AddAddressUse(CeRxDomainTestValues.HOME_ADDRESS);
            address.AddAddressUse(CeRxDomainTestValues.MOBILE_CONTACT);
            address.AddUseablePeriod(new DateWithPattern(date1, "yyyyMMddHHmmss.SSS0"), SetOperator.EXCLUDE);
            address.AddUseablePeriod(new DateWithPattern(date2, "yyyyMMddHHmmss.SSS0"), null);
            string result = new TelR2PropertyFormatter().Format(CreateContext("TEL"), new TELImpl(address));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("xml output", "<name use=\"H MC\" value=\"tel:aValue\"><useablePeriod operator=\"E\" value=\"20040610094243.1230\"/><useablePeriod operator=\"I\" value=\"20060711113132.4440\"/></name>"
                      , result);
        }