# Intro to FHIR

## What is FHIR?

FHIR, or Fast Healthcare Interoperability Resources, is a standard for exchanging healthcare information electronically. FHIR defines a set of resources that represent different aspects of healthcare information, such as patients, medications, and clinical observations.

Each resource is defined using a set of standardized data elements, or "fields", that describe the information being represented.

[Flexpa API](https://www.flexpa.com/docs/records) offers access to healthcare data using the FHIR standard in JSON format.

## How to pull patient data

This guide will walk through the steps required to pull all data on a patient that a payer has made available. We recommend starting here to gain a sense of the availability and formatting of patient FHIR data.

### Prerequisites

Ensure you have completed the [quickstart](https://www.flexpa.com/docs/guides/quickstart) and obtained a patient access token. All interactions with the FHIR API require authentication.

### 1. Read Patient resource

To begin, make a GET request to the [Patient](https://www.flexpa.com/docs/fhir/patient) resource. This request will pull basic data on a patient and will typically include a name, phone, email, member ID, address etc.

#### Example request to Patient

```shell
ACCESS_TOKEN=flexpa-link-access-token

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

View a [sample response](https://www.flexpa.com/docs/fhir/patient#sample-response).

### 2. Patient $everything

The example request in [Step 1](https://www.flexpa.com/docs/fhir/introduction#1-get-patient) may have returned the referenced resource that you need. However, you likely will want information beyond just core demographics, such as claims or clinical data.

FHIR defines a useful [Patient $everything](https://www.flexpa.com/docs/records#patient-everything) operation that can enhance our requests by retrieving all of the resources that belong to a patient:

```shell
ACCESS_TOKEN=flexpa-link-access-token

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

### 3. Search other resources

Steps 1 and 2 targeted the [Patient](https://www.flexpa.com/docs/fhir/patient) resource. To pull as much data as possible on a patient, we can search for the resources that [Patient $everything](https://www.flexpa.com/docs/records#patient-everything) does not return:

- [Device](https://www.flexpa.com/docs/fhir/device)
- [Location](https://www.flexpa.com/docs/fhir/location)
- [Medication](https://www.flexpa.com/docs/fhir/medication)
- [Organization](https://www.flexpa.com/docs/fhir/organization)
- [Practitioner](https://www.flexpa.com/docs/fhir/practitioner)
- [PractitionerRole](https://www.flexpa.com/docs/fhir/practitioner-role)

#### Example requests to other resources

```shell
ACCESS_TOKEN=flexpa-link-access-token

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

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

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

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

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

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

## Read vs. Search

In the guide above, we demonstrated examples of both Read and Search operations.

### Read

Reading a resource in FHIR refers to retrieving the details of a single resource instance. For example, you might want to read the details of a patient, medication, or a specific clinical observation. Reading requires knowledge of the resource ID ahead of time. See more about [reading resources](https://www.flexpa.com/docs/records#read).

### Search

Searching in FHIR allows you to find and retrieve multiple resources based on specific search criteria or filters. This operation is handy when you want to locate resources that match certain conditions or attributes, such as finding all patients with a specific condition, retrieving all medications prescribed by a particular practitioner, or searching for observations within a specific date range. Searching does NOT require knowledge of any resource IDs ahead of time. All of Flexpa's supported FHIR resources are searchable. See more about [searching resources](https://www.flexpa.com/docs/records#search).

## Resources List

The following table lists all the FHIR resources supported by Flexpa.

| Name | Description | JSON example |
| --- | --- | --- |
| [Condition](https://www.flexpa.com/docs/fhir/condition) | A clinical condition, problem, diagnosis, or other event, situation, issue, or clinical concept that has risen to a level of concern. | [JSON example](https://www.flexpa.com/docs/fhir/condition#sample-response) |
| [DocumentReference](https://www.flexpa.com/docs/fhir/document-reference) | A reference to a document of any kind for any purpose. Provides metadata about the document so that the document can be discovered and managed. | [JSON example](https://www.flexpa.com/docs/fhir/document-reference#sample-response) |
| [Encounter](https://www.flexpa.com/docs/fhir/encounter) | An interaction between a patient and healthcare provider(s) for the purpose of providing healthcare services or assessing the health status of a patient. | [JSON example](https://www.flexpa.com/docs/fhir/encounter#sample-response) |
| [ExplanationOfBenefit](https://www.flexpa.com/docs/fhir/explanation-of-benefit) | Claim details; adjudication details from the processing of a Claim; and optionally account balance information, for informing the subscriber of the benefits provided. | [JSON example](https://www.flexpa.com/docs/fhir/explanation-of-benefit#sample-response) |
| [Group](https://www.flexpa.com/docs/fhir/group) | A collection of entities such as people. Automatically created by Flexpa during sync jobs to organize all patients retrieved. | [JSON example](https://www.flexpa.com/docs/fhir/group#sample-response) |
| [Patient](https://www.flexpa.com/docs/fhir/patient) | Demographics and other administrative information about an individual receiving care or other health-related services. | [JSON example](https://www.flexpa.com/docs/fhir/patient#sample-response) |
| [Procedure](https://www.flexpa.com/docs/fhir/procedure) | An action that is or was performed on or for a patient, including physical interventions, consultations, counseling, and other clinical services. | [JSON example](https://www.flexpa.com/docs/fhir/procedure#sample-response) |
