コード例 #1
0
 // tests only
 public static ParseContext Create(string type, System.Type returnType, VersionNumber version, TimeZoneInfo dateTimeZone,
                                   TimeZoneInfo dateTimeTimeZone, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformance, Cardinality cardinality, CodingStrength
                                   strength, Int32?length, ConstrainedDatatype constraints, bool isCda)
 {
     return(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Parser.ParseContextImpl(type, returnType, version, dateTimeZone, dateTimeTimeZone
                                                                                  , conformance, cardinality, strength, length, constraints, isCda, false));
 }
コード例 #2
0
 public FormatContextImpl(ModelToXmlResult result, string propertyPath, string elementName, string type, string domainType
                          , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality, bool isSpecializationType, VersionNumber
                          version, TimeZoneInfo dateTimeZone, TimeZoneInfo dateTimeTimeZone, CodingStrength codingStrength, ConstrainedDatatype constraints
                          , bool isCda)
 {
     // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required)
     // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required)
     // TM - CDA - modified this case to set isSpecializationType to false (must specifically specify this value if it is required)
     // constraints not automatically passed on
     // tests only
     // tests only
     this.result               = result;
     this.propertyPath         = propertyPath;
     this.elementName          = elementName;
     this.type                 = type;
     this.domainType           = domainType;
     this.conformanceLevel     = conformanceLevel;
     this.cardinality          = cardinality;
     this.isSpecializationType = isSpecializationType;
     this.version              = version;
     this.dateTimeZone         = dateTimeZone;
     this.dateTimeTimeZone     = dateTimeTimeZone;
     this.codingStrength       = codingStrength;
     this.constraints          = constraints;
     this.isCda                = isCda;
 }
コード例 #3
0
 /// <summary>Get a flag indicating whether or not the relationship is populated.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is populated.</remarks>
 /// <returns>true if the relationship is populated; false otherwise.</returns>
 public static bool IsPopulated(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     // - this *almost* matches what MB was doing prior to a Remixer change to BaseMifProcessorImpl
     // - IGNORED and NOT_ALLOWED with a min cardinality > 0 (a very strange state!) will behave differently than before the Remixer change
     // - populated should eventually be removed as a conformance altogether
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED.Equals(conformanceLevel) || (Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                                                  .REQUIRED.Equals(conformanceLevel) && cardinality.Mandatory));
 }
コード例 #4
0
 public static ParseContext Create(string newType, System.Type newReturnType, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                   newConformance, Cardinality newCardinality, ParseContext oldContext)
 {
     // not passing constraints down unless constraints are explicitly provided
     return(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Parser.ParseContextImpl(newType, newReturnType, oldContext.GetVersion
                                                                                      (), oldContext.GetDateTimeZone(), oldContext.GetDateTimeTimeZone(), newConformance, newCardinality, oldContext.GetCodingStrength
                                                                                      (), oldContext.GetLength(), null, oldContext.IsCda(), oldContext.IsFixedValue()));
 }
コード例 #5
0
        protected virtual bool IsMandatoryOrPopulated(FormatContext context)
        {
            Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformance = context.GetConformanceLevel();
            Cardinality cardinality = context.GetCardinality();

            return(ConformanceLevelUtil.IsMandatory(conformance, cardinality) || ConformanceLevelUtil.IsPopulated(conformance, cardinality
                                                                                                                  ));
        }
コード例 #6
0
 private ParseContextImpl(string type, System.Type returnType, VersionNumber version, TimeZoneInfo dateTimeZone, TimeZoneInfo
                          dateTimeTimeZone, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformance, Cardinality cardinality, CodingStrength strength
                          , Int32?length, ConstrainedDatatype constraints, bool isCda, bool isFixedValue)
 {
     this.type = type;
     this.expectedReturnType = returnType;
     this.version            = version;
     this.dateTimeZone       = dateTimeZone;
     this.dateTimeTimeZone   = dateTimeTimeZone;
     this.conformance        = conformance;
     this.cardinality        = cardinality;
     this.strength           = strength;
     this.length             = length;
     this.constraints        = constraints;
     this.isCda        = isCda;
     this.isFixedValue = isFixedValue;
 }
