FHIR Chat · R4 JSONSchema · implementers

Stream: implementers

Topic: R4 JSONSchema


view this post on Zulip Joe Paquette (May 08 2019 at 21:01):

Looking at the R4 fhir.schema.json schema, I noticed that fields having a primitive type that is also required (i.e., 1..1) has no validation to enforce requiredness. As an example, look at careplan.profile.canonical.json. Note that "id": "CarePlan.status" and "id": "CarePlan.intent" both have 1..1 cardinality. Now, look in R4 fhir.schema.json at lines 10527-10530 and note that the "required" property for careplan only contains "subject" and "resourceType". Using example-json/careplan-example.json and the R4 fhir.schema.json schema on the https://www.jsonschemavalidator.net/ online validator confirms no validation errors when "status" and/or "intent" are deleted from the example.

Primitive fields in the fhir.schema.json have the pattern of defining 2 fields: "propName" (normal field) and "_propName" (extention field). Requiredness must take an either/or approach to these 2 fields since only one of each "status" and "intent" is required.

A straight forward change to the fhir.schema.json can fix this issue.
In fhir.schemn.json, replace lines 10527-10530:

      "required": [
        "subject",
        "resourceType"
      ]

with the following:

      "allOf": [
        {
          "required": ["subject", "resourceType"]
        },
        {
          "anyOf": [{ "required": ["status"] }, { "required": ["_status"] }],
          "not": { "required": ["status", "_status"] }
        },
        {
          "anyOf": [{ "required": ["intent"] }, { "required": ["_intent"] }],
          "not": { "required": ["intent", "_intent"] }
        }
      ]

Retesting with example-json/careplan-example.json and the R4 fhir.schema.json schema with the above changes confirms errors for missing any/all of the required fields.

NOTE: This is an issue for all resources having primitive fields that have a 1..1 cardinality!

I'd be happy to create a bug against the generated fhir.schema.json if someone would point me in the right direction.

view this post on Zulip Lloyd McKenzie (May 08 2019 at 22:34):

To log a bug, click on the "propose a change" link at the bottom of any page in the FHIR spec. You'll need to do a one-time registration, after which you can log as many bugs as you like :)

view this post on Zulip Grahame Grieve (May 14 2019 at 01:54):

getting back to the issue....

view this post on Zulip Grahame Grieve (May 14 2019 at 04:16):

returning to this, I do not understand what is going on here

view this post on Zulip Grahame Grieve (May 14 2019 at 04:17):

{
     "anyOf": [{ "required": ["status"] }, { "required": ["_status"] }],
    "not": { "required": ["status", "_status"] }
},

view this post on Zulip Grahame Grieve (May 14 2019 at 04:17):

the anyOf I understand, but not the not - what's that about?

view this post on Zulip nicola (RIO/SS) (May 14 2019 at 14:54):

_primitive just was a bad idea :/ - maybe it's not too late fix it :)

view this post on Zulip Grahame Grieve (May 14 2019 at 19:59):

I agree it was a bad idea and I said so at the time. (and people assured me I just didn't understand JSON at the time). But it is too late to change it now


Last updated: Apr 12 2022 at 19:14 UTC