FHIR Chat · How to get hl7.org/fhir valueset as json? · implementers

Stream: implementers

Topic: How to get hl7.org/fhir valueset as json?


view this post on Zulip Misha Kaletsky (Jun 04 2020 at 16:58):

I'd like to get the json structure definition for a valueset + version pair. As an example:

The patient resource has a gender property, which has a valueset binding of http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1

That url redirects to http://hl7.org/fhir/valueset-administrative-gender.html - and if you swap the .html at the end on _that_ with .json, you get a useful JSON-formatted StructureDefinition. But the string 4.0.1 doesn't appear anywhere in the redirect, so relying on this isn't a good idea.

Is there a URL scheme for converting from the original valueset url (http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1) to a versioned JSON url (something looking like http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1.json - but this just redirects to the html page)

view this post on Zulip Grahame Grieve (Jun 05 2020 at 01:09):

http://hl7.org/fhir/4.0.1/ValueSet/administrative-gender works. It's on my todo list to get the |4.0.1 syntax working

view this post on Zulip Misha Kaletsky (Jun 05 2020 at 14:10):

Thanks - so the algorithm to get the json from an hl7.org valueset binding is

  1. get the url, e.g. http://hl7.org/fhir/ValueSet/administrative-gender|4.0.1
  2. parse it to take the |4.0.1 at the end (or whatever number is there), and replace /fhir with /fhir/4.0.1
  3. hit the parsed url
  4. get redirected to something like http://hl7.org/fhir/R4/ValueSet/administrative-gender
  5. follow the redirect, get redirected again to http://hl7.org/fhir/R4/valueset-administrative-gender.html
  6. replace .html with .json
  7. finally, hit the json url

In doing all this, I feel like I must be barking up the wrong tree somehow. Is there a better way to go from what's in the Patient structure definition for gender to the correct json url? Also, I noticed that step 4 has the same result whether the original url is using 4.0.0 or 4.0.1.


Last updated: Apr 12 2022 at 19:14 UTC