FHIR Chat · Json Validation · implementers

Stream: implementers

Topic: Json Validation


view this post on Zulip Chris Lo (May 10 2018 at 13:26):

Are there any sites or tools you all use to validate your Json

view this post on Zulip Grahame Grieve (May 11 2018 at 19:05):

there's json schema, and then you can use any of the validating servers

view this post on Zulip Grahame Grieve (May 11 2018 at 19:05):

or the FHIR validator

view this post on Zulip Grahame Grieve (May 11 2018 at 19:05):

see http://hl7.org/fhir/validation.html

view this post on Zulip sayan samanta (Oct 19 2021 at 10:28):

Hi,

I am getting error while implementing some profile to Azure FHIR Server. It is showing JSON div error.

Please help me to resolve the issue.
Below are the list of profile I am getting issue in JSON.
PDEX-Clinical:
Coverage
Device
MedicationDispense

PDEX- Plannet-Provider:
PlannetLocation
PlannetNetwork

I would be helpful if you provide us updated json for this profiles.

view this post on Zulip Lloyd McKenzie (Oct 19 2021 at 13:25):

Can you provide examples of your instances and the specific errors you're seeing?

view this post on Zulip Vanya Yaneva-Cormack (Oct 27 2021 at 15:45):

Hi,

I am getting the following error when validating ServiceRequest resources using the FHIR validator (http://hl7.org/fhir/validation.html#jar): "Unrecognised property '@locationReference'"

However, locationReference is a valid field according to the specification (https://www.hl7.org/fhir/servicerequest-definitions.html#ServiceRequest.locationReference).

Could the FHIR Validator be wrong?

The JSON looks like this:

  "resource": {
    "resourceType": "ServiceRequest",
    ...
    "locationReference": [
      {
        "reference": "Location/{id}"
      }
    ],
    ...
  }

Thank you.

view this post on Zulip Vassil Peytchev (Oct 27 2021 at 15:51):

If this is the literal JSON, the line "reference": "Location/{id}" should contain the actual location id (e.g. "reference": "Location/33245")

I am not sure if that is the cause of the error, though.

view this post on Zulip Vanya Yaneva-Cormack (Oct 27 2021 at 15:54):

Thank you for the reply. Yes, the actual json has the correct Location id - I simply redacted it before posting.

view this post on Zulip Lloyd McKenzie (Oct 27 2021 at 16:37):

In ServiceRequest, 'location' is not a polymorphic type. I.e. its name is not "location[x]" in the spec. That means that the proper element name is just "location" not "locationReference". We only append the type name to an element name when we're replacing a "[x]".

view this post on Zulip Vanya Yaneva-Cormack (Oct 27 2021 at 17:07):

Thank you for the reply Lloyd.

I tried changing to:

    "location": [
      {
        "reference": "Location/{id}"
      }
    ]

but I am getting a new error: The property reference must be an Object, not a primitive property (at Bundle.entry[0].resource.location[0].reference). Here Bundle.entry[0].resource points to the ServiceRequest.

Could you help me make sense of it?

view this post on Zulip Lloyd McKenzie (Oct 27 2021 at 17:54):

If you're using R5, then "location" is a CodeableReference, which means you need location.reference.reference before you specify "Location/{id}". If you're trying to do something with R4, make sure you assert the version when you invoke the validator

view this post on Zulip Alan Pinder (Oct 28 2021 at 11:49):

Lloyd McKenzie said:

In ServiceRequest, 'location' is not a polymorphic type. I.e. its name is not "location[x]" in the spec. That means that the proper element name is just "location" not "locationReference". We only append the type name to an element name when we're replacing a "[x]".

Hi Lloyd, thanks for this answer. I don't think I understood this about the FHIR spec before, and I'm not clear exactly where it does and doesn't apply, apart from polymorphic types.

It doesn't seem intuitive to me, eg in the PatientResource we see nodes like managingOrganization which can only ever be an Organization, but I expected my Patient resource to carry the node managingOrganization. Ditto for generalPractitioner - it's not an [x] although it supports multiple different resources to represent it.

Could you clarify further? The system that is sending us the node 'locationReference' will need this to be clearly understood, I think. before they change their code.

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 15:01):

Essentially, the name that you see in the specification is the name that must appear in the instance except when the name ends with [x]. In those cases, you replace the [x] with the name of the type you're instantiating. It's certainly possible that some names will end in the name of a resource - e.g. generalPractitioner. However, there's no guarantee that the type name corresponds to what the element points to or contains. For example, generalPractitioner might be a reference to an Organization.

The issue with your instance was that the ServiceRequest resource defines an element called location. It does not define an element called locationReference. So if you use the latter, it's not going to validate.

view this post on Zulip Vassil Peytchev (Oct 28 2021 at 15:09):

In R4, there are two elements in the ServiceRequest resource, locationCode and locationReference. In R5, they have been conflated into location as a CodeableReference.

view this post on Zulip Lloyd McKenzie (Oct 28 2021 at 15:31):

Ah, sorry. I didn't look at R4.

view this post on Zulip Vassil Peytchev (Oct 28 2021 at 17:37):

So if the resource being validated is from R4, the element name should be locationReference and the validator should be told that the resource contents are following the R4 requirements.

view this post on Zulip Alan Pinder (Oct 28 2021 at 22:40):

Thanks all for these clarifications, got it now and thanks for the advice about asserting the version for the validator!

view this post on Zulip sayan samanta (Nov 02 2021 at 07:21):

Profile_error.png I am getting this issue.

view this post on Zulip sayan samanta (Nov 02 2021 at 07:25):

Can anybody please provide me the updated JSON for PDEX MedicationDispense and ValueSet to apply in FHIR server.

view this post on Zulip David Pyke (Nov 02 2021 at 13:09):

you can get them here: http://hl7.org/fhir/us/davinci-pdex/


Last updated: Apr 12 2022 at 19:14 UTC