{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/halaxy/json-schema/halaxy-document-reference-schema.json",
  "title": "DocumentReference",
  "description": "Create a new Note record",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/halaxy-document-reference-api-openapi.yml#/components/schemas/DocumentReference",
  "type": "object",
  "deprecated": false,
  "properties": {
    "masterIdentifier": {
      "description": "The master identifier for the document",
      "anyOf": [
        {
          "$ref": "#/$defs/FhirIdentifier"
        },
        {
          "type": "null"
        }
      ]
    },
    "status": {
      "description": "The status of the document reference",
      "default": "current",
      "type": "string",
      "enum": [
        "current",
        "superseded"
      ]
    },
    "docStatus": {
      "description": "The status of the clinical note - preliminary for Draft, final for Published",
      "type": "string",
      "enum": [
        "preliminary",
        "final"
      ]
    },
    "type": {
      "description": "Kind of document (LOINC if possible)",
      "$ref": "#/$defs/FhirCodeableConcept"
    },
    "category": {
      "description": "Categorization of the clinical note",
      "type": "array",
      "items": {
        "$ref": "#/$defs/FhirCodeableConcept"
      }
    },
    "subject": {
      "description": "The patient profile to create this clinical note for",
      "$ref": "#/$defs/FhirReference"
    },
    "date": {
      "readOnly": true,
      "description": "The date and time when the clinical note was created",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "author": {
      "minItems": 1,
      "description": "The practitioner and practice location linked as the clinical note's owner",
      "type": "array",
      "items": {
        "$ref": "#/$defs/FhirReference"
      }
    },
    "custodian": {
      "description": "Who/what is the custodian of the document",
      "$ref": "#/$defs/FhirReference"
    },
    "description": {
      "minLength": 1,
      "description": "The title of the clinical note",
      "type": [
        "string",
        "null"
      ]
    },
    "content": {
      "minItems": 1,
      "description": "The content of the clinical note",
      "type": "array",
      "items": {
        "$ref": "#/$defs/FhirDocumentReferenceContent"
      }
    },
    "text": {
      "readOnly": true,
      "description": "Text summary of the clinical note, for human interpretation",
      "anyOf": [
        {
          "$ref": "#/$defs/FhirNarrative"
        },
        {
          "type": "null"
        }
      ]
    },
    "contained": {
      "readOnly": true,
      "description": "Contained, inline Resources",
      "type": "array",
      "items": {
        "$ref": "#/$defs/FhirResourceInterface"
      }
    },
    "id": {
      "readOnly": true,
      "description": "Logical id of this artifact",
      "type": [
        "string",
        "null"
      ]
    },
    "meta": {
      "description": "Metadata about the resource",
      "anyOf": [
        {
          "$ref": "#/$defs/FhirResourceMeta"
        },
        {
          "type": "null"
        }
      ]
    },
    "resourceType": {
      "description": "Resource Type",
      "type": [
        "string",
        "null"
      ]
    },
    "context": {
      "description": "The clinical context of the document: the service period it covers, and the type of facility it came from",
      "anyOf": [
        {
          "$ref": "#/$defs/FhirDocumentReferenceContext"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "docStatus",
    "subject",
    "author",
    "description"
  ],
  "$defs": {
    "FhirAttachment": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "data": {
          "description": "The file encoded to base64 (maximum 20MB)",
          "type": "string"
        },
        "contentType": {
          "description": "The file format of the file attachment",
          "type": "string",
          "enum": [
            "application/json",
            "application/xml",
            "application/msword",
            "application/vnd.ms-excel",
            "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
            "application/pdf",
            "text/html",
            "text/xml",
            "text/plain",
            "image/jpeg",
            "image/png",
            "image/gif",
            "video/mp4",
            "application/zip",
            "application/fhir+json"
          ]
        },
        "language": {
          "description": "Human language of the content (BCP-47)",
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "ar",
            "bn",
            "cs",
            "da",
            "de",
            "el",
            "en",
            "en-AU",
            "es",
            "fi",
            "fr",
            "fy",
            "hi",
            "hr",
            "it",
            "ja",
            "ko",
            "nl",
            "no",
            "pa",
            "pl",
            "pt",
            "ru",
            "sr",
            "sv",
            "te",
            "zh",
            null
          ]
        },
        "url": {
          "description": "Uri where the data can be found",
          "type": [
            "string",
            "null"
          ]
        },
        "size": {
          "description": "Number of bytes of content (if url provided)",
          "type": [
            "integer",
            "null"
          ]
        },
        "hash": {
          "description": "Hash of the data (sha-1, base64ed)",
          "type": [
            "string",
            "null"
          ]
        },
        "title": {
          "description": "The file name",
          "type": [
            "string",
            "null"
          ]
        },
        "creation": {
          "description": "The date and time that the file attachment was first created",
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirCodeableConcept": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "coding": {
          "description": "defined by a terminology system",
          "type": "array",
          "items": {
            "$ref": "#/$defs/FhirCoding"
          }
        },
        "text": {
          "description": "Plain text representation of the concept",
          "type": [
            "string",
            "null"
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirCoding": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "system": {
          "format": "uri",
          "description": "Identity of the terminology system",
          "type": [
            "string",
            "null"
          ]
        },
        "code": {
          "description": "Symbol in syntax defined by the system",
          "type": [
            "string",
            "null"
          ]
        },
        "display": {
          "description": "Representation defined by the system",
          "type": [
            "string",
            "null"
          ]
        },
        "userSelected": {
          "readOnly": true,
          "description": "If this coding was chosen directly by the user",
          "type": [
            "boolean",
            "null"
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirDocumentReferenceContent": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "attachment": {
          "description": "Where to access the document",
          "$ref": "#/$defs/FhirAttachment"
        },
        "format": {
          "description": "Format/content rules for the attachment",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirCoding"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirDocumentReferenceContext": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "period": {
          "description": "Time of service that is being documented",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirPeriodDateTime"
            },
            {
              "type": "null"
            }
          ]
        },
        "facilityType": {
          "description": "Kind of facility where the patient was seen",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirCodeableConcept"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirIdentifier": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "use": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "usual",
            "official",
            "temp",
            "secondary",
            "old",
            null
          ]
        },
        "type": {
          "description": "Description of identifier",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirCodeableConcept"
            },
            {
              "type": "null"
            }
          ]
        },
        "system": {
          "description": "The namespace for the identifier value",
          "type": [
            "string",
            "null"
          ]
        },
        "value": {
          "description": "The unique identifier",
          "type": [
            "string",
            "null"
          ]
        },
        "period": {
          "description": "The time period when identifier is/was valid for use",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirPeriodDateTime"
            },
            {
              "type": "null"
            }
          ]
        },
        "assigner": {
          "description": "Organization that issued id (may be just text)",
          "anyOf": [
            {
              "$ref": "#/$defs/FhirReference"
            },
            {
              "type": "null"
            }
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirNarrative": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "status": {
          "readOnly": true,
          "description": "Describes how the narrative was generated",
          "type": "string",
          "enum": [
            "generated",
            "extensions",
            "additional",
            "empty"
          ]
        },
        "div": {
          "readOnly": true,
          "description": "Limited xhtml content",
          "type": "string"
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirPeriodDateTime": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "start": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "end": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirReference": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "required": [
        "reference"
      ],
      "properties": {
        "reference": {
          "description": "The URL (relative or absolute) to the resource being referenced",
          "type": "string"
        },
        "type": {
          "description": "The type of resource being referenced",
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "Organization",
            "Patient",
            "Practitioner",
            "PractitionerRole",
            "Appointment",
            "Coverage",
            "Invoice",
            "Communication",
            "Group",
            "DocumentReference",
            "InvoiceLine",
            "PaymentTransaction",
            "Referral",
            "ReferralDefinition",
            "Schedule",
            "Slot",
            "HealthcareService",
            "AllergyIntolerance",
            "Condition",
            "Immunization",
            "Subscription",
            "SubscriptionTopic",
            "ChargeItemDefinition",
            "ServiceRequest",
            "Medication",
            "MedicationRequest",
            "Questionnaire",
            "QuestionnaireResponse",
            "ValueSet",
            "ValueSetConcept",
            "Observation",
            "Binary",
            "Bundle",
            "OperationOutcome",
            "Parameters",
            "List",
            null
          ]
        },
        "id": {
          "readOnly": true,
          "description": "ID of the FHIR element (optional)",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "FhirResourceInterface": {
      "type": "object",
      "description": "",
      "deprecated": false
    },
    "FhirResourceMeta": {
      "type": "object",
      "description": "",
      "deprecated": false,
      "properties": {
        "lastUpdated": {
          "readOnly": true,
          "description": "When the resource version last changed",
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "profile": {
          "description": "Profiles this resource claims to conform to",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}