Schema

The schema defines elements and specifies constraint rules, which are applied on top of base schemas.

Syntax

Properties applicable only to schema

All properties are required

URL property

  • url : string

Resource type property

  • type : string

Name property

  • name : string

Derivation property

  • derivation : specialization or constraint

Optional properties

Base type property

  • base : string

Properties shared with elements

Requires and exclusions properties

  • excluded (array of strings)
  • required (array of strings)

Nested elements property

  • elements (object)

Constraints property

  • constraints

Extensions property

  • extensions

Base

The base property defines the base profile from which schema will inherit all elements and constraints

Example

You can create resource with base profile of US Core Patient:

url: http://example.com/patient
base: http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient|6.0.0
type: Patient
name: ExamplePatient

Valid Patient resource:

resourceType: Patient
meta:
  profile:
  - http://example.com/patient
identifier:
- system: exampleSystem
  value: exampleValue
gender: male
name:
- given:
  - Example name

Invalid Patient resource with wrong gender type:

resourceType: Patient
meta:
  profile:
  - http://example.com/patient
identifier:
- system: exampleSystem
  value: exampleValue
gender: true # wrong type
name:
- given:
  - Example name

Derivation

The derivation property defines the type of described object of FHIR Schema: specialization for custom resources and constraint for profiles (see details: TypeDerivationRule)

Examples

  • The custom resource with specialization:
url: http://example.com/Foo
base: http://hl7.org/fhir/StructureDefinition/Resource
name: Foo
type: Foo
derivation: specialization
  • The profile with constraint:
url: http://example.com/Foo-Bar-profile
base: Foo
name: Bar
type: Foo
derivation: constraint

URL

The url is used to reference the profile in base property in other profiles.

Example

After creating profile with following url:

base: http://hl7.org/fhir/StructureDefinition/Patient
url: http://example.com/Patient/patient
elements:
  new-element:
    type: string

You can reference it, for example, in base property from another profile:

base: http://example.com/Patient/patient|1.0.0

Or you can reference it with meta.profile in resource, if you want to validate resource against not default profile:

Valid Patient resource

meta:
  profile: http://example.com/Patient/patient|1.0.0
new-element: "Example"

Invalid Patient resource with wrong elements type

meta:
  profile: http://example.com/Patient/patient|1.0.0
new-element: true

Resource type

The type property defines which resource type being constrained. The type must match with type property of base profile.

Example:

base: http://hl7.org/fhir/StructureDefinition/Patient
type: Patient

Name

Property name is machine readable name of profile. It is can be used as alias.

Example

After creating profile

name: ExamplePatient

You can reference it with name in other profiles


elements:
  a:
    refers: [ExamplePatient]