The Healthcare: FHIR® Validation pattern provides an application for the validation and conversion of HL7® FHIR® standard resources.
Fast Healthcare Interoperability Resources (FHIR®) is a standard from Health Level 7 International (HL7®) that is designed to allow the exchange of electronic health records. The HL7® FHIR® standard uses XML and JSON for data representation. FHIR solutions can be created by using components called resources, which are built around particular concepts, such as the patient or provider, diagnostics, and care plans. Systems that implement FHIR must support resources in the XML format, but they can also support resources in the JSON format. You can use the Healthcare: FHIR Validation pattern to create an application that reads a FHIR R4 resource in either XML or JSON format from the file system, validates it against the FHIR R4 specification by using the FHIRValidate node, and sends it to the file system. You can choose whether the resource is sent as XML or JSON, or in the original format.
You can choose the level of FHIR validation that is performed. The Schema level comprises validation of Structure, Cardinality, and Value Domains. The All level comprises validation of Structure, Cardinality, Value Domains, Invariants, Bindings, and Profiles. For more information, see https://www.hl7.org/fhir/r4/validation.html. If the FHIR resource is JSON, you can select whether unknown elements in the resource are ignored or cause validation to fail. If you set the level of validation to All, you can select whether to switch off Profiles validation.
If Profiles validation is switched on, FHIR resources are validated against any profile references that are contained in the FHIR resource itself. You can also specify additional profile references. All profile references must resolve to a profile that is known to the FHIR validator at run time. Profiles for several FHIR implementation guides are available as JAR files, which can be imported by the pattern and deployed with your application.
If the resource passes validation, the output message is the validated FHIR resource, not a copy of the input message. If you select Inherit as the output format, the output domain is XMLNSC if the resource is XML, or JSON if the resource is JSON. If you select XML as the output format, the output domain is always XMLNSC, and JSON resources are converted to XML. If you select JSON as the output format, the output domain is always JSON, and XML resources are converted to JSON. FHIR warnings are saved in the local environment and are sent to the file system.
If the resource fails validation, the input message is sent to the file system unmodified. FHIR errors and warnings are saved in the local environment and are sent to the file system.
If an error occurs during processing, the input message is sent to the file system unmodified. The associated exception list is also sent to the file system.
The FHIRValidate node includes profiles that are defined in the base FHIR Specification (v4.0.1: R4 - Mixed Normative and STU). Profiles for the following FHIR implementation guides can be imported by the pattern:
You can create your own custom profile JAR files by following the steps at https://ibm.github.io/FHIR/guides/FHIRValidationGuide.