﻿{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://hl7.org/fhir/json-schema/EpisodeOfCare",
  "$ref": "#/definitions/EpisodeOfCare",
  "description": "see http://hl7.org/fhir/json.html#schema for information about the FHIR Json Schemas",
  "definitions": {
    "EpisodeOfCare": {
      "allOf": [
        {
          "$ref": "DomainResource.schema.json/definitions/DomainResource"
        },
        {
          "description": "An association between a patient and an organization / healthcare provider(s) during which time encounters may occur. The managing organization assumes a level of responsibility for the patient during this time.",
          "properties": {
            "resourceType": {
              "description": "This is a EpisodeOfCare resource",
              "type": "string",
              "enum": [
                "EpisodeOfCare"
              ]
            },
            "identifier": {
              "description": "Identifier(s) by which this EpisodeOfCare is known.",
              "type": "array",
              "items": {
                "$ref": "Identifier.schema.json/definitions/Identifier"
              }
            },
            "status": {
              "description": "planned | waitlist | active | onhold | finished | cancelled.",
              "type": "string",
              "pattern": "[^\\s]+([\\s]?[^\\s]+)*"
            },
            "status_": {
              "description": "Extensions for status",
              "$ref": "Element.schema.json/definitions/Element"
            },
            "statusHistory": {
              "description": "The history of statuses that the EpisodeOfCare has been through (without requiring processing the history of the resource).",
              "type": "array",
              "items": {
                "$ref": "#/definitions/EpisodeOfCare.StatusHistory"
              }
            },
            "type": {
              "description": "A classification of the type of episode of care; e.g. specialist referral, disease management, type of funded care.",
              "type": "array",
              "items": {
                "$ref": "CodeableConcept.schema.json/definitions/CodeableConcept"
              }
            },
            "condition": {
              "description": "A list of conditions/problems/diagnoses that this episode of care is intended to be providing care for.",
              "type": "array",
              "items": {
                "$ref": "Reference.schema.json/definitions/Reference"
              }
            },
            "patient": {
              "description": "The patient that this EpisodeOfCare applies to.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "managingOrganization": {
              "description": "The organization that has assumed the specific responsibilities for the specified duration.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "period": {
              "description": "The interval during which the managing organization assumes the defined responsibility.",
              "$ref": "Period.schema.json/definitions/Period"
            },
            "referralRequest": {
              "description": "Referral Request(s) that are fulfilled by this EpisodeOfCare, incoming referrals.",
              "type": "array",
              "items": {
                "$ref": "Reference.schema.json/definitions/Reference"
              }
            },
            "careManager": {
              "description": "The practitioner that is the care manager/care co-ordinator for this patient.",
              "$ref": "Reference.schema.json/definitions/Reference"
            },
            "team": {
              "description": "The list of practitioners that may be facilitating this episode of care for specific purposes.",
              "type": "array",
              "items": {
                "$ref": "Reference.schema.json/definitions/Reference"
              }
            },
            "account": {
              "description": "The set of accounts that may be used for billing for this EpisodeOfCare.",
              "type": "array",
              "items": {
                "$ref": "Reference.schema.json/definitions/Reference"
              }
            }
          },
          "required": [
            "patient",
            "resourceType"
          ]
        }
      ]
    },
    "EpisodeOfCare.StatusHistory": {
      "allOf": [
        {
          "$ref": "BackboneElement.schema.json/definitions/BackboneElement"
        },
        {
          "description": "An association between a patient and an organization / healthcare provider(s) during which time encounters may occur. The managing organization assumes a level of responsibility for the patient during this time.",
          "properties": {
            "status": {
              "description": "planned | waitlist | active | onhold | finished | cancelled.",
              "type": "string",
              "pattern": "[^\\s]+([\\s]?[^\\s]+)*"
            },
            "status_": {
              "description": "Extensions for status",
              "$ref": "Element.schema.json/definitions/Element"
            },
            "period": {
              "description": "The period during this EpisodeOfCare that the specific status applied.",
              "$ref": "Period.schema.json/definitions/Period"
            }
          },
          "required": [
            "period"
          ]
        }
      ]
    }
  }
}