private object GetRelatedClinicalStatement(TranslationContext context, ASTNode node, string idPropertyName, CREFModel.PatientQueryType type) { var propertyNode = GetRelatedClinicalStatementPropertyNode(node); if (propertyNode == null) { throw new InvalidOperationException("Could not resolve related clinical statement property access node."); } var id = new CREFModel.PropertyExpression(); var source = propertyNode.Children.FirstOrDefault(); if (source != null) { id.Item = context.TranslateNode(source); } id.Path = idPropertyName; var request = new CREFModel.RequestExpression(); request.Cardinality = CREFModel.RequestCardinality.Multiple; request.CardinalitySpecified = true; request.Type = type; request.TypeSpecified = true; var filter = new CREFModel.FilterExpression(); filter.Items.Add(request); var condition = new CREFModel.BinaryExpression(); condition.Operator = CREFModel.BinaryOperator.opEqual; condition.OperatorSpecified = true; var idReference = new CREFModel.PropertyExpression(); idReference.Path = "ID"; condition.Items.Add(idReference); condition.Items.Add(id); filter.Items.Add(condition); var first = new CREFModel.UnaryExpression(); first.Item = filter; first.Operator = CREFModel.UnaryOperator.opFirst; first.OperatorSpecified = true; return(first); }
public object Translate(TranslationContext context, ASTNode node) { // Model mapping var result = new CREFModel.RequestExpression(); if (node.ResultType == null) { throw new InvalidOperationException("Clinical request expression has no result type."); } var cardinality = (RequestCardinality)Enum.Parse(typeof(RequestCardinality), node.Attributes["cardinality"].ToString(), true); result.Cardinality = cardinality == RequestCardinality.Single ? CREFModel.RequestCardinality.Single : CREFModel.RequestCardinality.Multiple; result.CardinalitySpecified = true; var requestListType = node.ResultType as ListType; var requestType = (requestListType == null ? node.ResultType : requestListType.ElementType) as ObjectType; if (requestType == null) { throw new InvalidOperationException(String.Format("Unable to determine request type from source type: '{0}'.", node.ResultType.Name)); } result.Type = GetQueryType(context.TransformModelType(requestType)); result.TypeSpecified = true; // Translate Codes var codes = node.Children.Where(n => n.Name == "codes").FirstOrDefault(); if (codes != null) { var codesResult = context.TranslateNode(codes); result.Items.Add(codesResult); } // Translate DateRange var dateRange = node.Children.Where(n => n.Name == "dateRange").FirstOrDefault(); if (dateRange != null) { var dateRangeResult = context.TranslateNode(dateRange); result.Items.Add(dateRangeResult); } // Validate idProperty, dateProperty, and codeProperty ValidateIdProperty(requestType, node.GetAttribute<string>("idProperty")); ValidateDateProperty(requestType, node.GetAttribute<string>("dateProperty")); ValidateCodeProperty(requestType, node.GetAttribute<string>("codeProperty")); // Add status filters if necessary var filterValue = GetStatusFilterValue(requestType); if (!String.IsNullOrEmpty(filterValue)) { var filter = new CREFModel.FilterExpression(); filter.Items.Add(result); var condition = new CREFModel.BinaryExpression(); condition.Operator = CREFModel.BinaryOperator.opEqual; condition.OperatorSpecified = true; condition.Items.Add(new CREFModel.PropertyExpression() { Path = "Status" }); condition.Items.Add(new CREFModel.ValueExpression() { Type = CREFModel.ValueType.String, TypeSpecified = true, Value = filterValue }); filter.Items.Add(condition); return filter; } return result; }
public object Translate(TranslationContext context, ASTNode node) { // Model mapping var result = new CREFModel.RequestExpression(); if (node.ResultType == null) { throw new InvalidOperationException("Clinical request expression has no result type."); } var cardinality = (RequestCardinality)Enum.Parse(typeof(RequestCardinality), node.Attributes["cardinality"].ToString(), true); result.Cardinality = cardinality == RequestCardinality.Single ? CREFModel.RequestCardinality.Single : CREFModel.RequestCardinality.Multiple; result.CardinalitySpecified = true; var requestListType = node.ResultType as ListType; var requestType = (requestListType == null ? node.ResultType : requestListType.ElementType) as ObjectType; if (requestType == null) { throw new InvalidOperationException(String.Format("Unable to determine request type from source type: '{0}'.", node.ResultType.Name)); } result.Type = GetQueryType(context.TransformModelType(requestType)); result.TypeSpecified = true; // Translate Codes var codes = node.Children.Where(n => n.Name == "codes").FirstOrDefault(); if (codes != null) { var codesResult = context.TranslateNode(codes); result.Items.Add(codesResult); } // Translate DateRange var dateRange = node.Children.Where(n => n.Name == "dateRange").FirstOrDefault(); if (dateRange != null) { var dateRangeResult = context.TranslateNode(dateRange); result.Items.Add(dateRangeResult); } // Validate idProperty, dateProperty, and codeProperty ValidateIdProperty(requestType, node.GetAttribute <string>("idProperty")); ValidateDateProperty(requestType, node.GetAttribute <string>("dateProperty")); ValidateCodeProperty(requestType, node.GetAttribute <string>("codeProperty")); // Add status filters if necessary var filterValue = GetStatusFilterValue(requestType); if (!String.IsNullOrEmpty(filterValue)) { var filter = new CREFModel.FilterExpression(); filter.Items.Add(result); var condition = new CREFModel.BinaryExpression(); condition.Operator = CREFModel.BinaryOperator.opEqual; condition.OperatorSpecified = true; condition.Items.Add(new CREFModel.PropertyExpression() { Path = "Status" }); condition.Items.Add(new CREFModel.ValueExpression() { Type = CREFModel.ValueType.String, TypeSpecified = true, Value = filterValue }); filter.Items.Add(condition); return(filter); } return(result); }
private object GetRelatedClinicalStatement(TranslationContext context, ASTNode node, string idPropertyName, CREFModel.PatientQueryType type) { var propertyNode = GetRelatedClinicalStatementPropertyNode(node); if (propertyNode == null) { throw new InvalidOperationException("Could not resolve related clinical statement property access node."); } var id = new CREFModel.PropertyExpression(); var source = propertyNode.Children.FirstOrDefault(); if (source != null) { id.Item = context.TranslateNode(source); } id.Path = idPropertyName; var request = new CREFModel.RequestExpression(); request.Cardinality = CREFModel.RequestCardinality.Multiple; request.CardinalitySpecified = true; request.Type = type; request.TypeSpecified = true; var filter = new CREFModel.FilterExpression(); filter.Items.Add(request); var condition = new CREFModel.BinaryExpression(); condition.Operator = CREFModel.BinaryOperator.opEqual; condition.OperatorSpecified = true; var idReference = new CREFModel.PropertyExpression(); idReference.Path = "ID"; condition.Items.Add(idReference); condition.Items.Add(id); filter.Items.Add(condition); var first = new CREFModel.UnaryExpression(); first.Item = filter; first.Operator = CREFModel.UnaryOperator.opFirst; first.OperatorSpecified = true; return first; }