Skip to content

returns for identical codes (reflexivity broken) on LOINC, UCUM, BCP-47, ISO-3166 #86

@jmandel

Description

@jmandel

Bug

When the same code is provided as both codeA and codeB, the server should always return equivalent (reflexivity). For four code systems, it incorrectly returns not-subsumed. SNOMED CT works correctly.

Code System codeA=codeB Expected Actual
LOINC 1963-8 equivalent not-subsumed
UCUM kg equivalent not-subsumed
BCP-47 en equivalent not-subsumed
ISO-3166 US equivalent not-subsumed
SNOMED CT 22298006 equivalent equivalent (correct)

Root cause is likely that the subsumption logic doesn't check code equality before attempting hierarchy traversal, and for systems without hierarchy support it falls through to not-subsumed.

Repro

# LOINC — returns not-subsumed (WRONG)
curl -s 'https://tx-dev.fhir.org/r4/CodeSystem/$subsumes?system=http://loinc.org&codeA=1963-8&codeB=1963-8' \
  -H 'Accept: application/fhir+json'

# UCUM — returns not-subsumed (WRONG)
curl -s 'https://tx-dev.fhir.org/r4/CodeSystem/$subsumes?system=http://unitsofmeasure.org&codeA=kg&codeB=kg' \
  -H 'Accept: application/fhir+json'

# SNOMED — returns equivalent (CORRECT, for comparison)
curl -s 'https://tx-dev.fhir.org/r4/CodeSystem/$subsumes?system=http://snomed.info/sct&codeA=22298006&codeB=22298006' \
  -H 'Accept: application/fhir+json'

Spec reference

Subsumption is reflexive by definition — every concept subsumes itself. The outcome equivalent means "A subsumes B and B subsumes A", which must always be true when A=B. The fix is simple: check codeA === codeB before hierarchy lookup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions