{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "AlayaCare Careplan API Schemas",
  "definitions": {
    "VisitGoalList": {
      "description": "A list of visit goals",
      "type": "array",
      "items": {
        "$ref": "#/definitions/VisitGoalDetails"
      }
    },
    "VisitGoalDetails": {
      "description": "The visit goal details. The visit goal will be uniquely identified using the `visit_id` and the `goal_id`.",
      "type": "object",
      "required": [
        "completed",
        "created_at",
        "created_by",
        "goal",
        "visit_id",
        "updated_at",
        "updated_by"
      ],
      "properties": {
        "completed": {
          "description": "Whether the goal was completed during the course of the visit",
          "type": "boolean",
          "example": true
        },
        "progress_percentage": {
          "description": "Completion percentage of the goal at the end of the visit",
          "type": "integer",
          "example": 40
        },
        "progress_type": {
          "description": "none, percentage, per_visit",
          "type": "string",
          "example": "per_visit"
        },
        "comment": {
          "description": "Comment related to goal progress in the visit",
          "type": "string",
          "example": "He walks better now"
        },
        "created_at": {
          "description": "Entity created date-time.",
          "type": "string",
          "example": "2018-01-01T23:56:13+00:00"
        },
        "created_by": {
          "$ref": "#/definitions/User"
        },
        "goal": {
          "$ref": "#/definitions/CarePlanGoal"
        },
        "visit_id": {
          "description": "Visit ID",
          "type": "integer",
          "example": 100
        },
        "work_session_uuid": {
          "description": "Work session UUID",
          "type": "string",
          "example": "81de946c-45d2-11e9-b210-d663bd873d93"
        },
        "updated_at": {
          "description": "Entity last updated date-time.",
          "type": "string",
          "format": "date-time",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        }
      }
    },
    "VisitGoalUpdate": {
      "description": "Update a visit goal.",
      "type": "object",
      "required": [
        "goal_id",
        "visit_id"
      ],
      "properties": {
        "goal_id": {
          "description": "Care Plan Goal ID",
          "type": "integer",
          "example": 100
        },
        "visit_id": {
          "description": "Visit ID",
          "type": "integer",
          "example": 100
        },
        "comment": {
          "description": "A comment to be provided if the goal was not completed.",
          "type": "string",
          "example": "Unable to complete the goal today"
        },
        "completed": {
          "description": "Whether the goal was completed.",
          "type": "boolean",
          "example": true,
          "default": false
        },
        "progress_percentage": {
          "description": "Goal progress if the tracking method is `percentage`, between 0 and 100.",
          "type": "integer",
          "example": 50
        }
      }
    },
    "ItemSummaryList": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "name": {
            "type": "string",
            "example": "Some name"
          }
        }
      }
    },
    "CareplanItemSummaryList": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "type": {
            "type": "string",
            "example": "diagnosis"
          },
          "name": {
            "type": "string",
            "example": "Some name"
          }
        }
      }
    },
    "DepartmentChangeList": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "revision": {
            "type": "integer",
            "example": 2
          },
          "changes": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "example": "Department of Justice"
              }
            }
          }
        }
      }
    },
    "ServiceChangeList": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "example": 1
          },
          "revision": {
            "type": "integer",
            "example": 2
          },
          "changes": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "example": "bath"
              }
            }
          }
        }
      }
    },
    "CarePlanList": {
      "allOf": [
        {
          "$ref": "#/definitions/PaginatedList"
        }
      ],
      "description": "A list of Care Plans",
      "type": "object",
      "properties": {
        "total_pages": {
          "description": "Totalnumber of pages available",
          "type": "integer",
          "example": 10
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CarePlanSummary"
          }
        }
      }
    },
    "CarePlanSummary": {
      "description": "Describe care plan without inner objects (diagnoses, goals, etc)",
      "type": "object",
      "properties": {
        "id": {
          "description": "Care PlanID",
          "type": "integer",
          "example": 100
        },
        "created_at": {
          "description": "Care plan creation date (ISO date format)",
          "type": "string",
          "example": "2018-01-01T23:56:13+00:00"
        },
        "updated_at": {
          "description": "Last Careplan updated date (ISO date format)",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "status": {
          "$ref": "#/definitions/CareplanStatus"
        },
        "name": {
          "description": "The title of care plan",
          "type": "string",
          "example": "Test care plan"
        },
        "start_date": {
          "description": "The start date of the care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "The end date of the care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "client": {
          "description": "The client details",
          "$ref": "#/definitions/ClientDetails"
        },
        "created_by": {
          "description": "Alayacare user that created the care plan",
          "$ref": "#/definitions/User"
        },
        "updated_by": {
          "description": "Alayacare user that last modified the care plan",
          "$ref": "#/definitions/User"
        },
        "completed_at": {
          "description": "Careplan completion datetime (ISO date format)",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "description": "Alayacare user that completed the care plan",
          "$ref": "#/definitions/User",
          "x-nullable": true
        }
      }
    },
    "CarePlanCreate": {
      "description": "Create a Care Plan",
      "type": "object",
      "required": [
        "name",
        "start_date"
      ],
      "properties": {
        "name": {
          "description": "The title of the care plan",
          "type": "string",
          "example": "Test care plan"
        },
        "start_date": {
          "description": "The start date of the care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "The end date of the care plan",
          "type": "string",
          "example": "2018-01-10"
        }
      }
    },
    "CarePlanUpdate": {
      "description": "Create a Care Plan",
      "type": "object",
      "properties": {
        "name": {
          "description": "The title of care plan",
          "type": "string",
          "example": "Test care plan"
        },
        "start_date": {
          "description": "A start date of care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of care plan",
          "type": "string",
          "example": "2018-01-10"
        }
      }
    },
    "CarePlanDetails": {
      "description": "Care plan including all root items (`diagnoses`, `goals`, `interventions`)",
      "type": "object",
      "properties": {
        "id": {
          "description": "Care Plan ID",
          "type": "integer",
          "example": 100
        },
        "created_at": {
          "description": "Date of care plan creation (ISO Date format)",
          "type": "string",
          "example": "2018-01-01T23:56:13+00:00"
        },
        "updated_at": {
          "description": "Date of the last update thi care plan (ISO Date format)",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "status": {
          "$ref": "#/definitions/CareplanStatus"
        },
        "name": {
          "description": "The title of care plan",
          "type": "string",
          "example": "Test care plan"
        },
        "start_date": {
          "description": "A start date of care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of care plan",
          "type": "string",
          "example": "2018-01-10"
        },
        "client": {
          "description": "The client details",
          "$ref": "#/definitions/ClientDetails"
        },
        "diagnoses": {
          "description": "The list of diagnoses in the care plan",
          "type": "array",
          "items": {
            "$ref": "#/definitions/CarePlanDiagnosis"
          }
        },
        "goals": {
          "description": "The list of goals in the care plan",
          "type": "array",
          "items": {
            "$ref": "#/definitions/CarePlanGoal"
          }
        },
        "interventions": {
          "description": "the list of interventions in the care plan",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Intervention"
          }
        },
        "created_by": {
          "description": "User that create this plan",
          "$ref": "#/definitions/User"
        },
        "updated_by": {
          "description": "User that modified this plan",
          "$ref": "#/definitions/User"
        },
        "completed_at": {
          "description": "Datetime when the diagnosis was completed",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "$ref": "#/definitions/User",
          "x-nullable": true
        }
      }
    },
    "CarePlanTags": {
      "allOf": [
        {
          "$ref": "#/definitions/PaginatedList"
        }
      ],
      "description": "Paginated list of care plan tags",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CarePlanTagList"
          }
        }
      }
    },
    "CarePlanTagList": {
      "description": "List of care plan tags",
      "type": "object",
      "properties": {
        "id": {
          "description": "Tag ID",
          "type": "integer",
          "example": 2
        },
        "name": {
          "description": "Tag name",
          "type": "string",
          "example": "Review care plan"
        }
      }
    },
    "CarePlanDiagnosis": {
      "description": "Care plan diagnosis",
      "type": "object",
      "properties": {
        "id": {
          "description": "Care Plan Diagnosis ID",
          "type": "integer",
          "example": 100
        },
        "plan_id": {
          "description": "Care Plan ID",
          "type": "integer",
          "example": 345
        },
        "plan_name": {
          "description": "Care plan name",
          "type": "string",
          "example": "Episode #4"
        },
        "name": {
          "description": "A title of care plan diagnosis",
          "type": "string",
          "example": "Title example"
        },
        "start_date": {
          "description": "A start date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan diagnosis",
          "type": "string",
          "example": "Description of diagnosis"
        },
        "is_primary": {
          "description": "Define that this diagnosis is primary",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "description": "Used for ordering of diagnoses in list. The smaller, the higher ranked will the diagnosis be returned",
          "type": "integer",
          "example": 0
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        },
        "department": {
          "$ref": "#/definitions/EntitySummary"
        },
        "updated_at": {
          "description": "Datetime for the last update of the diagnosis",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "created_at": {
          "description": "Datetime of the creation of the diagnosis",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00"
        },
        "created_by": {
          "$ref": "#/definitions/User"
        },
        "completed_at": {
          "description": "Datetime when the diagnosis was completed",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "$ref": "#/definitions/User",
          "x-nullable": true
        },
        "completion_note": {
          "description": "Completion note of the diagnosis",
          "type": "string",
          "x-nullable": true
        },
        "service": {
          "description": "The list of services that are linked to a diagnosis",
          "$ref": "#/definitions/ServiceList"
        },
        "tag": {
          "description": "The list of tags that are linked to a diagnosis",
          "$ref": "#/definitions/EntitySummaryList"
        }
      }
    },
    "ClientDiagnosis": {
      "description": "Care plan diagnosis",
      "type": "object",
      "properties": {
        "id": {
          "description": "Care Plan Diagnosis ID",
          "type": "integer",
          "example": 100
        },
        "name": {
          "description": "A title of care plan diagnosis",
          "type": "string",
          "example": "Diabetes"
        },
        "plan_id": {
          "description": "Care Plan ID",
          "type": "integer",
          "example": 345
        },
        "plan_name": {
          "description": "Care plan name",
          "type": "string",
          "example": "Episode #4"
        },
        "start_date": {
          "description": "A start date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan diagnosis",
          "type": "string",
          "example": "Description of diagnosis"
        },
        "is_primary": {
          "description": "Define that this diagnosis is primary",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "description": "Used for ordering of diagnoses in list. The smaller, the higher ranked will the diagnosis be returned",
          "type": "integer",
          "example": 0
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        },
        "department": {
          "$ref": "#/definitions/EntitySummary"
        },
        "updated_at": {
          "description": "Datetime for the last update for this diagnosis",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "created_at": {
          "description": "Datetime for the creation of this diagnosis",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00"
        },
        "created_by": {
          "$ref": "#/definitions/User"
        },
        "completed_at": {
          "description": "Datetime when the diagnosis was completed",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "$ref": "#/definitions/User",
          "x-nullable": true
        },
        "completion_note": {
          "description": "Completion note of the diagnosis",
          "type": "string",
          "x-nullable": true
        },
        "services": {
          "description": "The list of services that are linked to created diagnosis",
          "$ref": "#/definitions/EntitySummaryList"
        },
        "tags": {
          "description": "The list of tags that are linked to created diagnosis",
          "$ref": "#/definitions/EntitySummaryList"
        }
      }
    },
    "CreateCarePlanDiagnosis": {
      "description": "JSON schema for creating care plan diagnosis.",
      "type": "object",
      "required": [
        "name",
        "start_date",
        "is_primary"
      ],
      "properties": {
        "name": {
          "description": "A title of care plan diagnosis",
          "type": "string",
          "example": "Title example"
        },
        "start_date": {
          "description": "A start date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan diagnosis",
          "type": "string",
          "example": "Description of diagnose"
        },
        "is_primary": {
          "description": "Define that this diagnosis is primary",
          "type": "boolean",
          "example": true
        },
        "department_id": {
          "description": "The ID of selected department",
          "type": "integer",
          "example": 1
        },
        "service_ids": {
          "description": "The list of service ID's that is linked to created diagnosis.Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            4,
            6
          ]
        },
        "external_service_ids": {
          "description": "The list of external service external ID's that is linked to a diagnosis. Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "sor_service_id_1",
            "sor_service_id_2",
            "sor_service_id_3"
          ]
        },
        "tag_ids": {
          "description": "The list of tag ID's that is linked to created diagnosis",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        }
      }
    },
    "UpdateCarePlanDiagnosis": {
      "description": "JSON schema for creating care plan diagnosis",
      "type": "object",
      "properties": {
        "name": {
          "description": "Title of the care plan diagnosis",
          "type": "string",
          "example": "Title example"
        },
        "start_date": {
          "description": "Start date of the diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "End date of the diagnosis",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "Description of the care plan diagnosis",
          "type": "string",
          "example": "Description of diagnosis"
        },
        "is_primary": {
          "description": "Define that this diagnosis is primary",
          "type": "boolean",
          "example": true
        },
        "department_id": {
          "description": "The ID of selected department",
          "type": "integer",
          "example": 1,
          "x-nullable": true
        },
        "service_ids": {
          "description": "The list of service ID's that is linked to created diagnosis.Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            4,
            6
          ]
        },
        "external_service_ids": {
          "description": "The list of external service external ID's that is linked to a diagnosis. Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "sor_service_id_1",
            "sor_service_id_2",
            "sor_service_id_3"
          ]
        },
        "tag_ids": {
          "description": "The list of tag ID's that is linked to created diagnosis",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        }
      }
    },
    "CarePlanGoal": {
      "description": "Care plan goal",
      "type": "object",
      "properties": {
        "id": {
          "description": "Care Plan Goal ID",
          "type": "integer",
          "example": 100
        },
        "plan_id": {
          "description": "Care Plan ID",
          "type": "integer",
          "example": 345
        },
        "plan_name": {
          "description": "Care plan name",
          "type": "string",
          "example": "Episode #4"
        },
        "name": {
          "description": "A title of care plan goal",
          "type": "string",
          "example": "Title example"
        },
        "start_date": {
          "description": "A start date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "target_end_date": {
          "description": "A end date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan goal",
          "type": "string",
          "example": "Description of goal"
        },
        "is_primary": {
          "description": "Define that this goal is primary",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "description": "Used for ordering of goals in the list. The smaller, the higher ranked will the diagnosis be returned.",
          "type": "integer",
          "example": 0
        },
        "department": {
          "$ref": "#/definitions/EntitySummary"
        },
        "type": {
          "type": "string",
          "description": "Goal Type",
          "example": "Desires/Motivations"
        },
        "progress_type": {
          "$ref": "#/definitions/GoalMethod"
        },
        "last_updated_progress": {
          "$ref": "#/definitions/GoalProgress"
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        },
        "services": {
          "description": "The list of services that are linked to the goal",
          "$ref": "#/definitions/ServiceList"
        },
        "tags": {
          "description": "The list of tags that are linked to the goal",
          "$ref": "#/definitions/EntitySummaryList"
        },
        "diagnoses": {
          "description": "The list of diagnoses that are linked to the goal",
          "$ref": "#/definitions/EntitySummaryList"
        },
        "updated_at": {
          "description": "Datetime for the last update for this goal",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "created_at": {
          "description": "Datetime for the creation of this goal",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00"
        },
        "created_by": {
          "$ref": "#/definitions/User"
        },
        "completed_at": {
          "description": "Datetime when the goal was completed",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "$ref": "#/definitions/User",
          "x-nullable": true
        },
        "completion_note": {
          "description": "Completion note of the goal",
          "type": "string",
          "x-nullable": true
        }
      }
    },
    "CreateCarePlanGoal": {
      "description": "JSON schema for creating care plan goal",
      "type": "object",
      "required": [
        "name",
        "start_date",
        "type",
        "progress_type",
        "department_id",
        "is_primary"
      ],
      "properties": {
        "name": {
          "description": "Title of the care plan goal",
          "type": "string",
          "example": "Example goal"
        },
        "start_date": {
          "description": "Start date of the goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "End date of the goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "Description of the care plan goal",
          "type": "string",
          "example": "Description of goal"
        },
        "is_primary": {
          "description": "Define that this goal is primary",
          "type": "boolean",
          "example": true
        },
        "type": {
          "type": "string",
          "description": "Goal Type",
          "example": "Desires/Motivations"
        },
        "progress_type": {
          "$ref": "#/definitions/GoalMethod"
        },
        "department_id": {
          "description": "The ID of selected department",
          "type": "integer",
          "example": 1,
          "x-nullable": true
        },
        "service_ids": {
          "description": "The list of service ID's that is linked to created diagnosis.Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            4,
            6
          ]
        },
        "external_service_ids": {
          "description": "The list of service external ID's that is linked to a diagnosis. Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "sor_service_id_1",
            "sor_service_id_2",
            "sor_service_id_3"
          ]
        },
        "tag_ids": {
          "description": "The list of tag ID's that is linked to created diagnosis",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        },
        "diagnosis_ids": {
          "description": "The list of diagnosis ID that is linked to created goal. Only giagnoses available in the careplan can be assigned to the goal.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        }
      }
    },
    "UpdateCarePlanGoal": {
      "description": "JSON schema for creating care plan diagnosis",
      "type": "object",
      "properties": {
        "name": {
          "description": "A title of care plan goal",
          "type": "string",
          "example": "Example goal"
        },
        "start_date": {
          "description": "A start date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "A end date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan goal",
          "type": "string",
          "example": "Description of goal"
        },
        "is_primary": {
          "description": "Define that this goal is primary",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "description": "Used for ordering of goals in list. The smaller, the higher. Can be the number of place in the list of goals in care plan",
          "type": "integer",
          "example": 0
        },
        "type": {
          "$ref": "#/definitions/GoalType"
        },
        "progress_type": {
          "$ref": "#/definitions/GoalMethod"
        },
        "department_id": {
          "description": "The ID of selected department",
          "type": "integer",
          "example": 1,
          "x-nullable": true
        },
        "service_ids": {
          "description": "The list of service ID's that is linked to created diagnosis.Only services assigned to the client can be linked to the diagnosis.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            4,
            6
          ]
        },
        "tag_ids": {
          "description": "The list of tag ID's that is linked to created diagnosis",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        },
        "diagnosis_ids": {
          "description": "The list of diagnosis IDs that is linked to created goal. ",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        }
      }
    },
    "User": {
      "description": "User id, first and last names",
      "type": "object",
      "properties": {
        "id": {
          "description": "The id of user",
          "type": "integer",
          "example": 5
        },
        "external_id": {
          "description": "The id of user",
          "type": "string",
          "example": "sor_external_id_1"
        }
      }
    },
    "Service": {
      "description": "Service for Care Plan items",
      "type": "object",
      "properties": {
        "id": {
          "description": "The ID of service",
          "type": "integer",
          "example": 1
        },
        "name": {
          "description": "The title of service",
          "type": "string",
          "example": "Service 1"
        }
      }
    },
    "Tag": {
      "description": "Tag for Care Plan items",
      "type": "object",
      "properties": {
        "id": {
          "description": "The ID of tag",
          "type": "integer",
          "example": 1
        },
        "name": {
          "description": "The tag of service",
          "type": "string",
          "example": "Tag 1"
        }
      }
    },
    "GoalTypeList": {
      "description": "List of goal types",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/GoalType"
          }
        }
      }
    },
    "GoalType": {
      "description": "List of goal types",
      "type": "object",
      "example": [
        "Nursing",
        "Physiotherapy",
        "Occupational Therapy",
        "Speech Therapy",
        "Personal Care"
      ]
    },
    "InterventionTypeList": {
      "description": "List of intervention types",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/InterventionType"
          }
        }
      }
    },
    "InterventionType": {
      "description": "Type of the care plan intervention",
      "type": "object",
      "example": [
        "Therapy",
        "Support",
        "Nutrition/Dietary"
      ]
    },
    "GoalMethod": {
      "description": "Progress tracking method of goal",
      "type": "string",
      "enum": [
        "none",
        "per_visits",
        "percentage"
      ],
      "example": "percentage"
    },
    "GoalProgress": {
      "description": "Goal progress information",
      "properties": {
        "comment": {
          "type": "string"
        },
        "percentage": {
          "type": "integer"
        },
        "completed": {
          "type": "boolean"
        }
      },
      "example": {
        "comment": "That was hard",
        "completed": false
      }
    },
    "ErrorResponse": {
      "description": "Error response",
      "type": "object",
      "properties": {
        "status_code": {
          "type": "integer",
          "description": "Response code"
        },
        "message": {
          "type": "string",
          "description": "Detailed error message"
        }
      },
      "required": [
        "code",
        "message"
      ]
    },
    "CarePlanDiagnosisList": {
      "description": "List of diagnosis",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ClientDiagnosis"
          }
        }
      }
    },
    "CarePlanGoalList": {
      "description": "The list of goals",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CarePlanGoal"
          }
        }
      }
    },
    "RevisionLinkedItem": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "revision": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        }
      }
    },
    "GoalsRevisionItem": {
      "description": "Diagnoses revision one item",
      "type": "object",
      "required": [
        "revision",
        "updated_by",
        "updated_at",
        "name",
        "start_date",
        "type",
        "is_primary",
        "rank",
        "progress_type",
        "status"
      ],
      "properties": {
        "revision": {
          "description": "Revision number of the goal",
          "type": "integer"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "updated_at": {
          "type": "string",
          "example": "2019-01-05T22:35:00+00.00"
        },
        "name": {
          "description": "A title of care plan goal",
          "type": "string",
          "example": "Title example"
        },
        "start_date": {
          "description": "A start date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "target_end_date": {
          "description": "A end date of goal",
          "type": "string",
          "example": "2018-01-10"
        },
        "description": {
          "description": "A description of care plan goal",
          "type": "string",
          "example": "Description of goal"
        },
        "is_primary": {
          "description": "Define that this goal is primary",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "description": "Used for ordering of goals in list. The smaller, the higher",
          "type": "integer",
          "example": 0
        },
        "department": {
          "$ref": "#/definitions/RevisionLinkedItem"
        },
        "tags": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "services": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "diagnoses": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "type": {
          "$ref": "#/definitions/GoalType"
        },
        "progress_type": {
          "$ref": "#/definitions/GoalMethod"
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        }
      }
    },
    "GoalsRevisionList": {
      "description": "A list of goal revisions",
      "type": "object",
      "required": [
        "count",
        "page",
        "total_pages",
        "items"
      ],
      "properties": {
        "count": {
          "description": "Number of items in response",
          "type": "integer",
          "example": 100
        },
        "page": {
          "description": "The current page",
          "type": "integer",
          "example": 1
        },
        "total_pages": {
          "description": "Total number of pages available",
          "type": "integer",
          "example": 10
        },
        "previous_item": {
          "$ref": "#/definitions/GoalsRevisionItem"
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/GoalsRevisionItem"
          }
        }
      }
    },
    "CreateCarePlanIntervention": {
      "description": "New intervention to create",
      "type": "object",
      "required": [
        "name",
        "type",
        "recurrence_type",
        "start_date",
        "is_required",
        "has_duration",
        "include_485",
        "department_id"
      ],
      "properties": {
        "name": {
          "description": "Name of the intervention",
          "type": "string",
          "example": "Walking Exercizes"
        },
        "recurrence_type": {
          "description": "Type of recurrence assigned to the unavailability",
          "type": "string",
          "enum": [
            "per_visit",
            "per_request",
            "custom"
          ]
        },
        "recurrence": {
          "$ref": "#/definitions/DeconstructedFrequency"
        },
        "start_date": {
          "description": "Start date of the intervention",
          "type": "string",
          "example": "2018-01-10"
        },
        "end_date": {
          "description": "End date of the intervention",
          "type": "string",
          "example": "2018-01-10"
        },
        "type": {
          "type": "string",
          "description": "Intervention type",
          "example": "Nursing"
        },
        "goal_ids": {
          "description": "List of goals linked to the intervention",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            2,
            3
          ]
        },
        "department_id": {
          "description": "The ID of selected department",
          "type": "integer",
          "example": 1,
          "x-nullable": true
        },
        "service_ids": {
          "description": "The list of service ID's that is linked to the intervention. Only services assigned to the client can be linked to the intervention.",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            1,
            4,
            6
          ]
        },
        "external_service_ids": {
          "description": "The list of external service external ID's that is linked to the intervention. Only services assigned to the client can be linked to the intervention.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "example": [
            "sor_service_id_1",
            "sor_service_id_2",
            "sor_service_id_3"
          ]
        },
        "tag_ids": {
          "description": "The list of tag ID's that is linked to created diagnosis",
          "type": "array",
          "items": {
            "type": "integer"
          },
          "example": [
            2,
            4,
            8
          ]
        },
        "external_link": {
          "$ref": "#/definitions/ExternalLink"
        },
        "module": {
          "$ref": "#/definitions/InterventionModule"
        },
        "description": {
          "description": "Description of the care plan intervention",
          "type": "string",
          "example": "Try walk short distances. Increase the distance each time."
        },
        "is_required": {
          "description": "Defines if the intervention is required to be completed, or commented on, to be able to clock out from a visit.",
          "type": "boolean",
          "example": true
        },
        "has_duration": {
          "description": "Captures time spent on the visit intervention.",
          "type": "boolean",
          "example": true
        },
        "include_485": {
          "description": "Include the intervention in 485 report. Is only required if the 485 feature flag is ON.",
          "type": "boolean",
          "example": true
        }
      }
    },
    "Intervention": {
      "description": "Careplan intervention",
      "type": "object",
      "required": [
        "updated_at",
        "updated_by",
        "created_at",
        "created_by",
        "id",
        "name",
        "status",
        "recurrence_type",
        "start_date",
        "intervention_type",
        "is_required",
        "has_duration",
        "include_485",
        "rank",
        "completed_at",
        "completed_by",
        "completion_note"
      ],
      "properties": {
        "careplan_id": {
          "description": "Identifier for the careplan",
          "type": "integer",
          "example": 52
        },
        "client_id": {
          "description": "Identifier for the client",
          "type": "integer",
          "example": 1043
        },
        "id": {
          "description": "Identifier for the intervention",
          "type": "integer",
          "example": 1
        },
        "name": {
          "description": "Name of the intervention",
          "type": "string",
          "example": "Walking Exercizes"
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        },
        "recurrence": {
          "$ref": "#/definitions/DeconstructedFrequency"
        },
        "start_date": {
          "type": "string"
        },
        "end_date": {
          "type": "string"
        },
        "external_client_id": {
          "type": "string",
          "description": "external identifier of the client associated to this intervention",
          "example": "NS001"
        },
        "intervention_type": {
          "type": "string",
          "description": "Intervention type",
          "example": "Nursing"
        },
        "updated_at": {
          "description": "Datetime for the last update for this intervention",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "created_at": {
          "description": "Datetime for the creation of this intervention",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00"
        },
        "created_by": {
          "$ref": "#/definitions/User"
        },
        "department": {
          "$ref": "#/definitions/EntitySummary"
        },
        "goals": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/EntitySummary"
          }
        },
        "services": {
          "$ref": "#/definitions/ServiceList"
        },
        "tags": {
          "$ref": "#/definitions/EntitySummaryList"
        },
        "external_link": {
          "$ref": "#/definitions/ExternalLink"
        },
        "module": {
          "$ref": "#/definitions/InterventionModule"
        },
        "description": {
          "description": "Description of the care plan intervention",
          "type": "string",
          "example": "Try walk short distances. Increase the distance each time."
        },
        "is_required": {
          "description": "Defines if the intervention is required to be completed or commented on to be able to clock out from a visit. If not set will be defaulted to false.",
          "type": "boolean",
          "example": true
        },
        "has_duration": {
          "description": "Captures time spent on the visit intervention. If not set will be defaulted to false.",
          "type": "boolean",
          "example": true
        },
        "include_485": {
          "description": "Include the intervention in 485 report. Is not set will be defaulted to false.",
          "type": "boolean",
          "example": true
        },
        "rank": {
          "type": "integer",
          "example": 0
        },
        "completed_at": {
          "description": "Datetime when the intervention was completed",
          "type": "string",
          "example": "2017-12-20T23:56:13+00:00",
          "x-nullable": true
        },
        "completed_by": {
          "$ref": "#/definitions/User",
          "x-nullable": true
        },
        "completion_note": {
          "description": "Completion note of the intervention",
          "type": "string",
          "x-nullable": true
        }
      }
    },
    "InterventionList": {
      "description": "List of interventions",
      "type": "object",
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Intervention"
          }
        }
      }
    },
    "InterventionCompletionPaginatedList": {
      "description": "List of fixed in time intervention revisions",
      "type": "object",
      "required": [
        "count",
        "page",
        "total_pages",
        "items"
      ],
      "properties": {
        "count": {
          "description": "Number of items in response",
          "type": "integer",
          "example": 100
        },
        "page": {
          "description": "The current page",
          "type": "integer",
          "example": 1
        },
        "total_pages": {
          "description": "Total number of pages available",
          "type": "integer",
          "example": 10
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/InterventionCompletion"
          }
        }
      }
    },
    "InterventionCompletion": {
      "description": "Information about an intervention completion during a visit",
      "type": "object",
      "required": [
        "updated_at",
        "updated_by",
        "completed",
        "comment"
      ],
      "properties": {
        "updated_at": {
          "description": "Date of the entry (ISO date format)",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "completed": {
          "type": "boolean"
        },
        "duration": {
          "type": "integer"
        },
        "comment": {
          "type": "string"
        }
      }
    },
    "InterventionRevisionPaginatedList": {
      "description": "List of fixed in time intervention revisions",
      "type": "object",
      "required": [
        "items",
        "total_pages",
        "page",
        "count"
      ],
      "properties": {
        "count": {
          "description": "Number of items in response",
          "type": "integer",
          "example": 100
        },
        "page": {
          "description": "The current page",
          "type": "integer",
          "example": 1
        },
        "total_pages": {
          "description": "Total number of pages available",
          "type": "integer",
          "example": 10
        },
        "previous_item": {
          "$ref": "#/definitions/InterventionRevisionItem"
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/InterventionRevisionItem"
          }
        }
      }
    },
    "InterventionRevisionItem": {
      "description": "Information about an intervention at a fixed point in its history defined by the revision number",
      "type": "object",
      "required": [
        "updated_at",
        "updated_by",
        "revision",
        "name",
        "status",
        "recurrence_type",
        "start_date",
        "type"
      ],
      "properties": {
        "updated_at": {
          "description": "Date of the last update thi care plan (ISO date format)",
          "type": "string",
          "example": "2018-01-23T23:56:13+00:00"
        },
        "updated_by": {
          "$ref": "#/definitions/User"
        },
        "revision": {
          "description": "Revision of the intervention, fixing its properties at a certain point in time",
          "type": "integer",
          "example": 2
        },
        "name": {
          "description": "Name of the intervention",
          "type": "string",
          "example": "Walking Exercizes"
        },
        "status": {
          "$ref": "#/definitions/CareplanItemStatus"
        },
        "recurrence_type": {
          "description": "Type of recurrence the user chose. The 'recurrence' field will be present if the value is 'custom' and absent otherwise",
          "type": "string",
          "enum": [
            "per_visit",
            "per_request",
            "custom"
          ]
        },
        "recurrence": {
          "$ref": "#/definitions/DeconstructedFrequency"
        },
        "start_date": {
          "type": "string"
        },
        "end_date": {
          "type": "string"
        },
        "type": {
          "description": "Categorization for the intervention",
          "type": "string",
          "example": "Category A"
        },
        "department": {
          "$ref": "#/definitions/RevisionLinkedItem"
        },
        "goals": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "services": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "tags": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/RevisionLinkedItem"
          }
        },
        "external_link": {
          "$ref": "#/definitions/ExternalLink"
        },
        "module": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "id": {
              "type": "integer"
            }
          }
        },
        "description": {
          "type": "string",
          "example": "Try walk short distances. Increase the distance each time."
        },
        "is_required": {
          "type": "boolean"
        },
        "has_duration": {
          "type": "boolean"
        },
        "rank": {
          "type": "integer",
          "example": 0
        }
      }
    },
    "DeconstructedFrequency": {
      "description": "Definition of the intervention frequency. \n- Is only required if `recurrence_type` is set to `custom`\n- `available_from` and `available_to` allow to define the Time of day when the intervention is available. Only present for `daily`, `weekly` and `monthly` frequencies. if not set will be defaulted to `any time of the day`.\n",
      "type": "object",
      "required": [
        "frequency",
        "interval"
      ],
      "properties": {
        "frequency": {
          "description": "The frequency type of the intervention. Additionnal information are required for `daily`, `weekly` and `monthly` frequencies.",
          "type": "string",
          "enum": [
            "daily",
            "weekly",
            "monthly"
          ]
        },
        "count": {
          "description": "The number of time the intervention must be executed. Only required for `daily`, `weekly` and `monthly` frequencies.",
          "type": "integer",
          "example": 3
        },
        "interval": {
          "description": "Only required for `daily`, `weekly` and `monthly` frequencies",
          "type": "integer",
          "example": 2
        },
        "weekdays": {
          "description": "Only present when the 'frequency' field is set to 'weekly'",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "monday",
              "tuesday",
              "wednesday",
              "thursday",
              "friday",
              "saturday",
              "sunday"
            ]
          }
        },
        "monthday": {
          "description": "Only present when the 'frequency' field is set to 'monthly'",
          "type": "integer",
          "example": 25
        },
        "available_from": {
          "type": "string",
          "example": "13:00:00"
        },
        "available_to": {
          "type": "string",
          "example": "15:00:00"
        }
      }
    },
    "ExternalLink": {
      "type": "object",
      "required": [
        "label",
        "url"
      ],
      "properties": {
        "label": {
          "type": "string",
          "example": "How to use a catheter"
        },
        "url": {
          "type": "string",
          "example": "www.youtube.com/catheter"
        }
      }
    },
    "CareplanStatus": {
      "type": "string",
      "enum": [
        "draft",
        "active",
        "completed",
        "archived"
      ]
    },
    "CareplanItemStatus": {
      "type": "string",
      "enum": [
        "active",
        "completed",
        "archived"
      ]
    },
    "EntitySummary": {
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "description": "AlayaCare entity ID",
          "example": 1001
        },
        "name": {
          "type": "string",
          "description": "Alayacare entity name",
          "example": "entity name"
        }
      }
    },
    "ServiceDetails": {
      "description": "Service details",
      "type": "object",
      "x-nullable": true,
      "properties": {
        "id": {
          "type": "integer",
          "description": "AlayaCare service ID",
          "example": 1001
        },
        "external_id": {
          "type": "string",
          "description": "External service ID",
          "example": "sor_service_id_1",
          "x-nullable": true
        }
      }
    },
    "EntitySummaryList": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/EntitySummary"
      }
    },
    "ServiceList": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/ServiceDetails"
      }
    },
    "ClientDetails": {
      "description": "Careplan client details",
      "type": "object",
      "x-nullable": true,
      "properties": {
        "id": {
          "type": "integer",
          "description": "AlayaCare client ID",
          "example": 1001
        },
        "external_id": {
          "type": "string",
          "description": "External client ID",
          "example": "sor_employee_id_1",
          "x-nullable": true
        },
        "branch_id": {
          "type": "integer",
          "description": "AlayaCare branch ID",
          "example": 1000
        }
      }
    },
    "InterventionModule": {
      "description": "Alayacare module attached to care plan intervention. If not set no alayacare module will be linked to the intervention.",
      "type": "object",
      "properties": {
        "name": {
          "description": "Alayacare module name linked to the intervention",
          "type": "string",
          "x-nullable": true,
          "enum": [
            "form",
            "medication",
            "vital"
          ]
        },
        "id": {
          "description": "`id` is the ID on the entity selected in the module and assigned to the client\n- Form ID of the linked form. Is required to be set if `form` module is selected.\n- vital ID of the linked vital. Can only be set if `vital` module is selected. Will be defaulted to `all` if no `vital_id` is sent.\n- Medication ID of the linked medication. Can only be set if `medication` module is selected. Will be defaulted to `all` if no `medication_id` is sent.\n",
          "type": "string",
          "example": 3948
        }
      }
    },
    "FormList": {
      "required": [
        "count",
        "page",
        "total_pages",
        "items"
      ],
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "description": "Number of items in the response",
          "example": null
        },
        "page": {
          "type": "integer",
          "description": "Current page number",
          "example": 1
        },
        "total_pages": {
          "type": "integer",
          "description": "Total number of pages available",
          "example": 1
        },
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Form"
          }
        }
      }
    },
    "Form": {
      "type": "object",
      "required": [
        "id",
        "name"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "description": "Report form ID of the task.",
          "example": 1604
        },
        "name": {
          "type": "string",
          "description": "Name of the report form. Limited to 256 chars.\n",
          "example": "New Client Assessment"
        },
        "branch": {
          "$ref": "#/definitions/Branch"
        }
      }
    },
    "Branch": {
      "description": "AlayaCare Branch",
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "description": "Branch ID",
          "example": 1000
        },
        "name": {
          "type": "string",
          "description": "Branch name",
          "example": "AlayaCare Health"
        }
      }
    },
    "PaginatedList": {
      "description": "Base model of all paginated lists",
      "type": "object",
      "properties": {
        "count": {
          "type": "integer",
          "description": "Number of items in the response",
          "example": 1
        },
        "page": {
          "type": "integer",
          "description": "Current page number",
          "example": 1
        },
        "total_pages": {
          "type": "integer",
          "description": "Total number of pages availbale",
          "example": 1
        }
      },
      "required": [
        "count",
        "page",
        "total_pages",
        "items"
      ]
    }
  }
}