CodeSystem` and `Identifier` - UP-Manila-SILab/ph-core GitHub Wiki

In FHIR, CodeSystem and Identifier serve distinct purposes in managing and referencing healthcare information. Understanding their differences is crucial for correct implementation and data interoperability.

Here's a breakdown of when to define a CodeSystem versus an Identifier:

Define a CodeSystem when:

  • You are creating a new set of concepts and their associated codes. If you have a list of terms, statuses, types, or any other categorizations that are not represented by an existing, standardized code system (like LOINC, SNOMED CT, ICD-10), you need to define your own CodeSystem. This resource will formally declare these codes, their meanings, and potentially their relationships (hierarchy).
    • Example: Defining a local set of codes for patient satisfaction survey responses (e.g., "very-satisfied", "satisfied", "neutral", "dissatisfied", "very-dissatisfied").
  • You need to declare the existence and properties of an externally defined set of codes that isn't already available as a FHIR CodeSystem resource. While major code systems often have official FHIR representations, smaller or proprietary ones might not. You would create a CodeSystem resource to describe its metadata (like its canonical URL, version, publisher) even if you don't enumerate all the codes within the resource itself (using content = not-present or example).
    • Example: Your organization uses a specific internal coding system for research study phases. You would define a CodeSystem to give this system a unique identifier (URL) so it can be referenced in FHIR resources, even if the full list of codes is managed elsewhere.
  • You need to manage and version a set of codes. The CodeSystem resource allows for versioning, status tracking (draft, active, retired), and detailed descriptions of the codes and their properties.
  • The codes will be used in Coding or CodeableConcept data types to provide specific, defined meanings to data elements. These data types expect a system (which is the canonical URL of a CodeSystem) and a code from that system.

In essence, a CodeSystem is about defining the "vocabulary" – the set of valid codes and their meanings.

Define an Identifier (as part of a resource, not as a standalone definitional resource like CodeSystem) when:

  • You need to assign a unique, business-level identifier to a specific instance of a resource (e.g., a patient, an organization, a device, an order). These are identifiers that have meaning outside of the FHIR server itself, often assigned by various systems or authorities.
    • Example: A patient's Medical Record Number (MRN), a doctor's National Provider Identifier (NPI), a product's serial number, an order's accession number.
  • You need to link a FHIR resource to its representation in other systems. Identifiers help correlate data across different healthcare IT systems.
  • The identifier has a defined issuing "system" or "namespace." The Identifier data type includes a system element (a URI) that specifies the context or assigning authority for that identifier (e.g., urn:oid:2.16.840.1.113883.3.15.2 for a specific hospital's MRN system).
  • A resource can have multiple identifiers from different systems. A patient, for instance, might have an MRN, a driver's license number, and a social security number, each represented as a separate Identifier within the Patient resource.

In essence, an Identifier is about uniquely "naming" or "pointing to" a specific thing or record within a particular context or system.

Key Differences Summarized:

Feature CodeSystem Identifier (Data Type)
Purpose Defines a set of codes and their meanings (vocabulary) Assigns a unique business ID to a resource instance
Nature A definitional FHIR resource A data type used within other FHIR resources
Uniqueness Its canonical URL uniquely identifies the system The combination of system and value aims for uniqueness for the identified entity. A resource can have many identifiers.
Manages Concepts, codes, definitions, relationships Values assigned by specific authorities/systems
Used When Creating new terminologies, declaring existing ones Referencing specific entities (patients, orders, etc.) across systems
Example Value http://loinc.org (system), 8310-5 (code for Body Temperature) system: urn:oid:1.2.3.4.5, value: 12345 (for an MRN)

Analogy:

Think of a CodeSystem as a dictionary. It defines words (codes) and what they mean. For example, a medical dictionary defines various diseases and their codes.

An Identifier is like a specific person's name or a book's ISBN. "John Doe" (value) from the "People in Springfield" registry (system) identifies a particular individual. An ISBN (value) from the "International Standard Book Number" system (system) identifies a unique book.

You wouldn't use an ISBN to define what "novel" means; you'd use a dictionary (or a CodeSystem for literary genres). Similarly, you wouldn't use a CodeSystem for "disease types" to assign a unique ID to a specific patient's medical record; you'd use an Identifier with an appropriate MRN system.

When might they seem related?

Sometimes, the system that assigns identifiers (like an OID for an issuing authority) might also be documented or referenced using a NamingSystem resource in FHIR. A NamingSystem can declare unique IDs (like OIDs or URIs) for both CodeSystems and Identifier systems. However, the CodeSystem resource itself is for the definition of the codes, while the Identifier data type is for the instance of an identifier on a resource.

Therefore, carefully consider whether you are defining a set of meaningful concepts/codes (use CodeSystem) or assigning a unique label to a specific data instance (use Identifier).