# Encounter

Source: https://www.flexpa.com/docs/fhir/encounter
Description: Encounter is the FHIR resource for visits and admissions. How Flexpa returns Encounters from EHRs and claims, with fields and examples.

[**Encounter**](https://www.hl7.org/fhir/encounter.html) is a FHIR resource that records an interaction between a patient and healthcare providers for the purpose of providing healthcare services or assessing the health status of a patient.

Encounters document the administrative and clinical details of a patient visit, including the type of visit, location, participating providers, diagnoses addressed, and the time period of care. They serve as the connective tissue linking clinical activities to the context in which they occurred.

Encounter data is available from health insurers (derived from claims), medical record systems (from provider EHRs), and nationwide exchanges (via TEFCA). The level of detail varies by source — claims-derived encounters are typically summarized, while provider-sourced encounters may include richer clinical context.

Flexpa makes encounter data available as FHIR resources conforming to the [US Core STU 6.1 Encounter Profile](http://hl7.org/fhir/us/core/STU6.1/StructureDefinition-us-core-encounter.html) to support communicating [USCDI v3](https://www.healthit.gov/isa/united-states-core-data-interoperability-uscdi#uscdi-v3) data. Data types used in this reference are defined in the [FHIR R4 Data Types](https://hl7.org/fhir/R4/datatypes.html) specification.

*FHIR API*

```bash
https://api.flexpa.com/fhir/Encounter
```

```bash
https://api.flexpa.com/fhir/Encounter/[id]
```

```bash
https://api.flexpa.com/fhir/Patient/$everything
```

New to FHIR?

Related

## Schema

The FHIR R4 [**Encounter**](https://hl7.org/fhir/R4/encounter.html) resource represents an interaction between a patient and healthcare provider(s). The [US Core Encounter Profile](http://hl7.org/fhir/us/core/STU6.1/StructureDefinition-us-core-encounter.html) constrains this resource to ensure consistent representation across US healthcare systems.

Encounters are structured around the visit context: **who** was seen, **where** and **when** the visit occurred, **what type** of visit it was, and **why** the patient was seen. They often reference other resources like [Condition](https://www.flexpa.com/docs/fhir/condition) for diagnoses and [Practitioner](https://www.flexpa.com/docs/fhir/practitioner) for participating providers.

**Elements**

- `meta` (Meta):
Metadata about the resource. See also [Tags](https://www.flexpa.com/docs/records#tags) defined by Flexpa.

  - `lastUpdated` (instant):
The last time the encounter was updated in the Endpoint's system of record

- `status` (code):
The current status of the encounter

- `class` (Coding):
Classification of patient encounter (e.g. ambulatory, emergency, inpatient)

- `type` (CodeableConcept[]):
Specific type of encounter (e.g. office visit, home health visit). Bound to the [US Core Encounter Type](http://hl7.org/fhir/us/core/STU6.1/ValueSet-us-core-encounter-type.html) value set (extensible).

- `subject` (Reference(Patient)):
Reference to the [Patient](https://www.flexpa.com/docs/fhir/patient) present at the encounter

- `participant` (BackboneElement[]):
Providers involved in the encounter

  - `type` (CodeableConcept[]):
Role of participant in the encounter

  - `period` (Period):
Period of time during the encounter that the participant was present

  - `individual` (Reference(Practitioner|PractitionerRole)):
Reference to the individual provider involved

- `period` (Period):
The start and end time of the encounter

  - `start` (dateTime):
Starting time with inclusive boundary

  - `end` (dateTime):
End time with inclusive boundary, if the encounter has ended

- `reasonCode` (CodeableConcept[]):
Coded reason the encounter takes place

- `reasonReference` (Reference(Condition|Procedure|Observation)[]):
Reference to reason the encounter takes place, such as a [Condition](https://www.flexpa.com/docs/fhir/condition), [Procedure](https://www.flexpa.com/docs/fhir/procedure), or Observation

- `diagnosis` (BackboneElement[]):
The list of diagnoses relevant to this encounter

  - `condition` (Reference(Condition)):
Reference to the [Condition](https://www.flexpa.com/docs/fhir/condition) diagnosed during this encounter

  - `use` (CodeableConcept):
Role that this diagnosis has within the encounter (e.g. admission, billing, discharge)

  - `rank` (positiveInt):
Ranking of the diagnosis (for each role type)

- `hospitalization` (BackboneElement):
Details about the admission to a healthcare service, primarily for inpatient encounters

  - `dischargeDisposition` (CodeableConcept):
Category or kind of location after discharge

- `location` (BackboneElement[]):
List of locations where the patient has been during this encounter

  - `location` (Reference(Location)):
Reference to the [Location](https://www.flexpa.com/docs/fhir/location) where the encounter took place

- `serviceProvider` (Reference(Organization)):
The organization that is primarily responsible for this encounter's services - see also the `EndpointId` [tag](https://www.flexpa.com/docs/records#tags) provided by Flexpa

*Encounter Example*

```json
{
  "resourceType": "Encounter",
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "meta": {
    "lastUpdated": "2024-03-15T10:30:00Z",
    "profile": [
      "http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter"
    ]
  },
  "status": "finished",
  "class": {
    "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
    "code": "AMB",
    "display": "ambulatory"
  },
  "type": [
    {
      "coding": [
        {
          "system": "http://www.ama-assn.org/go/cpt",
          "code": "99213",
          "display": "Office or other outpatient visit, established patient"
        }
      ]
    }
  ],
  "subject": {
    "reference": "Patient/example"
  },
  "participant": [
    {
      "type": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
              "code": "ATND",
              "display": "attender"
            }
          ]
        }
      ],
      "period": {
        "start": "2024-03-15T09:00:00Z",
        "end": "2024-03-15T09:30:00Z"
      },
      "individual": {
        "reference": "Practitioner/example",
        "display": "Dr. Jane Smith, MD"
      }
    }
  ],
  "period": {
    "start": "2024-03-15T09:00:00Z",
    "end": "2024-03-15T09:30:00Z"
  },
  "reasonCode": [
    {
      "coding": [
        {
          "system": "http://hl7.org/fhir/sid/icd-10-cm",
          "code": "Z00.00",
          "display": "Encounter for general adult medical examination without abnormal findings"
        }
      ]
    }
  ],
  "diagnosis": [
    {
      "condition": {
        "reference": "Condition/example"
      },
      "use": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/diagnosis-role",
            "code": "billing"
          }
        ]
      }
    }
  ],
  "location": [
    {
      "location": {
        "reference": "Location/example",
        "display": "Primary Care Clinic"
      }
    }
  ],
  "serviceProvider": {
    "reference": "Organization/example",
    "display": "Example Health System"
  }
}
```

#### Example FHIRPaths

| Data Point | FHIRPath Expression |
| --- | --- |
| Encounter class | `class.code` |
| Encounter type codes | `type.coding` |
| Encounter start date | `period.start` |
| Encounter period (with fallback) | `(period.start \| period.end).first()` |
| Attending provider | `participant.where(type.coding.code = 'ATND').individual` |
| Diagnosis conditions | `diagnosis.condition` |
| Discharge disposition | `hospitalization.dischargeDisposition.coding` |
| Service provider | `serviceProvider` |

## API

### Read

A read is the most basic operation in FHIR. It allows you to retrieve the current version of a single resource by its ID.

For a full list of available Resources, please refer to the [FHIR Resources documentation](https://www.flexpa.com/docs/fhir/introduction).

**Request headers**

- `Authorization` (string):
An `Authorization: Bearer` header value must be sent with a [Patient Access Token](#patient-access-token) or an [Application Access Token](#application-access-token)

**Request path parameters**

- `id` (string):
The id of the resource to be retrieved - used in the last part of the URL path segment

**Error codes**

- `transient` (429 status code):
The API is expected to return a 429 status code until the data is ready to be retrieved.
This error is returned by the API while in the [initial sync period](https://www.flexpa.com/docs/records#sync-job-states). Most syncs complete in under a minute, but patients with large record sets on slower endpoints can take several minutes.

You will need to implement retry logic to handle this error. If you are using the [Node SDK](https://flexpa.com/docs/records/node-sdk) which we demonstrate in our [Quickstart guide](https://www.flexpa.com/docs/guides/quickstart), retry logic is already built in and you don't need to implement it yourself.

- `processing` (422 status code): The API is expected to return a 422 when Flexpa fails to synchronize any resources from the Endpoint for the requested Patient. Please re-authorize or reach out to support.

*Request*

```bash
ACCESS_TOKEN=patient-access-token

curl https://api.flexpa.com/fhir/Encounter/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```js
const ACCESS_TOKEN="patient-access-token"

const response = await fetch("https://api.flexpa.com/fhir/Encounter/a1b2c3d4-e5f6-7890-abcd-ef1234567890", {
  headers: {
    "content-type": "application/json",
    "authorization": `Bearer ${ACCESS_TOKEN}`,
  },
});

const resource = await response.json();
```

---

### Search

Searches on Flexpa API follow the RESTful style of the FHIR specification by submitting a GET HTTP request to the base URL of the resource with parameters to define the exact search criteria to filter the response.

**Request headers**

- `Authorization` (string):
An `Authorization: Bearer` header value must be sent with a [Patient Access Token](#patient-access-token) or an [Application Access Token](#application-access-token)

**Search parameters**

**Note:**
Flexpa supports all Encounter `SearchParameter` values defined in the [FHIR R4 specification](https://www.hl7.org/fhir/R4/encounter.html#search)

- `_id` (token):
The logical ID of the resource

- `patient` (reference):
The patient or group present at the encounter

- `date` (date):
A date within the period the encounter lasted

- `class` (token):
Classification of the encounter (e.g. AMB, IMP, EMER)

- `type` (token):
Specific type of encounter

- `status` (token):
Current status of the encounter

- `identifier` (token):
Identifier(s) by which this encounter is known

- `diagnosis` (reference):
The diagnosis or procedure relevant to the encounter

- `location` (reference):
Location the encounter takes place

- `participant` (reference):
Persons involved in the encounter other than the patient

- `participant-type` (token):
Role of participant in the encounter

- `service-provider` (reference):
The organization (facility) responsible for this encounter

- `reason-code` (token):
Coded reason the encounter takes place

- `reason-reference` (reference):
Reason the encounter takes place (reference)

**Error codes**

- `transient` (429 status code):
The API is expected to return a 429 status code until the data is ready to be retrieved.
This error is returned by the API while in the [initial sync period](https://www.flexpa.com/docs/records#sync-job-states). Most syncs complete in under a minute, but patients with large record sets on slower endpoints can take several minutes.

You will need to implement retry logic to handle this error. If you are using the [Node SDK](https://flexpa.com/docs/records/node-sdk) which we demonstrate in our [Quickstart guide](https://www.flexpa.com/docs/guides/quickstart), retry logic is already built in and you don't need to implement it yourself.

- `processing` (422 status code): The API is expected to return a 422 when Flexpa fails to synchronize any resources from the Endpoint for the requested Patient. Please re-authorize or reach out to support.

*Request*

```bash
ACCESS_TOKEN=patient-access-token

curl https://api.flexpa.com/fhir/Encounter \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```js
const ACCESS_TOKEN="patient-access-token"

const response = await fetch("https://api.flexpa.com/fhir/Encounter", {
  headers: {
    "content-type": "application/json",
    "authorization": `Bearer ${ACCESS_TOKEN}`,
  },
});

const resource = await response.json();
```
