FHIR Chat · hierarchical CodeSystems and ValueSets · implementers

Stream: implementers

Topic: hierarchical CodeSystems and ValueSets


view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 15:50):

hi everybody,

I have a question regarding hierarchical codesystems.
I'm curretly converting an existing terminology to a FHIR one.
for the moment I have something like :

{
  "resourceType": "CodeSystem",
  "id": "someid",
  "language": "en",
  "url": "http://terminology.hl7.org/CodeSystem/something",
  "identifier": [
    {
      "system": "urn:ietf:rfc:3986",
      "value": "urn:oid:1111"
    }
   ],
  "valueSet": "http://terminology.hl7.org/CodeSystem/someide/vs",
  "name": "somename",
  "title": "sometitle",
  "status": "draft",
  "experimental": false,
  "hierarchyMeaning": "is-a",
  "content": "complete",
  "count": 110212,
  "property": [
    {
      "code": "active",
      "type": "string"
    },
    {
      "code": "abbreviation",
      "type": "string"
    },
    {
      "code": "meddra_code",
      "type": "string"
    }
  ],
  "concept": [
    {
      "code": "soc_10005329",
      "display": "Blood and lymphatic system disorders",
      "property": [
        {
          "code": "meddra_code",
          "valueCode": "10005329"
        },
        {
          "code": "abbreviation",
          "valueCode": "Blood"
        },
        {
          "code": "child",
          "valueCode": "hlgt_10002086"
        }
      ]
    }
 ]
}

the CodeSystem is imported correctly in HAPI.
The issue I'm facing is that I don't know how to create a ValueSet from it to be able to
perform queries on it, like what are the codes with text or what are the elements without
a parent.
Thing I don't know is should I create the ValueSet ? If yes, how can it represent the parent/child
relationship ?
Thanks

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 16:19):

I'm not seeing any hierarchy in what you've shared? https://build.fhir.org/valueset-filter-operator.html lets you define value sets based on hierarchical relationships.

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 16:53):

thank you, still trying to figure how it works. so it should be something like :

{
  "resourceType": "CodeSystem",
  "id": "someid",
  "language": "en",
  "url": "http://terminology.hl7.org/CodeSystem/something",
  "identifier": [
    {
      "system": "urn:ietf:rfc:3986",
      "value": "urn:oid:1111"
    }
   ],
  "valueSet": "http://terminology.hl7.org/CodeSystem/someide/vs",
  "name": "somename",
  "title": "sometitle",
  "status": "draft",
  "experimental": false,
  "hierarchyMeaning": "is-a",
  "content": "complete",
  "count": 110212,
      "filter": [
        {
            "code": "parent",
            "operator": [
                "="
            ],
            "value": "A Part code"
        },
        {
            "code": "child",
            "operator": [
                "="
            ],
            "value": "Child codes"
        },
    ],
  "property": [
    {
      "code": "active",
      "type": "string"
    },
    {
      "code": "abbreviation",
      "type": "string"
    },
    {
      "code": "meddra_code",
      "type": "string"
    }
  ],
  "concept": [
    {
      "code": "soc_10005329",
      "display": "Blood and lymphatic system disorders",
      "property": [
        {
          "code": "meddra_code",
          "valueCode": "10005329"
        },
        {
          "code": "abbreviation",
          "valueCode": "Blood"
        },
        {
          "code": "child",
          "valueCode": "hlgt_10002086"
        }
      ]
    }
 ]
}

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 16:57):

Still not following - you've only got one concept in that code system?

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:00):

i removed the rest because it's too long. let me share a longer example

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:02):

{
  "resourceType": "CodeSystem",
  "id": "someid",
  "language": "en",
  "url": "http://terminology.hl7.org/CodeSystem/something",
  "identifier": [
    {
      "system": "urn:ietf:rfc:3986",
      "value": "urn:oid:1111"
    }
   ],
  "valueSet": "http://terminology.hl7.org/CodeSystem/someide/vs",
  "name": "somename",
  "title": "sometitle",
  "status": "draft",
  "experimental": false,
  "hierarchyMeaning": "is-a",
  "content": "complete",
  "count": 110212,
      "filter": [
        {
            "code": "parent",
            "operator": [
                "="
            ],
            "value": "A Part code"
        },
        {
            "code": "child",
            "operator": [
                "="
            ],
            "value": "Child codes"
        },
    ],
  "property": [
    {
      "code": "active",
      "type": "string"
    },
    {
      "code": "abbreviation",
      "type": "string"
    },
    {
      "code": "meddra_code",
      "type": "string"
    }
  ],
  "concept": [
    {
      "code": "soc_10005329",
      "display": "Blood and lymphatic system disorders",
      "property": [
        {
          "code": "meddra_code",
          "valueCode": "10005329"
        },
        {
          "code": "abbreviation",
          "valueCode": "Blood"
        },
        {
          "code": "child",
          "valueCode": "hlgt_10002086"
        }
      ]
    },
    {
      "code": "hlgt_10002086",
      "display": "Anaemias nonhaemolytic and marrow depression",
      "property": [
        {
          "code": "meddra_code",
          "valueCode": "10002086"
        },
        {
          "code": "parent",
          "valueCode": "soc_10005329"
        }
      ]
    }
 ]
}

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 17:06):

Ok - there's still no hierarchy shown there.

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:07):

isn't it given by code=child and code=parent referencing each other ?

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:09):

or hlgt_10002086 should be inside soc_10005329 ?

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 17:10):

