Esempio n. 1
0
        private void AppendPostalAddressPart(StringBuilder buffer, PostalAddressPart postalAddressPart)
        {
            string openTag     = string.Empty;
            string closeTag    = string.Empty;
            bool   isDelimiter = IsDelimiter(postalAddressPart);

            if (postalAddressPart.Type != null)
            {
                if (isDelimiter && StringUtils.IsBlank(postalAddressPart.Value))
                {
                    openTag = "<" + postalAddressPart.Type.Value + "/>";
                }
                else
                {
                    openTag  = "<" + postalAddressPart.Type.Value + FormatCode(postalAddressPart.Code) + ">";
                    closeTag = "</" + postalAddressPart.Type.Value + ">";
                }
            }
            buffer.Append(openTag);
            string xmlEscapedValue = XmlStringEscape.Escape(postalAddressPart.Value);

            if (xmlEscapedValue != null)
            {
                buffer.Append(xmlEscapedValue);
            }
            buffer.Append(closeTag);
        }
Esempio n. 2
0
 private void AssertPostalAddressPartAsExpected(string message, PostalAddressPart postalAddressPart, PostalAddressPartType
                                                expectedType, string expectedValue, string expectedCode)
 {
     Assert.AreEqual(expectedType, postalAddressPart.Type, message + " type");
     Assert.AreEqual(expectedValue, postalAddressPart.Value, message + " value");
     Assert.AreEqual(expectedCode, postalAddressPart.Code == null ? null : postalAddressPart.Code.CodeValue, message + " code"
                     );
 }
Esempio n. 3
0
        private bool IsDelimiter(PostalAddressPart postalAddressPart)
        {
            bool result = false;

            if (postalAddressPart != null && postalAddressPart.Type != null)
            {
                result = PostalAddressPartType.DELIMITER.CodeValue.Equals(postalAddressPart.Type.CodeValue);
            }
            return(result);
        }
Esempio n. 4
0
        // Record Target Set up
        protected Patient CreateRecordTarget()
        {
            // Set the Patient we're querying against
            Patient patient = new Patient();

            // Set patient identifier(s)d
            patient.Id.Add(new Identifier("2.16.840.1.113883.3.19.3.163.1", "9880897949"));

            // Set Patient Name
            patient.PatientPerson      = new ActingPerson();
            patient.PatientPerson.Name = PersonName.CreateFirstNameLastName("Cyril", "Lambert");
            EntityNamePart prefix = new EntityNamePart("Mr.", PersonNamePartType.PREFIX);

            patient.PatientPerson.Name.Uses.Add(EntityNameUse.LEGAL);
            patient.PatientPerson.Name.AddNamePart(prefix);

            // Now set the patient's birthdate
            patient.PatientPerson.BirthTime = new PlatformDate(new DateTime(1949, 11, 05)); // client birth date

            // Set Gender
            patient.PatientPerson.AdministrativeGenderCode = AdministrativeGender.MALE;

            // Set the address for this patient
            PostalAddress addr = new PostalAddress();

            addr.Uses.Add(X_BasicPostalAddressUse.HOME);
            addr.Uses.Add(X_BasicPostalAddressUse.PHYSICAL);
            addr.Uses.Add(X_BasicPostalAddressUse.POSTAL);

            PostalAddressPart part = new PostalAddressPart();

            part.Type  = null;
            part.Value = "1234 Main Street";
            addr.AddPostalAddressPart(part);

            part       = new PostalAddressPart();
            part.Type  = PostalAddressPartType.CITY;
            part.Value = "Calgary";
            addr.AddPostalAddressPart(part);

            part       = new PostalAddressPart();
            part.Type  = PostalAddressPartType.STATE;
            part.Value = "Alberta";
            addr.AddPostalAddressPart(part);

            part       = new PostalAddressPart();
            part.Type  = PostalAddressPartType.COUNTRY;
            part.Value = "Canada";
            addr.AddPostalAddressPart(part);

            patient.Addr = addr;

            return(patient);
        }
Esempio n. 5
0
        private void AppendPostalAddressPart(StringBuilder buffer, PostalAddressPart postalAddressPart, int indentLevel)
        {
            bool   hasPartType = postalAddressPart.Type != null;
            bool   hasValue    = postalAddressPart.Value != null && postalAddressPart.Value.Length > 0;
            string tagName     = (hasPartType ? postalAddressPart.Type.Value : string.Empty);

            if (hasPartType)
            {
                if (!hasValue)
                {
                    buffer.Append(CreateElement(tagName, null, indentLevel, true, true));
                }
                else
                {
                    buffer.Append(CreateElement(tagName, GetCodeAttributes(postalAddressPart.Code), indentLevel, false, false));
                }
            }
            if (hasValue)
            {
                if (!hasPartType)
                {
                    Indenter.IndentBuffer(buffer, indentLevel);
                }
                string xmlEscapedValue = XmlStringEscape.Escape(postalAddressPart.Value);
                if (xmlEscapedValue != null)
                {
                    buffer.Append(xmlEscapedValue);
                }
            }
            if (hasPartType && hasValue)
            {
                buffer.Append(CreateElementClosure(tagName, 0, true));
            }
            else
            {
                buffer.Append(SystemUtils.LINE_SEPARATOR);
            }
        }