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

# Initiate a discharge

> Moves the admission to DISCHARGE_INITIATED, records the transition, and notifies every pharmacy the admission ordered from — in that order, as one operation. The status commits before any pharmacy is contacted, so a pharmacy is never told about a discharge that did not happen. A pharmacy that could not be reached comes back as `pharmacy_warning` and never fails the request.



## OpenAPI

````yaml api-reference/doc-tool/ipd-api/ipd-sdk-openapi.json post /ipd/v1/sdk/admissions/{admission_id}/discharge/initiate
openapi: 3.1.0
info:
  title: Eka IPD Admission API
  version: '1.0'
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
paths:
  /ipd/v1/sdk/admissions/{admission_id}/discharge/initiate:
    post:
      tags:
        - IPD API
      summary: Initiate a discharge
      description: >-
        Moves the admission to DISCHARGE_INITIATED, records the transition, and
        notifies every pharmacy the admission ordered from — in that order, as
        one operation. The status commits before any pharmacy is contacted, so a
        pharmacy is never told about a discharge that did not happen. A pharmacy
        that could not be reached comes back as `pharmacy_warning` and never
        fails the request.
      operationId: IpdSdkInitiateADischarge
      parameters:
        - name: auth
          in: header
          required: true
          schema:
            type: string
          example: >-
            eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJiX2lkIjoiMTIzNDU2IiwiY2xpZW50X2lkIjoiNzg5MCIsImV4dHJhX2ZpZWxkIjoiZXh0cmFfZmllbGRfZGF0YSJ9.q9KzBI6f4l3OyM_EkB5Quq0l9EEMFh5JS-fx3F_PHUM
        - schema:
            minLength: 1
            type: string
          in: path
          name: admission_id
          required: true
          description: Id of the IPD admission.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              additionalProperties: false
              type: object
              properties:
                by:
                  description: >-
                    Actor recorded on the transition and against each pharmacy
                    attempt. Defaults to the authenticated operator.
                  additionalProperties: true
                  type: object
                  required:
                    - id
                  properties:
                    id:
                      type: string
                    name:
                      type: string
                    role:
                      type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                additionalProperties: true
                type: object
                required:
                  - admission
                  - pharmacy
                properties:
                  admission:
                    additionalProperties: true
                    type: object
                    required:
                      - id
                      - bid
                      - admission_date
                      - ipid
                      - attendee
                      - patient
                      - refer
                      - doc
                      - stage
                      - status
                      - duration
                      - bed
                      - rateplan
                      - docid
                      - category
                      - date
                      - department
                      - pid
                      - created_at
                      - updated_at
                      - facility
                      - facilityid
                      - totalbilled
                      - totalpaid
                      - totalbilled_updated_at
                      - totalpaid_updated_at
                    properties:
                      id:
                        type: string
                      bid:
                        type: string
                      admission_date:
                        description: ISO date-time.
                        type: string
                      discharge_date:
                        type: string
                      ipid:
                        description: Patient IPD case number.
                        type: string
                      attendee:
                        additionalProperties: true
                        type: object
                        required:
                          - id
                          - name
                          - phone
                          - relation
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          phone:
                            additionalProperties: true
                            type: object
                            properties:
                              c:
                                type: string
                              'n':
                                type: string
                          relation:
                            additionalProperties: true
                            type: object
                            required:
                              - id
                              - label
                            properties:
                              id:
                                type: string
                              label:
                                type: string
                      patient:
                        additionalProperties: true
                        type: object
                        required:
                          - id
                          - uuid
                          - poid
                          - formData
                          - profile
                        properties:
                          id:
                            type: string
                          uuid:
                            type: string
                          poid:
                            type: string
                          formData:
                            type: array
                            items:
                              additionalProperties: true
                              type: object
                              required:
                                - label
                                - type
                                - key
                                - value
                              properties:
                                label:
                                  type: string
                                type:
                                  type: string
                                key:
                                  type: string
                                value:
                                  anyOf:
                                    - type: string
                                    - type: number
                                    - type: array
                                      items:
                                        type: string
                          profile:
                            additionalProperties: true
                            type: object
                            required:
                              - personal
                            properties:
                              personal:
                                additionalProperties: true
                                type: object
                                required:
                                  - gender
                                  - name
                                properties:
                                  gender:
                                    type: string
                                  name:
                                    type: string
                                  phone:
                                    additionalProperties: true
                                    type: object
                                    properties:
                                      c:
                                        type: string
                                      'n':
                                        type: string
                                  age:
                                    additionalProperties: true
                                    type: object
                                    properties:
                                      dob:
                                        type: string
                                      value:
                                        type: string
                                      month:
                                        type: string
                      procedures:
                        type: array
                        items:
                          additionalProperties: true
                          type: object
                          required:
                            - id
                            - name
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            date:
                              type: string
                            notes:
                              type: string
                      refer:
                        type: object
                        required:
                          - id
                          - name
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                      doc:
                        type: object
                        required:
                          - id
                          - name
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                      notes:
                        type: string
                      medico_legal_case:
                        type: boolean
                      stage:
                        description: >-
                          Coarse lifecycle stage (`IN`/`AD`/`DC`) — replaced the
                          legacy coarse `status`.
                        anyOf:
                          - type: string
                            enum:
                              - IN
                          - type: string
                            enum:
                              - AD
                          - type: string
                            enum:
                              - DC
                      status:
                        description: Granular lifecycle status within the current `stage`.
                        anyOf:
                          - type: string
                            enum:
                              - ADMISSION_RECOMMENDED
                          - type: string
                            enum:
                              - ADMISSION_ON_HOLD
                          - type: string
                            enum:
                              - ADMISSION_CONFIRMED
                          - type: string
                            enum:
                              - ADMISSION_CANCELLED
                          - type: string
                            enum:
                              - BED_ASSIGNED
                          - type: string
                            enum:
                              - UNDER_CARE
                          - type: string
                            enum:
                              - NOT_RECEIVED
                          - type: string
                            enum:
                              - FIT_FOR_DISCHARGE
                          - type: string
                            enum:
                              - DISCHARGE_INITIATED
                          - type: string
                            enum:
                              - REFERRAL_INITIATED
                          - type: string
                            enum:
                              - LAMA_IN_PROGRESS
                          - type: string
                            enum:
                              - DAMA_IN_PROGRESS
                          - type: string
                            enum:
                              - DEATH_BEING_RECORDED
                          - type: string
                            enum:
                              - PATIENT_MISSING
                          - type: string
                            enum:
                              - DISCHARGED
                          - type: string
                            enum:
                              - LAMA_COMPLETED
                          - type: string
                            enum:
                              - DAMA_COMPLETED
                          - type: string
                            enum:
                              - REFERRED
                          - type: string
                            enum:
                              - DECEASED
                          - type: string
                            enum:
                              - ABSCONDED
                      duration:
                        additionalProperties: true
                        type: object
                        required:
                          - value
                          - unit
                        properties:
                          value:
                            type: number
                          unit:
                            type: string
                      bed:
                        type: string
                      rateplan:
                        additionalProperties: true
                        type: object
                        required:
                          - id
                          - name
                          - inclusions
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                          inclusions:
                            type: array
                            items:
                              additionalProperties: true
                              type: object
                              required:
                                - id
                                - name
                                - rate
                              properties:
                                id:
                                  type: string
                                name:
                                  type: string
                                rate:
                                  type: number
                      docid:
                        type: string
                      category:
                        type: object
                        required:
                          - id
                          - name
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                      date:
                        type: string
                      department:
                        type: object
                        required:
                          - id
                          - name
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                      pid:
                        type: string
                      created_at:
                        type: string
                      updated_at:
                        type: string
                      facility:
                        type: object
                        required:
                          - id
                          - name
                        properties:
                          id:
                            type: string
                          name:
                            type: string
                      facilityid:
                        type: string
                      totalbilled:
                        type: number
                      totalpaid:
                        type: number
                      totalbilled_updated_at:
                        type: string
                      totalpaid_updated_at:
                        type: string
                      custom_attributes:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: string
                      clearances_summary:
                        additionalProperties: true
                        type: object
                        required:
                          - statuses
                          - completed_count
                          - total
                          - all_complete
                        properties:
                          statuses:
                            type: object
                            additionalProperties:
                              anyOf:
                                - type: string
                                  enum:
                                    - PENDING
                                - type: string
                                  enum:
                                    - COMPLETED
                          completed_count:
                            type: number
                          total:
                            type: number
                          all_complete:
                            type: boolean
                      archived:
                        type: boolean
                      actor_oid:
                        type: string
                    title: Admission
                  pharmacy_warning:
                    description: >-
                      Present when a pharmacy could not be notified. The
                      discharge still happened; the operator can resend.
                    type: string
                  pharmacy:
                    additionalProperties: true
                    type: object
                    required:
                      - state
                      - targets
                    properties:
                      skipped:
                        description: Set when the round was a deliberate no-op.
                        anyOf:
                          - type: string
                            enum:
                              - no-ipid
                          - type: string
                            enum:
                              - no-targets
                      state:
                        description: Rolled-up state across every pharmacy.
                        anyOf:
                          - type: string
                            enum:
                              - none
                          - type: string
                            enum:
                              - partial
                          - type: string
                            enum:
                              - all
                          - type: string
                            enum:
                              - failed
                      targets:
                        description: Per-pharmacy state, keyed by "provider:pharmacyId".
                        type: object
                        additionalProperties:
                          additionalProperties: true
                          type: object
                          required:
                            - provider
                            - pharmacy_id
                            - status
                            - attempts
                          properties:
                            provider:
                              type: string
                            pharmacy_id:
                              type: string
                            pharmacy_name:
                              type: string
                            status:
                              anyOf:
                                - type: string
                                  enum:
                                    - NOTIFIED
                                - type: string
                                  enum:
                                    - FAILED
                                - type: string
                                  enum:
                                    - CLEARED
                                - type: string
                                  enum:
                                    - CANCELLED
                                - type: string
                                  enum:
                                    - UNSUPPORTED
                            attempts:
                              description: Total attempts — drives the "Sent 4 times" copy.
                              type: number
                            last_error:
                              type: string
                    title: PharmacyClearanceNotifyResponse
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                properties:
                  message:
                    type: string
        '404':
          description: >-
            Not Found — the admission (or the addressed record) does not exist
            in your workspace.
          content:
            application/json:
              schema:
                type: object
                required:
                  - message
                properties:
                  message:
                    type: string

````

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