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

# What merging this chart into another would do

> Read-only. Asks the EHR whether each chart may be merged in its role (the path patient is the source, archived by the merge) and lists what EMA copies, what it leaves behind and conflicts staff should confirm. 501 `capability_unsupported` on an EHR without merge (EZDerm).



## OpenAPI

````yaml /openapi-v4.json get /ehr/patients/{patientId}/merge-preview
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/patients/{patientId}/merge-preview:
    get:
      tags:
        - Patient merges
      summary: What merging this chart into another would do
      description: >-
        Read-only. Asks the EHR whether each chart may be merged in its role
        (the path patient is the source, archived by the merge) and lists what
        EMA copies, what it leaves behind and conflicts staff should confirm.
        501 `capability_unsupported` on an EHR without merge (EZDerm).
      operationId: PatientMergesPublicController_preview
      parameters:
        - name: patientId
          required: true
          in: path
          schema:
            type: string
        - name: intoPatientId
          required: true
          in: query
          description: The chart that would survive.
          schema:
            type: string
            example: pat_c56103bcd39c46d39f3138dd2b5e05f6
        - 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/PatientMergePreviewSuccessResponse'
        '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'
        '409':
          description: Resource conflict (e.g. editing a signed note)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiConflictResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
        '501':
          description: >-
            This organization's EHR does not support the capability
            (`capability_unsupported`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiNotImplementedResponse'
        '502':
          description: EHR sync failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadGatewayResponse'
      security:
        - api-key: []
components:
  schemas:
    PatientMergePreviewSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/PatientMergePreviewResponse'
      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
    PublicApiConflictResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: conflict
        message:
          type: string
          description: Human-readable error message
          example: Cannot edit a signed note
        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
    PublicApiNotImplementedResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: capability_unsupported
        message:
          type: string
          description: Human-readable error message
          example: This organization's EHR has no appointment finder.
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiBadGatewayResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unexpected_integration_error
        message:
          type: string
          description: Human-readable error message
          example: EHR sync failed
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PatientMergePreviewResponse:
      type: object
      properties:
        isMergeable:
          type: boolean
          description: >-
            True when neither chart is blocked. The merge may still need
            `acknowledgeWarnings` (see `pairWarnings`).
        requiresAcknowledgement:
          type: boolean
          description: >-
            True when the EHR warned about the pair: send the merge with
            `acknowledgeWarnings`.
        source:
          $ref: '#/components/schemas/PatientMergeChartSide'
        target:
          $ref: '#/components/schemas/PatientMergeChartSide'
        pairWarnings:
          description: >-
            The EHR's warnings about the pair (its key data points differ).
            Advisory, as in EMA's own dialog.
          type: array
          items:
            $ref: '#/components/schemas/PatientMergeBlocker'
        conflicts:
          type: array
          items:
            $ref: '#/components/schemas/PatientMergeConflict'
        transfers:
          description: Copied into the surviving chart. The source keeps its own copy.
          type: array
          items:
            type: string
        doesNotTransfer:
          description: 'Not copied: they stay on the archived source chart.'
          type: array
          items:
            type: string
      required:
        - isMergeable
        - requiresAcknowledgement
        - source
        - target
        - pairWarnings
        - conflicts
        - transfers
        - doesNotTransfer
    PatientMergeChartSide:
      type: object
      properties:
        patientId:
          type: string
        isMergeable:
          type: boolean
          description: Whether the EHR accepts this chart in this role.
        blockers:
          type: array
          items:
            $ref: '#/components/schemas/PatientMergeBlocker'
        totals:
          type: object
          nullable: true
          description: Visits (finalized and preliminary), attachments, lab orders.
        futureAppointments:
          type: number
          description: Future appointments on this chart in Max AI's copy of the schedule.
        activePrimaryPolicies:
          type: number
          description: Active primary insurance policies on this chart in Max AI's copy.
      required:
        - patientId
        - isMergeable
        - blockers
        - totals
        - futureAppointments
        - activePrimaryPolicies
    PatientMergeBlocker:
      type: object
      properties:
        code:
          type: string
          enum:
            - pending_billing
            - open_authorization
            - unposted_bill
            - active_balance
            - not_found
            - other
        message:
          type: string
          description: The EHR's own sentence, for staff.
          example: >-
            There is an active balance that needs to be resolved prior to
            merging patient.
      required:
        - code
        - message
    PatientMergeConflict:
      type: object
      properties:
        code:
          type: string
          enum:
            - demographics_differ
            - two_primary_insurances
            - source_has_future_appointments
            - source_has_insurance
        fields:
          description: 'For `demographics_differ`: the fields whose values differ.'
          type: array
          items:
            type: string
        message:
          type: string
      required:
        - code
        - fields
        - message
  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.