示例#1
0
        private void HandleConstraints(Identifier identifier, FormatContext context)
        {
            ErrorLogger logger = new _ErrorLogger_164(context);

            this.constraintsHandler.HandleConstraints(context.GetConstraints(), identifier, logger, IsSingleCardinality(context.GetCardinality
                                                                                                                            ()));
        }
示例#2
0
        protected override string FormatNonNullDataType(FormatContext context, BareANY dataType, int indentLevel)
        {
            EncapsulatedData encapsulatedData = ExtractBareValue(dataType);

            HandleConstraints(encapsulatedData, context.GetConstraints(), context.GetPropertyPath(), context.GetModelToXmlResult());
            IDictionary <string, string> attributes = CreateAttributes(encapsulatedData, context);
            bool hasContent = HasContent(encapsulatedData);
            bool hasReferenceOrThumbnailOrDocument = HasReferenceOrThumbnailOrDocument(encapsulatedData);

            if (!this.isR2)
            {
                AddSpecializationType(encapsulatedData, attributes, context.Type, dataType.DataType, context.GetVersion());
                Validate(context, dataType, encapsulatedData);
            }
            StringBuilder buffer = new StringBuilder();

            buffer.Append(CreateElement(context, attributes, indentLevel, !hasContent, hasReferenceOrThumbnailOrDocument));
            if (hasContent)
            {
                WriteReference(encapsulatedData, buffer, indentLevel + 1, context);
                WriteThumbnail(encapsulatedData, buffer, indentLevel + 1, context);
                this.edContentRenderer.RenderContent(encapsulatedData, buffer, indentLevel + 1, context, hasReferenceOrThumbnailOrDocument
                                                     );
                buffer.Append(CreateElementClosure(context, hasReferenceOrThumbnailOrDocument ? indentLevel : 0, true));
            }
            return(buffer.ToString());
        }
示例#3
0
        // constraints are not passed down from collection attributes
        public override string Format(FormatContext context, BareANY hl7Value, int indentLevel)
        {
            if (hl7Value == null)
            {
                return(string.Empty);
            }
            ICollection <BareANY> bareAnyCollection = GenericClassUtil.ConvertToBareANYCollection(hl7Value);

            HandleConstraints(GetSubType(context), context.GetConstraints(), hl7Value, bareAnyCollection, context);
            return(base.Format(context, hl7Value, indentLevel));
        }
示例#4
0
        public virtual string Format(FormatContext context, BareANY dataType, int indentLevel)
        {
            if (dataType == null)
            {
                return(string.Empty);
            }
            HandleConstraints(context.GetConstraints(), context.GetModelToXmlResult(), context.GetPropertyPath(), (DateInterval)dataType
                              .BareValue);
            FormatContext newContext  = ConvertContext(context);
            BareANY       newDataType = ConvertDataType(dataType);

            return(this.r1Formatter.Format(newContext, newDataType, indentLevel));
        }
示例#5
0
        protected override string FormatNonNullDataType(FormatContext context, BareANY hl7Value, int indentLevel)
        {
            CodedTypeR2 <Code> codedType = ExtractBareValue(hl7Value);

            HandleConstraints(codedType, context.GetConstraints(), context.GetPropertyPath(), context.GetModelToXmlResult());
            StringBuilder result = new StringBuilder();
            IDictionary <string, string> attributes = GetAttributeNameValuePairs(context, codedType, hl7Value);

            ValidateChildContent(codedType, context);
            bool hasChildContent = HasChildContent(codedType, context);
            bool hasSimpleValue  = (SimpleValueAllowed() && HasSimpleValue(codedType));

            if (hasChildContent || hasSimpleValue || !attributes.IsEmpty())
            {
                result.Append(CreateElement(context, attributes, indentLevel, !(hasChildContent || hasSimpleValue), !hasSimpleValue || hasChildContent
                                            ));
                if (hasChildContent || hasSimpleValue)
                {
                    CreateChildContent(codedType, context, indentLevel + 1, result);
                    result.Append(CreateElementClosure(context, indentLevel, true));
                }
            }
            return(result.ToString());
        }
