コード例 #1
0
        /// <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 PopulateSharedHealthSummarySample_1A(string fileName)
        {
            XmlDocument xmlDoc;

            var sharedHealthSummary = PopulateSharedHealthSummary(true);

            sharedHealthSummary.SCSContent = SharedHealthSummary.CreateSCSContent();

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

            sharedHealthSummary.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);

            sharedHealthSummary.SCSContent.StructuredBodyFiles = structuredBodyFileList;

            try
            {
                CDAGenerator.NarrativeGenerator = new CDANarrativeGenerator();

                //Pass the E-Referral model into the GenerateEReferral method
                xmlDoc = CDAGenerator.GenerateSharedHealthSummary(sharedHealthSummary);

                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);
        }
コード例 #2
0
        /// <summary>
        /// This method populates a shared health summary model with either the mandatory sections only, or both
        /// the mandatory and optional sections
        /// </summary>
        /// <param name="mandatorySectionsOnly">mandatorySectionsOnly</param>
        /// <returns>SharedHealthSummary</returns>
        internal static SharedHealthSummary PopulateSharedHealthSummary(Boolean mandatorySectionsOnly)
        {
            var sharedHealthSummary = SharedHealthSummary.CreateSharedHealthSummary(DocumentStatus.Final);

            // Include Logo
            sharedHealthSummary.IncludeLogo = true;
            sharedHealthSummary.LogoPath    = OutputFolderPath;

            // Set Creation Time
            sharedHealthSummary.DocumentCreationTime = new ISO8601DateTime(DateTime.Now, ISO8601DateTime.Precision.Second);

            #region Setup and populate the CDA context model

            // Setup and populate the CDA context model
            var cdaContext = SharedHealthSummary.CreateCDAContext();

            // Document Id
            cdaContext.DocumentId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid());

            // CDA Context Version
            if (!mandatorySectionsOnly)
            {
                // Version
                cdaContext.Version = "1";

                // Set Id
                cdaContext.SetId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateGuid());
            }

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

            sharedHealthSummary.ShowAdministrativeObservationsSection = !mandatorySectionsOnly;

            cdaContext.LegalAuthenticator = BaseCDAModel.CreateLegalAuthenticator();
            GenericObjectReuseSample.HydrateAuthenticator(cdaContext.LegalAuthenticator, mandatorySectionsOnly);

            sharedHealthSummary.CDAContext = cdaContext;

            #endregion

            #region Setup and Populate the SCS Context model
            // Setup and Populate the SCS Context model

            sharedHealthSummary.SCSContext = SharedHealthSummary.CreateSCSContext();

            sharedHealthSummary.SCSContext.Author = BaseCDAModel.CreateAuthor();
            GenericObjectReuseSample.HydrateAuthorV2(sharedHealthSummary.SCSContext.Author, mandatorySectionsOnly);

            // Subject of Care
            sharedHealthSummary.SCSContext.SubjectOfCare = BaseCDAModel.CreateSubjectOfCare();
            GenericObjectReuseSample.HydrateSubjectofCare(sharedHealthSummary.SCSContext.SubjectOfCare, mandatorySectionsOnly, true);

            #endregion

            #region Setup and populate the SCS Content model
            // Setup and populate the SCS Content model

            sharedHealthSummary.SCSContent = SharedHealthSummary.CreateSCSContent();

            // Adverse reactions
            sharedHealthSummary.SCSContent.AdverseReactions = CreateAdverseReactions(mandatorySectionsOnly);

            // Reviewed medications
            sharedHealthSummary.SCSContent.Medications = CreateMedications(mandatorySectionsOnly);

            // Reviewed medical history
            sharedHealthSummary.SCSContent.MedicalHistory = CreateMedicalHistory(mandatorySectionsOnly);

            // Reviewed Immunizations
            sharedHealthSummary.SCSContent.Immunisations = CreateImmunisations(mandatorySectionsOnly);

            #endregion

            return(sharedHealthSummary);
        }