Skip to main content

Crate ferrobridge_validator

Crate ferrobridge_validator 

Source
Expand description

A FHIR R4 profile validator over FHIR packages read offline.

set::PackageSet::load reads packages from .tgz files and unpacked directories, checks that every dependency their manifests name is present, and resolves StructureDefinitions by canonical into the generated fhir_types::r4 model. validate::Validator walks an instance, the lexical document model of fhir-types, over the R4 element table and holds it to the snapshot of the profile it is validated against (https://hl7.org/fhir/R4/validation.html, https://hl7.org/fhir/R4/profiling.html). The result is a report::Report of typed issue::Issues that converts into an R4 OperationOutcome, and that names every constraint the validator met and did not evaluate.

use ferrobridge_validator::set::PackageSet;
use ferrobridge_validator::validate::Validator;
use fhir_types::codec::Value;
use fhir_types::r4::operation_outcome::OperationOutcome;

let set = PackageSet::load(["vendor/hl7.fhir.r4.core", "packages/my.profiles.tgz"])?;
let validator = Validator::new(&set);
let patient: Value = serde_json::from_str(r#"{"resourceType": "Patient", "active": true}"#)?;
let report = validator.validate_against(&patient, "http://example.org/StructureDefinition/my-patient")?;
let outcome = OperationOutcome::from(&report);
assert!(!outcome.issue.is_empty());

Modulesยง

canonical
Canonical references and the version order the package set resolves by.
issue
The issue model: one finding about an instance, in the shape of an R4 OperationOutcome.issue (https://hl7.org/fhir/R4/operationoutcome.html).
package
One FHIR package read offline, from a .tgz file or an unpacked directory.
report
The outcome of one validation: the issues, and every constraint the validator met and could not evaluate, convertible into an R4 OperationOutcome.
set
The package set: the packages given to the validator, checked for a complete dependency closure, and the StructureDefinitions, ValueSets and CodeSystems they carry, resolved by canonical.
validate
The validator: an instance walked over the R4 element table, held to the snapshot of the profile it is validated against and of every datatype and extension definition it reaches.