Skip to content

hapi.context.getFhirValidator

Signature: hapi.context.getFhirValidator(context)

Returns: FhirValidator fhirValidator - the cached FhirValidator for the context

Returns a FhirValidator based on the FhirContext supplied.

This validator is created and cached at the time the context is created.

It can support USCoreProfiles for DSTU3, R4, and R4b according to the context.

Note

FhirValidator Usage in QIE: var validator = hapi.context.getFhirValidator(context); var validationResult = validator.validateWithResult(patientString); var isSuccessful = validationResult.isSuccessful();

Note

FhirValidator documentation can be found on this kb.

Parameters

Type Name Description Default
FhirContext context the FHIR Context for the validator

Example

var fhirContext = hapi.context.getR5FhirContext();
var patientJson = '' +
'{' +
'    "resourceType": "Patient",' +
'    "id": "example",' +
'    "name": [' +
'        {' +
'            "family": "Doe",' +
'            "given": ["John","Jaques"]' +
'        }' +
'    ],' +
'    "gender": "male",' +
'    "birthDate": "1980-01-01"' +
'}';

var validator = hapi.context.getFhirValidator(fhirContext);
var validationResult = validator.validateWithResult(patientJson);
var isSuccessful = validationResult.isSuccessful();