Ejemplo n.º 1
0
        protected override string GetValue(MbDate mbDate, FormatContext context, BareANY bareAny)
        {
            PlatformDate date = (mbDate == null ? null : mbDate.Value);
            // write out the date using the "full" pattern; clients can override this using a system property or a DateWithPattern date
            VersionNumber version     = GetVersion(context);
            string        datePattern = DetermineDateFormat(date, version);

            ValidateDatePattern(datePattern, context);
            TimeZoneInfo timeZone = context != null && context.GetDateTimeTimeZone() != null?context.GetDateTimeTimeZone() : System.TimeZoneInfo.Local;

            return(DateFormatUtil.Format(date, datePattern, timeZone));
        }
Ejemplo n.º 2
0
        protected override string GetValue(PlatformDate date, FormatContext context, BareANY bareAny)
        {
            // write out the date using the applicable "full" pattern; clients can override this using a system property or a DateWithPattern date
            VersionNumber    version          = GetVersion(context);
            StandardDataType standardDataType = StandardDataType.GetByTypeName(context);
            string           datePattern      = DetermineDateFormat(standardDataType, date, version);

            ValidateDatePattern(datePattern, context);
            TimeZoneInfo timeZone = context != null && context.GetDateTimeTimeZone() != null?context.GetDateTimeTimeZone() : System.TimeZoneInfo.Local;

            return(DateFormatUtil.Format(date, datePattern, timeZone));
        }
Ejemplo n.º 3
0
 public FormatContextImpl(string newType, bool isSpecializationType, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel newConformanceLevel
                          , Cardinality newCardinality, string elementName, FormatContext context) : this(context.GetModelToXmlResult(), context.GetPropertyPath
                                                                                                              (), elementName, newType, context.GetDomainType(), newConformanceLevel, newCardinality, isSpecializationType, context.GetVersion
                                                                                                              (), context.GetDateTimeZone(), context.GetDateTimeTimeZone(), context.GetCodingStrength(), null, context.IsCda())
 {
 }
Ejemplo n.º 4
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));
                }
            }
        }
Ejemplo n.º 5
0
 // only checking II constraints for now
 protected virtual FormatContext CreateSubContext(FormatContext context)
 {
     return(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(context.GetModelToXmlResult(), context.GetPropertyPath
                                                                                          (), context.GetElementName(), GetSubType(context), context.GetDomainType(), context.GetConformanceLevel(), context.GetCardinality
                                                                                          (), context.IsSpecializationType(), context.GetVersion(), context.GetDateTimeZone(), context.GetDateTimeTimeZone(), null
                                                                                      , null, context.IsCda()));
 }