コード例 #7
0
        public override string Format(FormatContext context, BareANY hl7Value, int indentLevel)
        {
            string result = string.Empty;

            if (hl7Value != null)
            {
                V value = ExtractBareValue(hl7Value);
                Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel = context.GetConformanceLevel();
                Cardinality cardinality = context.GetCardinality();
                if (hl7Value.HasNullFlavor())
                {
                    result = CreateElement(context, CreateNullFlavorAttributes(hl7Value.NullFlavor), indentLevel, true, true);
                    if (ConformanceLevelUtil.IsMandatory(conformanceLevel, cardinality))
                    {
                        CreateMissingMandatoryWarning(context);
                    }
                }
                else
                {
                    if (value == null || IsEmptyCollection(value))
                    {
                        if (conformanceLevel == null || IsMandatoryOrPopulated(context))
                        {
                            if (ConformanceLevelUtil.IsMandatory(conformanceLevel, cardinality))
                            {
                                result = CreateElement(context, AbstractPropertyFormatter.EMPTY_ATTRIBUTE_MAP, indentLevel, true, true);
                                CreateMissingMandatoryWarning(context);
                            }
                            else
                            {
                                result = CreateElement(context, AbstractPropertyFormatter.NULL_FLAVOR_ATTRIBUTES, indentLevel, true, true);
                            }
                        }
                    }
                    else
                    {
                        result = FormatNonNullDataType(context, hl7Value, indentLevel);
                    }
                }
            }
            return(result);
        }
コード例 #8
0
 private void HandleNullFlavor(CodedTypeR2 <Code> codedType, IDictionary <string, string> result, BareANY bareAny, FormatContext
                               context)
 {
     if (bareAny != null && bareAny.HasNullFlavor())
     {
         result.PutAll(CreateNullFlavorAttributes(bareAny.NullFlavor));
     }
     else
     {
         if (codedType == null)
         {
             Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel = context.GetConformanceLevel();
             Cardinality cardinality = context.GetCardinality();
             if (conformanceLevel == null || ConformanceLevelUtil.IsPopulated(conformanceLevel, cardinality))
             {
                 result.PutAll(AbstractPropertyFormatter.NULL_FLAVOR_ATTRIBUTES);
             }
         }
     }
 }
コード例 #9
0
 public FormatContextImpl(ModelToXmlResult result, string propertyPath, string elementName, string type, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                          conformanceLevel, Cardinality cardinality, bool isSpecializationType, VersionNumber version, TimeZoneInfo dateTimeZone,
                          TimeZoneInfo dateTimeTimeZone, CodingStrength codingStrength, bool isCda) : this(result, propertyPath, elementName, type
                                                                                                           , null, conformanceLevel, cardinality, isSpecializationType, version, dateTimeZone, dateTimeTimeZone, codingStrength, null
                                                                                                           , isCda)
 {
 }
コード例 #10
0
 /// <summary>Get a flag indicating whether or not the relationship is not allowed.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is not allowed.</remarks>
 /// <returns>true if the relationship is not allowed; false otherwise.</returns>
 public static bool IsNotAllowed(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.NOT_ALLOWED.Equals(conformanceLevel));
 }
コード例 #11
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())
 {
 }
コード例 #12
0
 public FormatContextImpl(ModelToXmlResult result, string propertyPath, string elementName, string type, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                          conformanceLevel, Cardinality cardinality, bool isCda) : this(result, propertyPath, elementName, type, null, conformanceLevel
                                                                                        , cardinality, false, null, null, null, null, null, isCda)
 {
 }
コード例 #13
0
 private ParseContext CreateContext(string typeName, Type c, VersionNumber version, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                    conformance, CodingStrength strength)
 {
     return(ParseContextImpl.Create(typeName, c, version, null, null, conformance, null, strength, null, null, false));
 }
コード例 #14
0
 public FormatContextImpl(string newType, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel newConformanceLevel, Cardinality
                          newCardinality, string elementName, FormatContext context) : this(newType, false, newConformanceLevel, newCardinality, elementName
                                                                                            , context)
 {
 }
コード例 #15
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());
        }
コード例 #16
0
 /// <summary>Get a flag indicating whether or not the relationship is required.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is required.</remarks>
 /// <returns>true if the relationship is required; false otherwise.</returns>
 public static bool IsRequired(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.REQUIRED.Equals(conformanceLevel) && !cardinality.Mandatory);
 }
コード例 #17
0
 /// <summary>Get a flag indicating whether or not the relationship is mandatory.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is mandatory.</remarks>
 /// <returns>true if the relationship is mandatory; false otherwise.</returns>
 public static bool IsMandatory(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY.Equals(conformanceLevel));
 }
コード例 #18
0
 /// <summary>Get a flag indicating whether or not the relationship is optional.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is optional.</remarks>
 /// <returns>true if the relationship is optional; false otherwise.</returns>
 public static bool IsOptional(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL.Equals(conformanceLevel));
 }
コード例 #19
0
 /// <summary>Get a flag indicating whether or not the relationship is ignored.</summary>
 /// <remarks>Get a flag indicating whether or not the relationship is ignored.</remarks>
 /// <returns>true if the relationship is ignored; false otherwise.</returns>
 public static bool IsIgnored(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality)
 {
     return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.IGNORED.Equals(conformanceLevel));
 }