Skip to main content

ValueSet Validate Code

Validating whether a given coding is in a specified set forms the backbone of FHIR terminology bindings: many resource properties can be required to have their values drawn from a given set of values specified by a ValueSet, which may need to be expanded behind the scenes.

[baseUrl]/ValueSet/$validate-code
[baseUrl]/ValueSet/[id]$validate-code

Parameters

NameTypeDescriptionRequired
urluriThe canonical URL of the ValueSet to validate againstNo*
codestringThe code to look up.No
systemstringThe canonical URL of the code system the code belongs to.No
codingCodingLook up via full Coding.No
codeableConceptCodeableConceptLook up multiple related codes.No
displaystringAdditionally validate the given display textNo
abstractbooleanWhether codes labeled as abstract, i.e. representing broad concepts rather than specific values, should be includedNo

* If no url is provided, the operation must be invoked on a specific ValueSet instance.

Required Parameters

Although no parameters are strictly required by the operation, at least one of the following must be provided:

  • Both code and system parameters (and optionally display)
  • The coding parameter
  • The codeableConcept parameter with at least one contained coding

Output

The operation returns a Parameters resource containing the validation result.

NameTypeDescriptionRequired
resultbooleanWhether or not any given coding is included in the ValueSetYes
displaystringThe display text of the included codeNo

Error Responses

Example: Specified ValueSet could not be found by URL (400 Bad Request)

{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error"
"code": "invalid",
"details": {
"text": "ValueSet http://example.com/ValueSet/missing not found"
},
}
]
}

Examples

Request:

const result = await medplum.post(medplum.fhirUrl('ValueSet', '$validate-code').toString(), {
resourceType: 'Parameters',
parameter: [
{ name: 'url', valueUri: 'http://hl7.org/fhir/ValueSet/condition-severity' },
{ name: 'coding', valueCoding: { system: 'http://snomed.info/sct', code: '255604002' } },
],
});

Response: (200 OK)

{
"resourceType": "Parameters",
"parameter": [
{ "name": "result", "valueBoolean": true },
{ "name": "display", "valueString": "Mild (qualifier value)" }
]
}