{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/elation-health/main/json-schema/elation-health-problem-schema.json",
  "title": "Problem",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elation-health-problems-api-openapi.yml#/components/schemas/Problem",
  "allOf": [
    {
      "$ref": "#/$defs/ProblemCreate"
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "created_date": {
          "type": "string",
          "format": "date-time",
          "readOnly": true
        },
        "deleted_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "readOnly": true
        }
      }
    }
  ],
  "$defs": {
    "Diagnosis": {
      "type": "object",
      "properties": {
        "icd9": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "icd10": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "snomed": {
          "type": "string"
        }
      }
    },
    "ProblemCreate": {
      "type": "object",
      "required": [
        "description",
        "status",
        "start_date",
        "patient"
      ],
      "properties": {
        "description": {
          "type": "string",
          "description": "Description of the problem"
        },
        "status": {
          "type": "string",
          "enum": [
            "Active",
            "Controlled",
            "Resolved"
          ]
        },
        "synopsis": {
          "type": "string",
          "description": "Brief synopsis of the problem"
        },
        "start_date": {
          "type": "string",
          "format": "date-time",
          "description": "Date the problem started"
        },
        "resolved_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Date the problem was resolved (required when status is Resolved)"
        },
        "patient": {
          "type": "integer",
          "description": "Patient ID"
        },
        "dx": {
          "$ref": "#/$defs/Diagnosis"
        }
      }
    }
  }
}