Ignixa.FhirFakes 0.6.4

dotnet add package Ignixa.FhirFakes --version 0.6.4
                    
NuGet\Install-Package Ignixa.FhirFakes -Version 0.6.4
                    
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.FhirFakes" Version="0.6.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ignixa.FhirFakes" Version="0.6.4" />
                    
Directory.Packages.props
<PackageReference Include="Ignixa.FhirFakes" />
                    
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.FhirFakes --version 0.6.4
                    
#r "nuget: Ignixa.FhirFakes, 0.6.4"
                    
#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.FhirFakes@0.6.4
                    
#: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.FhirFakes&version=0.6.4
                    
Install as a Cake Addin
#tool nuget:?package=Ignixa.FhirFakes&version=0.6.4
                    
Install as a Cake Tool

Ignixa.FhirFakes

A comprehensive FHIR test data generation library for modeling patient populations and medical histories.

Installation

dotnet add package Ignixa.FhirFakes

Quick Start

Generate a Single Patient with Full Lifecycle

using Ignixa.FhirFakes.Lifecycle;
using Ignixa.Specification.Generated;

// Create schema provider
var schemaProvider = new R4CoreSchemaProvider();

// Generate a 50-year-old with metabolic syndrome progression
var context = LifecycleExampleScenarios.GetMetabolicSyndromeLifecycle(schemaProvider);

// Access generated resources
Console.WriteLine($"Patient: {context.Patient.Id}");
Console.WriteLine($"Conditions: {context.Conditions.Count}"); // 2-4 chronic conditions
Console.WriteLine($"Medications: {context.Medications.Count}"); // 3-6 medications
Console.WriteLine($"Encounters: {context.Encounters.Count}"); // 40-45 visits over 50 years
Console.WriteLine($"Observations: {context.Observations.Count}"); // 150+ vitals and labs

Generate a Population from a State

using Ignixa.FhirFakes.Population;
using Ignixa.Specification.Generated;

var schemaProvider = new R4CoreSchemaProvider();
var generator = new PopulationGenerator(schemaProvider);

// Generate 100 patients with Massachusetts demographics
// Note: First parameter is state name, not city name
var patients = generator.Generate("Massachusetts", 100);

// Result: 100 patients with:
// - Names: Culturally appropriate (Bogus locales)
// - Ages: Sampled from Boston age distribution
// - Race: 53% White, 25% Black, 19% Hispanic, 9% Asian
// - Zip Codes: 02101-02199 (Boston area)
// - Phone Numbers: 617-xxx-xxxx or 857-xxx-xxxx
// - Full medical history: birth to current age with realistic disease onset

Discover Available Cities with KnownCities

using Ignixa.FhirFakes.Population;

// Strongly-typed access with IntelliSense
var boston = KnownCities.Boston;
var seattle = KnownCities.Seattle;
var allCities = KnownCities.All; // All 11 cities

// Inspect city demographics
Console.WriteLine($"City: {boston.Name}, {boston.State}");
Console.WriteLine($"Population: {boston.Population:N0}");
Console.WriteLine($"Race Distribution: {boston.RaceDistribution["White"]:P0} White");
Console.WriteLine($"Zip Codes: {boston.ZipCodePrefix}xx");
Console.WriteLine($"Area Codes: {string.Join(", ", boston.AreaCodes)}");

Create Custom Scenarios with Probabilistic Branching

using Ignixa.FhirFakes.Scenarios;
using Ignixa.FhirFakes.Scenarios.States;

var builder = new ScenarioBuilder(schemaProvider)
    // Simple patient with basic demographics
    .WithPatient(p => p.WithAge(55).WithGender(g => g.Male))

    // Or use realistic patient from specific city (ethnically appropriate names, real demographics)
    // .WithPatient(p => p.FromCity(KnownCities.Boston).WithAge(55).WithGender(g => g.Male))

    .AddEncounter("Annual wellness visit")

    // Use reusable fragments
    .AddSubScenario(CommonScenarios.RecordVitalSigns(), "Vitals")
    .AddSubScenario(CommonScenarios.LipidPanel(), "Cholesterol Screening")

    // Probabilistic disease onset (15% chance of elevated cholesterol)
    .AddProbabilisticBranch(
        0.15,

        // TRUE PATH: Elevated cholesterol - prescribe statin
        new ConditionOnsetState
        {
            Code = FhirCode.Conditions.Hyperlipidemia,
            Severity = 2
        }
        .ThenAddMedicationOrder(MedicationOrderState.Atorvastatin20mg())
        .ThenDelay(TimeSpan.FromDays(90))
        .ThenAddEncounter("Lipid panel follow-up"),

        // FALSE PATH: Normal screening (85%)
        new DelayState { Exact = TimeSpan.Zero }
    );

