> ## Documentation Index
> Fetch the complete documentation index at: https://developer.eka.care/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate Discharge Summary

> 
### Overview

This API uses AI to **draft a discharge summary** for an IPD admission of your workspace, from the patient's details and the prescriptions of the admission's visits (latest visit first, each dated). The draft is **streamed** as HTML while it is written. To save it, use [Create Discharge Summary](/api-reference/doc-tool/ipd-api/discharge-summaries/create-discharge-summary).

**Response format:** `text/event-stream`. Each event is one line starting with `data:` followed by JSON:

- `text` — the next piece of the summary as HTML, sent a line at a time (append it to what you have).
- `is_eof` — `true` on the last event, which has empty `text`.
- `tokens.index` — the position of the piece in the stream.

Events are separated by a single newline. If the summary cannot be started (for example the admission does not exist), a JSON error is returned instead with status `400`.



## OpenAPI

````yaml get /ipd/v1/service/admissions/generate-discharge-summary/{admission_id}
openapi: 3.0.0
info:
  title: Ekacare API & Webhook Documentation
  contact: {}
  version: '1.0'
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
paths:
  /ipd/v1/service/admissions/generate-discharge-summary/{admission_id}:
    get:
      tags:
        - IPD API
      summary: Generate Discharge Summary
      description: >-

        ### Overview


        This API uses AI to **draft a discharge summary** for an IPD admission
        of your workspace, from the patient's details and the prescriptions of
        the admission's visits (latest visit first, each dated). The draft is
        **streamed** as HTML while it is written. To save it, use [Create
        Discharge
        Summary](/api-reference/doc-tool/ipd-api/discharge-summaries/create-discharge-summary).


        **Response format:** `text/event-stream`. Each event is one line
        starting with `data:` followed by JSON:


        - `text` — the next piece of the summary as HTML, sent a line at a time
        (append it to what you have).

        - `is_eof` — `true` on the last event, which has empty `text`.

        - `tokens.index` — the position of the piece in the stream.


        Events are separated by a single newline. If the summary cannot be
        started (for example the admission does not exist), a JSON error is
        returned instead with status `400`.
      operationId: GenerateIpdDischargeSummary
      parameters:
        - name: auth
          in: header
          required: true
          schema:
            type: string
          example: >-
            eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiX2lkIjoiMTIzNDU2IiwiY2xpZW50X2lkIjoiNzg5MCIsImV4dHJhX2ZpZWxkIjoiZXh0cmFfZmllbGRfZGF0YSJ9.q9KzBI6f4l3OyM_EkB5Quq0l9EEMFh5JS-fx3F_PHUM
        - name: admission_id
          in: path
          description: Id of the IPD admission.
          required: true
          style: simple
          schema:
            type: string
          example: a1b2c3d4-5678-90ab-cdef-1234567890ab
      responses:
        '200':
          description: >-
            OK — the discharge summary, streamed as server-sent events (HTML
            text).
          content:
            text/event-stream:
              schema:
                type: string
              example: >
                data:{"text":"<h2>Discharge
                Summary</h2>","is_eof":false,"tokens":{"input":-1,"index":0}}

                data:{"text":"<p>Patient was admitted with
                fever.</p>","is_eof":false,"tokens":{"input":-1,"index":1}}

                data:{"text":"","is_eof":true,"tokens":{"input":-1,"index":2}}
        '400':
          description: >-
            Bad Request — the discharge summary could not be generated (for
            example the admission was not found).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpdServiceFailure'
              example:
                success: false
                error: Admission not found
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IpdServiceError'
      deprecated: false
components:
  schemas:
    IpdServiceFailure:
      title: IpdServiceFailure
      type: object
      properties:
        success:
          type: boolean
          description: Always `false`.
        error:
          type: string
          description: Human-readable error message.
    IpdServiceError:
      title: IpdServiceError
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.

````

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