Ignixa.NarrativeGenerator
0.0.127
dotnet add package Ignixa.NarrativeGenerator --version 0.0.127
NuGet\Install-Package Ignixa.NarrativeGenerator -Version 0.0.127
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ignixa.NarrativeGenerator" Version="0.0.127" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ignixa.NarrativeGenerator" Version="0.0.127" />
<PackageReference Include="Ignixa.NarrativeGenerator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ignixa.NarrativeGenerator --version 0.0.127
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Ignixa.NarrativeGenerator, 0.0.127"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ignixa.NarrativeGenerator@0.0.127
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ignixa.NarrativeGenerator&version=0.0.127
#tool nuget:?package=Ignixa.NarrativeGenerator&version=0.0.127
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Ignixa.NarrativeGenerator
FHIR narrative generation using Scriban templates with FHIRPath support. Generates human-readable summaries of FHIR resources in multiple output formats (XHTML, Markdown, Compact).
Why Use This Package?
- Multi-format output: Generate XHTML (FHIR-compliant), Markdown, or Compact (single-line) narratives
- Template-based: Uses Scriban templates for flexible, customizable output
- FHIRPath integration: Templates can use FHIRPath expressions for data extraction
- XSS protection: Built-in XHTML sanitization for secure HTML output
- Localization support: Full i18n support via
IStringLocalizer - Version-aware: Templates can be version-specific (R4, R4B, R5, R6, STU3)
Installation
dotnet add package Ignixa.NarrativeGenerator
Quick Start
Basic Usage
using Ignixa.NarrativeGenerator;
using Ignixa.Specification.Generated;
using Ignixa.Serialization;
using Ignixa.Serialization.SourceNodes;
// Create a schema and generator
var schema = new R4CoreSchemaProvider();
var generator = FhirNarrativeGenerator.Create(schema);
// Parse a FHIR resource
var json = """
{
"resourceType": "Patient",
"id": "example",
"name": [{
"use": "official",
"family": "Doe",
"given": ["John"]
}],
"gender": "male",
"birthDate": "1980-01-01"
}
""";
var patient = JsonSourceNodeFactory.Parse<ResourceJsonNode>(json)!;
patient.FhirVersion = FhirVersion.R4;
var element = patient.ToElement(schema);
// Generate narrative (defaults to XHTML)
var narrative = await generator.GenerateNarrativeAsync(element, "Patient");
// Result: Sanitized XHTML suitable for FHIR Narrative.div
Multiple Output Formats
// XHTML (default) - for FHIR Narrative.div
var xhtml = await generator.GenerateNarrativeAsync(
element, "Patient", format: TemplateFormat.Html);
// Markdown - for documentation/display
var markdown = await generator.GenerateNarrativeAsync(
element, "Patient", format: TemplateFormat.Markdown);
// Compact - single-line for AI/ML embeddings
var compact = await generator.GenerateNarrativeAsync(
element, "Patient", format: TemplateFormat.Compact);
Localization
using System.Globalization;
// Generate with specific culture
var narrative = await generator.GenerateNarrativeAsync(
element,
"Patient",
culture: new CultureInfo("es-ES"),
format: TemplateFormat.Html);
// Or provide a custom localizer
var customLocalizer = new MyCustomStringLocalizer();
var generator = FhirNarrativeGenerator.Create(schema, customLocalizer);
Output Formats
Html (XHTML)
FHIR-compliant XHTML for Narrative.div. Includes:
- WCAG 2.1 AA accessibility
- XSS sanitization
- CSS classes for styling
Markdown
Human-readable Markdown for documentation:
- Headers and sections
- Bold/italic formatting
- Lists and tables
Compact
Single-line dense format for AI/ML:
- Token-efficient
- Structured data extraction
- Suitable for vector embeddings
Template Resolution
Templates are resolved in this order:
- Format-specific + Version-specific (e.g.,
Patient.R4.html.scriban) - Format-specific + Generic (e.g.,
Patient.html.scriban) - Generic fallback (e.g.,
Generic.html.scriban)
FHIRPath in Templates
Templates can use FHIRPath expressions:
{{ fhirpath "name.where(use='official').family" }}
{{ fhirpath "telecom.where(system='phone').value" }}
{{ fhirpath "birthDate" | date.to_string "%Y-%m-%d" }}
Related Packages
- Ignixa.Abstractions: Provides
IElementandISchemainterfaces - Ignixa.Serialization: Parse JSON to
IElementtrees - Ignixa.FhirPath: FHIRPath evaluation engine used by templates
- Ignixa.Specification: FHIR structure definitions and schema providers
License
MIT License - see LICENSE file in repository root
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Ignixa.Abstractions (>= 0.0.127)
- Ignixa.FhirPath (>= 0.0.127)
- Ignixa.Serialization (>= 0.0.127)
- Microsoft.Extensions.Localization.Abstractions (>= 9.0.11)
- Scriban (>= 5.12.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.