# Flexpa Scan

A health insurance card serves as an essential instrument in administering healthcare services. Quickly getting crucial data like insurer, member, prescription, and group number in structured JSON format can accelerate patient registration, enable access to health records, streamline clinical workflows, verify coverage, and process financial transactions.

Flexpa Scan lets your app collect this data with a mobile phone camera. You can use Flexpa Scan to complement the more detailed information available via Flexpa Link and API.

To use Flexpa Scan you need:

- A frontend app to start the **authentication flow** with a user. Flexpa Scan runs in an `<iframe>` and can be added to your frontend with a `<script>` tag.
- A backend web server to complete the authentication flow (see below).
- A Flexpa Scan publishable key. Today this is available only by request and manual provisioning by a Flexpa admin.

## [#](https://www.flexpa.com/docs/scan#authentication-flow) Authentication flow

The diagram below shows how Flexpa Scan is used to obtain insurance card details from a user.

Your frontend application opens Flexpa Scan with your `publishable_key` using the`create()` and `open()` functions in the [install](https://www.flexpa.com/docs/scan#install) step below.

The patient then uses a webcam or phone camera to scan their insurance card.

They can then verify the scanned details in Flexpa Scan.

In the `onSuccess` callback you will receive the verified insurance card information parsed from the scanned card in FHIR format.

## [#](https://www.flexpa.com/docs/scan#install) Install

You can add Flexpa Scan to your application within a couple of minutes.

Inside an HTML document add the Flexpa Scan script to create a global `FlexpaLink` object in your application:

### Add script tag

```html
<head>
  ...
  <script src="https://js.flexpa.com/v1/"></script>
</head>
```

### [#](https://www.flexpa.com/docs/scan#create) Create

Next, initialize `FlexpaLink` by calling `create()`. [Contact us](https://www.flexpa.com/demo) to receive a Flexpa Scan `publishable_key_test` or `publishable_key_live` key you can use to initialize:

### Initialize FlexpaLink

```js
FlexpaLink.create({
    // Replace with your Flexpa Scan key
  publishableKey: '...',
  mode: 'scan',
  onSuccess: (result: ScanResult) => {
    console.log(result)
  };
});
```

#### Parameters

- **publishableKey**: string Required – The unique Flexpa Link key to identify your app with Scan enabled. This is provided to you by Flexpa support.
- **onSuccess(response: object)** => void Required – This callback is executed when a patient successfully scans and validates their card information.
- **onLoad() => void** – This callback is executed when Flexpa Scan has finished loading after calling `open`.
- **onExit() => void** – This callback is executed whenever a patient exits the Flexpa Scan flow without successfully authorizing access to their health plan.

### [#](https://www.flexpa.com/docs/scan#open) Open

To start the flow where your users scan their health card, use the `open()` function on the `FlexpaLink` object. For example, opening on a button click:

### Open

```html
<button onclick="FlexpaLink.open()">Scan your insurance card</button>
```

### [#](https://www.flexpa.com/docs/scan#receive-scanned-card-information) Receive scanned card information

That's it! You now have the core information from the patient's insurance card. When a user successfully links a health data source, `FlexpaLink` calls the `onSuccess` callback defined in the [Create](https://www.flexpa.com/docs/scan#create) step. This callback includes the information related to the scanned insurance card:

- **patient**: object - A FHIR [Patient](https://www.flexpa.com/docs/fhir/patient) resource containing the key demographic information present on the card, such as name and date of birth.
- **coverage**: object - A FHIR [Coverage](https://www.flexpa.com/docs/fhir/coverage) resource containing the insurance coverage information present on the card, such as member ID, group number, RxBin, RxGroup, RxPCN.
- **document-reference**: object - A FHIR [DocumentReference](https://www.flexpa.com/docs/fhir/document-reference) resource containing the card image.
- **endpoint**: string - An optional UUID string for the [Endpoint](https://www.flexpa.com/docs/network/directory) corresponding to the insurance card. This can be used in combination with the Flexpa Link and API flow, as providing this value skips the search-and-select health plan step in the authorization flow. Patients will still need to authorize with their username and password.

## [#](https://www.flexpa.com/docs/scan#next-steps) Next steps

[Contact us](https://www.flexpa.com/demo) if you are interested and would like to get started. We will provide you with a Flexpa Scan publishable key to initialize Flexpa Scan in your application.
