示例#1
0
 /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
 private void WriteIndicator(BeanWrapper bean, Hl7Source source, IList <XmlNode> nodes, Relationship relationship, string traversalName
                             )
 {
     try
     {
         // if "false", as in the indicator element is absent, we will never actually get here :)
         // can't really parse a boolean here, but we need to check for null flavor
         NullFlavorHelper nullFlavorHelper = new NullFlavorHelper(relationship.Conformance, nodes.IsEmpty() ? null : nodes[0], new
                                                                  XmlToModelResult(), true);
         NullFlavor nullFlavor = nullFlavorHelper.ParseNullNode();
         object     value      = (nullFlavor == null ? new BLImpl(!nodes.IsEmpty()) : new BLImpl(nullFlavor));
         bean.Write(relationship, value);
     }
     catch (InvalidCastException e)
     {
         this.log.Info("Can't parse relationship name=" + relationship.Name + ", traversalName=" + traversalName + " [" + e.Message
                       + "]");
     }
 }
示例#2
0
        private bool MapNodeAttributesToTeal(Hl7Source source, BeanWrapper wrapper, Relationship relationship)
        {
            XmlElement       currentElement   = source.GetCurrentElement();
            NullFlavorHelper nullFlavorHelper = new NullFlavorHelper(relationship != null ? relationship.Conformance : Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                     .OPTIONAL, currentElement, source.GetResult(), true);
            bool hasValidNullFlavorAttribute = nullFlavorHelper.HasValidNullFlavorAttribute();

            if (hasValidNullFlavorAttribute)
            {
                wrapper.WriteNullFlavor(source, relationship, nullFlavorHelper.ParseNullNode());
            }
            else
            {
                XmlAttributeCollection map = currentElement.Attributes;
                foreach (XmlNode attributeNode in new XmlNamedNodeMapIterable(map))
                {
                    Relationship attributeRelationship = source.GetRelationship(NodeUtil.GetLocalOrTagName(attributeNode));
                    if (!NamespaceUtil.IsHl7Node(attributeNode))
                    {
                    }
                    else
                    {
                        // quietly ignore it
                        if (attributeRelationship == null)
                        {
                            this.log.Info("Can't find NodeAttribute relationship named: " + attributeNode.Name);
                        }
                        else
                        {
                            ValidateNamespace(attributeNode, attributeRelationship, source);
                            if (attributeRelationship.HasFixedValue())
                            {
                                ValidateFixedValue(source, currentElement, (XmlAttribute)attributeNode, attributeRelationship);
                            }
                            wrapper.WriteNodeAttribute(attributeRelationship, attributeNode.Value, source.GetVersion(), source.IsR2());
                        }
                    }
                    ValidateMandatoryAttributesExist(source, currentElement);
                }
            }
            return(hasValidNullFlavorAttribute);
        }