{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/nextgen-healthcare/main/json-schema/nextgen-healthcare-medication-administration-schema.json",
  "title": "MedicationAdministration",
  "description": "Administration of medication to a patient",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nextgen-healthcare-medication-administration-api-openapi.yml#/components/schemas/MedicationAdministration",
  "type": "object",
  "properties": {
    "resourceType": {
      "type": "string",
      "minLength": 1,
      "description": "The type of the FHIR resource (should be 'MedicationAdministration')"
    },
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "The id of the resource"
    },
    "meta": {
      "type": "object",
      "description": "Metadata about the resource",
      "properties": {
        "profile": {
          "description": "Profiles this resource claims to conform to",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "profile"
      ]
    },
    "status": {
      "type": "string",
      "minLength": 1,
      "description": "in-progress | not-done | on-hold | completed | entered-in-error | stopped | unknown"
    },
    "medicationCodeableConcept": {
      "type": "object",
      "description": "Coded form of the medication being administered (e.g., RxNorm)",
      "properties": {
        "coding": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "system": {
                "type": "string",
                "minLength": 1,
                "description": "The identification of the code system (e.g., RxNorm)"
              },
              "code": {
                "type": "string",
                "minLength": 1,
                "description": "The code itself from the code system"
              },
              "display": {
                "type": "string",
                "minLength": 1,
                "description": "Representation defined by the system"
              }
            },
            "required": [
              "system",
              "code",
              "display"
            ]
          }
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "description": "Plain text representation of the concept"
        }
      },
      "required": [
        "coding"
      ]
    },
    "subject": {
      "type": "object",
      "properties": {
        "reference": {
          "type": "string",
          "minLength": 1,
          "description": "The patient to whom the medication was administered"
        }
      },
      "required": [
        "reference"
      ]
    },
    "context": {
      "type": "object",
      "description": "Encounter associated with the administration",
      "properties": {
        "reference": {
          "type": "string",
          "description": "Reference to the Encounter resource"
        }
      }
    },
    "effectiveDateTime": {
      "type": "string",
      "format": "date-time",
      "description": "Start and end time of administration (may be dateTime or Period)"
    },
    "performer": {
      "type": "array",
      "description": "Who performed the administration",
      "items": {
        "type": "object",
        "properties": {
          "actor": {
            "type": "object",
            "properties": {
              "reference": {
                "type": "string",
                "minLength": 1,
                "description": "Reference to the performer resource (Practitioner)"
              }
            },
            "required": [
              "reference"
            ]
          }
        },
        "required": [
          "actor"
        ]
      }
    },
    "request": {
      "type": "object",
      "description": "Back-reference to the originating MedicationRequest",
      "properties": {
        "reference": {
          "type": "string",
          "description": "Reference to the MedicationRequest resource"
        }
      }
    },
    "dosage": {
      "type": "object",
      "description": "Details of how medication was taken",
      "properties": {
        "text": {
          "type": "string",
          "description": "Free text dosage instructions e.g. SIG"
        },
        "route": {
          "type": "object",
          "description": "Path of substance into body",
          "properties": {
            "coding": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "system": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Code system for route (e.g., NCI Thesaurus)"
                  },
                  "code": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Code for the route"
                  },
                  "display": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Representation defined by the system"
                  }
                },
                "required": [
                  "system",
                  "code",
                  "display"
                ]
              }
            }
          }
        },
        "dose": {
          "type": "object",
          "description": "Amount of medication per dose",
          "properties": {
            "value": {
              "type": "number",
              "description": "Amount administered"
            },
            "unit": {
              "type": "string",
              "minLength": 1,
              "description": "Unit defined by the system"
            },
            "system": {
              "type": "string",
              "minLength": 1,
              "description": "Code system for the unit (e.g. http://unitsofmeasure.org)"
            },
            "code": {
              "type": "string",
              "minLength": 1,
              "description": "UCUM code for the unit"
            }
          },
          "required": [
            "value",
            "unit",
            "system",
            "code"
          ]
        }
      }
    }
  },
  "required": [
    "resourceType",
    "id",
    "meta",
    "status",
    "medicationCodeableConcept",
    "subject"
  ]
}