private string ResolveTemplateType(string templateName, string elementName, bool topmostOnly) { RelationshipFormat format = ResolveTemplateType(GetInteraction().Arguments, templateName); if (format == null) { throw new MarshallingException("Could not resolve Hl7 template information for template " + templateName); } else { if (!topmostOnly && format.GetArgument().Choice) { Relationship option = format.GetArgument().FindChoiceOption(ChoiceSupport.ChoiceOptionNamePredicate(elementName)); if (option == null) { throw new MarshallingException("Could not resolve Hl7 template choice information for template " + templateName + " and element name " + elementName); } else { return(option.Type); } } else { return(format.Type); } } }
private MessagePartHolder GetMessagePart(Interaction interaction, Relationship relationship, object value) { string typeName = relationship.Type; if (relationship.TemplateRelationship) { Argument argument = interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName); if (argument.Choice) { Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(GetTypes(value) ); Relationship option = argument.FindChoiceOption(predicate); if (option != null) { typeName = option.Type; } else { // couldn't find a choice type to use (most likely, value is null) // can't leave typeName as null, so just use first choice type from argument typeName = argument.Choices[0].Type; } } else { typeName = argument.Name; } } else { if (relationship.Choice) { Relationship option = relationship.FindChoiceOption(ChoiceSupport.ChoiceOptionTypePredicate(GetTypes(value))); if (option != null) { typeName = option.Type; } } } return(BuildMessagePartHolder(relationship, typeName, interaction)); }
private string DetermineXmlName(PartBridge tealBean, Relationship relationship) { if (!relationship.Choice && !relationship.TemplateRelationship) { return(relationship.Name); } else { if (relationship.TemplateRelationship) { Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName); if (argument == null) { throw new RenderingException("Cannot determine the template/choice parameter type : " + relationship.Name); } else { if (argument.Choice) { Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] { tealBean.GetTypeName() }); Relationship option = argument.FindChoiceOption(predicate); if (option == null) { throw new RenderingException("Cannot determine the choice type of template argument : " + argument.Name); } else { return(option.Name); } } else { return(argument.TraversalName); } } } else { if (tealBean.IsEmpty()) { return(relationship.Choices[0].Name); } else { if (relationship.Cardinality.Multiple) { return(relationship.Name); } Relationship option = BeanBridgeChoiceRelationshipResolver.ResolveChoice(tealBean, relationship); if (option == null) { // log an error instead? throw new RenderingException("Cannot determine the choice type of relationship : " + relationship.Name); } else { return(option.Name); } } } } }
private void AddChoiceAnnotation(PartBridge part, Relationship relationship) { NamedAndTyped choiceOptionRelationship = null; string choiceType = relationship.Type; if (relationship.Choice) { choiceOptionRelationship = BeanBridgeChoiceRelationshipResolver.ResolveChoice(part, relationship); } else { if (relationship.TemplateRelationship) { Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName); if (argument != null && argument.Choice) { Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] { part.GetTypeName() }); choiceOptionRelationship = argument.FindChoiceOption(predicate); choiceType = argument.Name; } } } if (choiceOptionRelationship != null) { CurrentBuffer().AddInfo("Selected option " + choiceOptionRelationship.Type + " (" + choiceOptionRelationship.Name + ") from choice " + choiceType); } }
internal virtual string ResolveChoiceType(Relationship relationship, string selectedElementName) { return(relationship.FindChoiceOption(ChoiceSupport.ChoiceOptionNamePredicate(selectedElementName)).Type); }
internal static Relationship ResolveChoice(PartBridge tealBean, Relationship relationship) { return(relationship.FindChoiceOption(ChoiceSupport.ChoiceOptionTypePredicate(new string[] { tealBean.GetTypeName() }))); }