Ignixa.SqlOnFhir
0.0.163
dotnet add package Ignixa.SqlOnFhir --version 0.0.163
NuGet\Install-Package Ignixa.SqlOnFhir -Version 0.0.163
<PackageReference Include="Ignixa.SqlOnFhir" Version="0.0.163" />
<PackageVersion Include="Ignixa.SqlOnFhir" Version="0.0.163" />
<PackageReference Include="Ignixa.SqlOnFhir" />
paket add Ignixa.SqlOnFhir --version 0.0.163
#r "nuget: Ignixa.SqlOnFhir, 0.0.163"
#:package Ignixa.SqlOnFhir@0.0.163
#addin nuget:?package=Ignixa.SqlOnFhir&version=0.0.163
#tool nuget:?package=Ignixa.SqlOnFhir&version=0.0.163
Ignixa.SqlOnFhir
SQL on FHIR v2 implementation for analytics queries. Enables SQL-like querying over FHIR resources by flattening hierarchical FHIR data into tabular views.
Why Use This Package?
- SQL on FHIR v2 spec compliance: Implements the official specification
- FHIRPath-based column extraction: Uses FHIRPath for flexible data access
- Array unnesting: Handle FHIR arrays (name, identifier, etc.) with forEach
- Type conversion: Automatic conversion of FHIR types to SQL types
Installation
dotnet add package Ignixa.SqlOnFhir
Quick Start
Define a View
using Ignixa.SqlOnFhir.Models;
// Create a view definition for patient demographics
var viewDefinition = new ViewDefinition
{
Resource = "Patient",
Select = new List<SelectGroup>
{
new SelectGroup
{
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "id" },
new() { Name = "birth_date", Path = "birthDate", Type = "date" },
new() { Name = "gender", Path = "gender", Type = "string" }
}
}
}
};
Execute View Against Resources
using Ignixa.SqlOnFhir.Evaluation;
using Ignixa.Abstractions;
// Get FHIR resources
IEnumerable<IElement> patients = GetPatientElements();
// Create evaluator
var evaluator = new SqlOnFhirEvaluator(schema);
// Execute view
var rows = evaluator.Evaluate(viewDefinition, patients);
// Process results
foreach (var row in rows)
{
var id = row["id"];
var birthDate = row["birth_date"];
var gender = row["gender"];
Console.WriteLine($"Patient {id}: {gender}, born {birthDate}");
}
Advanced Features
Array Unnesting with forEach
Extract values from FHIR arrays:
var viewDefinition = new ViewDefinition
{
Resource = "Patient",
Select = new List<SelectGroup>
{
// Base columns (one row per patient)
new SelectGroup
{
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "id" }
}
},
// Name columns (one row per name)
new SelectGroup
{
ForEach = "name", // Unnest name array
Column = new List<ViewColumnDefinition>
{
new() { Name = "name_use", Path = "use" },
new() { Name = "family", Path = "family" },
new() { Name = "given", Path = "given.first()" }
}
}
}
};
// Result: One row per patient name
// id | name_use | family | given
// 123| official | Doe | John
// 123| maiden | Smith | Jane
Filtering with WHERE
var viewDefinition = new ViewDefinition
{
Resource = "Patient",
Where = new List<WhereClause>
{
new() { Path = "active = true" },
new() { Path = "birthDate > @2000-01-01" }
},
Select = new List<SelectGroup>
{
new SelectGroup
{
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "id" },
new() { Name = "name", Path = "name.first().family" }
}
}
}
};
// Only evaluates active patients born after 2000
Using Constants
Parameterize your views:
var viewDefinition = new ViewDefinition
{
Resource = "Observation",
Constant = new List<ViewConstant>
{
new() { Name = "minValue", Value = "100" }
},
Where = new List<WhereClause>
{
new() { Path = "value.value >= %minValue" }
},
Select = new List<SelectGroup>
{
new SelectGroup
{
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "id" },
new() { Name = "value", Path = "value.value" }
}
}
}
};
Multiple Select Groups
Create multiple row groups from a single resource:
var viewDefinition = new ViewDefinition
{
Resource = "Patient",
Select = new List<SelectGroup>
{
// First SELECT: Names (one row per name)
new SelectGroup
{
ForEach = "name",
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "%resource.id" }, // Use %resource to access root
new() { Name = "family", Path = "family" }
}
},
// Second SELECT: Identifiers (one row per identifier)
new SelectGroup
{
ForEach = "identifier",
Column = new List<ViewColumnDefinition>
{
new() { Name = "id", Path = "%resource.id" },
new() { Name = "identifier_value", Path = "value" }
}
}
}
};
// Result: Multiple row groups
// Group 1 (names):
// id | family
// 123| Doe
// 123| Smith
//
// Group 2 (identifiers):
// id | identifier_value
// 123| MRN123
// 123| SSN456
SQL Type Conversions
Supported column types:
new ViewColumnDefinition
{
Name = "string_col",
Path = "someString",
Type = "string"
};
new ViewColumnDefinition
{
Name = "int_col",
Path = "someInteger",
Type = "integer"
};
new ViewColumnDefinition
{
Name = "decimal_col",
Path = "someDecimal",
Type = "decimal"
};
new ViewColumnDefinition
{
Name = "bool_col",
Path = "someBoolean",
Type = "boolean"
};
new ViewColumnDefinition
{
Name = "date_col",
Path = "someDate",
Type = "date"
};
new ViewColumnDefinition
{
Name = "datetime_col",
Path = "someDatetime",
Type = "datetime"
};
Integration with Other Packages
- Ignixa.FhirPath: Used to evaluate column Path expressions
- Ignixa.Abstractions: Works with
IElementrepresentations - Ignixa.Specification: Uses schema for type information
Use Cases
Analytics and Reporting
Flatten FHIR resources for BI tools:
// Create views for your BI dashboard
var patientView = CreatePatientDemographicsView();
var observationView = CreateVitalsView();
var conditionView = CreateDiagnosesView();
// Export to SQL database
var patientRows = evaluator.Evaluate(patientView, patients);
await BulkInsertToSql("patient_demographics", patientRows);
Data Export for Research
Extract specific data elements for research datasets:
var researchView = new ViewDefinition
{
Resource = "Patient",
Where = new List<WhereClause>
{
new() { Path = "meta.tag.code contains 'research-approved'" }
},
Select = new List<SelectGroup> { /* De-identified columns */ }
};
Specification Compliance
This implementation follows the SQL on FHIR v2 specification.
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. |
-
net9.0
- Ignixa.Abstractions (>= 0.0.163)
- Ignixa.FhirPath (>= 0.0.163)
- Ignixa.Serialization (>= 0.0.163)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Ignixa.SqlOnFhir:
| Package | Downloads |
|---|---|
|
Ignixa.SqlOnFhir.Writers
Writers for SQL on FHIR - Parquet and CSV output formats |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.163 | 114 | 2/11/2026 |
| 0.0.160 | 110 | 2/9/2026 |
| 0.0.155 | 109 | 1/24/2026 |
| 0.0.151 | 108 | 1/21/2026 |
| 0.0.150 | 105 | 1/20/2026 |
| 0.0.149 | 109 | 1/19/2026 |
| 0.0.148 | 113 | 1/18/2026 |
| 0.0.142 | 115 | 1/12/2026 |
| 0.0.137 | 115 | 1/9/2026 |
| 0.0.127 | 120 | 12/29/2025 |
| 0.0.109 | 300 | 12/18/2025 |
| 0.0.101 | 301 | 12/16/2025 |
| 0.0.96 | 452 | 12/10/2025 |
| 0.0.87 | 456 | 12/8/2025 |
| 0.0.70 | 315 | 12/7/2025 |
| 0.0.68 | 235 | 12/7/2025 |
| 0.0.62 | 245 | 12/6/2025 |
| 0.0.59 | 188 | 12/5/2025 |
| 0.0.58 | 206 | 12/5/2025 |
| 0.0.57 | 205 | 12/3/2025 |