示例#1
0
        private object GetRelatedClinicalStatement(TranslationContext context, ASTNode node, string idPropertyName, SQLModel.PatientQueryType type)
        {
            var propertyNode = GetRelatedClinicalStatementPropertyNode(node);

            if (propertyNode == null)
            {
                throw new InvalidOperationException("Could not resolve related clinical statement property access node.");
            }

            var id     = new SQLModel.PropertyExpression();
            var source = propertyNode.Children.FirstOrDefault();

            if (source != null)
            {
                id.Item = context.TranslateNode(source);
            }
            id.Path = idPropertyName;

            var request = new SQLModel.RequestExpression();

            request.Cardinality          = SQLModel.RequestCardinality.Multiple;
            request.CardinalitySpecified = true;

            request.Type          = type;
            request.TypeSpecified = true;

            var filter = new SQLModel.FilterExpression();

            filter.Items.Add(request);

            var condition = new SQLModel.BinaryExpression();

            condition.Operator          = SQLModel.BinaryOperator.opEqual;
            condition.OperatorSpecified = true;

            var idReference = new SQLModel.PropertyExpression();

            idReference.Path = "ID";
            condition.Items.Add(idReference);
            condition.Items.Add(id);

            filter.Items.Add(condition);

            var first = new SQLModel.UnaryExpression();

            first.Item              = filter;
            first.Operator          = SQLModel.UnaryOperator.opFirst;
            first.OperatorSpecified = true;

            return(first);
        }
		protected object GetCalculateAgeExpression(TranslationContext context, object result)
		{
			var calculateAge = new SQLModel.CalculateAge();

			calculateAge.Items.Add(result);

			var binaryExpression = new SQLModel.BinaryExpression();

			// Returns as years, so multiply by days/year to get consistent results with the physical quantity translator
			binaryExpression.Operator = SQLModel.BinaryOperator.opMultiply;
			binaryExpression.OperatorSpecified = true;
			binaryExpression.Items.Add(calculateAge);

			var multiplier = new SQLModel.ValueExpression();
			multiplier.Type = SQLModel.ValueType.Decimal;
			multiplier.TypeSpecified = true;
			multiplier.Value = Convert.ToString(365.25m);

			binaryExpression.Items.Add(multiplier);

			return binaryExpression;
		}
示例#3
0
        protected object GetCalculateAgeExpression(TranslationContext context, object result)
        {
            var calculateAge = new SQLModel.CalculateAge();

            calculateAge.Items.Add(result);

            var binaryExpression = new SQLModel.BinaryExpression();

            // Returns as years, so multiply by days/year to get consistent results with the physical quantity translator
            binaryExpression.Operator          = SQLModel.BinaryOperator.opMultiply;
            binaryExpression.OperatorSpecified = true;
            binaryExpression.Items.Add(calculateAge);

            var multiplier = new SQLModel.ValueExpression();

            multiplier.Type          = SQLModel.ValueType.Decimal;
            multiplier.TypeSpecified = true;
            multiplier.Value         = Convert.ToString(365.25m);

            binaryExpression.Items.Add(multiplier);

            return(binaryExpression);
        }
        private object GetRelatedClinicalStatement(TranslationContext context, ASTNode node, string idPropertyName, SQLModel.PatientQueryType type)
        {
            var propertyNode = GetRelatedClinicalStatementPropertyNode(node);
            if (propertyNode == null)
            {
                throw new InvalidOperationException("Could not resolve related clinical statement property access node.");
            }

            var id = new SQLModel.PropertyExpression();
            var source = propertyNode.Children.FirstOrDefault();
            if (source != null)
            {
                id.Item = context.TranslateNode(source);
            }
            id.Path = idPropertyName;

            var request = new SQLModel.RequestExpression();
            request.Cardinality = SQLModel.RequestCardinality.Multiple;
            request.CardinalitySpecified = true;

            request.Type = type;
            request.TypeSpecified = true;

            var filter = new SQLModel.FilterExpression();
            filter.Items.Add(request);
                    
            var condition = new SQLModel.BinaryExpression();
            condition.Operator = SQLModel.BinaryOperator.opEqual;
            condition.OperatorSpecified = true;

            var idReference = new SQLModel.PropertyExpression();
            idReference.Path = "ID";
            condition.Items.Add(idReference);
            condition.Items.Add(id);

            filter.Items.Add(condition);

            var first = new SQLModel.UnaryExpression();
            first.Item = filter;
            first.Operator = SQLModel.UnaryOperator.opFirst;
            first.OperatorSpecified = true;

            return first;
        }