{
    "$schema": "https://json-schema.org/draft/2020-12/schema#",
    "$vocabulary": {
        "https://json-schema.org/draft/2020-12/vocab/core": true,
        "https://json-schema.org/draft/2020-12/vocab/applicator": true,
        "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
        "https://json-schema.org/draft/2020-12/vocab/validation": true,
        "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
        "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
        "https://json-schema.org/draft/2020-12/vocab/content": true
    },
    "$id": "https://www.medbiq.org/standards/virtual-patient",
    "title": "Virtual Patient Data",
    "description": "Schema for MedBiq Data Availability Model",
    "type": "object",
    "$defs": {
        "VirtualPatientDataType": {
            "type": "object",
            "properties": {
                "PatientDemographics": {
                    "$ref": "#/$defs/PatientDemographicsType"
                },
                "VPDText": {
                    "type": "array",
                    "$ref": "#/$defs/VPDTextType"
                },
                "Medication": {
                    "type": "array",
                    "$ref": "#/$defs/MedicationType"
                },
                "InterviewItem": {
                    "type": "array",
                    "$ref": "#/$defs/InterviewItemType"
                },
                "PhysicalExam": {
                    "type": "array",
                    "$ref": "#/$defs/PhysicalExamType"
                },
                "DiagnosticTest": {
                    "type": "array",
                    "$ref": "#/$defs/DiagnosticTestType"
                },
                "Diagnosis": {
                    "type": "array",
                    "$ref": "#/$defs/DiagnosisType"
                },
                "Intervention": {
                    "type": "array",
                    "$ref": "#/$defs/InterventionType"
                },
                "Organization": {
                    "$ref": "#/$defs/OrganizationType"
                },
                "XtensibleInfo": {
                    "$ref": "#/$defs/XtensibleInfoType"
                }
            }
        },
        "MediaType": {
            "type": "object",
            "allOf": [
                {
                    "$ref": "http://medbiq.pixelbytellc.com/virtual-patient/vpd-xhtml.schema.json#/$defs/xhtmlDivType"
                }
            ],
            "properties": {
                "refPath": {
                    "type": "string",
                    "pattern": "^\\s*/manifest/resources/resource\\[@identifier\\s?=\\s?'[^']*'\\]\\s*$"
                },
                "width": {
                    "type": "integer",
                    "minimum": 0
                },
                "height": {
                    "type": "integer",
                    "minimum": 0
                },
                "align": {
                    "type": "string",
                    "enum": ["left", "right", "center"]
                }
            },
            "required": ["refPath"]
        },
        "NonNullStringType": {
            "$ref": "http://medbiq.pixelbytellc.com/common.schema.json#/$defs/NonNullStringType"
        },
        "ProximalOrDistalType": {
            "type": "string",
            "enum": ["Proximal", "Distal"]
        },
        "RightOrLeftType": {
            "type": "string",
            "enum": ["Right", "Left"]
        },
        "FrontOrBackType": {
            "type": "string",
            "enum": ["Front", "Back"]
        },
        "InferiorOrSuperiorType": {
            "type": "string",
            "enum": ["Inferior", "Superior"]
        },
        "SexType": {
            "type": "string",
            "enum": ["Male", "Female", "Indeterminate"]
        },
        "AppropriatenessType": {
            "type": "string",
            "enum": ["always", "ok", "never", "none"]
        },
        "LikelihoodType": {
            "type": "string",
            "enum": ["high", "medium", "low", "none"]
        },
        "TextType": {
            "type": "string",
            "enum": ["chief complaint", "history", "problem", "allergy", "narrative"]
        },
        "InterviewItemType": {
            "type": "object",
            "properties": {
                "Question": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Response": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["Question", "Response", "id"]
        },
        "VPDTextType": {
            "type": "object",
            "allOf": [
                {
                    "$ref": "http://medbiq.pixelbytellc.com/xhtml.schema.json#/$defs/div"
                }
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "textType": {
                    "$ref": "#/$defs/TextType",
                    "default": "narrative"
                }
            }
        },
        "PhysicalExamType": {
            "type": "object",
            "properties": {
                "ExamName": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "LocationOnBody": {
                    "$ref": "#/$defs/LocationOnBodyType"
                },
                "Action": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Finding": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Description": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["ExamName", "Finding", "Description", "id"]
        },
        "DiagnosticTestType": {
            "type": "object",
            "properties": {
                "TestName": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Unit": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Result": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Normal": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["TestName", "Unit", "Result", "Normal", "id"]
        },
        "DiagnosisType": {
            "type": "object",
            "properties": {
                "DiagnosisName": {
                    "type": "object",
                    "properties": {
                        "source": {
                            "type": "string",
                            "$ref": "#/$defs/NonNullStringType"
                        },
                        "sourceID": {
                            "type": "string",
                            "$ref": "#/$defs/NonNullStringType"
                        },
                        "Likelihood": {
                            "$ref": "#/$defs/LikelihoodType"
                        }
                    }
                },
                "id": {
                    "type": "string"
                },
                "authorDiagnosis": {
                    "type": "boolean",
                    "default": false
                }
            }
        },
        "InterventionType": {
            "type": "object",
            "properties": {
                "InterventionName": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Medication": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Appropriateness": {
                    "$ref": "#/$defs/AppropriatenessType"
                },
                "Results": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["InterventionName", "id"]
        },
        "MedicationType": {
            "type": "object",
            "properties": {
                "MedicationName": {
                    "type": "object",
                    "properties": {
                        "source": {
                            "$ref": "#/$defs/NonNullStringType"
                        },
                        "sourceID": {
                            "$ref": "#/$defs/NonNullStringType"
                        }
                    }
                },
                "Dose": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Route": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Frequency": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["MedicationName", "Dose", "Route", "Frequency", "id"]
        },
        "LocationOnBodyType": {
            "type": "object",
            "properties": {
                "BodyPart": {
                    "type": "object",
                    "properties": {
                        "source": {
                            "type": "string",
                            "$ref": "#/$defs/NonNullStringType"
                        },
                        "sourceID": {
                            "type": "string",
                            "$ref": "#/$defs/NonNullStringType"
                        },
                        "Likelihood": {
                            "$ref": "#/$defs/LikelihoodType"
                        }
                    }
                },
                "ProximalOrDistal": {
                    "$ref": "#/$defs/ProximalOrDistalType"
                },
                "RightOrLeft": {
                    "$ref": "#/$defs/RightOrLeftType"
                },
                "FrontOrBack": {
                    "$ref": "#/$defs/FrontOrBackType"
                },
                "InferiorOrSuperior": {
                    "$ref": "#/$defs/InferiorOrSuperiorType"
                }
            },
            "required": ["BodyPart"]
        },
        "PatientDemographicsType": {
            "type": "object",
            "properties": {
                "CoreDemographics": {
                    "$ref": "#/$defs/CoreDemographicsType"
                },
                "DemographicCharacteristic": {
                    "type": "array",
                    "$ref": "#/$defs/DemographicCharacteristicType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["id"]
        },
        "DemographicCharacteristicType": {
            "type": "object",
            "properties": {
                "Title": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Description": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["Title", "id"]
        },
        "CoreDemographicsType": {
            "type": "object",
            "properties": {
                "PatientID": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Name": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Age": {
                    "type": "integer",
                    "format": "duration"
                },
                "Sex": {
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Race": {
                    "type": "array",
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Species": {
                    "type": "array",
                    "$ref": "#/$defs/NonNullStringType"
                },
                "Breed": {
                    "type": "array",
                    "$ref": "#/$defs/NonNullStringType"
                },
                "id": {
                    "type": "string"
                }
            },
            "required": ["id"]
        },
        "ItemType": {
            "type": "object",
            "properties": {
                "idRef": {
                    "type": "string"
                },
                "label": {
                    "type": "string"
                },
                "source": {
                    "type": "string"
                },
                "sourceID": {
                    "type": "string"
                }
            },
            "required": ["idRef"]
        },
        "SectionType": {
            "type": "array",
            "oneOf": [
                {
                    "$ref": "#/$defs/ItemType"
                },
                {
                    "$ref": "#/$defs/SectionType"
                }
            ]
        },
        "OrganizationType": {
            "type": "array",
            "oneOf": [
                {
                    "$ref": "#/$defs/ItemType"
                },
                {
                    "$ref": "#/$defs/SectionType"
                }
            ]
        },
        "XtensibleInfoType": {
            "type": "object",
            "properties": {
                "other": {
                    "type": "array",
                    "items": {
                        "type": "object"
                    },
                    "additionalProperties": true
                }
            }
        }
    },
    "properties": {
        "VirtualPatientData": {
            "$ref": "#/$defs/VirtualPatientDataType"
        },
        "media": {
            "$ref": "#/$defs/MediaType"
        }
    }
}