示例#6
0
        public override string Format(FormatContext context, BareANY hl7Value, int indentLevel)
        {
            bool isAny = false;
            CD   cd    = null;

            if (hl7Value is CD)
            {
                cd = (CD)hl7Value;
            }
            else
            {
                isAny = true;
                // bypass some validations
                cd = ConvertAnyToCd(hl7Value);
            }
            StringBuilder result = new StringBuilder();

            if (cd != null)
            {
                HandleConstraints(cd.Value, context.GetConstraints(), context.GetPropertyPath(), context.GetModelToXmlResult());
                // don't bother validating if we don't have anything to validate
                if (cd.HasNullFlavor() || HasValue(cd, context))
                {
                    Hl7Errors     errors  = context.GetModelToXmlResult();
                    VersionNumber version = context.GetVersion();
                    string        type    = context.Type;
                    bool          isCne   = context.GetCodingStrength() == CodingStrength.CNE;
                    bool          isCwe   = context.GetCodingStrength() == CodingStrength.CWE;
                    // we can't lookup a code supplied in an ANY datatype as we don't know the domain
                    // a "reverse" lookup of domain type by code/codesystem could be possible, but difficult to implement to be 100% correct (MB does not track code systems)
                    if (!isAny)
                    {
                        if (cd.Value != null && cd.Value.CodeValue != null)
                        {
                            ValidateCodeExists(cd.Value, context.GetDomainType(), version, context.IsCda(), context.GetPropertyPath(), errors);
                        }
                    }
                    string codeAsString = (cd.Value != null ? cd.Value.CodeValue : null);
                    CD_VALIDATION_UTILS.ValidateCodedType(cd, codeAsString, isCwe, isCne, false, context.IsFixed(), type, version, null, context
                                                          .GetPropertyPath(), errors);
                }
                IDictionary <string, string> attributes = new Dictionary <string, string>();
                Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel = context.GetConformanceLevel();
                Cardinality cardinality = context.GetCardinality();
                if (cd.HasNullFlavor())
                {
                    if (ConformanceLevelUtil.IsMandatory(conformanceLevel, cardinality))
                    {
                        LogMandatoryError(context);
                    }
                    else
                    {
                        attributes.PutAll(CreateNullFlavorAttributes(hl7Value.NullFlavor));
                    }
                }
                else
                {
                    if (!HasValue(cd, context))
                    {
                        if (conformanceLevel == null || IsMandatoryOrPopulated(context))
                        {
                            if (ConformanceLevelUtil.IsMandatory(conformanceLevel, cardinality))
                            {
                                LogMandatoryError(context);
                            }
                            else
                            {
                                attributes.PutAll(AbstractPropertyFormatter.NULL_FLAVOR_ATTRIBUTES);
                            }
                        }
                    }
                }
                // Codes can have other attributes in map even if has NullFlavor
                attributes.PutAll(GetAttributeNameValuePairs(context, cd.Value, hl7Value));
                bool hasChildContent = HasChildContent(cd, context);
                if (hasChildContent || (!attributes.IsEmpty() || ConformanceLevelUtil.IsMandatory(conformanceLevel, cardinality)))
                {
                    result.Append(CreateElement(context, attributes, indentLevel, !hasChildContent, !hasChildContent));
                    if (hasChildContent)
                    {
                        CreateChildContent(cd, result);
                        result.Append("</").Append(context.GetElementName()).Append(">");
                        result.Append(SystemUtils.LINE_SEPARATOR);
                    }
                }
            }
            return(result.ToString());
        }
示例#7
0
        private void HandleConstraints(FormatContext context, Hl7Errors errors, string propertyPath, DateInterval dateInterval)
        {
            ErrorLogger logger = new _ErrorLogger_74(errors, propertyPath);

            this.constraintsHandler.HandleConstraints(context.GetConstraints(), dateInterval, logger);
        }
示例#8
0
        public override string Format(FormatContext formatContext, BareANY hl7Value, int indentLevel)
        {
            if (hl7Value == null)
            {
                return(string.Empty);
            }
            string           specializationType       = hl7Value.DataType.Type;
            StandardDataType specializationTypeAsEnum = StandardDataType.GetByTypeName(specializationType);

            if (specializationTypeAsEnum != null && StandardDataType.ANY.Equals(specializationTypeAsEnum.RootDataType))
            {
                // specializationType has been determined to be an ANY variant; this (most likely) means specializationType has not been specified, so don't do any special processing
                return(base.Format(formatContext, hl7Value, indentLevel));
            }
            else
            {
                string            mappedSpecializationType = this.polymorphismHandler.MapCdaR1Type(hl7Value.DataType, formatContext.IsCda());
                PropertyFormatter formatter  = FormatterRegistry.GetInstance().Get(mappedSpecializationType);
                string            parentType = formatContext.Type;
                if (formatter == null || !AnyHelper.IsValidTypeForAny(parentType, specializationType))
                {
                    string errorText = "Cannot support properties of type " + specializationType + " for " + parentType + ". Please specify a specializationType applicable for "
                                       + parentType + " in the appropriate message bean.";
                    throw new ModelToXmlTransformationException(errorText);
                }
                else
                {
                    // pass processing off to the formatter applicable for the given specializationType
                    StandardDataType type = hl7Value.DataType;
                    return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(formatContext.GetModelToXmlResult
                                                                                                                          (), formatContext.GetPropertyPath(), formatContext.GetElementName(), mappedSpecializationType, type.Coded ? "Code" : formatContext
                                                                                                                      .GetDomainType(), formatContext.GetConformanceLevel(), formatContext.GetCardinality(), true, formatContext.GetVersion(),
                                                                                                                      formatContext.GetDateTimeZone(), formatContext.GetDateTimeTimeZone(), null, formatContext.GetConstraints(), formatContext
                                                                                                                      .IsCda()), hl7Value, indentLevel));
                }
            }
        }