# List Episode Patients (v2)

Finds patients with the same search as `GET /v3/patients` (Hero data, at least one of full_name, first_name, last_name, dob, nhs_number or ehr_partner_id), then counts how many of each patient's episodes matching the other filters are open, in progress and closed. Patients come in the v3 order (last name, first name, date of birth), at most 20, and a patient with no matching episodes has zero counts. `count` is the total number of matching patients.

Endpoint: GET /v2/episodes/patients
Version: 1.0.0
Security: apiKeyAuth, practiceGroupId

## Security:

  - `apiKeyAuth` (unknown)
    apiKey in header x-api-key

  - `practiceGroupId` (unknown)
    apiKey in header x-practice-group-id

## Query parameters:

  - `assignee_id[]` (array)

  - `assignee_type[]` (array)

  - `status[]` (array)

  - `priority[]` (array)

  - `full_name` (string)
    Words from the patient's name, in any order; each word must appear in the first name or surname, as in `GET /v3/patients`.

  - `first_name` (string)
    Part of the patient's first name, as in `GET /v3/patients`.

  - `last_name` (string)
    Part of the patient's last name, as in `GET /v3/patients`.

  - `dob` (string)
    The patient's date of birth (YYYY-MM-DD), matched exactly.

  - `nhs_number` (string)
    The patient's NHS number, matched exactly (spaces ignored).

  - `ehr_partner_id` (string)
    The patient's EHR patient ID, matched exactly.

## Response 200:

  - `200` (unknown)
    Ok

## Response 200 fields (application/json):

  - `count` (number, required)

  - `data` (array, required)

  - `data.id` (string, required)

  - `data.full_name` (string, required)

  - `data.first_name` (string, required)

  - `data.last_name` (string, required)

  - `data.dob` (string, required)

  - `data.nhs_number` (string, required)

  - `data.sex` (string, required)
    Enum: "Not known", "Not specified", "Male", "Female", "Other"

  - `data.ehr_partner_id` (string, required)

  - `data.data_source` (string, required)
    Enum: "hero", "emis", "pds", "gha", "systm_one"

  - `data.ehr_partner` (string, required)
    Enum: "emis", "systm_one", "other"

  - `data.registration_status` (string, required)
    Enum: "unregistered", "registered", "invited", "archived"

  - `data.ehr_registered` (boolean, required)

  - `data.restricted` (boolean, required)

  - `data.deceased_at` (string, required)

  - `data.last_sync_at` (string, required)

  - `data.episodes` (object, required)

  - `data.episodes.open` (integer, required)

  - `data.episodes.in_progress` (integer, required)

  - `data.episodes.closed` (integer, required)

  - `data.episodes.total` (integer, required)

## Response 400:

  - `400` (unknown)
    Validation error

## Response 400 fields (application/json):

  - `error` (boolean, required)
    Example: true

  - `statusCode` (number, required)
    Example: 400

  - `message` (array, required)

  - `message.code` (string, required)
    Example: invalid_type

  - `message.expected` (string, required)
    Example: string

  - `message.path` (array, required)
    Example: ["patient_id"]

  - `message.message` (string, required)
    Example: Required

## Response 401:

  - `401` (unknown)
    Unauthorised

## Response 429:

  - `429` (unknown)
    Too Many Requests

## Response 500:

  - `500` (unknown)
    Unknown error

