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" />
                    
Directory.Packages.props
<PackageReference Include="Ignixa.NarrativeGenerator" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=Ignixa.NarrativeGenerator&version=0.0.127
                    
Install as a Cake Tool

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:

  1. Format-specific + Version-specific (e.g., Patient.R4.html.scriban)
  2. Format-specific + Generic (e.g., Patient.html.scriban)
  3. 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" }}
  • Ignixa.Abstractions: Provides IElement and ISchema interfaces
  • Ignixa.Serialization: Parse JSON to IElement trees
  • 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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.127 95 12/29/2025
0.0.109 337 12/18/2025