✅ Mappings from FHIR resources to C# classes
✅ GetInfo
Use appropriate field types for storing fhir dates, date times (and other types)
var patient = new Patient();
// instead of string
patient.BirtDate = "2000-01-01";
// use Date type
patient.BirthDate = new DateOnly(2000, 1, 1);
var fhirBool = new FhirBoolean(true);
var fhirString = new FhirString("sample string");
var fhirDate = new FhirDate("2024-01-01");
...
Instead of using one of the fields like here
var patient = new Patient();
patient.DeceasedBoolean = true;
// or
patient.DeceasedDateTime = new DateOnly("2024-01-01")
Use polymorphic field
var patient = new Patient();
patient.Deceased = new FhirBoolean(true);
// or
patient.Deceased = new FhirDateTime("2024-01-01T100:00:00")
Value sets as enums
enum AdministrativeGender
{
Male,
Female,
Other,
Unknown
}
var patient = new Patient();
patient.Gender = AdministrativeGender.Unknown;
Or value sets as union types
public abstract record AdministrativeGender
{
private AdministrativeGender(){ }
public record Male(): AdministrativeGender;
public record Female() : AdministrativeGender;
public record Other() : AdministrativeGender;
public record Unknown() : AdministrativeGender;
}
var patient = new Patient();
patient.Gender = AdministrativeGender.Unknown();
Make it possible to add extensions.
var patient = new Patient();
var mothersName = new Extension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", "Doe");
patient.Extension.Add(patient);
There are fields with the same name as resources in FHIR. It is not allowed to have the same property name as a class name. Come up with a workaround.
Problem: we don't want to concat string every time "Patient" + "/" + ""
// FHIR: { reference: "Patient/<uuid>" }
// AIDBOX: { resourceType: Patient, id: <uuid> }
patient.managingOrganization = new Reference<Organization>() { id:<uuid> }
JsonParse(patient) => { "name": [], "managingOrganization": { "reference": "Organization/<uuid>" } }
It is hard to reach the exact extension in array with nested extensions. Implement a convenient way of extractting data from extension.
Given example of patient data:
{
"resourceType" : "Patient",
"id" : "child-example",
"meta" : {
"profile" : ["http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient|7.0.0"]
},
"extension" : [
{
"extension" : [
{
"url" : "ombCategory",
"valueCoding" : {
"system" : "urn:oid:2.16.840.1.113883.6.238",
"code" : "2028-9",
"display" : "Asian"
}
},
{
"url" : "text",
"valueString" : "Asian"
}
],
"url" : "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"
},
...
{
"url" : "http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex",
"valueCode" : "M"
},
{
"url" : "http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex",
"valueCode" : "248153007"
}
]
}
Instead of extracting patient extension data like in the next example:
var raceExtension = patient.extension.FirstOrDefault(e => e["url"].ToString() == "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race");
var raceText = raceExtension.extension.FirstOrDefault(e => e["url"].ToString() == "text")["valueString"];
We would like to provide a more convenient way:
var raceName = patient.Race.Text;
{
"code": {
"pattern": {
"coding": [
{
"system": "http://loinc.org",
"code": "29549-3",
"display": "Medication administered Narrative"
}
]
}
}
}
class CodeableConcept1 : CodeableConcept {
readonly coding: [new Conding295493() { System = "http://loinc.org", Code = "29549-3"}]
}
patient.gender = male | female
Link to aidbox doc: https://docs.aidbox.app/api-1/api/crud-1/patch#merge-patch
var (result, error) = await aidbox.Patch<Patient>(newData);
Link to aidbox doc: https://docs.aidbox.app/api-1/transaction
Chaining of params, pagination, sorting (like in TypeScript SDK)
var search = aidbox.Search<Patient>(params)
.Where(...)
.SortBy(...);
Handle HTTP exceptions with appropriate C# classes.
OperationOutcome example in Aidbox:
resourceType: OperationOutcome
text:
status: generated
div: Invalid resource
issue:
- severity: fatal
code: invalid
expression:
- Appointment.participant
diagnostics: ':participant is required'
- severity: fatal
code: invalid
expression:
- Appointment.status
diagnostics: ':status is required'
Example TBD
Example TBD
Example TBD
Example TBD
https://docs.aidbox.app/app-development/aidbox-sdk/aidbox-apps
It might not be so trivial, considering there are numerous FHIR profiles and each client would need its own set.