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

# Generate a Patient Summary for One Encounter

> Trigger encounter Patient Summary generation and store the returned patient_summary_id

**Problem:** You need a summary for one upcoming visit, but generation is asynchronous and the summary is not in the create response.

**Solution:** Call [Generate Patient Summary for an encounter](/patient-summary-api-reference/summary-generation/encounter-summary) with `fhir_encounter_id` and `fhir_practitioner_id`, then store `patient_summary_id`. Poll status next, then retrieve.

<Note>
  This cookbook assumes CKG ingestion for the patient, encounter, and practitioner is already `COMPLETED`, and you have Partner ID, `sdp_suki_token`, and matching FHIR identifiers.
</Note>

<Tabs>
  <Tab title="CURL">
    ```bash theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    curl --request POST \
      --url https://sdp.suki.ai/api/v1/patient-summary/generate/encounter \
      --header 'Content-Type: application/json' \
      --header 'sdp_suki_token: <sdp_suki_token>' \
      --header 'sdp_provider_id: <sdp_provider_id>' \
      --data '{
        "fhir_encounter_id": "enc-123",
        "fhir_practitioner_id": "pract-456"
      }'
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    const BASE_URL = "https://sdp.suki.ai";

    const res = await fetch(`${BASE_URL}/api/v1/patient-summary/generate/encounter`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        sdp_suki_token: sdpSukiToken,
        sdp_provider_id: sdpProviderId,
      },
      body: JSON.stringify({
        fhir_encounter_id: "enc-123",
        fhir_practitioner_id: "pract-456",
      }),
    });

    if (!res.ok) {
      throw new Error(`Generate for encounter failed: ${res.status}`);
    }

    const { patient_summary_id: patientSummaryId } = await res.json();
    // Store patientSummaryId, then poll status before retrieve
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    import requests

    BASE_URL = "https://sdp.suki.ai"

    res = requests.post(
        f"{BASE_URL}/api/v1/patient-summary/generate/encounter",
        headers={
            "Content-Type": "application/json",
            "sdp_suki_token": sdp_suki_token,
            "sdp_provider_id": sdp_provider_id,
        },
        json={
            "fhir_encounter_id": "enc-123",
            "fhir_practitioner_id": "pract-456",
        },
        timeout=30,
    )
    res.raise_for_status()
    patient_summary_id = res.json()["patient_summary_id"]
    # Store patient_summary_id, then poll status before retrieve
    ```
  </Tab>
</Tabs>

## Common mistakes

* Generating before CKG ingestion is `COMPLETED`.
* Mismatched `fhir_encounter_id` or `fhir_practitioner_id` versus ingested FHIR data.
* Treating the generate response as the finished summary instead of saving `patient_summary_id` and polling.
* Re-generating when a usable summary for the appointment already exists.

## Other cookbooks

<div className="cookbook-hub-wrap">
  <div className="hp-io-method-grid tut-hub-card-grid" data-cookbook-related-grid>
    <a className="hp-io-method-card tut-hub-method-card" href="/documentation/cookbooks/upload-fhir-to-ckg-and-poll">
      <div className="tut-hub-card-media" aria-hidden="true" />

      <div className="hp-io-method-card-body">
        <div className="tut-hub-card-badges">
          <span className="hp-wn-badge hp-wn-badge-new">Patient Summary</span>
          <span className="hp-wn-badge cookbook-hub-badge-surface cookbook-hub-badge-surface--api">API</span>
        </div>

        <h3 className="hp-io-method-card-title">Upload FHIR to CKG and Poll Ingestion</h3>

        <p className="hp-io-method-card-desc cookbook-hub-card-desc">
          Upload FHIR, then wait for COMPLETED.
        </p>

        <div className="hp-io-method-card-meta tut-hub-card-foot" aria-label="5 min">
          <div className="tut-hub-card-foot-meta">
            <span className="hp-io-method-card-meta-time">5 min</span>
          </div>
        </div>
      </div>
    </a>

    <a className="hp-io-method-card tut-hub-method-card" href="/documentation/cookbooks/poll-patient-summary-status-before-retrieve">
      <div className="tut-hub-card-media tut-hub-card-media--blue" aria-hidden="true" />

      <div className="hp-io-method-card-body">
        <div className="tut-hub-card-badges">
          <span className="hp-wn-badge hp-wn-badge-new">Patient Summary</span>
          <span className="hp-wn-badge cookbook-hub-badge-surface cookbook-hub-badge-surface--api">API</span>
        </div>

        <h3 className="hp-io-method-card-title">Poll Patient Summary Status Before Retrieve</h3>

        <p className="hp-io-method-card-desc cookbook-hub-card-desc">
          Poll until status is COMPLETED.
        </p>

        <div className="hp-io-method-card-meta tut-hub-card-foot" aria-label="5 min">
          <div className="tut-hub-card-foot-meta">
            <span className="hp-io-method-card-meta-time">5 min</span>
          </div>
        </div>
      </div>
    </a>
  </div>
</div>
