#FHIR: Extensible bindings and stating the value set for a code

Jun 1, 2018

FHIR defines an extension to use to state the the value set a Coding was taken from: ```` “coding”: [{ “system”: “http://snomed.info/sct”, “code”: “39065001”, “display”: “Burn of ear”, “extension” : [{ “url” : “http://hl7.org/fhir/StructureDefinition/valueset-reference”, “valueUri” : “http://example.org/ValueSet/example” }] }]


This extension states that the SNOMED CT concept 39065001 was chosen from the value set "http://example.org/ValueSet/example". There's a lot of confusion about this particular extension and it's correct use, which this post intends to clarify. Note that this extension corresponds to CD.valueSet in CDA and CWE.15 etc in HL7 v2 and the confusion applies there too.

The definition of this extension says that it  "identifies the value set that identifies the set of possible coded values this coding was chosen from or constrained by".

There's 2 uses for this extension. The first is the most obvious and also the most difficult. I've [previously described](/2013/02/08/question-cd-data-type-and-value-sets.html) how the set of concepts in the value set changes the effective meaning of the concepts, since users pick the nearest concept to what they want. So you could include the value set extension in a coding so that a sophisticated user could try and reverse engineer the user's choice of code. But in practice, I've never seen this work without being able to actually talk to the user in person, since so many other things constrain and influence the user's choice of concept (aside: if any one has ever really done this, I'd like to hear about it).

The other use of this extension relates to extensible bindings.

The simplest kind of binding is a required binding: that is, the profile specifies a list of codes in a value set, and the application populating the element must choose one of the specified codes. We like required bindings, but in practice, they're pretty much reserved for status /workflow elements - real clinical elements (like Condition.code, as above) rarely have required bindings, because if none of the codes are applicable, you can't proceed/communicate/record, and that's not how healthcare works - both patients and providers are unhappy about it. So most bindings are labelled as 'extensible':

> To be conformant, codes in this element SHALL be from the specified value set if any of the codes within the value set can apply to the concept being communicated. If the value set does not cover the concept (based on human review), an alternate system/code may be used instead. ([from the FHIR spec](http://build.fhir.org/terminologies.html#extensible))

Extensible bindings are a slippery beast (we don't like them) - because there's no way to enforce them computationally. If you're validating an instance, and you find a system/code combination that is outside the value set to which the element is bound, then a human has to inspect the code, and decide whether the code is actually outside the bound value set.

For an example, lets's say that we have a Condition.code, and the applicable profile binds the code to the value set [http://hl7.org/fhir/ValueSet/condition-code:](http://build.fhir.org/valueset-condition-code.html)

 { “path”: “Condition.code”, “definition” : “Identification of the condition, problem or diagnosis.” “binding”: { “strength”: “extensible”, “valueSetCanonical”: “http://hl7.org/fhir/ValueSet/condition-code” } }


This value set includes all SCT concepts that  are clinical findings. Now we are presented with an instance:

{ “resourceType”: “Condition”, “code”: { “coding”: [ { “system”: “http://snomed.info/sct”, “code”: “39065001”, “display”: “Burn of ear” } ], “text”: “Burnt Ear” } }


This concept is in the value set - great. It's valid. but what about this instance?:

{ “resourceType”: “Condition”, “code”: { “coding”: [ { “system”: “http://snomed.info/sct”, “code”: “312824007”, “display”: “Family history of cancer of colon” } ] } }


This SCT concept is not a clinical finding. So is it valid? Well, given that it's an extensible binding, there's 2 questions that have to be answered:
* Is there a proper code for 'family history of cancer of colon' (- it doesn't look like it to me, so it's valid in that respect)
* Does this code fit into the definition of the element in the profile: "Identification of the condition, problem or diagnosis." - seems to (at least to me, but I'm sure there's plenty of scope to argue about it - but that's exactly the challenge of extensible bindings)

So yes, it's probably valid... but is it really? maybe the application that created the instance made a mistake and the concept is wrong? maybe it's just an outright implementation error.... we'd want to pick that up when validating... how can we improve on this situation? Well, there is a way - if we add the value set source to the instance, our 2 examples now become 3 examples:

A code in the specified value set:

{ “resourceType”: “Condition”, “code”: { “coding”: [ { “system”: “http://snomed.info/sct”, “code”: “39065001”, “display”: “Burn of ear”, “extension” : [{ “url” : “http://hl7.org/fhir/StructureDefinition/valueset-reference”, “valueUri” : “http://hl7.org/fhir/ValueSet/condition-code” }] } ], “text”: “Burnt Ear” } }


A code not in the specified value set (an ERROR!)

{ “resourceType”: “Condition”, “code”: { “coding”: [ { “system”: “http://snomed.info/sct”, “code”: “312824007”, “display”: “Family history of cancer of colon”, “extension” : [{ “url” : “http://hl7.org/fhir/StructureDefinition/valueset-reference”, “valueUri” : “http://hl7.org/fhir/ValueSet/condition-code” }] } ] } }


We know that this is an error, because the source application claims that the SCT concept 312824007 is in http://example.org/ValueSet/example, and we know (and can test) that it's not. It's important to understand how extensible bindings work: **it's the binding that's extensible, not the value set**. Just because a value set is used in an extensible binding, doesn't mean that somehow codes that are not in it magically become part of it.

Instead, the source application must claim that the code comes from some other value set (valid, in an extensible binding)

{ “resourceType”: “Condition”, “code”: { “coding”: [ { “system”: “http://snomed.info/sct”, “code”: “312824007”, “display”: “Family history of cancer of colon”, “extension” : [{ “url” : “http://hl7.org/fhir/StructureDefinition/valueset-reference”, “valueUri” : “http://example.org/ValueSet/example” }] } ] } } ````

btw, If we could go get the definition of http://example.org/ValueSet/example, we could validate the code against that too.

So, if the source application is sending a the value set along with the concept, and not paying careful attention to the rules, validation will pick up the small % of cases where the application is sending an invalid code by mistake, but still sending the claim that the code is in the original value set. (easily fixed: change your claim!). If you’re in a very heavily validated environment - that is, typically, government enterprises, where there’s lots of money flowing to ensure technical correctness - then catching that small % of errors makes it worth sending the value set in the extension. Otherwise, my advice is: don’t use the extension; you’re just wasting your time (or money). Any application actually trying to use the data is in a binary situation: either it understands the code, or it doesn’t. Any claim about the source value set really doesn’t make any difference to what it does with the code.

Note that this advice strictly applies to FHIR. The statement “it’s the binding that’s extensible, not the value set.” is clearly defined in FHIR, and a matter of technical neccessity given how the terminology services and validator are defined and implemented. However the situation is not at all clear in CDA and v2, where the definitions are not clear. Personally, I think it needs to be clarified to be made clear, and clear in the fashion documented here.