# Fill a purchase delivery from a supplier invoice

## Overview

This flow describes how to use [AI Vision](https://docs.ohc.network/apps/ai-vision.md) to add delivered items to a [purchase delivery](https://docs.ohc.network/concepts/supply/purchase-delivery.md) from images or PDF files of the supplier invoice. AI Vision matches the invoice lines to products in Care and adds the matched lines as rows that you check and save.

## Pre-requisites

* Your deployment has installed the AI Vision app and the Filly backend service.
* You turned on AI Vision for your account. See [Turn on AI Vision for your account](https://docs.ohc.network/apps/ai-vision/turn-on-ai-vision.md).
* You created a purchase delivery from a supplier, and the delivery is still a draft. See [Create a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/create-purchase-delivery.md).
* If the delivery comes from another location in your facility, AI Vision does not appear.
* You can add delivered items to the purchase delivery. See [Add delivered items to a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/add-items-purchase-delivery.md).
* You have the supplier invoice as images or PDF files, or you can photograph it.
* You have the permission listed below.

## Permissions

| Permission | Access |
| - | - |
| Can Use Filly | Lets AI Vision read the invoice. You can hold it through a role in any organization of the facility. Default roles: Doctor, Nurse, Staff, Facility Admin and Administrator. Pharmacist and Volunteer do not have it by default. If your role does not have it, ask your deployment to add it to your role. |

## Steps

### 1. Open the delivery form

Open the draft purchase delivery.

Open the form where you add delivered items. See [Add delivered items to a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/add-items-purchase-delivery.md).

![The form that adds items to a draft purchase delivery from a supplier](/assets/images/fill-a-delivery-from-a-supplier-invoice-1-67ee95f947c54ed850b199bc0be8c7f3.webp)

### 2. Find the AI Vision banner

On the delivery form, find the **Autofill using AI Vision** banner.

![The Autofill using AI Vision banner on the delivery form](/assets/images/fill-a-delivery-from-a-supplier-invoice-2-4f5878b2cd57c39dd8e5651db57f68d9.webp)

### 3. Add the invoice files

Select **Upload Files**.

Choose the images or PDF files of the invoice.

On a small screen, you can select **Take Photo** to photograph the invoice instead.

### 4. Start the autofill

Select the button that reads "Autofill from N docs". N is the number of files in the list.

If you do not have Can Use Filly in this facility, AI Vision shows "You do not have permission to use filly."

If the delivery form is saving, AI Vision shows "The receipt is being saved. Extract the invoice again after saving finishes." Wait for the save to finish. Then start the autofill again.

### 5. Match the lines that have no clear product

If an invoice line has no clear product match, AI Vision shows **Select matching product** for that row.

For each of these rows, do one of these:

* To choose the product, select **Select matching product**. Then search in **Search CARE products** and select the product.
* To leave the line out, select the skip icon. Its tooltip is **Skip row**.

To stop the import, select **Cancel import**.

### 6. Review the rows that need attention

AI Vision lists the rows that need your attention under **Receipt rows to review**.

Check each row in this list.

If AI Vision cannot read all the invoice rows, it shows how many rows it read.

If no invoice line matches a product in Care, AI Vision shows "No invoice products matched the CARE catalog. No rows were changed."

### 7. Check the added rows and save

AI Vision adds each matched line as a new row of the delivery form. It keeps the rows that were already there.

AI Vision shows how many invoice rows it added.

Compare each new row with the invoice. Correct the values that are wrong.

Save the delivered items, as in [Add delivered items to a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/add-items-purchase-delivery.md).

## Expected Outcome

* The delivery form has a new row for each matched invoice line.
* The rows that were already in the form stay there.
* The lines that you skipped are not added.
* The new rows become part of the purchase delivery only when you save them.

## Related

Concepts:

* [AI Vision](https://docs.ohc.network/apps/ai-vision.md)
* [Purchase Delivery](https://docs.ohc.network/concepts/supply/purchase-delivery.md)
* [Product](https://docs.ohc.network/concepts/supply/product.md)

Flows:

* [Create a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/create-purchase-delivery.md)
* [Add delivered items to a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/add-items-purchase-delivery.md)
* [Receive and complete a purchase delivery](https://docs.ohc.network/flows/supply/purchase-delivery/receive-purchase-delivery.md)
* [Turn on AI Vision for your account](https://docs.ohc.network/apps/ai-vision/turn-on-ai-vision.md)
