Skip to main content

fml_check/
lib.rs

1//! Type checker for the FHIR Mapping Language.
2//!
3//! Follows every rule with the types of its variables and reports what cannot work: elements that
4//! do not exist on the type they are read from or written to, a type annotation that is not one of
5//! the element's types, unknown variables, writes into source variables, unknown or abstract types
6//! in `create`, transforms with the wrong number of arguments, and calls to groups that are not
7//! declared or take a different number of arguments. It also reports what the Mapping Language IG
8//! requires of a map: a `url` and a `name`, groups that extend another with its parameters,
9//! default groups with a typed source and target, and rule names used once.
10//!
11//! Groups without parameter types, such as the per-backbone groups of the cross-version maps, are
12//! checked with the types they are called with.
13//!
14//! ```
15//! # #[cfg(feature = "fhirschema")] {
16//! use fml_check::{CoreDefinitions, Release, check};
17//!
18//! let parse = fml_syntax::parse(r#"
19//! /// url = 'http://example.org/StructureMap/Copy'
20//! /// name = 'Copy'
21//! uses "http://hl7.org/fhir/StructureDefinition/Patient" as source
22//! uses "http://hl7.org/fhir/StructureDefinition/Patient" as target
23//!
24//! group Copy(source src : Patient, target tgt : Patient) {
25//!   src.nmae -> tgt.name;
26//! }
27//! "#);
28//! let diagnostics = check(&parse.tree(), &CoreDefinitions::new(Release::R5));
29//! assert_eq!(diagnostics[0].message, "`Patient` has no element `nmae`");
30//! # }
31//! ```
32
33mod check;
34#[cfg(feature = "fhirschema")]
35mod core;
36pub mod definitions;
37#[cfg(feature = "fhirschema")]
38mod package;
39pub mod types;
40
41pub use check::check;
42#[cfg(feature = "fhirschema")]
43pub use core::{CoreDefinitions, Release};
44pub use definitions::{Definitions, Element, Kind, NoDefinitions, Structure};
45#[cfg(feature = "fhirschema")]
46pub use package::PackageDefinitions;
47pub use types::{ElementRef, Lookup, Type, Types};