> ## Documentation Index
> Fetch the complete documentation index at: https://agents.nanonets.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# AdvancedMD Upload EHR Document From File

> Files a stored task file, such as a signed DocuSign PDF, on an AdvancedMD patient chart.

`advancedmd_upload_ehr_document_from_file` uploads a file the task already holds to a patient's AdvancedMD EHR chart.
The typical source is `docusign_get_envelope_document`, whose `file_url` is passed by its task variable reference.
Use it instead of the catalog operation `advancedmd_op_ehr_upload_document` when the content is a stored file rather than base64 text.

## Authentication and enablement

Uses the workspace's AdvancedMD connection (office code, username, password are bound from it and hidden from the model).
Off by default: enable it on the agent.

## Inputs

| Field | Required | Notes |
| - | - | - |
| `patient_id` | yes | Numeric AdvancedMD patient id. A `pat` prefix is stripped. |
| `file_url` | yes | The stored file, by its task variable reference. |
| `name` | yes | Document name shown on the chart. |
| `description` | no | Shown with the document. |
| `file_extension` | no | Without the dot, 1–5 letters or digits. Defaults to the stored file's extension or type, else `pdf`. The document name is never used. |
| `dry_run` | no | Reads and checks the file without uploading. Default `false`. |

## Output

```json theme={null}
{
  "status": "success",
  "dry_run": false,
  "patient_id": "11516590",
  "document_id": "98765",
  "document_name": "Office Policy_13401623.pdf",
  "size_bytes": 182344
}
```

A dry run returns `status: "dry_run"` with the patient id, document name and size, and writes nothing. It applies the same file checks as a real upload but does not call AdvancedMD, so it checks only the patient id's format, not that the patient exists or the credentials work.

## Limits and side effects

* Posts to AdvancedMD's ehr-api `files/documents`. AdvancedMD files the document on the patient timeline without a category and cannot attach it to a visit.
* Each call creates a new document. Calling it twice for the same file uploads it twice.
* Files over 25 MB are refused while downloading, before the whole file is read.

## Errors

* `patient_id must be a positive number` — the id has no digits.
* `could not read file_url` — the reference does not point at a stored file this task can read, or the file is over 25 MB.
* `file extension … is not a short alphanumeric extension` — `file_extension` was not 1–5 letters or digits.
* `the document is empty` — the stored file has no content.
* `AdvancedMD rejected the document: …` — AdvancedMD's own message, for example an unknown patient.
* An AdvancedMD-not-connected result when the workspace has no AdvancedMD connection.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.