private CREFModel.ClinicalAssertion TranslateClinicalAssertion(TranslationContext context, Node node) { // node is expected to be an ActionGroup // Action types determine the assertion to be created // CreateAction - MissingDataAssertion // UpdateAction - MissingDataAssertion // MessageAction - OutOfRangeAssertion // CollectInformationAction - MissingDataAssertion // Any other action cannot be represented var assertions = new List<CREFModel.ClinicalAssertion>(); var subElements = node.Children.FirstOrDefault(c => c.Name == "subElements"); if (subElements != null) { foreach (var element in subElements.Children) { if (element.Name == "simpleAction") { switch (element.NodeType.GetLocalName()) { case "CreateAction" : assertions.Add(TranslateCreateAction(context, element)); break; case "UpdateAction" : assertions.Add(TranslateUpdateAction(context, element)); break; case "MessageAction" : assertions.Add(TranslateMessageAction(context, element)); break; case "CollectInformationAction" : assertions.Add(TranslateCollectInformationAction(context, element)); break; default: throw new NotSupportedException(String.Format("Translation of {0} actions is not supported.", element.NodeType.GetLocalName())); } } else if (element.Name == "actionGroup") { assertions.Add(TranslateClinicalAssertion(context, element)); } else if (element.Name == "actionGroupReference") { throw new NotSupportedException("Translation of action group references is not supported."); } } } if (assertions.Count > 1) { var compositeAssertion = new CREFModel.CompositeAssertion(); compositeAssertion.CompositionType = GetCompositionType(GetGroupSelectionBehavior(node)); var descriptionNode = node.Children.FirstOrDefault(c => c.Name == "Description"); if (descriptionNode != null) { compositeAssertion.Description = descriptionNode.GetAttribute<string>("value"); } compositeAssertion.CompositeAssertionAssertions.AddRange(assertions); return compositeAssertion; } return assertions[0]; }
private CREFModel.ClinicalAssertion TranslateClinicalAssertion(TranslationContext context, Node node) { // node is expected to be an ActionGroup // Action types determine the assertion to be created // CreateAction - MissingDataAssertion // UpdateAction - MissingDataAssertion // MessageAction - OutOfRangeAssertion // CollectInformationAction - MissingDataAssertion // Any other action cannot be represented var assertions = new List <CREFModel.ClinicalAssertion>(); var subElements = node.Children.FirstOrDefault(c => c.Name == "subElements"); if (subElements != null) { foreach (var element in subElements.Children) { if (element.Name == "simpleAction") { switch (element.NodeType.GetLocalName()) { case "CreateAction": assertions.Add(TranslateCreateAction(context, element)); break; case "UpdateAction": assertions.Add(TranslateUpdateAction(context, element)); break; case "MessageAction": assertions.Add(TranslateMessageAction(context, element)); break; case "CollectInformationAction": assertions.Add(TranslateCollectInformationAction(context, element)); break; default: throw new NotSupportedException(String.Format("Translation of {0} actions is not supported.", element.NodeType.GetLocalName())); } } else if (element.Name == "actionGroup") { assertions.Add(TranslateClinicalAssertion(context, element)); } else if (element.Name == "actionGroupReference") { throw new NotSupportedException("Translation of action group references is not supported."); } } } if (assertions.Count > 1) { var compositeAssertion = new CREFModel.CompositeAssertion(); compositeAssertion.CompositionType = GetCompositionType(GetGroupSelectionBehavior(node)); var descriptionNode = node.Children.FirstOrDefault(c => c.Name == "Description"); if (descriptionNode != null) { compositeAssertion.Description = descriptionNode.GetAttribute <string>("value"); } compositeAssertion.CompositeAssertionAssertions.AddRange(assertions); return(compositeAssertion); } return(assertions[0]); }