---
title: "ABDM API — Patient Visits"
description: "Nice HMS ABDM visit endpoints: opd_patient (OPD visit), admit_patient (IPD admission), and discharge_patient (discharge / close encounter)."
date: 2026-08-26
lastModified: 2026-08-26
category: "developer"
author: "Dr. Umesh Bilagi"
beta: true
---

Visit endpoints are authenticated (`Authorization: Bearer <idToken>`). `opd_patient` and
`admit_patient` are **POST**; `discharge_patient` is **PUT**.

Each route accepts **"patientNeeds"** — at least one of `abhaAddress` (string) or
`patientId` (number). Omitting both yields `400 VALIDATION_ERROR` with the message
*"Either abhaAddress or patientId is required"*.

---

## `/opd_patient` — POST (auth)

Creates an OPD (outpatient) visit and care context within the ABDM framework. Before
sending, check whether there is already an active OPD visit.

### Request fields

| Name | Type | Required | Description |
|---|---|---|---|
| `date` | string | Yes | ISO date of the visit, e.g. `"2023-05-08T19:21:23.918Z"`. |
| `doctorDetails` | array | Yes | Array of `{ doctorName, doctorGcpId }`, min 1. |
| `abhaAddress` | string | —* | Patient's ABHA address (alternative to `patientId`). |
| `patientId` | number | —* | Nice HMS patient id (alternative to `abhaAddress`). |

\* At least one of `abhaAddress` / `patientId` is required.

### Example request

```json
{
  "date": "2023-05-08T19:21:23.918Z",
  "doctorDetails": [
    { "doctorName": "Dr Umesh Bilagi", "doctorGcpId": "cf4a6ab1-3f32-4b92-adc5-89489da6ca14" }
  ],
  "abhaAddress": "savitribilagi@sbx"
}
```

### Example response

Returns an `EncounterRes` object — an `encounter` FHIR resource with `id`, `status`
(`in-progress`), `subject.reference`, `participant`, and `period`.

```json
{
  "encounter": {
    "id": "65cb5b6a-f08e-4e46-a826-67e117573d71",
    "status": "in-progress",
    "class": { "code": "AMB", "display": "ambulatory", "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode" },
    "subject": { "reference": "Patient/9b4ec056-991d-4237-b1fd-a65770349610" },
    "period": { "start": "2023-05-08T19:21:23.918Z" }
  }
}
```

### Error codes

- `INVALID_DOCTOR_GCP_FHIR_ID` (400) — a `doctorGcpId` is not a valid Practitioner.
- `PATIENT_NOT_FOUND` (404)
- shared codes

---

## `/admit_patient` — POST (auth)

Creates an IPD (inpatient) admission visit and care context within ABDM. Before sending,
check whether there is already an active IPD visit.

### Request fields

| Name | Type | Required | Description |
|---|---|---|---|
| `doa` | string | Yes | Date of admission (ISO), e.g. `"2023-05-10T19:21:23.918Z"`. |
| `doctorDetails` | array | Yes | Array of `{ doctorName, doctorGcpId }`, min 1. |
| `abhaAddress` | string | —* | Patient's ABHA address. |
| `patientId` | number | —* | Nice HMS patient id. |

\* At least one of `abhaAddress` / `patientId` is required.

### Example request

```json
{
  "doa": "2023-05-10T19:21:23.918Z",
  "doctorDetails": [
    { "doctorName": "Dr Umesh Bilagi", "doctorGcpId": "cf4a6ab1-3f32-4b92-adc5-89489da6ca14" }
  ],
  "patientId": 236
}
```

### Example response

Returns an `EncounterRes` object (same shape as `/opd_patient`).

### Error codes

- `INVALID_DOCTOR_GCP_FHIR_ID` (400)
- `PATIENT_NOT_FOUND` (404)
- shared codes

---

## `/discharge_patient` — PUT (auth)

Discharges a patient by setting the discharge date and closing the encounter. Call this
**before** sending the discharge summary document, as it updates the discharge date.

### Request fields

| Name | Type | Required | Description |
|---|---|---|---|
| `encounterId` | string | Yes | The encounter id to close, e.g. `"21ba04cd-d922-4412-bfdc-c0293e638f1d"`. |
| `dod` | string | Yes | Date of discharge (ISO). |
| `doctorDetails` | array | No | Array of `{ doctorName, doctorGcpId }`. |
| `abhaAddress` | string | —* | Patient's ABHA address. |
| `patientId` | number | —* | Nice HMS patient id. |

\* At least one of `abhaAddress` / `patientId` is required.

### Example request

```json
{
  "encounterId": "21ba04cd-d922-4412-bfdc-c0293e638f1d",
  "dod": "2023-05-11T19:21:23.918Z",
  "doctorDetails": [
    { "doctorName": "Dr Umesh Bilagi", "doctorGcpId": "cf4a6ab1-3f32-4b92-adc5-89489da6ca14" }
  ],
  "patientId": 236
}
```

### Example response

Returns an `EncounterRes` object (with `status` updated and `period.end` set).

### Error codes

- `INVALID_DOCTOR_GCP_FHIR_ID` (400)
- `PATIENT_NOT_FOUND` (404)
- `ENCOUNTER_NOT_FOUND` (404) — the supplied `encounterId` was not found.
- shared codes
