{
    "$id": "https://scandihealth.github.io/lpr3-docs/resources/acl.schema.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "definitions": {
        "uuid": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "uuid-5": {
            "type": "string",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "ruleId": {
            "type": "string"
        },
        "ruleVersion": {
            "type": "string",
            "pattern": "^([a-zA-Z][a-zA-Z0-9]*:)+[0-9]+\\.[0-9]+\\.[0-9](-[0-9a-zA-Z]+)*$"
        },
        "errors": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/error"
            },
            "minItems": 1
        },
        "error": {
            "type": "object",
            "properties": {
                "ruleId": {
                    "$ref": "#/definitions/ruleId"
                },
                "ruleVersion": {
                    "$ref": "#/definitions/ruleVersion"
                },
                "code": {
                    "type": "string"
                },
                "message": {
                    "type": "string"
                }
            },
            "required": [
                "ruleId",
                "ruleVersion",
                "code",
                "message"
            ]
        },
        "warnings": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/warning"
            },
            "minItems": 1
        },
        "warning": {
            "type": "object",
            "properties": {
                "ruleId": {
                    "$ref": "#/definitions/ruleId"
                },
                "ruleVersion": {
                    "$ref": "#/definitions/ruleVersion"
                },
                "code": {
                    "type": "string"
                },
                "message": {
                    "type": "string"
                },
                "errorBy": {
                    "type": "string",
                    "pattern": "^[1-9][0-9]{3,}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-9][0-9]:[0-9][0-9](\\.[0-9]+)?[+-][01][0-9](:[03]0)?$"
                }
            },
            "required": [
                "ruleId",
                "ruleVersion",
                "code",
                "message"
            ]
        },
        "identifiers": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/identifier"
            },
            "minItems": 1
        },
        "identifier": {
            "type": "object",
            "properties": {
                "root": {
                    "$ref": "#/definitions/uuid"
                },
                "extension": {
                    "$ref": "#/definitions/uuid-5"
                }
            },
            "required": [
                "root",
                "extension"
            ]
        },
        "patientIdentifiers": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/patientIdentifier"
            },
            "minItems": 1
        },
        "patientIdentifier": {
            "type": "object",
            "properties": {
                "root": {
                    "type": "string"
                },
                "extension": {
                    "type": "string"
                }
            },
            "required": [
                "root",
                "extension"
            ]
        },
        "patient": {
            "type": "object",
            "properties": {
                "identifiers": {
                    "$ref": "#/definitions/patientIdentifiers"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                }
            },
            "required": [
                "identifiers"
            ]
        },
        "encounters": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/encounter"
            },
            "minItems": 1
        },
        "encounter": {
            "type": "object",
            "properties": {
                "identifier": {
                    "$ref": "#/definitions/identifier"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                },
                "observationOrganizers": {
                    "$ref": "#/definitions/observationOrganizers"
                },
                "procedures": {
                    "$ref": "#/definitions/procedures"
                },
                "conditions": {
                    "$ref": "#/definitions/conditions"
                }
            },
            "required": [
                "identifier"
            ]
        },
        "procedures": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/procedure"
            },
            "minItems": 1
        },
        "procedure": {
            "type": "object",
            "properties": {
                "identifier": {
                    "$ref": "#/definitions/identifier"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                },
                "observationOrganizers": {
                    "$ref": "#/definitions/observationOrganizers"
                }
            },
            "required": [
                "identifier"
            ]
        },
        "conditions": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/condition"
            },
            "minItems": 1
        },
        "condition": {
            "type": "object",
            "properties": {
                "identifier": {
                    "$ref": "#/definitions/identifier"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                },
                "observationOrganizers": {
                    "$ref": "#/definitions/observationOrganizers"
                }
            },
            "required": [
                "identifier"
            ]
        },
        "markers": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/marker"
            },
            "minItems": 1
        },
        "marker": {
            "type": "object",
            "properties": {
                "identifier": {
                    "$ref": "#/definitions/identifier"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                },
                "observationOrganizers": {
                    "$ref": "#/definitions/observationOrganizers"
                }
            },
            "required": [
                "identifier"
            ]
        },
        "observationOrganizers": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/observationOrganizer"
            },
            "minItems": 1
        },
        "observationOrganizer": {
            "type": "object",
            "properties": {
                "identifier": {
                    "$ref": "#/definitions/identifier"
                },
                "errors": {
                    "$ref": "#/definitions/errors"
                },
                "warnings": {
                    "$ref": "#/definitions/warnings"
                }
            },
            "required": [
                "identifier"
            ]
        }
    },
    "properties": {
        "identifier": {
            "$ref": "#/definitions/identifier"
        },
        "errors": {
            "$ref": "#/definitions/errors"
        },
        "warnings": {
            "$ref": "#/definitions/warnings"
        },
        "patient": {
            "$ref": "#/definitions/patient"
        },
        "markers": {
            "$ref": "#/definitions/markers"
        },
        "encounters": {
            "$ref": "#/definitions/encounters"
        },
        "procedures": {
            "$ref": "#/definitions/procedures"
        },
        "observationOrganizers": {
            "$ref": "#/definitions/observationOrganizers"
        }
    },
    "required": [
        "identifier"
    ]
}