> ## 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 Get Visit Summary

> Native AdvancedMD visit summary tool exposed through the Agents Platform.

This document covers `advancedmd_get_visit_summary`, the native AdvancedMD visit summary tool exposed through the Agents Platform.

## Authentication

AdvancedMD tools use the existing AdvancedMD connector. Users configure:

* `office_code`
* `username`
* `password`

The client performs AdvancedMD's two-step API login, discovers the tenant API base URL, caches the security token, and refreshes it when needed. Tools do not accept raw AdvancedMD tokens or direct `processrequest.aspx` URLs.

## `advancedmd_get_visit_summary`

Fetches AdvancedMD visit context for realtime coding by porting Fleming's `GetDateVisitsRaw` API call. The tool calls AdvancedMD `getdatevisits` over the requested date window and returns the target visit plus nearby same-patient visits when available.

This tool is read-only.

### Inputs

Required:

* `visit_id`: AdvancedMD visit ID.

Optional:

* `visit_window_days`: Days around the current date to inspect for nearby visits. Defaults to `7`.

### Lookup Behavior

The tool:

* authenticates to AdvancedMD,
* calls AdvancedMD `getdatevisits` over the requested window,
* filters to the target `visit_id`,
* returns embedded charge, insurance, and patient data from the visit bundle,
* returns nearby same-patient visits to support coding context.

This is intentionally not a schedule approximation. It uses the same visit bundle endpoint Fleming uses for coding sync because that payload can include `ChargeList`, `InsuranceList`, and `PatientList`.

### Output

```json theme={null}
{
  "success": true,
  "visit_id": "vst123",
  "visit": {},
  "nearby_visits": [],
  "summary": {
    "has_unbilled_charges": true,
    "existing_procedure_codes": ["99214"],
    "patient_id": "pat123"
  }
}
```

Common failure reasons:

* `advancedmd_not_connected`
* authentication failure
* schedule/visit lookup failure

## Human-readable text

The tool emits markdown for the feed: a `## Visit Summary` table, a `## Visit` field table, `## Patient`, `## Insurance`, `## Charges`, and `## Nearby Visits` sections. The full visit bundle stays in `structuredContent`.

## Agent Instruction Guidance

Use this as the first AdvancedMD realtime coding step. AdvancedMD has no chart-alert equivalent and does not run Athena-style precheck; once summary-level skip checks pass, fetch documentation and proceed to the shared coding LLM pipeline.
