{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "http://smart.who.int/base/StructureDefinition-KGNode.schema.json",
  "title": "Knowledge graph: node",
  "description": "One typed node of a knowledge-graph document. Its instance fields are an instance of the logical model of its class (see definedBy), e.g. KGPublication for a publication.",
  "type": "object",
  "properties": {
    "resourceType": {
      "type": "string",
      "const": "KGNode",
      "description": "Resource type identifier for KGNode logical model"
    },
    "@context": {
      "description": "JSON-LD context for this logical model with ValueSet vocabularies",
      "anyOf": [
        {
          "type": "string",
          "format": "uri",
          "description": "URI reference to external JSON-LD context"
        },
        {
          "type": "object",
          "description": "Inline JSON-LD context",
          "properties": {
            "@version": {
              "type": "number",
              "const": 1.1
            },
            "fhir": {
              "type": "string",
              "const": "http://hl7.org/fhir/"
            }
          },
          "additionalProperties": {
            "type": "string",
            "format": "uri"
          }
        },
        {
          "type": "array",
          "description": "Array of JSON-LD context objects/URIs",
          "items": {
            "anyOf": [
              {
                "type": "string",
                "format": "uri"
              },
              {
                "type": "object"
              }
            ]
          }
        }
      ]
    },
    "@type": {
      "type": "string",
      "description": "JSON-LD type identifier for KGNode logical model",
      "examples": [
        "LogicalModel-KGNode"
      ]
    },
    "id": {
      "type": "string",
      "description": "IRI, unique within the document."
    },
    "type": {
      "oneOf": [
        {
          "type": "string",
          "description": "Code from ValueSet KGL1ClassesVS (plain string)"
        },
        {
          "type": "object",
          "description": "Code from ValueSet KGL1ClassesVS (JSON-LD structure)",
          "properties": {
            "@type": {
              "type": "string",
              "const": "http://smart.who.int/base/ValueSet-KGL1ClassesVS.jsonld",
              "description": "JSON-LD type reference to ValueSet KGL1ClassesVS"
            },
            "@id": {
              "type": "string",
              "format": "uri",
              "description": "Full IRI of the code from ValueSet KGL1ClassesVS"
            }
          },
          "required": [
            "@type",
            "@id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "The node's class."
    },
    "label": {
      "type": "string",
      "description": "Human-readable name. Required so a retrieved node reads without resolving it."
    },
    "definedBy": {
      "type": "string",
      "format": "uri",
      "description": "Canonical URL of the logical model giving this node's instance shape."
    },
    "properties": {
      "type": "object",
      "description": "Instance fields, as declared by the class's logical model."
    },
    "derivation": {
      "oneOf": [
        {
          "type": "string",
          "description": "Code from ValueSet KGDerivationVS (plain string)"
        },
        {
          "type": "object",
          "description": "Code from ValueSet KGDerivationVS (JSON-LD structure)",
          "properties": {
            "@type": {
              "type": "string",
              "const": "http://smart.who.int/base/ValueSet-KGDerivationVS.jsonld",
              "description": "JSON-LD type reference to ValueSet KGDerivationVS"
            },
            "@id": {
              "type": "string",
              "format": "uri",
              "description": "Full IRI of the code from ValueSet KGDerivationVS"
            }
          },
          "required": [
            "@type",
            "@id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "derived | inferred | decided."
    },
    "note": {
      "type": "string",
      "description": "Why it is what it is. Required unless derived."
    },
    "evidence": {
      "$ref": "http://smart.who.int/base/StructureDefinition-KGEvidenceLocation.schema.json",
      "description": "Where it came from. Required unless derived."
    },
    "flagRef": {
      "type": "string",
      "description": "Id of a flag raised while extracting this node."
    },
    "skill": {
      "type": "string",
      "description": "Skill id that produced this node."
    }
  },
  "required": [
    "resourceType",
    "id",
    "type",
    "label",
    "derivation"
  ],
  "resourceDefinition": "http://smart.who.int/base/StructureDefinition/KGNode",
  "fhir:parent": "http://hl7.org/fhir/StructureDefinition/Base",
  "jsonld:valuesets": [
    "KGDerivationVS",
    "KGL1ClassesVS"
  ],
  "jsonld:contextTemplate": {
    "@version": 1.1,
    "fhir": "http://hl7.org/fhir/",
    "KGDerivationVS": "http://smart.who.int/base/ValueSet-KGDerivationVS.jsonld",
    "KGL1ClassesVS": "http://smart.who.int/base/ValueSet-KGL1ClassesVS.jsonld"
  }
}