public void FormatPatient()
        {
            // Create a formatter with a graph aide
            XmlIts1Formatter fmtr = new XmlIts1Formatter();

            // Gets or sets a list of aide formatters
            // that assist in the formatting of this instance
            fmtr.GraphAides.Add(new DatatypeFormatter());

            // Format to a string
            StringWriter   sw    = new StringWriter();
            XmlStateWriter xmlSw = new XmlStateWriter(
                XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            })
                );

            // Call our method here...
            var patient = Utils.CreatePatient(
                Guid.NewGuid(),
                EN.CreateEN(EntityNameUse.Legal,
                            new ENXP("John", EntityNamePartType.Given),
                            new ENXP("Smith", EntityNamePartType.Family)
                            ),
                AD.CreateAD(PostalAddressUse.HomeAddress,
                            "123 Main Street West",
                            "Hamilton",
                            "Ontario",
                            "Canada"
                            ),
                "*****@*****.**"
                );

            // Format to the formatter.
            // Details results in a result code
            //  that indicates the outcome of the graph.
            var details = fmtr.Graph(xmlSw, patient);

            // Flush and close
            xmlSw.Close();

            // Output to console
            Console.WriteLine("XML: ");
            Console.WriteLine(sw.ToString());
            Console.WriteLine("Validation:");
            foreach (var dtl in details.Details)
            {
                Console.WriteLine("{0} : {1}", dtl.Type, dtl.Message);
            }
        }
 /// <summary>
 /// Create a location
 /// </summary>
 /// <param name="serviceDeliveryLocation"></param>
 /// <returns></returns>
 private Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.BirthPlace CreateLocation(Place serviceDeliveryLocation)
 {
     return(new Everest.RMIM.UV.NE2008.PRPA_MT201303UV02.BirthPlace(
                null,
                new Everest.RMIM.UV.NE2008.COCT_MT710007UV.Place(
                    serviceDeliveryLocation.AlternateIdentifiers != null ? CreateIISet(serviceDeliveryLocation.AlternateIdentifiers) : null,
                    serviceDeliveryLocation.LocationType != null ? CreateCD <string>(serviceDeliveryLocation.LocationType) : null,
                    serviceDeliveryLocation.Name != null ? BAG <EN> .CreateBAG(EN.CreateEN(EntityNameUse.Legal, new ENXP(serviceDeliveryLocation.Name))) : null,
                    null,
                    serviceDeliveryLocation.Address != null ? CreateAD(serviceDeliveryLocation.Address) : null,
                    null,
                    null,
                    null
                    ),
                null
                ));
 }
        public void BuildPatientTest02()
        {
            // Flag used to verify if the graph result
            // contains details alongside its errors.
            bool noDetails = true;

            // Flag used to verify that the create instance is valid.
            bool valInstance = false;

            // Create a formatter with a graph aide
            XmlIts1Formatter fmtr = new XmlIts1Formatter();

            // Gets or sets a list of aide formatters
            // that assist in the formatting of this instance
            fmtr.GraphAides.Add(new DatatypeFormatter());

            // Format to a string
            StringWriter   sw    = new StringWriter();
            XmlStateWriter xmlSw = new XmlStateWriter(
                XmlWriter.Create(sw, new XmlWriterSettings()
            {
                Indent = true
            })
                );

            // Call our method here with invalid instance identifier.
            var patient = Utils.CreatePatient(
                new II(),
                EN.CreateEN(EntityNameUse.Legal,
                            new ENXP("John", EntityNamePartType.Given),
                            new ENXP("Smith", EntityNamePartType.Family)
                            ),
                AD.CreateAD(PostalAddressUse.HomeAddress,
                            "123 Main Street West",
                            "Hamilton",
                            "Ontario",
                            "Canada"
                            ),
                "*****@*****.**"
                );

            // Format to the formatter
            var result = fmtr.Graph(xmlSw, patient);

            // Flush and close
            xmlSw.Close();

            // Output to console
            Console.WriteLine("XML:");
            Console.WriteLine(sw.ToString());

            // If we get errors, set error catching flag to false and
            // print the details of each error.
            if (result.Details.Count() > 0)
            {
                noDetails = false;
                Console.WriteLine("validation:");
                foreach (var dtl in result.Details)
                {
                    Console.WriteLine("{0} : {1}", dtl.Type, dtl.Message);
                }
            }
            else
            {
                valInstance = true;
            }

            // Assert:  Either there are no errors,
            //          or there are details in the 'details' collection.
            if (noDetails)
            {
                Assert.AreEqual(valInstance, true);
            }
            else if (!valInstance)
            {
                Assert.AreEqual(noDetails, false);
            }
            else
            {
                // Test fails
                Assert.Fail();
            }
        }