Hierarchy should only be shown using properties if there's a polyhierarchy - i.e. one concept is a specialization of multiple parents. Even then, at least part of the hierarchy is typically shown through nesting. The property also needs to be one that's understood by the terminology server for it to work. The way you define value sets is the same regardless of whether the hierarchy is defined the 'standard' way by nesting or by supplementing additional parents via property.

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:11):

do you have any example I could follow ?

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:13):

In this case, it's a simple one, one parent multiple children. From my understanding, which is wrong :smile:, declaring the parent/child in the properties

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 17:13):

https://terminology.hl7.org/CodeSystem-v3-ActClass.html has both.

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 17:16):

Thank you, will check it. May I bother again in case I have issues ?

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 17:22):

That's what Zulip is for :)

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 18:11):

last test for tonight :smile:
does it make more sense like this ?

{
  "resourceType": "CodeSystem",
  "id": "someid",
  "language": "en",
  "url": "http://terminology.hl7.org/CodeSystem/something",
  "identifier": [
    {
      "system": "urn:ietf:rfc:3986",
      "value": "urn:oid:1111"
    }
   ],
  "valueSet": "http://terminology.hl7.org/CodeSystem/someide/vs",
  "name": "somename",
  "title": "sometitle",
  "status": "draft",
  "experimental": false,
  "hierarchyMeaning": "is-a",
  "content": "complete",
  "count": 110212,
      "filter": [
        {
            "code": "parent",
            "operator": [
                "="
            ],
            "value": "A Part code"
        },
        {
            "code": "child",
            "operator": [
                "="
            ],
            "value": "Child codes"
        },
    ],
  "property": [
    {

        "code": "parent",
        "uri": "http://hl7.org/fhir/concept-properties#parent",
        "description": "A parent code in the Multiaxial Hierarchy"
    },
    {
        "code": "child",
        "uri": "http://hl7.org/fhir/concept-properties#child",
        "description": "A child code in the Multiaxial Hierarchy"
    },
    {
      "code": "active",
      "type": "string"
    },
    {
      "code": "abbreviation",
      "type": "string"
    },
    {
      "code": "meddra_code",
      "type": "string"
    }
  ],
  "concept": [
    {
      "code": "soc_10005329",
      "display": "Blood and lymphatic system disorders",
      "property": [
        {
          "code": "child",
          "valueCode": "hlgt_10002086"
        }
      ]
    },
    {
      "code": "hlgt_10002086",
      "display": "Anaemias nonhaemolytic and marrow depression",
      "property": [
        {
          "code": "parent",
          "valueCode": "soc_10005329"
        }
      ]
    }
 ]
}

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 18:12):

so , properties parent and child are declared. the valueCode referenced in parent and child are valid...

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 18:22):

I'm not seeing hierarchy being used. If you don't have a polyhierarchy, don't use properties to represent parent/child. Also, NEVER use properties to point both directions.

view this post on Zulip Gjergj Sheldija (Apr 16 2021 at 19:00):

so I should remove the parent,child in the properties then ?
the hierarchy is quite simple parent > child > child
so i should declare only parents or only children for a code, not both ?
thank you for your patience

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 20:49):

If you don't have polyhierarchy, you should nest concepts inside one another as per the hierarchy and not declare properties at all. If you have polyhierarchy, then use a property to indicate additional parents.

view this post on Zulip Rob Hausam (Apr 16 2021 at 21:01):

I think that Lloyd is quite right that it's the simplest and most understandable and probably the best choice to use the explicit nesting if you have a simple hierarchy (with only single parents). But I don't think that we've ever said or have a rule that enforces that it's wrong to model a simple hierarchy using concept properties (as long as they are understood by the terminology server, as Lloyd says). If there was a situation where there is only a simple hierarchy with single parents at present, but there was a possibility that it might become a polyhierarchy in the future, then I think that I might consider using properties to model it initially. I'm not sure that mixing nesting and parent properties to build the complete hierarchy is a great idea - that's like to be confusing and potentially error-prone (and could have incomplete and inconsistent behavior on different servers).

view this post on Zulip Lloyd McKenzie (Apr 16 2021 at 21:39):

Mixing nesting and properties is what we do with polyhierarchies right now - rendering is driven by the 'primary' hierarchy and all other relationships show up as properties.

view this post on Zulip Rob Hausam (Apr 16 2021 at 23:10):

I would just say, yes - but not necessarily. There are some pros and cons both ways.

view this post on Zulip Gjergj Sheldija (Apr 19 2021 at 11:43):

hi,
manage to have it working with nesting, it's a bit ugly, since it does go five levels deep, but it's working. so i can see the children of entries and so forth.
there are a couple of things that i'm having issues with, first is that apparently i cannot use parent and child with hapi as it's limited to the loinc code system only. i will post that in the hapi channel.
second, how do i implement a ValueSet that contains all values from the CodeSystem.
I've tried with the one below, but not sure if it's ok :

  "compose": {
    "include": [
      {
        "system": "http://terminology.hl7.org/CodeSystem/mdr"
      }
    ]
  }

view this post on Zulip Lloyd McKenzie (Apr 19 2021 at 14:18):

That 'compose' should work.

view this post on Zulip Rob Hausam (Apr 19 2021 at 14:20):

Yes. That's the correct 'compose'.

view this post on Zulip Gjergj Sheldija (Apr 19 2021 at 16:03):

yep it worked. finally managed to have the whole thing working. thank you !


Last updated: Apr 12 2022 at 19:14 UTC