# Rank surgeons by procedure

> Build a call list of the highest-volume operators for a procedure in a territory.

Source: https://openpipe.health/docs/guides/surgeons-by-procedure/

This guide builds a ranked list of clinicians who perform a given procedure in a given state, then pulls a full profile for the top name. The first three steps spend 3 credits.

## 1. Find the code

```sh
curl "$OPH_API/api/procedures?q=knee%20arthroplasty" -H "Authorization: Bearer $OPH_KEY"
```

Take the `code` of the row you want. Total knee replacement is `27447`.

## 2. Rank clinicians

```sh
curl "$OPH_API/api/providers?hcpcs=27447&state=AZ&min_services=50&limit=50" \
  -H "Authorization: Bearer $OPH_KEY"
```

Rows come back sorted by `services`, highest first. `min_services` drops occasional operators.

To narrow to one metro, add `city=Phoenix`. The match is on the whole city name, so `Phoenix` will not return `Scottsdale`; run one call per city.

## 3. Profile the top name

```sh
curl "$OPH_API/api/providers/1234567893" -H "Authorization: Bearer $OPH_KEY"
```

The parts a rep usually wants:

- `procedures`: the rest of their case mix, with `place_of_service` showing hospital (`F`) against office (`O`).
- `groups`: the practice to route the account to.
- `payments`: which manufacturers already pay them, and how much.

## 4. Export the whole list

The search returns up to 200 rows a page. For every clinician that matches, send the same filters to [exports](https://openpipe.health/docs/api/exports.md) (10 credits):

```sh
curl "$OPH_API/api/exports" \
  -H "Authorization: Bearer $OPH_KEY" -H "Content-Type: application/json" \
  -d '{"list": "providers", "params": {"hcpcs": "27447", "state": "AZ", "min_services": 50}}'
```

The response has a `url` to a CSV with the same columns as the search.

## A figure the search does not return

For something the search has no column for, such as each surgeon's share of cases done in a hospital, ask in plain English (25 credits):

```sh
curl "$OPH_API/api/ask" \
  -H "Authorization: Bearer $OPH_KEY" \
  -H "Content-Type: application/json" -H "Accept: application/json" \
  -d '{"question": "For the top knee replacement surgeons in Arizona, what share of their cases are done in a facility?"}'
```

Each tile in the answer carries the `sql` the model wrote, so you can see how the share was computed.

> **Caution:** These are Medicare fee-for-service volumes. They rank surgeons well, and undercount every one of them. See [Caveats](https://openpipe.health/docs/data/caveats.md).
