Validate a code against a ValueSet
$validate-code checks whether a supplied code belongs to a ValueSet. It can also check an optional display string and return the preferred display for a valid concept.
| Method | Path |
|---|---|
GET or POST | /fhir/R4/ValueSet/$validate-code |
At this type-level route, identify the ValueSet with url, context, or valueSet. Provide exactly one code input: code (with a code system), coding, or codeableConcept.
GET request
Pass the canonical ValueSet URL and code details as query parameters:
curl --get 'https://api.sandbox.ovok.com/fhir/R4/ValueSet/$validate-code' \
--header "Authorization: Bearer ${OVOK_TOKEN}" \
--data-urlencode 'url=https://example.org/fhir/ValueSet/vitals' \
--data-urlencode 'system=http://loinc.org' \
--data-urlencode 'code=8867-4' \
--data-urlencode 'display=Heart rate'
POST request
For structured input, send a FHIR Parameters resource. This example supplies the ValueSet canonical URL and a Coding:
curl --request POST \
--url 'https://api.sandbox.ovok.com/fhir/R4/ValueSet/$validate-code' \
--header "Authorization: Bearer ${OVOK_TOKEN}" \
--header 'Content-Type: application/fhir+json' \
--data @validate-valueset-code-parameters.json
Example validate-valueset-code-parameters.json:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "url",
"valueUri": "https://example.org/fhir/ValueSet/vitals"
},
{
"name": "coding",
"valueCoding": {
"system": "http://loinc.org",
"code": "8867-4",
"display": "Heart rate"
}
}
]
}
Successful response
The operation returns a FHIR Parameters resource.
| Response path | Example | Meaning |
|---|---|---|
resourceType | Parameters | FHIR wrapper for the operation output. |
parameter[name=result].valueBoolean | true | Whether the supplied concept is valid in the ValueSet; false means it is not. |
parameter[name=display].valueString | Heart rate | Preferred display string, when available. |
parameter[name=message].valueString | Optional | Validation failure details, hint, or warning, when present. |
If the ValueSet cannot be resolved or the request cannot be evaluated, the server can return an OperationOutcome with diagnostic details.
Reference: HL7 FHIR R4 ValueSet $validate-code.