FHIR Chat · FHIR schema validation · implementers

Stream: implementers

Topic: FHIR schema validation


view this post on Zulip Radha Rajendran (Apr 09 2021 at 08:28):

Hello all,

I am validating resource using validation schema downloaded from here https://www.hl7.org/fhir/downloads.html .
My problem is when json key is available , the schema validating the value of the key . When value is null it throws error
I could not apply default value for null keys .

Example I am receiving patients with active field and its value is null. my schema validation rejecting this message.
But i want to receive the patient and apply default value of patients active field is true

FHIR Schema restricting when key is available the value also should be follow schema mentioned data type .
Is this correct workflow or Shall i change the FHIR schema JSON ?

Can anyone please help to resolve this problem ?

view this post on Zulip Gino Canessa (Apr 09 2021 at 15:30):

I am not sure I understand your question - are you saying that you have a JSON with null-value elements such as:

"active": null,

If so, the FHIR validator will throw them out, since null is not allowed in FHIR JSON (I suggest reading the FHIR JSON page - that constraint is in section 2.6.2.1).

So, if you are getting external data with null fields, you will need to do that processing before trying to validate it as FHIR (e.g., apply defaults, remove the keys, etc.).

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

'null' is only allowed in FHIR when you've got an array of simple-type elements and you need to worry about extensions, ids or other elements and thus have both a foo array and an _foo array. In that case, if you don't have a value for one of the repetitions, you'd have 'null' in that slot for the foo array (and would have an object in that location in the _foo array). The reverse would occur if you have a value and have no extensions or id. That's the only time 'null' is allowed in FHIR JSON.


Last updated: Apr 12 2022 at 19:14 UTC