{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "http://smart.who.int/base/StructureDefinition-MedicationOverviewMin.schema.json",
  "title": "Medication Overview (Minimal)",
  "description": "Minimal medication overview payload for use within a QR code payload. Based on the IHE Pharmacy Medication Overview logical model, with short element labels (one or two letters) and simple data",
  "type": "object",
  "properties": {
    "resourceType": {
      "type": "string",
      "const": "MedicationOverviewMin",
      "description": "Resource type identifier for MedicationOverviewMin 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 MedicationOverviewMin logical model",
      "examples": [
        "LogicalModel-MedicationOverviewMin"
      ]
    },
    "n": {
      "type": "string",
      "description": "Patient Name"
    },
    "dob": {
      "type": "string",
      "format": "date",
      "description": "Patient Date of Birth"
    },
    "s": {
      "oneOf": [
        {
          "type": "string",
          "description": "Code from ValueSet administrative-gender (plain string)"
        },
        {
          "type": "object",
          "description": "Code from ValueSet administrative-gender (JSON-LD structure)",
          "properties": {
            "@type": {
              "type": "string",
              "const": "http://smart.who.int/base/ValueSet-administrative-gender.jsonld",
              "description": "JSON-LD type reference to ValueSet administrative-gender"
            },
            "@id": {
              "type": "string",
              "format": "uri",
              "description": "Full IRI of the code from ValueSet administrative-gender"
            }
          },
          "required": [
            "@type",
            "@id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Sex"
    },
    "nt": {
      "oneOf": [
        {
          "type": "string",
          "description": "Code from ValueSet iso3166-1-3 (plain string)"
        },
        {
          "type": "object",
          "description": "Code from ValueSet iso3166-1-3 (JSON-LD structure)",
          "properties": {
            "@type": {
              "type": "string",
              "const": "http://smart.who.int/base/ValueSet-iso3166-1-3.jsonld",
              "description": "JSON-LD type reference to ValueSet iso3166-1-3"
            },
            "@id": {
              "type": "string",
              "format": "uri",
              "description": "Full IRI of the code from ValueSet iso3166-1-3"
            }
          },
          "required": [
            "@type",
            "@id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Nationality"
    },
    "id": {
      "type": "string",
      "description": "National Identifier"
    },
    "dt": {
      "oneOf": [
        {
          "type": "string",
          "description": "Code from ValueSet v2-0203 (plain string)"
        },
        {
          "type": "object",
          "description": "Code from ValueSet v2-0203 (JSON-LD structure)",
          "properties": {
            "@type": {
              "type": "string",
              "const": "http://smart.who.int/base/ValueSet-v2-0203.jsonld",
              "description": "JSON-LD type reference to ValueSet v2-0203"
            },
            "@id": {
              "type": "string",
              "format": "uri",
              "description": "Full IRI of the code from ValueSet v2-0203"
            }
          },
          "required": [
            "@type",
            "@id"
          ],
          "additionalProperties": false
        }
      ],
      "description": "Type of national identifier (e.g., social security number, national health ID, etc.)"
    },
    "m": {
      "type": "array",
      "items": {
        "$ref": "http://smart.who.int/base/StructureDefinition-MedicationTreatmentLineMin.schema.json"
      },
      "description": "List of medication treatment lines associated with the patient, represented in a minimal format suitable for encoding in a compact QR code payload."
    }
  },
  "required": [
    "resourceType",
    "n",
    "dob",
    "s"
  ],
  "resourceDefinition": "http://smart.who.int/ph4h/StructureDefinition/MedicationOverviewMin",
  "fhir:parent": "http://hl7.org/fhir/StructureDefinition/Base",
  "jsonld:valuesets": [
    "administrative-gender",
    "iso3166-1-3",
    "v2-0203"
  ],
  "jsonld:contextTemplate": {
    "@version": 1.1,
    "fhir": "http://hl7.org/fhir/",
    "administrative-gender": "http://smart.who.int/base/ValueSet-administrative-gender.jsonld",
    "iso3166-1-3": "http://smart.who.int/base/ValueSet-iso3166-1-3.jsonld",
    "v2-0203": "http://smart.who.int/base/ValueSet-v2-0203.jsonld"
  }
}