Skip to content

A narrative generator for fhir resources using HAPI-FHIR and Thymeleaf.

License

Notifications You must be signed in to change notification settings

3abdel3ali/fhirNarrativeGenerator

Repository files navigation

fhirNarrativeGenerator

In FHIR, all resources extending DomainResource include a Narrative element. The Narrative provides a human-readable summary of the structured data and is typically used for display and review by clinicians or end users.

Manual Narrative authoring can be labor-intensive and error-prone. This project enables automatic Narrative generation for FHIR resources by leveraging HAPI-FHIR as the FHIR processing engine and Thymeleaf as the templating engine.

License: Apache 2.0 with Attribution Requirement

This project is licensed under Apache 2.0 with an additional attribution clause. Any use of this code must provide explicit attribution of the original author and repository, as specified in the LICENSE file.

Quick overview

  • Entry point: src/main/java/fr/gouv/esante/fhirNarrativeGenerator/App.java
  • JSON output writer: src/main/java/fr/gouv/esante/fhirNarrativeGenerator/JsonFileCreator.java
  • Properties loader: src/main/java/fr/gouv/esante/fhirNarrativeGenerator/PropertiesUtil.java
  • Runtime version helper: src/main/java/fr/gouv/esante/fhirNarrativeGenerator/VersionUtil.java
  • Thymeleaf narrative template: src/main/resources/NamingSystem.html
  • Template configuration: src/main/resources/narrative.properties
  • Execution configuration (input/output paths): configuration.properties
  • Build: pom.xml

Important structure

  • Example input JSON: target/input/namingSystem_IheRoleCode.json
  • Example generated outputs:
    • target/output/namingSystem_ADICAP_withNarrativeGenerated.json
    • target/output/namingSystem_UCUM_withNarrativeGenerated.json
    • other files under target/output/
  • Unit tests: src/test/java/fr/gouv/esante/fhirNarrativeGenerator/AppTest.java — reports in target/surefire-reports/

Build and run

  1. Build:
    mvn clean package
    
  2. Run:
    mvn org.codehaus.mojo:exec-maven-plugin:3.1.0:java -Dexec.mainClass="fr.gouv.esante.fhirNarrativeGenerator.App"
    

The application reads JSON files from the directory configured in configuration.properties (inputFileDirectory) and writes results to outputFileDirectory.

Template customization

  • Edit the Thymeleaf template for ConceptMap resources: src/main/resources/NamingSystem.html
  • Add new templates for other type of resources: src/main/resources/
  • If you move the template, update src/main/resources/narrative.properties and rebuild.

Logs

Log4j configuration: src/main/resources/log4j2.properties (also copied to target/classes/).

Troubleshooting pointers

  • Invalid input / JSON parsing: logic in App.java
  • File writing: JsonFileCreator.java
  • Missing properties: PropertiesUtil.java and configuration.properties

Tests

  • Unit tests: src/test/java/fr/gouv/esante/fhirNarrativeGenerator/AppTest.java
  • Test reports: target/surefire-reports/

Edit the referenced files to modify behavior or templates.

About

A narrative generator for fhir resources using HAPI-FHIR and Thymeleaf.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published