Custom resources are defined by individual organizations or projects to meet specific needs not covered by the FHIR standard. While these resources can be useful within a particular ecosystem, they may not be interoperable with other systems that do not recognize or support those custom resources.
FHIR uses StructureDefinition resources to model data structures. Aidbox allows you to model data in the same way by expressing your custom resource using a FHIR StructureDefinition resource.
Configure Aidbox
To begin using custom FHIR resources, enable the FHIR Schema validation engine in Aidbox.
derivation: If it is set to specialization - Aidbox will create a new resource type with tables in the database and other resource infrastructure. If it is set to constraint - Aidbox will create a new profile that can be referenced on resource instances.
The further guide details the process of creating custom resources for a notification system, demonstrating the typical workflow of creating, managing, and sending template-based notifications from a healthcare system to patients using custom resources defined through StructureDefinition.
To implement a notification flow, you may need a notification resource and a template resource to store your notification messages.
Let's start with shaping a TutorNotificationTemplate resource.
This resource contains one property defined under StructureDefinition.differential:
template: This property is for notification template text and is of the FHIR string data type. Also, it is a required property.
Now, that we got resource to store our templates, let's shape a more complex one - a resource TutorNotification that has the following properties:
type: property that contains binding value set URL in valueSet property and strength: required, that is used to force binding validation.
status: property with binding to valueSet: http://hl7.org/fhir/ValueSet/task-status with additional constraints to requested, in-progress or completed values.
template: reference to TutorNotificationTemplate that we created above.
message: message text and is of the FHIR string data type.
sendAfter: property that specifies the dateTime after which this notification should be sent.
subject: reference to the Patient resource to whom this notification will be sent.
POST /fhir/TutorNotificationTemplatecontent-type: application/jsonaccept: application/json{"id":"welcome","resourceType":"TutorNotificationTemplate","template":"Hello user name: {{patient.name.given}}\n"}
POST /fhir/SearchParametercontent-type: application/jsonaccept: application/json{"resourceType":"SearchParameter","id":"TutorNotification-subject","url":"http://example.com/aidbox-sms-tutor/TutorNotification-subject","version":"0.0.1","status":"draft","name":"subject","code":"subject","base": ["TutorNotification" ],"type":"reference","description":"Search TutorNotification by subject","expression":"TutorNotification.subject"}
{"description":"Search TutorNotification by subject","expression":"TutorNotification.subject","name":"subject","type":"reference","resourceType":"SearchParameter","status":"draft","id":"TutorNotification-subject","url":"http://example.com/aidbox-sms-tutor/TutorNotification-subject","code":"subject","base": ["TutorNotification" ],"version":"0.0.1"}
The other one is used to include related Patient resources in the search bundle.
This one defines the expression to achieve resource status, which allows you to search for TutorNotification resources by status like this:
POST /fhir/SearchParametercontent-type: application/jsonaccept: application/json{"resourceType":"SearchParameter","id":"TutorNotification-status","url":"http://example.com/aidbox-sms-tutor/TutorNotification-status","version":"0.0.1","status":"draft","name":"status","code":"status","base": ["TutorNotification" ],"type":"token","description":"Search TutorNotification by status","expression":"TutorNotification.status"}
Status: 200{"description":"Search TutorNotification by status","expression":"TutorNotification.status","name":"status","type":"token","resourceType":"SearchParameter","status":"draft","id":"TutorNotification-status","url":"http://example.com/aidbox-sms-tutor/TutorNotification-status","code":"status","base": ["TutorNotification" ],"version":"0.0.1"}
Let's create the search parameters mentioned above.
With defined resources, most of the work is done, but there is one missing aspect of any FHIR resource. You definitely want to check your requested notifications or include related subjects to the search bundle. Aidbox allows you to define SearchParameter resources in addition to custom resources.
Convenience
Manually writing StructureDefinitions can be overwhelming. Fortunately, there is an alternative: FSH/SUSHI allows you to generate a FHIR NPM package with your custom resources, which you can load into Aidbox and use.
How Aidbox Deals with FHIR Limitations for Custom Resources
FHIR Type ValueSet Bindings
FHIR defines certain ValueSets that list all resource types and binds them with required strength to some properties. For example, the SearchParameter.base property points to the resource this SearchParameter is intended for and has this exact binding. Your custom resource type is not mentioned in this ValueSet. However, you still want to create and use search parameters for your custom resources.
During validation, Aidbox checks whether the resource type is in the given ValueSet or if it is a known custom resource for Aidbox. This allows you to use custom resources in resources like CapabilityStatement or SearchParameter, or in the type property of references.
References to Unknown FHIR Types
FHIR allows references to point only to FHIR resources. Aidbox, however, allows you to specify custom resources in reference targets as well.
Bundle Entries Must Inherit from Resource FHIR Type
FHIR explicitly states that Bundle.entry.resource must be a type that inherits from the Resource FHIR type. Aidbox relaxes this constraint and checks that the referenced resource inherits from at least one StructureDefinition/FHIRSchema with kind: resource and derivation: specialization.