Enabling FHIR Interfaces
To enable the HL7 FHIR interface on your SanteDB iCDR you will need to:
  • Enable the FHIR Message Service in your host context
  • Configure the FhirServiceConfigurationSection
  • Optionally enable FHIR audit dispatcher notifications

Enabling the FHIR Interface

Enable the FHIR Message Handler Services

To enable the FHIR message handler, you should include the following option in your santedb.config.xml file:
1
<section xsi:type="ApplicationServiceContextConfigurationSection" threadPoolSize="8">
2
<serviceProviders>
3
<add type="SanteDB.Messaging.FHIR.FhirMessageHandler, SanteDB.Messaging.FHIR, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null" />
4
<add type="SanteDB.Messaging.FHIR.FhirDataInitializationService, SanteDB.Messaging.FHIR, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null" />
5
</serviceProviders>
6
</section>
Copied!
This enables two services for FHIR:
  • FhirMessageHandler: Which is responsible for the processing of FHIR messages over HTTP REST
  • FhirDataInitializationService: Which is responsible for the import of FHIR resource files from the hard disk drive in the /data/fhir directory.
Alternately, you can enable the FHIR services via the environment variable (in Docker or Kubernetes) using:
1
SDB_FEATURE=...;FHIR;...
Copied!

Configuring FHIR Message Handler

The FHIR Message Handler uses the FhirServiceConfigurationSection in order to drive the configuration of the FHIR services.
1
<SanteDBConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1.0.0" xmlns="http://santedb.org/configuration">
2
<sections>
3
<add type="SanteDB.Messaging.FHIR.Configuration.FhirServiceConfigurationSection, SanteDB.Messaging.FHIR, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null" />
4
</sections>
5
<!-- Truncated for space -->
6
<section xsi:type="RestConfigurationSection">
7
<!-- -->
8
<service name="FHIR">
9
<behaviors>
10
<add type="SanteDB.Rest.Common.Security.TokenAuthorizationAccessBehavior, SanteDB.Rest.Common" />
11
</behaviors>
12
<endpoint contract="SanteDB.Messaging.FHIR.Rest.IFhirServiceContract, SanteDB.Messaging.FHIR" address="http://0.0.0.0:8080/fhir">
13
<behaviors>
14
<add type="SanteDB.Rest.Common.Behavior.MessageLoggingEndpointBehavior, SanteDB.Rest.Common" />
15
<add type="SanteDB.Rest.Common.Behavior.MessageCompressionEndpointBehavior, SanteDB.Rest.Common" />
16
<add type="SanteDB.Rest.Common.Behavior.MessageDispatchFormatterBehavior, SanteDB.Rest.Common" />
17
<add type="SanteDB.Rest.Common.Behavior.AcceptLanguageEndpointBehavior, SanteDB.Rest.Common" />
18
</behaviors>
19
</endpoint>
20
</service>
21
22
</section>
23
24
<section xsi:type="FhirServiceConfigurationSection">
25
<resourceHandlers>
26
<!-- Resources enabled on this server as type references for example:
27
<add type="SanteDB.Messaging.FHIR.Handlers.AdverseEventResourceHandler, SanteDB.Messaging.FHIR" />
28
-->
29
</resourceHandlers>
30
<resources>
31
<!-- Resources enabled on this server as resource type names, for example:
32
<add type="Patient"/>
33
-->
34
</resources>
35
<operationHandlers>
36
<!-- Custom fhir operation handlers enabled on this instance, for example:
37
<add type="SanteMPI.Messaging.IHE.FHIR.PatientIdentityCrossReferenceMobileOperation, SanteMPI.Messaging.IHE" />
38
-->
39
</operationHandlers>
40
<operations>
41
<!-- Custom operations which are enabled on this instance, for example:
42
<add>ihe-pix</add>
43
<add>process-message</add>
44
-->
45
</operations>
46
<messageHandlers>
47
<!-- Custom message operations / message handlers , for example:
48
<add type="SanteMPI.Messaging.IHE.FHIR.PatientMasterIdentityOperation, SanteMPI.Messaging.IHE" />
49
-->
50
</messageHandlers>
51
<messages>
52
<!-- Custom message operations by the URN of the message event, for example:
53
<add>urn:fhir:message:foo</add>
54
-->
55
<extensionHandlers>
56
<!-- Custom extension handlers for process/producing extensions, for example:
57
<add type="SanteMPI.Messaging.IHE.FHIR.MothersMaidenNameExtension, SanteMPI.Messaging.IHE" />
58
-->
59
</extensionHandlers>
60
<extensions>
61
<!-- Custom extensions to enable on this instance -->
62
</extensions>
63
<base><!-- Base URL for producing absolute references --></base>
64
<behaviorModifiers>
65
<!-- Custom behaviors which should be enabled on this FHIR service :
66
<add type="SanteMPI.Messaging.IHE.FHIR.PatientIdentityCrossReferenceMobileOperation, SanteMPI.Messaging.IHE" />
67
-->
68
</behaviorModifiers>
69
</section>
70
71
</SanteDBConfiguration>
Copied!

