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

# Unlink Fax Patient

> Undo a fax→patient filing.

Archives the chart document(s) this fax produced, which dissolves the
derived fax↔patient link (the fax row stores no patient). A dedicated action
because the link dialog inherently requires selecting a patient to confirm —
there's no "select nobody". The GCS file is retained (soft-delete),
consistent with ``delete_document``; only the chart document row is archived.



## OpenAPI

````yaml post /faxes/{fax_id}/unlink-patient
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /faxes/{fax_id}/unlink-patient:
    post:
      tags:
        - Faxes
      summary: Unlink Fax Patient
      description: >-
        Undo a fax→patient filing.


        Archives the chart document(s) this fax produced, which dissolves the

        derived fax↔patient link (the fax row stores no patient). A dedicated
        action

        because the link dialog inherently requires selecting a patient to
        confirm —

        there's no "select nobody". The GCS file is retained (soft-delete),

        consistent with ``delete_document``; only the chart document row is
        archived.
      operationId: unlink_fax_patient_faxes__fax_id__unlink_patient_post
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: fax_id
          in: path
          required: true
          schema:
            type: string
            title: Fax Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FaxPatientLinkResult'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    FaxPatientLinkResult:
      properties:
        fax:
          $ref: '#/components/schemas/FaxResponse'
        affectedDocument:
          anyOf:
            - $ref: '#/components/schemas/DocumentSummary'
            - type: 'null'
      type: object
      required:
        - fax
      title: FaxPatientLinkResult
      description: >-
        Result of ``link-patient`` / ``unlink-patient``: the updated fax plus
        the

        chart document the action created, moved, or archived.


        Returning both lets the client patch the fax detail cache *and* the
        patient's

        chart document list straight from the response — no refetch — the same
        way

        send-fax and the fax-contact mutations update their caches.
        ``affected_document``

        is null only on the idempotent unlink-when-nothing-was-filed path, where
        no

        document changed.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FaxResponse:
      properties:
        id:
          type: string
          title: Id
        direction:
          $ref: '#/components/schemas/FaxDirection'
        status:
          $ref: '#/components/schemas/FaxStatus'
        signalwireFaxSid:
          anyOf:
            - type: string
            - type: 'null'
          title: Signalwirefaxsid
        phoneNumberId:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumberid
        phoneNumberE164:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumbere164
        faxContact:
          anyOf:
            - $ref: '#/components/schemas/FaxContactResponse'
            - type: 'null'
        patientId:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientid
        patient:
          anyOf:
            - $ref: '#/components/schemas/LinkedPatientRef'
            - type: 'null'
        filedDocument:
          anyOf:
            - $ref: '#/components/schemas/LinkedDocumentRef'
            - type: 'null'
        numPages:
          anyOf:
            - type: integer
            - type: 'null'
          title: Numpages
        cost:
          anyOf:
            - type: string
              pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
            - type: 'null'
          title: Cost
        errorCode:
          anyOf:
            - type: string
            - type: 'null'
          title: Errorcode
        errorMessage:
          anyOf:
            - type: string
            - type: 'null'
          title: Errormessage
        pdfPath:
          anyOf:
            - type: string
            - type: 'null'
          title: Pdfpath
        sentAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Sentat
        completedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completedat
        createdByUserId:
          anyOf:
            - type: string
            - type: 'null'
          title: Createdbyuserid
        createdDate:
          type: string
          format: date-time
          title: Createddate
        updatedDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updateddate
        readDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Readdate
        attachments:
          items:
            $ref: '#/components/schemas/FaxAttachmentResponse'
          type: array
          title: Attachments
        analysis:
          anyOf:
            - $ref: '#/components/schemas/FaxAnalysisResponse'
            - type: 'null'
      type: object
      required:
        - id
        - direction
        - status
        - signalwireFaxSid
        - phoneNumberId
        - phoneNumberE164
        - faxContact
        - numPages
        - cost
        - errorCode
        - errorMessage
        - pdfPath
        - sentAt
        - completedAt
        - createdByUserId
        - createdDate
        - updatedDate
      title: FaxResponse
    DocumentSummary:
      properties:
        id:
          type: string
          title: Id
        patientId:
          type: string
          title: Patientid
        filePath:
          type: string
          title: Filepath
        fileType:
          type: string
          title: Filetype
        title:
          type: string
          title: Title
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
        docType:
          type: string
          title: Doctype
        signatureUrl:
          anyOf:
            - type: string
            - type: 'null'
          title: Signatureurl
        expiryDate:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Expirydate
        createdDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Createddate
        updatedDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updateddate
        noteIds:
          items:
            type: string
          type: array
          title: Noteids
          default: []
        sourceNoteId:
          anyOf:
            - type: string
            - type: 'null'
          title: Sourcenoteid
        reviewedByProviderId:
          anyOf:
            - type: string
            - type: 'null'
          title: Reviewedbyproviderid
        reviewedDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Revieweddate
        reviewComment:
          anyOf:
            - type: string
            - type: 'null'
          title: Reviewcomment
        sharedWithPatient:
          type: boolean
          title: Sharedwithpatient
          default: false
        sharedDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Shareddate
        sharedByProviderId:
          anyOf:
            - type: string
            - type: 'null'
          title: Sharedbyproviderid
        patientMessage:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientmessage
        sourceAnsweredFormId:
          anyOf:
            - type: string
            - type: 'null'
          title: Sourceansweredformid
        sourceFormId:
          anyOf:
            - type: string
            - type: 'null'
          title: Sourceformid
        sourceFormName:
          anyOf:
            - type: string
            - type: 'null'
          title: Sourceformname
      type: object
      required:
        - id
        - patientId
        - filePath
        - fileType
        - title
        - summary
        - docType
        - signatureUrl
      title: DocumentSummary
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    FaxDirection:
      type: string
      enum:
        - OUTBOUND
        - INBOUND
      title: FaxDirection
      description: >-
        Direction of a fax. INBOUND is defined now so inbound work later just
        adds rows.
    FaxStatus:
      type: string
      enum:
        - QUEUED
        - SENDING
        - DELIVERED
        - FAILED
        - CANCELED
        - NO_ANSWER
        - BUSY
      title: FaxStatus
      description: >-
        Lifecycle status of a fax. Values mirror SignalWire's LaML fax status
        values.
    FaxContactResponse:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        faxNumber:
          type: string
          title: Faxnumber
        organization:
          anyOf:
            - type: string
            - type: 'null'
          title: Organization
        notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Notes
        addressLineOne:
          anyOf:
            - type: string
            - type: 'null'
          title: Addresslineone
        addressLineTwo:
          anyOf:
            - type: string
            - type: 'null'
          title: Addresslinetwo
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
        state:
          anyOf:
            - type: string
            - type: 'null'
          title: State
        zipCode:
          anyOf:
            - type: string
            - type: 'null'
          title: Zipcode
        createdByUserId:
          anyOf:
            - type: string
            - type: 'null'
          title: Createdbyuserid
      type: object
      required:
        - id
        - name
        - faxNumber
        - organization
        - notes
        - addressLineOne
        - addressLineTwo
        - city
        - state
        - zipCode
        - createdByUserId
      title: FaxContactResponse
    LinkedPatientRef:
      properties:
        id:
          type: string
          title: Id
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
      type: object
      required:
        - id
      title: LinkedPatientRef
      description: |-
        Minimal patient reference for a fax linked to a chart (id + name only).

        Lets the detail pane show "Linked to {name}" and the create-task dialog
        pre-fill the patient without a second fetch.
    LinkedDocumentRef:
      properties:
        id:
          type: string
          title: Id
        title:
          type: string
          title: Title
        docType:
          type: string
          title: Doctype
      type: object
      required:
        - id
        - title
        - docType
      title: LinkedDocumentRef
      description: >-
        Minimal reference to the chart document a fax is filed to (id + current

        title + type). Lets the link dialog seed its fields with what's actually
        filed

        instead of opening blank, so re-confirming/relinking preserves them
        unless the

        user edits — no clobber from resent defaults.
    FaxAttachmentResponse:
      properties:
        id:
          type: string
          title: Id
        filename:
          type: string
          title: Filename
        gcsPath:
          type: string
          title: Gcspath
        sourceType:
          $ref: '#/components/schemas/FaxAttachmentSourceType'
        displayOrder:
          type: integer
          title: Displayorder
        documentId:
          anyOf:
            - type: string
            - type: 'null'
          title: Documentid
      type: object
      required:
        - id
        - filename
        - gcsPath
        - sourceType
        - displayOrder
      title: FaxAttachmentResponse
    FaxAnalysisResponse:
      properties:
        status:
          $ref: '#/components/schemas/FaxAnalysisStatus'
        errorMessage:
          anyOf:
            - type: string
            - type: 'null'
          title: Errormessage
        extraction:
          anyOf:
            - $ref: '#/components/schemas/FaxExtraction'
            - type: 'null'
        suggestedPatient:
          anyOf:
            - $ref: '#/components/schemas/LinkedPatientRef'
            - type: 'null'
        patientMatchConfidence:
          anyOf:
            - $ref: '#/components/schemas/FaxPatientMatchConfidence'
            - type: 'null'
        patientMatchReason:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientmatchreason
        suggestedTemplate:
          anyOf:
            - $ref: '#/components/schemas/SuggestedTemplateRef'
            - type: 'null'
        suggestedProvider:
          anyOf:
            - $ref: '#/components/schemas/SuggestedProviderRef'
            - type: 'null'
        createdNoteId:
          anyOf:
            - type: string
            - type: 'null'
          title: Creatednoteid
        createdTaskId:
          anyOf:
            - type: string
            - type: 'null'
          title: Createdtaskid
        patientSuggestionDismissedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Patientsuggestiondismissedat
        noteSuggestionDismissedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Notesuggestiondismissedat
        taskSuggestionDismissedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Tasksuggestiondismissedat
        completedAt:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completedat
      type: object
      required:
        - status
      title: FaxAnalysisResponse
      description: |-
        The AI analysis surface on the fax detail: status + the three
        suggest-only cards (patient link / note / provider task).

        ``extraction`` is the raw LLM output (summary, key sections, as-printed
        identity, title/type hints); the ``suggested_*`` refs are the
        deterministically matched rows staff can accept. ``*_dismissed_at``
        timestamps hide a card without deleting the underlying data.
    FaxAttachmentSourceType:
      type: string
      enum:
        - PATIENT_CHART
        - COVER_SHEET
        - UPLOAD
        - REFERRAL_LETTER
      title: FaxAttachmentSourceType
      description: |-
        Origin of a fax attachment.

        Slice 1 only emits ``UPLOAD``. ``PATIENT_CHART`` / ``COVER_SHEET`` are
        customer-validated origins for the slice 2 ``FaxTemplate`` work — kept
        here so historical rows surface the right origin when slice 2 lands.
    FaxAnalysisStatus:
      type: string
      enum:
        - PENDING
        - PROCESSING
        - COMPLETED
        - FAILED
      title: FaxAnalysisStatus
      description: Lifecycle of the background AI analysis run for an inbound fax.
    FaxExtraction:
      properties:
        patientFirstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientfirstname
          description: >-
            Patient's first (given) name exactly as printed, without honorifics
            or middle names. Null when the document identifies no patient.
        patientLastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientlastname
          description: >-
            Patient's last (family) name exactly as printed. Null when the
            document identifies no patient.
        patientDateOfBirth:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientdateofbirth
          description: >-
            Patient's date of birth exactly as printed (e.g. '12/12/1985' or
            'Dec 12, 1985'). Do NOT reformat or infer — copy the printed text
            verbatim. Null if not printed.
        patientPhone:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientphone
          description: >-
            Patient's phone number as printed, if any. Not the sending or
            receiving fax number.
        patientMrn:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientmrn
          description: >-
            Patient's medical record number / MRN / chart number as printed, if
            any.
        requestingProviderName:
          anyOf:
            - type: string
            - type: 'null'
          title: Requestingprovidername
          description: >-
            Name of the clinic provider this fax is for — e.g. after 'Exam
            requested by:', 'Ordering provider:', 'Attn:', or 'Referred to:'.
            Include credentials as printed (e.g. 'RANI RAMASWAMY MD'). This is
            the recipient/orderer at the clinic, NOT the author of the document.
        documentCategory:
          anyOf:
            - type: string
            - type: 'null'
          title: Documentcategory
          description: >-
            What kind of document this is, in a few words: e.g. 'radiology
            report', 'lab result', 'referral letter', 'medical records', 'prior
            authorization'.
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
          description: >-
            2-4 sentence plain-language summary of the fax for clinic triage
            staff: who it concerns, what it reports or requests, and anything
            time-sensitive.
        keySections:
          items:
            $ref: '#/components/schemas/FaxKeySection'
          type: array
          title: Keysections
          description: >-
            The document's notable sections (e.g. Findings, Impression,
            Recommendations), summarized.
        suggestedDocumentTitle:
          anyOf:
            - type: string
            - type: 'null'
          title: Suggesteddocumenttitle
          description: >-
            Short title for filing this fax into the patient's chart, e.g. 'MRI
            Lumbar Spine Report — Mercy Radiology'. Under 80 characters.
        suggestedDocType:
          anyOf:
            - type: string
            - type: 'null'
          title: Suggesteddoctype
          description: >-
            The best-matching document type NAME chosen from the 'Document
            types' list in the instructions, copied exactly. Null if none fits.
        suggestedNoteTemplateId:
          anyOf:
            - type: string
            - type: 'null'
          title: Suggestednotetemplateid
          description: >-
            The id (in brackets) of the note template from the 'Note template
            catalog' in the instructions whose sections/questions best fit
            documenting this fax as a clinical note. Null if none fits.
      type: object
      title: FaxExtraction
      description: >-
        Structured LLM extraction from an inbound fax PDF.


        This model doubles as the Gemini ``response_schema`` — every field

        description below IS the extraction prompt for that field. Identity
        fields

        are captured *as printed* so the deterministic SQL match ladder (not the

        LLM) decides which patient they correspond to.
    FaxPatientMatchConfidence:
      type: string
      enum:
        - HIGH
        - MEDIUM
        - LOW
      title: FaxPatientMatchConfidence
      description: |-
        How strongly the extracted patient identity matched a tenant patient.

        HIGH = name+DOB or MRN; MEDIUM = last name+DOB or name+phone;
        LOW = name only. The match itself is deterministic SQL — confidence only
        reflects which identity fields agreed, so the UI can calibrate its copy.
    SuggestedTemplateRef:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
      type: object
      required:
        - id
        - name
      title: SuggestedTemplateRef
      description: >-
        Minimal note-template reference for the note-suggestion card (id +
        name).
    SuggestedProviderRef:
      properties:
        id:
          type: string
          title: Id
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
      type: object
      required:
        - id
      title: SuggestedProviderRef
      description: >-
        Minimal provider reference for the task-suggestion card (id + first/last
        name).
    FaxKeySection:
      properties:
        heading:
          type: string
          title: Heading
          description: >-
            Section heading as printed in the document (e.g. 'Impression',
            'Findings').
        content:
          type: string
          title: Content
          description: Concise summary of that section in at most 2-3 sentences.
      type: object
      required:
        - heading
        - content
      title: FaxKeySection
      description: One notable section of the faxed document (e.g. Findings, Impression).

````