# ID Info

The ID Info module extracts text from a captured identity document using [Optical Character Recognition (OCR)](https://developer.incode.com/docs/glossary#ocr)​. It then shows that text to the user to confirm it's correct before the session continues. When enabled, users can correct missing or misread fields.

For an overview of this module and how it works, see [Review OCR Data](https://developer.incode.com/docs/review-ocr-data-dashboard).

How you use this module depends on your [integration pattern](https://developer.incode.com/docs/android-common-implementation-patterns#integration-patterns). In Patterns 1 and 2, you add the module to a `FlowConfig` in code as shown on this page. In Pattern 3, you define your modules and configuration in Dashboard as a Flow or Workflow and reference it by ID with `startFlow()` or `startWorkflow()` as shown on [Run Flows Configured in Dashboard](https://developer.incode.com/docs/android-run-flows-configured-online).

## Add ID Info

1. Add [ID Scan](https://developer.incode.com/docs/android-id-scan), then [Process ID](https://developer.incode.com/docs/android-process-id), before ID Info. ID Info reviews data that has already been captured and processed, so it only works when these two modules run before it, in that order.
2. Add the module with `addIdInfo()` (default config) or `addIdInfo(idInfo)` (custom config):

   ```kotlin
   flowConfigBuilder.addIdInfo()
   // or with a configured instance:
   flowConfigBuilder.addIdInfo(idInfo)
   ```
   ```java
   flowConfigBuilder.addIdInfo();
   // or with a configured instance:
   flowConfigBuilder.addIdInfo(idInfo);
   ```

ID Info ships both a v1 (legacy View) and a v2 (Jetpack Compose) capture screen; the active one depends on your Incode configuration. Contact your Incode representative to enable v2.

### Example

The example below builds an `IdInfo` module with editable [OCR](https://developer.incode.com/docs/glossary#ocr) enabled for the first captured ID, adds it to the flow after the ID Scan and Process ID modules, and listens for the result through `onIdInfoCompleted()`.

```kotlin
val idInfo = IdInfo.Builder()
    .setEditableOcr(true)
    .setIdCategory(IdCategory.FIRST)
    .build()

val flowConfig = FlowConfig.Builder()
    // ... add the ID Scan and Process ID steps first
    .addIdInfo(idInfo)
    .build()

val onboardingListener = object : OnboardingListener() {
    override fun onIdInfoCompleted(idInfoResult: IdInfoResult) {
        // ID info confirmed. Process the result.
    }
}

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener)
```
```java
IdInfo idInfo = new IdInfo.Builder()
    .setEditableOcr(true)
    .setIdCategory(IdCategory.FIRST)
    .build();

FlowConfig flowConfig = new FlowConfig.Builder()
    // ... add the ID Scan and Process ID steps first
    .addIdInfo(idInfo)
    .build();

IncodeWelcome.OnboardingListener onboardingListener = new IncodeWelcome.OnboardingListener() {
    @Override
    public void onIdInfoCompleted(@NonNull IdInfoResult idInfoResult) {
        // ID info confirmed. Process the result.
    }
};

IncodeWelcome.getInstance()
    .startOnboarding(activityContext, sessionConfig, flowConfig, onboardingListener);
```

## Configuration Options

Configure the module with `IdInfo.Builder`. The table below lists the available options.

| Setting                     | Description                                                                                           |
| --------------------------- | ----------------------------------------------------------------------------------------------------- |
| `setEditableOcr(Boolean)`   | Lets the user edit the OCR-extracted fields instead of only reviewing them.                           |
| `setIdCategory(IdCategory)` | Selects which captured ID in the flow the data applies to: `IdCategory.FIRST` or `IdCategory.SECOND`. |

For the complete option set, see `IdInfo.Builder` in [API Reference](https://developer.incode.com/docs/android-api-reference).

## Result

ID Info delivers an `IdInfoResult` to the `onIdInfoCompleted(IdInfoResult)` callback on the `OnboardingListener`. Key fields include:

- `fullName`: The full name read from the ID; `null` when unavailable.
- `dateOfBirth`: The date of birth read from the ID; `null` when unavailable.
- `sex`: The sex read from the ID; `null` when unavailable.
- `address`: The address read from the ID; `null` when unavailable.
- `documentNumber`: The document number read from the ID; `null` when unavailable.
- `documentExpiryDate`: The document expiry date read from the ID; `null` when unavailable.
- Fields inherited from `BaseResult`:
  - `resultCode`: The `ResultCode` for this result.
  - `error`: When `resultCode` is `ERROR`, the `Throwable` that caused it; otherwise, `null`.
  - `deviceStats`: The `DeviceStats` snapshot of the device state when the result was produced.
  - `motionStatus`: Device motion assessment during capture. One of the following:
    - `UNCLEAR`: Motion could not be determined; the default.
    - `PASS`: Device motion was within acceptable limits.
    - `FAIL`: Excessive device motion was detected.

Errors surface through `OnboardingListener.onError(Throwable)`.

For all fields, see `IdInfoResult` in [API Reference](https://developer.incode.com/docs/android-api-reference).
