/// <summary> Populates the given group object with data from the given group element, ignoring /// any unrecognized nodes. /// </summary> private void parse(ca.uhn.hl7v2.model.Group groupObject, System.Xml.XmlElement groupElement) { System.String[] childNames = groupObject.Names; System.String messageName = groupObject.Message.getStructureName(); //UPGRADE_TODO: Method 'org.w3c.dom.Node.getChildNodes' was converted to 'System.Xml.XmlNode.ChildNodes' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" System.Xml.XmlNodeList allChildNodes = groupElement.ChildNodes; System.Collections.ArrayList unparsedElementList = new System.Collections.ArrayList(); for (int i = 0; i < allChildNodes.Count; i++) { System.Xml.XmlNode node = allChildNodes.Item(i); System.String name = node.Name; if (System.Convert.ToInt16(node.NodeType) == (short)System.Xml.XmlNodeType.Element && !unparsedElementList.Contains(name)) { unparsedElementList.Add(name); } } //we're not too fussy about order here (all occurances get parsed as repetitions) ... for (int i = 0; i < childNames.Length; i++) { SupportClass.ICollectionSupport.Remove(unparsedElementList, childNames[i]); parseReps(groupElement, groupObject, messageName, childNames[i], childNames[i]); } for (int i = 0; i < unparsedElementList.Count; i++) { System.String segName = (System.String)unparsedElementList[i]; System.String segIndexName = groupObject.addNonstandardSegment(segName); parseReps(groupElement, groupObject, messageName, segName, segIndexName); } }
/// <summary> Copies data from a group object into the corresponding group element, creating any /// necessary child nodes. /// </summary> private void encode(ca.uhn.hl7v2.model.Group groupObject, System.Xml.XmlElement groupElement) { System.String[] childNames = groupObject.Names; System.String messageName = groupObject.Message.getStructureName(); try { for (int i = 0; i < childNames.Length; i++) { Structure[] reps = groupObject.getAll(childNames[i]); for (int j = 0; j < reps.Length; j++) { System.Xml.XmlElement childElement = groupElement.OwnerDocument.CreateElement(makeGroupElementName(messageName, childNames[i])); bool hasValue = false; if (reps[j] is Group) { hasValue = true; encode((Group)reps[j], childElement); } else if (reps[j] is Segment) { hasValue = encode((Segment)reps[j], childElement); } if (hasValue) { groupElement.AppendChild(childElement); } } } } //UPGRADE_TODO: Class 'org.w3c.dom.DOMException' was converted to 'System.Exceptiont' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'" catch (System.Exception e) { throw new HL7Exception("Can't encode group " + groupObject.GetType().FullName, HL7Exception.APPLICATION_INTERNAL_ERROR, e); } }