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

# A merge this app requested

> Poll until `completed` or `failed`. Each poll re-reads the source chart in the EHR while the merge runs.



## OpenAPI

````yaml /openapi-v4.json get /ehr/patient-merges/{id}
openapi: 3.0.0
info:
  title: Max AI Public API
  description: API for third-party marketplace apps
  version: '4.0'
  contact: {}
servers:
  - url: https://api.maxcare.ai/v4
security: []
tags: []
paths:
  /ehr/patient-merges/{id}:
    get:
      tags:
        - Patient merges
      summary: A merge this app requested
      description: >-
        Poll until `completed` or `failed`. Each poll re-reads the source chart
        in the EHR while the merge runs.
      operationId: PatientMergesPublicController_get
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PatientMergeSuccessResponse'
        '400':
          description: Missing or invalid request parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadRequestResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUnauthorizedResponse'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiForbiddenResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiNotFoundResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
      security:
        - api-key: []
components:
  schemas:
    PatientMergeSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/ExternalPatientMergeResponse'
      required:
        - code
        - data
    PublicApiBadRequestResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: bad_request
        message:
          type: string
          description: Human-readable error message
          example: '''id'' must be a valid UUID'
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnauthorizedResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unauthorized
        message:
          type: string
          description: Human-readable error message
          example: Invalid or missing API key
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiForbiddenResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: forbidden
        message:
          type: string
          description: Human-readable error message
          example: Insufficient scope
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiNotFoundResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: not_found
        message:
          type: string
          description: Human-readable error message
          example: Resource not found
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiRateLimitResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: rate_limit_exceeded
        message:
          type: string
          description: Human-readable error message
          example: Rate limit exceeded. Maximum 1000 requests per 60 seconds.
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    ExternalPatientMergeResponse:
      type: object
      properties:
        id:
          type: string
          example: pmg_0b6f1c1e8d2a4f7e9a3b5c7d9e1f2a3b
        status:
          type: string
          enum:
            - queued
            - running
            - completed
            - failed
            - uncertain
          description: >-
            `queued` → `running` (the EHR accepted the merge and is moving data)
            → `completed` | `failed`. `uncertain`: the merge was sent but the
            EHR never answered; it settles to `completed` or `failed` without
            being sent again.
        patientId:
          type: string
          description: The chart merged away; archived in the EHR once completed.
        intoPatientId:
          type: string
          description: The surviving chart.
        errorCode:
          type: string
          nullable: true
          description: >-
            `ehr_write_uncertain`, `merge_not_confirmed`, `merge_failed_in_ehr`
            or `merged_elsewhere`; null otherwise.
        errorMessage:
          type: string
          nullable: true
        requiresReconciliation:
          type: boolean
          description: >-
            True while the outcome is unknown: check the EHR before merging
            again.
        requestedAt:
          type: string
        completedAt:
          type: string
          nullable: true
        updatedAt:
          type: string
      required:
        - id
        - status
        - patientId
        - intoPatientId
        - errorCode
        - errorMessage
        - requiresReconciliation
        - requestedAt
        - completedAt
        - updatedAt
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Marketplace API key

````

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