Skip to main content

Overview

Validates whether a code is a member of an implicit ValueSet. EHRbase uses this during composition validation to check if a submitted code falls within the allowed set for a template field. Supports the same ValueSet URL patterns as $expand.

Supported Patterns

All codes in a code system

curl "https://fhir.omophub.com/fhir/r4/ValueSet/\$validate-code?\
url=http://snomed.info/sct?fhir_vs&\
system=http://snomed.info/sct&code=44054006" \
  -H "Authorization: Bearer YOUR_API_KEY"
Is SNOMED code 44054006 valid? (Yes, if it exists in the SNOMED vocabulary.)

Descendants of a concept (is-a filter)

curl "https://fhir.omophub.com/fhir/r4/ValueSet/\$validate-code?\
url=http://snomed.info/sct?fhir_vs=isa/73211009&\
system=http://snomed.info/sct&code=44054006" \
  -H "Authorization: Bearer YOUR_API_KEY"
Is “Type 2 diabetes mellitus” (44054006) a descendant of “Diabetes mellitus” (73211009)? (Yes.)

Parameters

ParameterTypeRequiredDescription
urluriYesImplicit ValueSet URL (e.g., http://snomed.info/sct?fhir_vs or http://snomed.info/sct?fhir_vs=isa/73211009)
systemuriNoCode system URI of the code being validated (defaults to the ValueSet system)
codecodeYesThe code to validate
displaystringNoExpected display text to verify

Response (valid code)

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "result", "valueBoolean": true },
    { "name": "display", "valueString": "Type 2 diabetes mellitus" }
  ]
}

Response (not a member)

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "result", "valueBoolean": false },
    { "name": "message", "valueString": "Code '22298006' is not a member of the ValueSet (not a descendant of '73211009')." }
  ]
}

Response (display mismatch)

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "result", "valueBoolean": true },
    { "name": "display", "valueString": "Type 2 diabetes mellitus" },
    { "name": "message", "valueString": "Display mismatch: provided 'Diabetes type 2', actual 'Type 2 diabetes mellitus'." }
  ]
}

Errors

HTTPIssue CodeCause
400invalidMissing url or code parameter, invalid ValueSet URL, or unknown code system
403forbiddenRestricted vocabulary (CPT4)
404not-foundValueSet root concept not found