Missing "required" definitions for primitive fields in fhir.schema.json

XMLWordPrintableJSON

    • Type: Change Request
    • Resolution: Unresolved
    • Priority: Medium
    • FHIR Core (FHIR)
    • STU3
    • FHIR Infrastructure
    • Downloads
    • Enhancement

      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. I tested the proposed resolution as follows.

      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 for careplan.

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

            Assignee:
            Unassigned
            Reporter:
            paqrat76
            Watchers:
            1 Start watching this issue

              Created:
              Updated: