Validate Code
The FHIR $validate-code operation validates whether a coded value is in a value set.
Endpoint
POST /w/{tenant}/{project}/api/v1/fhir/r4/ValueSet/$validate-code
Where {id} is the logical ID of a specific ValueSet or CodeSystem resource (optional for type-level operations).
Request Body (POST)
For POST requests, the request body should contain a Parameters resource with the input parameters:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "url",
"valueUri": "http://hl7.org/fhir/ValueSet/administrative-gender"
},
{
"name": "code",
"valueCode": "male"
}
]
}
Response
If the validation is successful, the server will respond with a 200 OK status code and a Parameters resource containing the validation result:
HTTP/1.1 200 OK
Content-Type: application/fhir+json
{
"resourceType": "Parameters",
"parameter": [
{
"name": "result",
"valueBoolean": true
},
{
"name": "message",
"valueString": "The code 'male' is valid in the value set 'http://hl7.org/fhir/ValueSet/administrative-gender'"
},
{
"name": "display",
"valueString": "Male"
}
]
}
Response parameters:
result- Boolean (required): True if the code is valid, false otherwisemessage- String (optional): Additional information about the validationdisplay- String (optional): The recommended display text for the code
Validation Failure Response
If the code is not valid in the value set:
{
"resourceType": "Parameters",
"parameter": [
{
"name": "result",
"valueBoolean": false
},
{
"name": "message",
"valueString": "The code 'invalid-code' is not in the value set 'http://hl7.org/fhir/ValueSet/administrative-gender'"
}
]
}
Error Handling
If there are any issues with the request (e.g., missing required parameters, invalid value set), the server will respond with an appropriate error status code and include an OperationOutcome resource in the response body.
HTTP/1.1 400 Bad Request
Content-Type: application/fhir+json
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "required",
"diagnostics": "Missing required parameter: code"
}
]
}