Skip to content

Operation $validate

Operation $validate allows users to validate a resource against specific rules to ensure that the content has a valid structure and does not violate any rules defined in the profiles, without saving or updating actual resources in the FHIR Server Storage. An input for this operation is a resource and an output is always an Operation Outcome, indicating whether the operation would be expected to succeed or not.

Endpoints

[fhir_base]/[resource_type]/$validate

[fhir_base]/[resource_type]/[id]/$validate

Query parameters

Query parameters Status
resource supported
mode supported
profile unsupported

The action the server takes depends on the mode parameter:

  • [mode not provided]: The server checks the content of the resource against any schema, constraint rules, and other general terminology rules.
  • create: The server checks the content, and then checks that the content would be acceptable as a create (e.g. that the content would not violate any uniqueness constraints).
  • update: The server checks the content, and then checks that it would accept it as an update against the nominated specific resource (e.g. that there are no changes to immutable fields the server does not allow to change, and checking version integrity if appropriate).
  • delete: The server ignores the content, and checks that the nominated resource is allowed to be deleted (e.g. checking referential integrity rules).

Operation $validate is not supported for Terminology Service

Operation $validate also supports POST using the Parameters syntax.

Examples

Example - Validate Patient resource

curl --location --request POST 'https://kodjin-example.edenlab.dev/fhir/Patient/$validate' \
--header 'Content-Type: application/json' \
--data-raw '{
"resourceType": "Patient",
    "id": "b095f89f-bf9c-4583-a1df-2fa0fd7a9d21",
    "meta": {
        "source": "b095f89f-bf9c-4583-a1df-2fa0fd7a9d21",
        "versionId": "1",
        "lastUpdated": "2022-09-20T07:47:49.390+00:00"
    },
    "identifier": [
        {
            "type": {
                "coding": [
                    {
                        "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                        "code": "VS",
                        "display": "VISA"
                    }
                ]
            },
            "system": "http://example.sa/identifier/visa",
            "value": "c0si1"
        }
    ],
    "active": true,
    "name": [
        {
            "use": "official",
            "text": "Nick Shevchenko",
            "family": "Shevchenko",
            "given": [
                "Nick"
            ]
        }
    ],
    "telecom": [
        {
            "system": "email",
            "value": "patient@email.com",
            "use": "work"
        }
    ],
    "gender": "male",
    "birthDate": "1973-09-23",
    "managingOrganization": {
        "reference": "Organization/ad216ed0-6088-4d71-be71-ac561bc48cb9"
    }
}'
{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "information",
            "code": "informational",
            "details": {
                "text": "All OK"
            }
        },
        {
            "severity": "warning",
            "code": "code-invalid",
            "expression": [
                "Patient.identifier[0].type.coding[0]"
            ],
            "details": {
                "text": "The value provided 'VS' is not in the value set http://hl7.org/fhir/ValueSet/identifier-type and code system http://terminology.hl7.org/CodeSystem/v2-0203|4.0.1"
            }
        },
        {
            "severity": "warning",
            "code": "invariant",
            "expression": [
                "Patient"
            ],
            "details": {
                "text": "dom-6: A resource should have narrative for robust management"
            }
        }
    ]
}
curl --location --request POST 'https://kodjin-example.edenlab.dev/fhir/Patient/$validate' \
--header 'Content-Type: application/json' \
--data-raw '{
"resourceType": "Parameters",
"parameter": [
    {
        "name": "profile",
        "valueUri": "http://hl7.org/fhir/StructureDefinition/Patient"
    },
    {
        "name": "resource",
        "resource": {
            "resourceType": "Patient",
            "id": "b095f89f-bf9c-4583-a1df-2fa0fd7a9d21",
            "meta": {
                "source": "b095f89f-bf9c-4583-a1df-2fa0fd7a9d21",
                "versionId": "1",
                "lastUpdated": "2022-09-20T07:47:49.390+00:00"
            },
            "identifier": [
                {
                    "type": {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
                                "code": "VS",
                                "display": "VISA"
                            }
                        ]
                    },
                    "system": "http://nphies.sa/identifier/visa",
                    "value": "c0si1"
                }
            ],
            "active": true,
            "name": [
                {
                    "use": "official",
                    "text": "Nick Shevchenko",
                    "family": "Shevchenko",
                    "given": [
                        "Nick"
                    ]
                }
            ],
            "telecom": [
                {
                    "system": "email",
                    "value": "patient@email.com",
                    "use": "work"
                }
            ],
            "gender": "male",
            "birthDate": "1973-09-23",
            "managingOrganization": {
                "reference": "Organization/ad216ed0-6088-4d71-be71-ac561bc48cb9"
            }
        }
    }
]
}'