StructureDefinition is a resource that describes the structure of other resources, including profiles, extensions, and data types.
Aidbox allows you to create StructureDefinition resources at runtime using the FHIR API. This enables you to define profiles for standard resources, create extensions, and design custom user-defined resources.‍
In this example, a profile is created for the Patient resource, where the name field is marked as required. This can be done via a REST request to the FHIR endpoint for StructureDefinition, with the profile definition included in the body of the request.
POST /fhir/StructureDefinition
content-type: application/json
accept: application/json
{
"derivation": "constraint",
"name": "my-patient-profile",
"abstract": false,
"type": "Patient",
"status": "active",
"kind": "resource",
"url": "http://example.org/StructureDefinition/my-patient-profile",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
"differential": {
"element": [
{
"id": "Patient.name",
"path": "Patient.name",
"min": 1
}
]
}
}
‍
An extension named insurance-plan is created to allow referencing a related insurance plan (the InsurancePlan resource).
POST /fhir/StructureDefinition
{
"abstract": false,
"url": "http://my.company/StructureDefinition/insurance-plan",
"id": "insurance-plan",
"name": "InsurancePlanReference",
"status": "active",
"kind": "complex-type",
"type": "Extension",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/Extension",
"version": "0.0.1",
"differential": {
"element": [
{
"id": "Extension",
"max": "1",
"min": 0,
"path": "Extension",
"short": "Reference to the insurance plan"
},
{
"id": "Extension.url",
"max": "1",
"min": 1,
"path": "Extension.url",
"fixedUri": "http://my.company/StructureDefinition/insurance-plan"
},
{
"id": "Extension.value[x]",
"max": "1",
"min": 1,
"path": "Extension.value[x]",
"type": [
{
"code": "Reference",
"targetProfile": [
"http://hl7.org/fhir/StructureDefinition/InsurancePlan"
]
}
]
}
]
},
"resourceType": "StructureDefinition",
"derivation": "constraint"
}
‍
In this example, a custom resource named TutorNotificationTemplate is created, which contains a single required field template of type string.
POST /fhir/StructureDefinition
content-type: application/json
accept: application/json
{
"derivation": "specialization",
"name": "TutorNotificationTemplate",
"abstract": false,
"type": "TutorNotificationTemplate",
"status": "active",
"kind": "resource",
"url": "http://example.org/StructureDefinition/TutorNotificationTemplate",
"baseDefinition": "http://hl7.org/fhir/StructureDefinition/DomainResource",
"differential": {
"element": [
{
"id": "TutorNotificationTemplate",
"path": "TutorNotificationTemplate",
"min": 0,
"max": "*"
},
{
"id": "TutorNotificationTemplate.template",
"path": "TutorNotificationTemplate.template",
"min": 1,
"max": "1",
"type": [
{
"code": "string"
}
]
}
]
}
}
‍
You can use these examples as a starting point for creating your own profiles, extensions, and custom resources in Aidbox FHIR server. For more advanced scenarios, refer to the official Aidbox and FHIR documentation.
Get in touch with us today!