NextGen Knowledge Center

Generating Resource Narratives

Almost all resources can include a human-readable narrative describing the resource. This is an XHTML div element contained in the "narrative" node of the XML/JSON. More information: Narrative.

This FHIR extension utilizes HAPI FHIR and Thymeleaf to help auto-generate resource narratives. Several templates are built-in, but you can override them and/or provide your own. The extensions/fhir/narratives/ folder in the installation directory contains all narrative-related resources that aren't built into HAPI. The narratives.properties file determines which HTML templates to use for specific classes. Two resources (CapabilityStatement and OperationOutcome) are overridden by default, and their template HTML pages are in that folder as well for reference.

As mentioned before, the FhirUtil class also has a convenience method for generating resource narratives.

For more information, check out the HAPI FHIR documentation: Narrative Generation.