public void CreateDocumentBeanAndConvertToXml()
        {
            // this method creates a ConsultationNote object and populates various fields (attempting to match some but not all values in the sample CDA ConsultationNote xml)

            // Relaxes code vocabulary code checks and sets up some basic code resolvers
            DefaultCodeResolutionConfigurator.ConfigureCodeResolversWithTrivialDefault();

            ConsultationNoteCreator  consultationNoteCreator = new ConsultationNoteCreator();
            ConsultationNoteDocument consultationNote        = consultationNoteCreator.CreateConsultationNote();

            string xml = ProcessDocumentObject(consultationNote);

            // note the errors reported about missing the "History of Present Illness Section" - so let's add that section now
            consultationNoteCreator.AddHistoryOfPresentIllness(consultationNote);

            Console.WriteLine("\n\nModifying objects to clear out some errors. Re-converting to xml");
            xml = ProcessDocumentObject(consultationNote);

            // xml can now be used as necessary (embedded in message, sent using a transport mechanism, etc)
        }
        /*
         * Note that many of these methods could be placed in a central location for reuse (if a group of Authors was always the same, they could be cached, etc.)
         */

        public ConsultationNoteDocument CreateConsultationNote()
        {
            // Community Health and Hospitals: Consultation Note
            // templateId 2.16.840.1.113883.10.20.22.1.4

            ConsultationNoteDocument consultationNote = new ConsultationNoteDocument();

            consultationNote.TypeId = new Identifier("2.16.840.1.113883.1.3", "POCD_HD000040");
            consultationNote.TemplateId.Add(new Identifier("2.16.840.1.113883.10.20.22.1.4"));
            consultationNote.Id                  = new Identifier("2.16.840.1.113883.19.5.99999.1", "TT988");
            consultationNote.Code                = GetLoincCode();
            consultationNote.Title               = "Community Health and Hospitals: Consultation Note";
            consultationNote.EffectiveTime       = new MbDate(DateUtil.GetDate(2012, 8, 16));
            consultationNote.ConfidentialityCode = GetConfidentialityCode();
            consultationNote.LanguageCode        = GetLanguageCode();
            consultationNote.RecordTarget.Add(CreateRecordTarget());
            consultationNote.Author.Add(CreateAuthor());
            consultationNote.Custodian = CreateCustodian();
            consultationNote.InFulfillmentOf.Add(CreateInFulfillmentOf());
            consultationNote.ComponentOf = CreateComponentOf();
            consultationNote.Component   = CreateComponent();

            return(consultationNote);
        }