/// <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 PopulateEventSummarySample_1A(string fileName) { XmlDocument xmlDoc; var document = PopulatedEventSummary(true); // Hide Administrative Observations Section document.ShowAdministrativeObservationsSection = false; document.SCSContent = EventSummary.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.GenerateEventSummary(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 sample populates both the mandatory and optional Sections / Entries depending on the /// mandatorySectionsOnly Boolean /// </summary> internal static EventSummary PopulatedEventSummary(Boolean mandatorySectionsOnly) { var eventSummary = EventSummary.CreateEventSummary(); // Include Logo eventSummary.IncludeLogo = true; eventSummary.LogoPath = OutputFolderPath; // Set Creation Time eventSummary.DocumentCreationTime = new ISO8601DateTime(DateTime.Now); #region Setup and populate the CDA context model // Setup and populate the CDA context model var cdaContext = EventSummary.CreateCDAContext(); // Document Id cdaContext.DocumentId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateOid()); // Set Id if (!mandatorySectionsOnly) { cdaContext.SetId = BaseCDAModel.CreateIdentifier(BaseCDAModel.CreateGuid()); } // CDA Context Version if (!mandatorySectionsOnly) { cdaContext.Version = "1"; } // Custodian cdaContext.Custodian = BaseCDAModel.CreateCustodian(); GenericObjectReuseSample.HydrateCustodian(cdaContext.Custodian, mandatorySectionsOnly); cdaContext.LegalAuthenticator = BaseCDAModel.CreateLegalAuthenticator(); GenericObjectReuseSample.HydrateAuthenticator(cdaContext.LegalAuthenticator, mandatorySectionsOnly); eventSummary.CDAContext = cdaContext; #endregion #region Setup and Populate the SCS Context model // Setup and Populate the SCS Context model eventSummary.SCSContext = EventSummary.CreateSCSContext(); eventSummary.SCSContext.Author = BaseCDAModel.CreateAuthor(); GenericObjectReuseSample.HydrateAuthorV2(eventSummary.SCSContext.Author, mandatorySectionsOnly); eventSummary.SCSContext.SubjectOfCare = BaseCDAModel.CreateSubjectOfCare(); GenericObjectReuseSample.HydrateSubjectofCare(eventSummary.SCSContext.SubjectOfCare, mandatorySectionsOnly, false); // DateTime Health Event Started & DateTime Health Event Ended allowable combinations var dateTimeHealthEventEnded = new ISO8601DateTime(DateTime.Now); var dateTimeHealthEventStarted = new ISO8601DateTime(DateTime.Now.AddMonths(-12)); eventSummary.SCSContext.EncounterPeriod = !mandatorySectionsOnly? BaseCDAModel.CreateLowHigh(dateTimeHealthEventStarted, dateTimeHealthEventEnded) : BaseCDAModel.CreateHigh(dateTimeHealthEventEnded); #endregion #region Setup and populate the SCS Content model // Setup and populate the SCS Content model eventSummary.SCSContent = EventSummary.CreateSCSContent(); if (!mandatorySectionsOnly) { eventSummary.SCSContent.EventDetails = CreateEventDetails(); // Adverse reactions eventSummary.SCSContent.AdverseReactions = CreateAdverseReactions(); // Medications eventSummary.SCSContent.Medications = CreateMedications(); // Medical history eventSummary.SCSContent.DiagnosesIntervention = CreateDiagnosesIntervention(mandatorySectionsOnly); // Immunisations eventSummary.SCSContent.Immunisations = CreateImmunisations(); // Diagnostic Investigations eventSummary.SCSContent.DiagnosticInvestigations = CreateDiagnosticInvestigations(mandatorySectionsOnly); } #endregion return(eventSummary); }