FHIR Chat · Getting all the codes in a CodeSystem? · implementers

Stream: implementers

Topic: Getting all the codes in a CodeSystem?


view this post on Zulip Paul Lynch (Jun 10 2021 at 18:03):

Given a CodeSystem, is there a way to query a read-only FHIR server for the codes that are in it?

We have an app for which we would like to show a list of the values in ResearchStudy.category, on the particular FHIR server to which we've connected. The category Codings on the FHIR server are looking at have a custom CodeSystem, in the resource for which I can see a dozen or so values. My thought was:

1) Fetch the first ResearchStudy
2) Get the CodeSystem resource for the system listed in ResearchStudy.category
3) Get the list of codes for that CodeSystem

I am stuck on (3). CodeSystem does not define $expand, so presumably I need a ValueSet that includes all the codes in the CodeSystem. Assuming there is such a ValueSet, I don't know how to find it. There doesn't seem to be a way search for it.

view this post on Zulip Paul Lynch (Jun 10 2021 at 19:08):

Most likely, for the CodeSystems for which this is practical, I can probably just read from CodeSystem.concept.

view this post on Zulip Yunwei Wang (Jun 10 2021 at 19:48):

If the CapabilityStatement provide profile, you can get the profile and check the valueset binding on the profile and call valueset/$expand to get all codes in the valueset.

view this post on Zulip Jim Steel (Jul 06 2021 at 06:13):

For 3), you could try sending a ValueSet/$expand request with a POST body like:

{
  "resourceType": "ValueSet",
  "compose": {
    "include": [{
      "system": "http://my.code.system.url"
    }]
  }
}

Last updated: Apr 12 2022 at 19:14 UTC