# Validate against FHIR profiles ## What you'll do You check that the FHIR your mappings produce is valid: against base FHIR and against the profiles of the loaded IG packages. Atlas validates the FHIR example pane after each conversion, marks the issues in the pane, lists them in the Problems dock and links each one back to the mapping that produced the element. ```{figure} ../images/check/validation-controls.png :class: screenshot :alt: The FHIR pane with the validation chip, the not-loaded profiles link and the validation settings The validation controls of the FHIR pane, with the settings open. ``` ## Before you start - Open a template in the Workspace; the FHIR pane must show **Example**. - Load the IG packages that define your profiles ({doc}`/codes-and-profiles/fhir-packages`). Without them, the result is only checked against base FHIR. :::{note} Validation runs in Atlas, with the HAPI FHIR validator, against base FHIR and the packages loaded for your tenant. The openFHIR engine itself doesn't validate: a conversion succeeds whether or not its output is valid. ::: ## Steps ### 1. Read the validation chip The controls sit in the header of the FHIR pane. The numbers match the screenshot above. [1]{.callout} **The validation chip** : The result for the FHIR shown in the pane: the error and warning counts, or **valid**. Hover it: "Validated by Atlas against base FHIR + in N ms.", with how many issues were informational or ignored and which profiles weren't loaded. Click it to open the Problems dock. [2]{.callout} **N profile(s) not loaded** : The FHIR declares or needs profiles no loaded package defines, so it was validated without them. Hover it for the profiles; click it to go to the FHIR packages page. [3]{.callout} **Validate** : Validates the FHIR now, against base FHIR and the loaded profiles. Disabled while the pane is empty or a validation runs. [4]{.callout} **Validation settings** : Opens the settings below. [5]{.callout} **Validate after each conversion** : On by default: every conversion, and every edit of the FHIR pane as the source, is validated 0.6 seconds later. Turn it off to validate only with **Validate**. [6]{.callout} **Terminology checks (codes & bindings)** : Off by default: also checks codes against their ValueSets (in memory; code systems the validator doesn't know are reported). Expect more issues with it on. Each resource is also checked against the profile of the model that produced it, even when the resource doesn't name the profile in `meta.profile`. Atlas remembers both settings in this browser. The chip can also say: | Chip | Meaning | |---|---| | **Validator starting…** | The validator loads the FHIR definitions, once, which takes a few seconds; Atlas retries by itself. | | **Validating…** | A validation is running. | | **Validator busy** | Too many validations at once; run it again shortly. | | **Validation timed out** | The validation took too long; hover for details. | | **Not FHIR** | The pane doesn't hold FHIR JSON the validator can read; hover for the parser's message. | | **Validation failed** | Atlas couldn't validate; hover for the reason. | ### 2. Find the issues Issues are underlined in the FHIR pane (hover one for its message, the profile and the mapping) and listed in the Problems dock with the source **FHIR validation**. Pick that source to see only them. ```{figure} ../images/check/validation-problems.png :class: screenshot :alt: The Problems dock filtered to FHIR validation issues Validation issues of the IPS example, grouped by the model that produced them. ``` [1]{.callout} **FHIR validation**: the source filter. [2]{.callout} **go to mapping**: opens the mapping that produces the element, with the cursor in its FHIR path. [3]{.callout} **FHIR**: clicking the row selects the element in the FHIR pane. [4]{.callout} **Ignore this kind of issue here for this template** (the eye icon, on hover). Issues Atlas can trace to a mapping are grouped under that mapping's model; the others are grouped as **Produced FHIR (no mapping traced)**. Each issue's **?** opens {ref}`FHIR validation issues `. ### 3. Ignore a recurring issue Some issues are expected, for example a profile you don't load on purpose. Hover the issue and click the eye icon: Atlas hides every issue with the same message id at the same place (list indexes don't matter) for this template. The settings list the ignored kinds under **Ignored for this template (N)**; **×** ("Stop ignoring") shows them again. ```{figure} ../images/check/ignored-rule.png :class: screenshot :alt: The validation settings listing one ignored kind of issue One ignored kind of issue; **Stop ignoring** [1]{.callout} brings it back. ``` ## Check it worked The chip shows **valid**, or only the issues you expect. After you fix a mapping and save, the conversion runs again and so does the validation. ## Tips :::{tip} Load the IG package first. Without it, the result is only checked against base FHIR, and the chip says which profiles were missing (**N profile(s) not loaded**). ::: :::{tip} Use **go to mapping** rather than the row: the row shows *where* in the FHIR the issue is, **go to mapping** shows *which mapping* wrote it. ::: ## Watch out :::{warning} Validation runs in Atlas, not in the engine. Nothing stops the engine from producing invalid FHIR for your systems; validate before you release. ::: :::{warning} Ignored issues are kept **in this browser**, per template. Your teammates don't share them. ::: ## If something goes wrong - Validation chip states: {ref}`msg-validation-chip`. - **N profile(s) not loaded**: {ref}`msg-profiles-not-loaded`. - Each FHIR validation issue: {ref}`FHIR validation issues `. ## Related - {doc}`/codes-and-profiles/fhir-packages` - {doc}`fix-problems` - {doc}`see-in-action`