Beispiel #1
0
        // Children
        // date
        // granularity
        // numberOfPeriods
        public object Translate(TranslationContext context, ASTNode node)
        {
            var result = new CREFModel.DateAdd();

            var date = node.Children[0];

            result.Items.Add(context.TranslateNode(date));

            var granularity = node.Children[1];

            if (granularity.NodeType == "urn:hl7-org:v3:knowledgeartifact:r1:Literal")             // TODO: Better story for this type of thing....
            {
                result.Granularity          = (CREFModel.DateGranularity)Enum.Parse(typeof(CREFModel.DateGranularity), granularity.GetAttribute <string>("value"));
                result.GranularitySpecified = true;
            }
            else
            {
                throw new NotSupportedException("Date granularity argument to a DateAdd expression must be a literal because CREF does not support granularity as an argument, only as an attribute of the target DateAdd expression.");
            }

            var numberOfPeriods = node.Children[2];

            result.Items.Add(context.TranslateNode(numberOfPeriods));

            return(result);
        }
Beispiel #2
0
        // Children
        // date
        // granularity
        // numberOfPeriods
        public object Translate(TranslationContext context, ASTNode node)
        {
            var result = new CREFModel.DateAdd();

            var date = node.Children[0];
            result.Items.Add(context.TranslateNode(date));

            var granularity = node.Children[1];
            if (granularity.NodeType == "urn:hl7-org:v3:knowledgeartifact:r1:Literal") // TODO: Better story for this type of thing....
            {
                result.Granularity = (CREFModel.DateGranularity)Enum.Parse(typeof(CREFModel.DateGranularity), granularity.GetAttribute<string>("value"));
                result.GranularitySpecified = true;
            }
            else
            {
                throw new NotSupportedException("Date granularity argument to a DateAdd expression must be a literal because CREF does not support granularity as an argument, only as an attribute of the target DateAdd expression.");
            }

            var numberOfPeriods = node.Children[2];
            result.Items.Add(context.TranslateNode(numberOfPeriods));

            return result;
        }