{
  "$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-bundled-schema.json",
  "title": "MedicationAdministrationBundled",
  "description": "A FHIR Bundle of MedicationAdministration resources",
  "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/MedicationAdministrationBundled",
  "type": "object",
  "properties": {
    "resourceType": {
      "type": "string",
      "description": "Always 'Bundle'"
    },
    "id": {
      "type": "string",
      "description": "Persistent identifier for the bundle"
    },
    "meta": {
      "type": "object",
      "description": "Metadata about the resource",
      "properties": {
        "lastUpdated": {
          "type": "string",
          "format": "date-time",
          "description": "When the bundle was last updated"
        }
      },
      "required": [
        "lastUpdated"
      ]
    },
    "type": {
      "type": "string",
      "description": "document | message | transaction | transaction-response | batch | batch-response | history | searchset | collection"
    },
    "total": {
      "type": "integer",
      "description": "Number of MedicationAdministration in entry field"
    },
    "link": {
      "type": "array",
      "description": "Links related to this bundle",
      "items": {
        "type": "object",
        "properties": {
          "relation": {
            "type": "string",
            "description": "Relation type (e.g., self, next, previous)"
          },
          "url": {
            "type": "string",
            "minLength": 1,
            "description": "Reference details for the link"
          }
        },
        "required": [
          "relation",
          "url"
        ]
      }
    },
    "entry": {
      "type": "array",
      "description": "Entries in the bundle (each is a MedicationAdministration resource)",
      "items": {
        "type": "object",
        "properties": {
          "fullUrl": {
            "type": "string",
            "minLength": 1,
            "description": "URI for resource (Absolute URL server address or URI for UUID/OID)"
          },
          "resource": {
            "$ref": "#/$defs/MedicationAdministration"
          }
        },
        "required": [
          "fullUrl",
          "resource"
        ]
      }
    }
  },
  "required": [
    "resourceType",
    "type",
    "entry"
  ],
  "$defs": {
    "MedicationAdministration": {
      "type": "object",
      "description": "Administration of medication to a patient",
      "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"
      ]
    }
  }
}