示例#1
0
        protected virtual string FormatAllElements(FormatContext originalContext, FormatContext subContext, ICollection <BareANY>
                                                   collection, int indentLevel)
        {
            StringBuilder builder = new StringBuilder();

            ValidateCardinality(originalContext, collection);
            PropertyFormatter formatter = this.formatterRegistry.Get(subContext.Type);

            if (collection.IsEmpty())
            {
                builder.Append(formatter.Format(subContext, null, indentLevel));
            }
            else
            {
                foreach (BareANY hl7Value in EmptyIterable <object> .NullSafeIterable <BareANY>(collection))
                {
                    string type = DetermineActualType(subContext.Type, hl7Value, originalContext.GetModelToXmlResult(), originalContext.GetPropertyPath
                                                          (), originalContext.IsCda());
                    if (!StringUtils.Equals(type, subContext.Type))
                    {
                        subContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, true, subContext);
                        formatter  = this.formatterRegistry.Get(type);
                    }
                    builder.Append(formatter.Format(subContext, hl7Value, indentLevel));
                }
            }
            return(builder.ToString());
        }
示例#2
0
        internal static IList <Mapping> From(IList <string> mappings, Hl7MapByPartTypeAttribute[] exceptions)
        {
            IList <Mapping> result = new List <Mapping>();

            foreach (string mapping in EmptyIterable <object> .NullSafeIterable <string>(mappings))
            {
                result.Add(new Mapping(mapping, ExtractPartTypeMappings(exceptions)));
            }
            return(result);
        }
示例#3
0
        protected sealed override string FormatNonNullValue(FormatContext context, PostalAddress postalAddress, int indentLevel)
        {
            Hl7BaseVersion baseVersion = context.GetVersion().GetBaseVersion();
            string         dataType    = context.Type;

            AbstractAdPropertyFormatter.AD_VALIDATION_UTILS.ValidatePostalAddress(postalAddress, dataType, context.GetVersion(), null
                                                                                  , context.GetPropertyPath(), context.GetModelToXmlResult());
            PostalAddress basicAddress = new PostalAddress();
            StringBuilder builder      = new StringBuilder();

            // remove any non-basic address parts
            foreach (PostalAddressPart part in EmptyIterable <object> .NullSafeIterable(postalAddress.Parts))
            {
                if (part.Type == PostalAddressPartType.CITY || part.Type == PostalAddressPartType.STATE || part.Type == PostalAddressPartType
                    .COUNTRY || part.Type == PostalAddressPartType.POSTAL_CODE || part.Type == PostalAddressPartType.DELIMITER)
                {
                    Flush(builder, basicAddress);
                    basicAddress.AddPostalAddressPart(part);
                }
                else
                {
                    if (StringUtils.IsNotBlank(part.Value))
                    {
                        if (builder.Length > 0)
                        {
                            builder.Append(" ");
                        }
                        builder.Append(part.Value);
                    }
                }
            }
            Flush(builder, basicAddress);
            foreach (Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse use in postalAddress.Uses)
            {
                if (AbstractAdPropertyFormatter.AD_VALIDATION_UTILS.IsAllowableUse(dataType, use, baseVersion))
                {
                    basicAddress.AddUse(use);
                }
            }
            return(base.FormatNonNullValue(context, basicAddress, indentLevel));
        }