Esempio n. 1
0
        private bool IsValidTypeForAny(string parentType, string specializationType)
        {
            if (StringUtils.IsBlank(specializationType))
            {
                return(false);
            }
            bool valid = AnyHelper.IsValidTypeForAny(parentType, specializationType);

            if (!valid)
            {
                // unqualify only the inner types
                string innerUnqualified = Hl7DataTypeName.UnqualifyInnerTypes(specializationType);
                valid = AnyHelper.IsValidTypeForAny(parentType, innerUnqualified);
            }
            if (!valid)
            {
                // unqualify both outer and inner types)
                string bothUnqualified = Hl7DataTypeName.Unqualify(specializationType);
                valid = AnyHelper.IsValidTypeForAny(parentType, bothUnqualified);
            }
            return(valid);
        }
Esempio n. 2
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));
                }
            }
        }