Get to know FHIR Coded Elements – code, Coding, CodeableConcept

By: Amos (Kippi) Bordowitz

 

Coded Elements in FHIR

In the FHIR® standard, coded elements are used to represent clinical concepts using standard terminology systems. FHIR defines a number of data types that are used to represent coded elements, weather if in a patient’s health record or in other resources. The code, coding, and CodeableConcept data types are commonly used in FHIR resources to represent various types of clinical data, and understanding the difference between them is imperative for anybody using FHIR.

If you are doing something as simple as casually reading a resource or working hard at defining (or implementing) a profile, here is a simple breakdown of these elements. Let’s break it down.

 

code

The code data type is a
primitive data type in FHIR
(which you can tell by the first letter being lowercase). It represents a
single code from a set of controlled strings
, usually defined elsewhere. This set of controlled strings is typically defined in a ValueSet, which is a list of possible codes that can be used to
populate the element
. According to the FHIR specs, the code data type is represented as a string, which must have at least one character and no leading or trailing whitespace, and where there is no whitespace other than single spaces in the contents. For example, a code might be used to represent a patient’s blood type, such as “A+”, “B-“, or “AB+”.

 

Coding

The coding data type, on the other hand, is a more complex data type that includes both a code and a system that defines the meaning of the code, as well as the code display, as defined in the
code system
. The system is typically a URI that identifies a particular code system or terminology. While codes are represented using these three fields, it has several extra elements that aren’t
used as frequently. These include
version and userSelected, of which you can read here.

The coding data type is used to represent more specific information about a code, such as its origin or meaning. For example, a coding might be used to represent a medication, such as
“Atorvastatin”, which is represented by the code 83367, and the system  “http://www.nlm.nih.gov/research/umls/rxnorm”. Note that only the combination of the code and the system produce the actual concept. 

Here’s an example of a Coding filed in a FHIR JSON resource, from the Encounter Resource, in the class element:

In this example, the Coding element represents an emergency Encounter, as defined in the v3-ActCode CodeSystem. 

CodebaleConcept

The “CodeableConcept” data type is used to represent a concept that may be represented by one or more codes from one or more code systems. A CodeableConcept consists of an array of one or more “coding” elements, each of which represents a code system and a code within that system, and an optional “text” element, which is used to represent the concept in a human-readable format. The best practice according to the FHIR specs, to increase interoperability, a CodeableConcept should have at least one code from a local code system and at least one from an international one.

The “text” field serves two purposes: it provides a human-readable representation of the concept and allows for cases where no code currently exists to represent the concept. “text” is useful when the concept represented by the codes may not be immediately clear.

  In this example, we have three codes, each from a different code system, representing the concept “Diabetes Mellitus”. The first code is taken from SNOMED-CT, the second from LOINC, and the third from a local CodeSystem.

 

Searching with coded elements

A fundamental feature of FHIR is the ability to search for resources using REST GET operations. according to the FHIR specs: “Search operations traverse through an existing set of resources filtering by parameters supplied to the search operation”. One possibility for using search is using “tokens” – “a parameter that provides a close to exact match search on a string of characters”. All three datatypes mentioned above may be used as tokens in search. 

Let’s look at a few examples. Note that in all examples shown below, the term “[base]” refers to the FHIR server endpoint. E.g., http://hapi-fhir.example.co.il/.

To search for any Patient with a gender with the code “male”:

GET [base]/Patient?gender=male

To search for any Composition that contains an “Allergies and adverse reaction” section (LOINC code 48765-2):

GET [base]/Composition?section=48765-2

To search for any condition with a code “ha125” in the code system “http://acme.org/conditions/codes”:

GET [base]/Condition?code=http://acme.org/conditions/codes|ha125

To Search for any Condition with a code that has a text “headache” associated with it (either in the text, or a display):

GET [base]/Condition?code:text=headache


Conclusion

In summary, the code data type is a primitive data type that represents a single code from a set of
controlled strings, the coding data type is a complex data type that includes both a code and a system, and the CodeableConcept data type is a combination of one or more coding elements and an optional text description. These data types are used in FHIR resources to represent a wide variety of clinical concepts and data, and understanding their differences is important for accurately representing and exchanging health information.

 

Now that you have a grasp of coded elements, perhaps you’d like to learn more about FHIR®   profiling. Check it out here.

Follow us on LinkedIn

 

More To Explore

synergy

the Synergistic Interoperability Power of ImplementationGuides and CapabilityStatements

Within the healthcare domain, seamless data exchange between disparate systems is paramount for improved patient care and coordinated healthcare delivery. The Fast Healthcare Interoperability Resources (FHIR) standard plays a critical role in facilitating this exchange. Two key resources, ImplementationGuide and CapabilityStatement, act as the cornerstones for ensuring successful interoperability.