30.7.1Narrative Generation
Experimental

 

The CDA Exchange+ module provides several methods of populating the <text> element of each section in the document.

30.7.1.1Provided narrative

If the field Composition.section.text is populated in the provided or generated Composition, the contents of that field will be transcribed into the <text> element of the corresponding section of the CDA document. This is the only means of populating the <text> element if the section does not contain any entries.

30.7.1.2Generated narrative

If the field Composition.section.text is not populated for a given FHIR section, the module will attempt to generate a <text> element for the corresponding CDA section from the entries of the section. This generated narrative will take the form of a simple tabular summary of the most relevant fields of the entries. The specific format of these tables will vary from section to section.

30.7.1.2.1Overriding the default narrative templates

If the default generated narrative does not meet your business needs, it is possible to override the default narrative templates using the Narrative Generator module.

  1. Create your own set of Thymeleaf templates.
  2. Create an instance of the Narrative Generator module.
  3. Configure the Narrative Generator, specifying your Narrative Template Manifest File either by an absolute file path or relative to the classpath.
  4. Start the Narrative Generator module.
  5. Configure your CDA Exchange+ module with a dependency on your new Narrative Generator module and restart it.

30.7.1.2.1.1Tips and Tricks

In order to generate a single, cohesive narrative block for the whole section, the CDA Exchange+ module copies the entries from the Composition.section into a Bundle resource and passes this Bundle to the Narrative Generator. Therefore, your custom template must be written to accept a Bundle as its input and iterate over the entries of that Bundle to find the individual resources.

In order to disambiguate which template file to apply to each Bundle, CDA Exchange+ uses Composition.section.code as a discriminator. Your manifest file will need to include these codes to facilitate filtering. The value of Composition.section.code must be placed in a property my_section.tag as shown in the example below.

allergyIntolerance.resourceType=Bundle
allergyIntolerance.tag=http://loinc.org|48765-2
allergyIntolerance.narrative=file:my_file_path/allergy_intolerance_template.html

encounter.resourceType=Bundle
encounter.tag=http://loinc.org|46240-8
encounter.narrative=file:my_file_path/encounter_template.html

A Composition.section may have nested sections to group the entries. Since a Bundle does not provide such a nested structure, all the entries in the section will be flattened into a single list in the Bundle provided to the template.

If any section does not have a specific template defined for its Composition.section.code, default text will be added that simply states that no narrative template exists for the section.