REST Configuration

The endpoint on which the service listens is driven by the RestConfigurationSection , a service with name FHIR is registered with one or more <endpoint> elements which dictate the IP/Port and scheme of binding.
As with all SanteDB services, it is recommended to use SSL termination at an upstream host. The HTTPS scheme is only supported on Windows and only after an appropriate netsh http sslcert add command has been executed to bind a certificate to the WinHTTP layer.

Controlling Resource Access

By default, the FHIR message handler will scan the application domain for all resource handlers and will, by default, enable all available resources. There are use cases where this list of resources needs to be constrained for a particular SanteDB role (for example, in SanteMPI it may not be advisable to expose the AdverseEvent resource handlers).
To enable a resource on the FHIR handler using the default implementation of the resource handler, appropriate <resources> should be registered in the configuration section, for example, to enable only Patient and RelatedPerson:
1
<resources>
2
<add type="Patient"/>
3
<add type="RelatedPerson"/>
4
</resources>
Copied!
Alternately, if you would like to implement a custom resource handler which can provides specific behaviours for a particular resource type, you can use the <resourceHandlers> section and provide an assembly-qualified pointer to the resource handler:
1
<resourceHandlers>
2
<add type="Sample.Custom.FHIR.Handlers.PatientHandler, Sample.Custom"/>
Copied!

Extended Operations and Extensions

The Extending FHIR Functionality wiki article described the process of extending the FHIR interface with custom operations and custom extensions.

Configuring Dispatcher Targets

FHIR dispatchers are classes which are responsible for sending data from your SanteDB iCDR server to another server. These dispatchers can be created using a Subscription resource, or can be the FHIR Audit Dispatcher (described below).
The configuration for these dispatchers are driven by the settings in the Subscription resource, however can further be configured using FhirDispatchConfigurationSection.
1
<sections>
2
<add type="SanteDB.Messaging.FHIR.Configuration.FhirDispatcherConfigurationSection, SanteDB.Messaging.FHIR, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null" />
3
</sections>
4
5
<section xsi:type="FhirDispatcherConfigurationSection">
6
<targets>
7
<add>
8
<name>audit</name>
9
<endpoint>http://localhost:8989/fhir/Audit</endpoint>
10
<user>user_to_authenticate</user>
11
<password>password_to_authenticate</password>
12
<authenticator type="Class.Of.Authenticator" />
13
</add>
14
</targets>
15
</section>
Copied!
By default, the <user> and <password> fields are used to drive HTTP BASIC authentication, however a custom <authenticator can be used if the target service requires obtaining a security certificate, an authorization token, etc.
To modify/customize a Subscription resource , a <target> is added with <name> matching the id of the subscription.

Enabling FHIR Audits

All message layer functions in SanteDB produce audits which are stored in the local SanteDB audit repository instance (or in the SanteGuard audit repository if installed). These audits can optionally be shipped or forwarded to another audit repository by enabling an IAuditDispatcher service.
The FHIR service in SanteDB contains a FHIR based audit dispatcher which creates instances of AuditEvent and ships them to a FHIR server. To enable the FHIR audit dispatcher, add it as a service in your service configuration:
1
<section xsi:type="ApplicationServiceContextConfigurationSection" threadPoolSize="8">
2
<serviceProviders>
3
<add type="SanteDB.Messaging.FHIR.Auditing.FhirAuditDispatcher, SanteDB.Messaging.FHIR, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null" />
4
</serviceProviders>
Copied!
In Docker or Kubernetes, this feature is enabled using:
1
SDB_FEATURE=...;FHIR_AUDIT;...
Copied!
After configuration of the audit dispatcher, you will need to configure a dispatcher target named AUDIT which provides the destination registration of where to send the audit information. In Kubernetes/Docker this is configured with:
1
SDB_FHIR_AUDIT_EP=http://target:port/path
2
SDB_FHIR_AUDIT_UN=user_to_authenticate
3
SDB_FHIR_AUDIT_PWD=password_to_authenticate
4
SDB_FHIR_AUDIT_AUTH=AuthenticatorType
Copied!