Smile CDR v2024.08.PRE
On this page:

43.20.1smileutil: Validate FHIR Resources


The validate command can be used to validate that a resource conforms to the FHIR specification, and potentially to one or more profiles. This validation may be performed using either Profile or Schema/Schematron mode.


bin/smileutil validate --fhir-version "dstu3" --profile --file "mypatient.json"

The example above shows a patient resource file being validated against the DSTU3 FHIR definitions.

bin/smileutil validate --fhir-version "dstu2" --profile -file "argo-dstu2-observation.json"

The example above shows a DSTU2 example resource from the Argonaut Profile being validated.



One of the following options must be specified in order to supply the content to be validated.

  • -n [filename] (or --file [filename]) – This argument contains the name of a file to validate.
  • -d "[text]" (or --data "[text]") – This argument contains the text of a resource to validate.

The following options control Profile validation mode.

  • -p (or --profile) – This argument enables profile mode.
  • -r (or --fetch-remote) – This argument enables fetching remote resources via the network (in other words, if a resource being validated refers to an external StructureDefinition, Questionnaire, etc. this flag allows the validator to access the network to try and fetch this resource).
  • -l [filename] (or --fetch-local [filename]) – This argument provides the path to a file on the local filesystem that should be loaded as a conformance resource. In other words, this file should contain a StructureDefinition, ValueSet, etc. that will be used by the validator as a part of validating the resource specified by the -n or -d option.

The following options control Schema and Schematron validation mode.

  • -x (or --xsd) – This argument enables XSD (Schema) validation.
  • -s (or --sch) – This argument enables SCH (Schematron) validation.

The following additional options exist:

  • -e [encoding] (or --encoding [encoding]) – (optional) This argument may be used to specify that the file being validated uses a specific file encoding (default is UTF-8).

43.20.4Profile Mode


Profile mode validates resources against FHIR conformance resources (StructureDefinition, ValueSet, CodeSystem, etc).

By default, this mode validates resources using the FHIR built-in StructureDefinition resources and has no outside dependencies. This can be used to validate structure, field cardinalities, invariants (rules about dependencies between fields), coded values, and several best practices for certain resource types.

If the resource being validated contains one or more profile declarations, the resource may also be validated against these profiles. For example, the following snippet shows the ID and Metadata section of an Observation resource declaring conformance to the Argonaut Observation-Results profile.

  "resourceType": "Observation",
  "id": "123",
  "meta": {
    "profile": [
  (..other content not shown..)

Given the declaration shown above, the validator will attempt to locate the StructureDefinion with canonical URL and will use it for validation if it is found.

43.20.5Schema and Schematron Mode


Schema and Schematron modes may be used as a fallback if profile mode is not producing useful results for any reason. This mode can validate field names and cardinality (Schema) and invariants (Schematron).