> ## 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.

# Nanonets Health Call Operation

> Call a named, allowlisted Nanonets Health operation through one generic tool.

This document covers `nanonetshealth_call_operation`, a single generic tool for calling named operations in Nanonets Health (Fleming), such as the census billing-line store.

Nanonets Health owns each operation: its name, its params schema, its validation and the permission it requires. New operations are added in Nanonets Health and become callable through this tool without a new Agents Platform tool — but only once an admin adds them to a tool's allowlist.

## Authentication and enablement

The tool uses the Nanonets Health integration. The platform injects:

* `api_key`

The API key is excluded from the model-visible tool schema. Nanonets Health scopes every operation to the API key's organization — no operation accepts an organization from its params — and checks the permission each operation requires against the key's role. For the census operations that is `manage_patients` (save) and `view_patients` (get).

The tool is **off by default**. Enable it per agent and configure its allowlist.

## Allowed operations (required)

`allowed_operations` is a configuration-only setting: a comma-separated list of operation names, set in the tool settings and never chosen by the model.

```
census_billing_lines.get
```

**An empty allowlist refuses every operation.** This is deliberately the opposite of `delegate_tasks`, where an empty allowlist allows every agent. These operations read and write patient data, so an enabled tool that has not been configured must not be able to reach all of it. Until `allowed_operations` is set, every call fails with an error saying the tool needs an allowlist.

The allowlist is enforced inside the tool **before** any request is sent. A call to an operation that is not listed is refused with an error naming the operations that are allowed.

The allowlist only narrows what Nanonets Health already permits: an allowed operation still fails if the API key's role lacks that operation's permission.

**Enable this tool only as a configured tool with `allowed_operations` bound.** A bound value always overrides one sent by the model, so the allowlist holds. If the base tool is enabled directly instead, nothing binds `allowed_operations`, and a model that sends the field itself would supply its own allowlist. Nanonets Health still enforces the API key's role on every operation in that case, but the tool's own allowlist no longer narrows it.

## Inputs

* `operation` (required): the operation name, for example `census_billing_lines.get`.
* `params`: the operation's arguments as a JSON object. Omit it, or send `{}`, for none. Params are validated strictly by Nanonets Health: unknown fields are rejected.

## Discovering operations

Call `operations.list` with no params. It returns each operation's `name`, `description`, `params_schema` and required `permission` — metadata only, never patient data.

Nanonets Health lists only the operations the API key's role may call, and the tool then removes any operation not on its allowlist, so the list shows exactly what this tool can do. `operations.list` needs no allowlist entry of its own, but it is still refused while the allowlist is empty.

## Operations available today

| Operation | Permission | What it does |
| - | - | - |
| `census_billing_lines.save` | `manage_patients` | Replaces every stored billing line for one facility-month (`phs_id` + `census_year` + `census_month`) atomically. |
| `census_billing_lines.get` | `view_patients` | Fetches stored billing lines, optionally narrowed by `phs_id`, `census_year`, `census_month`. |

### `census_billing_lines.save`

Params: `phs_id`, `census_year`, `census_month` (1–12), `source_type` (`csv`, `excel` or `pdf`), `billing_lines` — all required — plus optional `source_file_name`, `source_task_id`, `reviewed` and `content_hash`.

Each billing line takes `patient_name` (required), `resident_id`, `payer_code`, `payer_name`, `start_day` and `end_day`. `start_day`/`end_day` are day-of-month bounds of the resident's stay within the census month, validated against the month's real length.

* The call **replaces** the whole facility-month: lines you omit are deleted. An empty `billing_lines` is rejected rather than treated as a delete. At most 20,000 lines.
* Identical content is a **no-op**. Nanonets Health hashes the submitted lines itself; if `content_hash` is sent it must match that hash.
* `reviewed: true` is accepted only for `source_type: pdf`, and only for a census whose extraction passed human review.

Result:

```json theme={null}
{
  "operation": "census_billing_lines.save",
  "result": { "status": "stored", "rows_written": 142, "rows_replaced": 138, "content_hash": "3f1c…" }
}
```

`status` is `unchanged` when the content already matched; nothing is rewritten.

### `census_billing_lines.get`

Params, all optional: `phs_id`, `census_year`, `census_month` (requires `census_year`), `limit` (default and maximum 20,000).

Result: `{"operation": "census_billing_lines.get", "result": {"data": [...], "total": N}}`. Each line carries `phs_id`, `census_year`, `census_month`, `patient_name`, `resident_id`, `payer_code`, `payer_name`, `start_day`, `end_day`, `source_file_name`, `source_task_id`, `source_type`, `reviewed`, `content_hash` and `created_at`.

### Retention

Stored census billing lines are purged **90 days** after they are written. An empty `data` array means "not stored (any more)", not "no residents".

## Errors

* No `allowed_operations` configured → every call refused; nothing is sent.
* Operation not on the allowlist → refused with the allowed list; nothing is sent.
* Unknown operation → HTTP 404 from Nanonets Health.
* API key role lacks the operation's permission → HTTP 403.
* Params that fail validation, including unknown fields → HTTP 400 with the reason.

## Output variables

Every successful result is stored as a JSON-valued task variable. Use the `output_variable` the tool result returns, for example `${VAR_N}.result.data` or `${VAR_N}.result.status`.


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