A type-safe C# SDK for interacting with Aidbox FHIR server, generated from FHIR R4 specifications. The SDK provides strongly-typed classes for all FHIR resources and a synchronous client for server communication.
- Install dependencies:
dotnet restore- Start Aidbox server:
cd ../. && docker compose up -d- Get license (first run only):
- Open http://localhost:8888
- Follow setup instructions
using Aidbox;
var auth = new Auth
{
Method = AuthMethods.BASIC,
Credentials = new AuthCredentials
{
Username = "root",
Password = "secret"
}
};
var client = new Client("https://localhost:8888", auth);The SDK provides strongly-typed classes for all FHIR resources. Here's an example of creating a Patient:
using Aidbox.FHIR.R4.Core;
var patient = new Patient
{
Identifier = [new Identifier { System = "http://org.io/id", Value = "0000-0000" }],
Name = [new HumanName { Given = ["John"], Family = "Doe" }],
Gender = "male",
BirthDate = "1990-01-01",
};
var (result, error) = await client.Create(patient);This SDK was automatically generated using the FHIR Schema Codegen tool. The generation process:
- Reads FHIR R4 resource definitions
- Generates C# classes for each FHIR resource
- Creates a type-safe client for interacting with the Aidbox server
cd fhir-schema-codegen
npm run build
node dist/cli.js generate --generator csharp --output ./example/csharp/aidbox --packages hl7.fhir.r4.core@4.0.1This will:
- Generate C# classes in the
aidbox/modelsdirectory - Create the client implementation in
aidbox/Client.cs - Set up the package structure with proper imports
example/csharp/
├── aidbox/
│ ├── Client.cs
│ ├── Config.cs
│ └── hl7_fhir_r4_core/
│ ├── base.cs
│ ├── Patient.cs
│ └── ... (other FHIR resources)
├── Program.cs
├── csharp.csproj
└── README.md
- .NET 8
- Node.js (for generation)
- Restore dependencies:
dotnet restore- Build the project:
dotnet build- Run the example:
dotnet run