Exemple #1
0
        private ParseContext HandleSpecializationType(ParseContext context, XmlNode node, XmlToModelResult xmlToModelResult)
        {
            string         type = context.Type;
            string         specializationType = GetSpecializationType(node);
            IList <string> errors             = new List <string>();
            string         newType            = this.ivlValidationUtils.ValidateSpecializationType(type, specializationType, errors);

            RecordAnyErrors(errors, (XmlElement)node, xmlToModelResult);
            if (!StringUtils.Equals(type, newType))
            {
                // replace the context with one using the specialization type
                context = ParseContextImpl.CreateWithConstraints(newType, context);
            }
            return(context);
        }
Exemple #2
0
        private BareANY CreateType(ParseContext context, XmlElement element, XmlToModelResult parseResult)
        {
            string        type   = GetParameterizedType(context);
            ElementParser parser = ParserRegistry.GetInstance().Get(type);

            if (parser != null)
            {
                return(parser.Parse(ParseContextImpl.CreateWithConstraints(type, context), Arrays.AsList((XmlNode)element), parseResult));
            }
            else
            {
                parseResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("Cannot find a parser for type {0}"
                                                                                                        , type), element));
                return(null);
            }
        }
Exemple #3
0
        private object DelegateToConcreteParser(ParseContext context, XmlNode node, BareANY hl7Result, XmlToModelResult xmlToModelResult
                                                )
        {
            object result             = null;
            string parentType         = context == null ? null : context.Type;
            string specializationType = ObtainSpecializationType(parentType, node, xmlToModelResult);

            if (StringUtils.IsNotBlank(specializationType))
            {
                string mappedSpecializationType = this.polymorphismHandler.MapCdaR1Type(StandardDataType.GetByTypeName(specializationType
                                                                                                                       ), context.IsCda());
                ElementParser elementParser = ParserRegistry.GetInstance().Get(mappedSpecializationType);
                if (elementParser == null || !IsValidTypeForAny(parentType, specializationType))
                {
                    xmlToModelResult.AddHl7Error(Hl7Error.CreateInvalidTypeError(specializationType, parentType, (XmlElement)node));
                }
                else
                {
                    BareANY parsedValue = elementParser.Parse(ParseContextImpl.CreateWithConstraints(mappedSpecializationType, DetermineReturnType
                                                                                                         (specializationType, GetReturnType(context)), context), Arrays.AsList(node), xmlToModelResult);
                    result = parsedValue.BareValue;
                    // Yes, this is a side effect of calling this method. If we don't do this then the actual type of the ANY.LAB (i.e. PQ.LAB) is lost.
                    hl7Result.DataType   = parsedValue.DataType;
                    hl7Result.NullFlavor = parsedValue.NullFlavor;
                    // preserve all metadata (yes, also not a great side effect); this will have to be adjusted whenever new metadata is added to a data type (extremely infrequently)
                    if (hl7Result is ANYMetaData && parsedValue is ANYMetaData)
                    {
                        ANYMetaData anyMetaDataResult = (ANYMetaData)hl7Result;
                        ANYMetaData anyMetaDataParsed = (ANYMetaData)parsedValue;
                        anyMetaDataResult.Language     = anyMetaDataParsed.Language;
                        anyMetaDataResult.DisplayName  = anyMetaDataParsed.DisplayName;
                        anyMetaDataResult.OriginalText = anyMetaDataParsed.OriginalText;
                        anyMetaDataResult.Translations.AddAll(anyMetaDataParsed.Translations);
                        anyMetaDataResult.IsCdata  = anyMetaDataParsed.IsCdata;
                        anyMetaDataResult.Operator = anyMetaDataParsed.Operator;
                        anyMetaDataResult.Unsorted = anyMetaDataParsed.Unsorted;
                    }
                }
            }
            else
            {
                xmlToModelResult.AddHl7Error(Hl7Error.CreateMissingMandatoryAttributeError(AbstractElementParser.SPECIALIZATION_TYPE, (XmlElement
                                                                                                                                       )node));
            }
            return(result);
        }
Exemple #4
0
        private ParseContext ConvertContext(ParseContext context)
        {
            string newType = "IVL<" + Hl7DataTypeName.GetParameterizedType(context.Type) + ">";

            return(ParseContextImpl.CreateWithConstraints(newType, context));
        }