/// <summary>
        /// This example show an example of populating a 1B document
        /// </summary>
        public XmlDocument PopulateSpecialistLetterSample_1B(string fileName)
        {
            XmlDocument xmlDoc = null;

            var document = PopulateSpecialistLetter(true);

            document.SCSContent = SpecialistLetter.CreateSCSContent();

            document.IncludeLogo = false;
            // Hide Administrative Observations Section
            document.ShowAdministrativeObservationsSection = false;

            var narrativeOnlyDocumentList = new List <NarrativeOnlyDocument>();

            var narrativeOnlyDocument = BaseCDAModel.CreateNarrativeOnlyDocument();

            narrativeOnlyDocument.Title     = "Narrative Title";
            narrativeOnlyDocument.Narrative = new StrucDocText
            {
                paragraph = new[] { new StrucDocParagraph {
                                        Text = new[] { "The narrative goes here" }
                                    } }
            };


            // Add One
            narrativeOnlyDocumentList.Add(narrativeOnlyDocument);

            document.SCSContent.NarrativeOnlyDocument = narrativeOnlyDocumentList;

            try
            {
                CDAGenerator.NarrativeGenerator = new CDANarrativeGenerator();

                //Pass the document model into the Generate method
                xmlDoc = CDAGenerator.GenerateSpecialistLetter(document);

                using (var writer = XmlWriter.Create(OutputFolderPath + @"\" + fileName, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    if (!fileName.IsNullOrEmptyWhitespace())
                    {
                        xmlDoc.Save(writer);
                    }
                }
            }
            catch (ValidationException ex)
            {
                //Catch any validation exceptions
                var validationMessages = ex.GetMessagesString();

                //Handle any validation errors as appropriate.
                throw;
            }

            return(xmlDoc);
        }
        /// <summary>
        /// This example populates only the mandatory Sections / Entries; as a result this sample omits all
        /// of the content within the body of the CDA document; as each of the sections within the body
        /// are optional.
        /// </summary>
        public XmlDocument PopulateSpecialistLetterSample_1A(string fileName)
        {
            XmlDocument xmlDoc;

            var document = PopulateSpecialistLetter(true);

            // Hide Administrative Observations Section
            document.ShowAdministrativeObservationsSection = false;

            document.SCSContent = SpecialistLetter.CreateSCSContent();

            document.IncludeLogo = false;

            var structuredBodyFileList = new List <ExternalData>();

            var structuredBodyFile = BaseCDAModel.CreateStructuredBodyFile();

            structuredBodyFile.Caption = "Structured Body File";
            structuredBodyFile.ExternalDataMediaType = MediaType.PDF;
            structuredBodyFile.Path = StructuredFileAttachment;
            structuredBodyFileList.Add(structuredBodyFile);

            document.SCSContent.StructuredBodyFiles = structuredBodyFileList;

            try
            {
                CDAGenerator.NarrativeGenerator = new CDANarrativeGenerator();

                //Pass the document model into the Generate method
                xmlDoc = CDAGenerator.GenerateSpecialistLetter(document);

                using (var writer = XmlWriter.Create(OutputFolderPath + @"\" + fileName, new XmlWriterSettings {
                    Indent = true
                }))
                {
                    if (!fileName.IsNullOrEmptyWhitespace())
                    {
                        xmlDoc.Save(writer);
                    }
                }
            }
            catch (ValidationException ex)
            {
                //Catch any validation exceptions
                var validationMessages = ex.GetMessagesString();

                //Handle any validation errors as appropriate.
                throw;
            }

            return(xmlDoc);
        }
        /// <summary>
        /// This method populates a specialistLetter
        /// </summary>
        /// <param name="mandatorySectionsOnly">mandatorySectionsOnly</param>
        /// <returns>SpecialistLetter</returns>
        internal static SpecialistLetter PopulateSpecialistLetter(Boolean mandatorySectionsOnly)
        {
            var specialistLetter = SpecialistLetter.CreateSpecialistLetter();

            // Set Creation Time
            specialistLetter.DocumentCreationTime = new ISO8601DateTime(DateTime.Now);

            // Include Logo
            specialistLetter.IncludeLogo = true;

            #region Setup and populate the CDA context model

            // Setup and populate the CDA context model
            var cdaContext = SpecialistLetter.CreateCDAContext();
            // Document Id
            cdaContext.DocumentId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid(), null);
            // Set Id
            cdaContext.SetId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateGuid(), null);
            // CDA Context Version
            cdaContext.Version = "1";

            // Custodian
            cdaContext.Custodian = BaseCDAModel.CreateCustodian();
            GenericObjectReuseSample.HydrateCustodian(cdaContext.Custodian, mandatorySectionsOnly);

            // Legal authenticator
            if (!mandatorySectionsOnly)
            {
                cdaContext.LegalAuthenticator = BaseCDAModel.CreateLegalAuthenticator();
                GenericObjectReuseSample.HydrateAuthenticator(cdaContext.LegalAuthenticator, mandatorySectionsOnly);
            }

            // Create information recipient
            if (!mandatorySectionsOnly)
            {
                var recipient1 = BaseCDAModel.CreateInformationRecipient();
                var recipient2 = BaseCDAModel.CreateInformationRecipient();
                GenericObjectReuseSample.HydrateRecipient(recipient1, RecipientType.Primary, mandatorySectionsOnly);
                GenericObjectReuseSample.HydrateRecipient(recipient2, RecipientType.Secondary, mandatorySectionsOnly);
                cdaContext.InformationRecipients = new List <IParticipationInformationRecipient> {
                    recipient1, recipient2
                };
            }

            specialistLetter.CDAContext = cdaContext;

            #endregion

            #region Setup and Populate the SCS Context model

            specialistLetter.SCSContext = SpecialistLetter.CreateSCSContext();

            specialistLetter.SCSContext.Author = BaseCDAModel.CreateAuthor();
            GenericObjectReuseSample.HydrateAuthor(specialistLetter.SCSContext.Author, mandatorySectionsOnly);

            specialistLetter.SCSContext.SubjectOfCare = BaseCDAModel.CreateSubjectOfCare();
            GenericObjectReuseSample.HydrateSubjectofCare(specialistLetter.SCSContext.SubjectOfCare, mandatorySectionsOnly);

            specialistLetter.SCSContext.DateTimeSubjectSeen = new ISO8601DateTime(DateTime.Now);

            if (!mandatorySectionsOnly)
            {
                specialistLetter.SCSContext.Referrer = CreateReferrer(mandatorySectionsOnly);
                specialistLetter.SCSContext.UsualGP  = CreateUsualGPPerson(mandatorySectionsOnly);
            }
            #endregion

            #region Setup and populate the SCS Content model

            specialistLetter.SCSContent = SpecialistLetter.CreateSCSContent();

            // Response details
            specialistLetter.SCSContent.ResponseDetails = CreateResponseDetails(mandatorySectionsOnly);

            // Recommendations
            specialistLetter.SCSContent.Recommendations = CreateRecommendations(mandatorySectionsOnly);

            // Medications
            specialistLetter.SCSContent.Medications = CreateMedications(mandatorySectionsOnly);

            if (!mandatorySectionsOnly)
            {
                // Adverse reactions
                specialistLetter.SCSContent.AdverseReactions = CreateAdverseReactions();

                // Diagnostic Investigations
                specialistLetter.SCSContent.DiagnosticInvestigations = CreateDiagnosticInvestigations(mandatorySectionsOnly);
            }

            #endregion

            return(specialistLetter);
        }