/// <summary> Converts XML message to ER7, first checking integrity of parse and throwing
        /// an exception if parse not correct
        /// </summary>
        private static System.String safeER7Conversion(System.String xmlMessage)
        {
            Message m = parser.parse(xmlMessage);

            System.String check = parser.encode(m, "XML");
            if (!equivalent(xmlMessage, check))
            {
                throw new NuGenHL7Exception("Parsed and encoded message not equivalent to original (possibilities: invalid message, bug in parser)");
            }

            return(parser.encode(m, "VB"));
        }