var context = builder.Build();

Discover and Invoke Predefined Scenarios Programmatically

ScenarioCatalog and ObservationStateCatalog discover the library's predefined scenarios and observation states by reflection, so a UI or other consumer can enumerate and invoke them without hard-coding extension method names:

using Ignixa.FhirFakes.Scenarios;
using Ignixa.FhirFakes.Scenarios.States;

foreach (var scenario in ScenarioCatalog.GetAll())
{
    Console.WriteLine($"{scenario.Id}: {scenario.Title} ({scenario.Category})");
}

var found = ScenarioCatalog.Find("DiabeticPatient");
if (found is not null)
{
    var context = ScenarioCatalog.Invoke(found, schemaProvider,
        new Dictionary<string, object?> { ["age"] = 60, ["severity"] = 3 });
}

foreach (var name in ObservationStateCatalog.GetNames())
{
    if (ObservationStateCatalog.TryCreate(name, out var state))
    {
        // use state
    }
}

Theme-Consistent Generation

At any density, SchemaBasedFhirResourceFaker can keep sibling coded fields on one resource drawn from the same clinical specialty instead of picking each independently at random:

var faker = new SchemaBasedFhirResourceFaker(schemaProvider)
{
    Density = GenerationDensity.Maximum,
    Theme = ClinicalDomain.Cardiology   // omit for a random (but still coherent) theme
};

var procedure = faker.Generate("Procedure");

Architecture

Layer 1: Random Resources

  • BindingAwareGenerator: Core resource generation
  • Respects FHIR profiles and terminology bindings
  • Generates valid references and complex types
  • ClinicalDomain / Theme: keeps sibling coded fields on one resource thematically coherent

Layer 2: Clinical Scenarios

  • ScenarioBuilder: Fluent composition API
  • ScenarioCatalog / ObservationStateCatalog: public, attribute-driven discovery of predefined scenarios and observation states
  • ProbabilisticBranchState: Evidence-based branching
  • VitalSignCorrelationEngine: Physiological realism
  • CommonScenarios: Reusable clinical fragments

Layer 3: Patient Lifecycles

  • LifecycleSimulator: Age-based event scheduling
  • DiseaseRiskCalculator: Evidence-based risk modeling
  • LifecycleExampleScenarios: Pre-built patient archetypes:
    • Healthy child (0-18 years)
    • Typical adult (0-45 years)
    • Metabolic syndrome (0-50 years)
    • Pediatric asthma (0-10 years)
    • Elderly multi-morbidity (0-80 years)

Layer 4: Population Generation

  • PopulationGenerator: Large-scale cohort creation
  • CityDemographics: US Census-based distributions
  • KnownCities: 11 major US cities with real demographics
  • EthnicNameGenerator: Culturally appropriate names via Bogus locales

Dependencies:

  • Ignixa.Specification (FHIR schema provider)
  • Ignixa.Serialization (FHIR serialization)
  • Bogus (name and data generation)

Inspiration and Complementary Tools

This library was inspired by Synthea, the well-established synthetic patient generator developed by The MITRE Corporation. Synthea is a mature, comprehensive tool that has been instrumental in advancing healthcare interoperability and providing high-quality synthetic data to the community.

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 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Ignixa.FhirFakes:

Package Downloads
Ignixa.TestScript.FhirFakes

FhirFakes integration for TestScript fixture generation - auto-generate test data from resource type

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.4 122 7/5/2026
0.5.13 114 7/3/2026
0.5.11 96 7/2/2026
0.5.6 111 6/17/2026
0.5.2 108 6/16/2026
0.5.0 106 6/15/2026
0.0.163 143 2/11/2026
0.0.160 119 2/9/2026
0.0.155 122 1/24/2026
0.0.151 126 1/21/2026
0.0.150 117 1/20/2026
0.0.149 121 1/19/2026
0.0.148 127 1/18/2026
0.0.142 124 1/12/2026
0.0.137 131 1/9/2026
0.0.127 133 12/29/2025
0.0.109 306 12/18/2025
0.0.101 298 12/16/2025
0.0.96 458 12/10/2025
0.0.87 467 12/8/2025
Loading failed