Skip to main content
Updated:Starting with Mobile SDK v2.6.0+ on iOS SDK, you can attach structured medication orders to an ambient session’s context by passing SukiAmbientConstant.kOrdersInfo into setSessionContext(with:) after you create the session.Learn more in the Medication orders section.
Quick summary
The setSessionContext(with:) method in the mobile SDK allows you to provide optional clinical context to the ambient session for better note generation. This context helps Suki generate more accurate and relevant clinical notes. Call setSessionContext(with:) multiple times. Each call updates or adds to the existing context. This allows you to provide information as it becomes available in your app.

Overview

After creating a session, you can provide additional clinical information using the setSessionContext(with:) method. This context helps Suki’s AI generate more accurate and relevant clinical notes.
All context parameters mentioned below are optional. Use one or more of these parameters to help Suki generate more accurate and relevant clinical notes. The absence of any parameter will not break existing functionality.
Why provide context?
  • Better note quality: More accurate sections and diagnoses
  • Specialty-specific formatting: Notes match your medical specialty
  • Structured organization: Notes organized by the sections you need
  • Diagnosis accuracy: Better identification of conditions discussed
After creating a session, you can provide additional clinical information using the setSessionContext(with:) method. This context helps Suki’s AI generate more accurate and relevant clinical notes.
Call setSessionContext(with:) multiple times. Each call updates or adds to the existing context. This allows you to provide information as it becomes available in your app.
do {
    let contextDetail: [String: AnyHashable] = [
        SukiAmbientConstant.kPatientInfo: [
            SukiAmbientConstant.kBirthdate: Date(), // Use yyyy-mm-dd format
            SukiAmbientConstant.kGender: "MALE"
        ],
        SukiAmbientConstant.kProviderContext: [
            SukiAmbientConstant.kSpeciality: "FAMILY_MEDICINE",
            SukiAmbientConstant.kProviderRole: "PRIMARY/ATTENDING" // New in v2.5.0: Optional provider role (Primary/Attending or Consulting)
        ],
        SukiAmbientConstant.kVisitContext: [ 
          // New in v2.5.0: Visit context parameters for improved note generation
            SukiAmbientConstant.kVisitType: "ESTABLISHED_PATIENT", // Optional: New Patient / Intake, Established patient, Wellness, ED
            SukiAmbientConstant.kEncounterType: "AMBULATORY", // Optional: ambulatory, inpatient, ED
            SukiAmbientConstant.kReasonForVisit: "Annual checkup", // Optional: String, max 255 characters
            SukiAmbientConstant.kChiefComplaint: "Routine follow-up" // Optional: String, max 255 characters
        ],

        SukiAmbientConstant.kEmrInfo: [ // New in v2.6.0: Optional EMR info (string)
            SukiAmbientConstant.kTargetEmr: "<emr_identifier>" // Required: which EMR this session uses (string)
        ],
        SukiAmbientConstant.kSections: [
            [SukiAmbientConstant.kCode: "51848-0", SukiAmbientConstant.kCodeType: "loinc"],
            [SukiAmbientConstant.kCode: "11450-4", SukiAmbientConstant.kCodeType: "loinc"]
        ],
        SukiAmbientConstant.kDiagnosisInfo: [
            [
                SukiAmbientConstant.kDiagnosisNote: "Patient presents with chest pain",
                SukiAmbientConstant.kCodes: [
                    [
                        SukiAmbientConstant.kCodeType: "ICD-10",
                        SukiAmbientConstant.kCode: "R06.02",
                        SukiAmbientConstant.kCodeDescription: "Shortness of breath"
                    ]
                ]
            ]
        ],
        // New in v2.6.0: medication orders context parameter for suggesting medication orders
        SukiAmbientConstant.kOrdersInfo: [ 
            MedicationOrderKeys.kMedicationOrders: [
                [
                    MedicationOrderKeys.kDrugName: "Atorvastatin",
                    MedicationOrderKeys.kMedicationCode: [
                        SukiAmbientConstant.kCodeType: "<code_type>", // required; coded values must match a supported catalog in your SDK version
                        SukiAmbientConstant.kCode: "<code>" // required
                    ],
                    MedicationOrderKeys.kStrength: "10 mg", // required
                    MedicationOrderKeys.kFormat: "tablet", // required
                    MedicationOrderKeys.kRoute: "oral", // required
                    MedicationOrderKeys.kLinkedDiagnosisCodes: [
                        [
                            SukiAmbientConstant.kCodeType: "ICD-10",
                            SukiAmbientConstant.kCode: "E78.5"
                        ]
                    ],
                    MedicationOrderKeys.kMetadata: [
                        MedicationOrderKeys.kOrigin: "EMR",
                        MedicationOrderKeys.kEncounterRelation: "CURRENT_ENCOUNTER"
                    ]
                    // Optional: MedicationOrderKeys.kDosage, kFrequency, kMedicationTiming, kStatus, kQuantityDispensed, kNumberOfRefills, kStartDate, kEndDate, kDurationInDays, kInstructions, etc

                ]
            ]
        ]
    ]
    
    try SukiAmbientCore.shared.setSessionContext(with: contextDetail) { result in
        switch result {
        case .success:
            print("Context updated successfully")
        case .failure(let error):
            print("Error updating context: \(error)")
        }
    }
} catch {
    print(error)
}
Call setSessionContext(with:) only after a session has been successfully created. Call createSession first and wait for it to succeed before calling setSessionContext.
Retrieve the generated note and structured dataAfter you call setSessionContext with your additional clinical context (such as provider, patient, or visit details), you can use the Suki Mobile SDK to retrieve your results.Use the content(for:) method to retrieve the generated clinical note and extracted blocks. To pull structured output once processing completes, call getStructuredData(for:).The structured output includes all data the service produces from your specific context, including diagnoses and medication order payloads.For more information on how to retrieve these elements, read our guide on Session status and content retrieval.

Additional context parameters

Patient info

SukiAmbientConstant.kPatientInfo
dictionary
Use this parameter to provide demographic information that helps personalize the note generation.

Provider context

SukiAmbientConstant.kProviderContext
dictionary
Use this parameter to provide information about the healthcare provider to tailor note generation to your specialty and role.

Visit context

SukiAmbientConstant.kVisitContext
dictionary
Use this parameter to provide visit-related metadata that provides context about the type and purpose of the encounter.

EMR info

SukiAmbientConstant.kEmrInfo
dictionary
Use this parameter to identify which EMR applies to an ambient session. Provide a string identifier that matches what your integration and Suki use for that EMR (for example a vendor code or environment-specific label).
SukiAmbientConstant.kSections
array of dictionaries
An array of LOINC codes that specify which clinical note sections you want in the generated note. Each dictionary contains a LOINC code.
You only need to provide LOINC codes. The SDK automatically generates the appropriate clinical section titles based on the codes you provide.
Code example:
Swift
SukiAmbientConstant.kSections: [
    [SukiAmbientConstant.kCode: "51848-0", SukiAmbientConstant.kCodeType: "loinc"],
    [SukiAmbientConstant.kCode: "11450-4", SukiAmbientConstant.kCodeType: "loinc"]
]

Diagnosis info

SukiAmbientConstant.kDiagnosisInfo
array of dictionaries
Structured diagnosis information that helps the AI identify and code conditions discussed during the encounter. Each dictionary represents one diagnosis.

Orders info

SukiAmbientConstant.kOrdersInfo
dictionary
Use this parameter to provide information about medications relevant to a patient visit, such as existing prescriptions or the patient’s current medication list.The data is structured as a single bundle. On the wire, the outer payload key is orders. Inside this bundle, you must include a single list keyed by MedicationOrderKeys.kMedicationOrders (wire string medication_orders). Each entry in this list represents a single medication order and must be formatted as an individual dictionary.You can skip kOrdersInfo entirely if it is not required for your workflow. If you do send the MedicationOrderKeys.kMedicationOrders list, each order in that list must satisfy the following requirements.
Missing information or incomplete metadata fails with invalidMedicationOrder. If you include origin or encounter_relation under metadata, each value must be non-empty and match one of the allowed choices. Values that do not match can fail parsing with invalidOrderMetadata.
Payload keysYou must include the following payload (wire) keys for every order in the MedicationOrderKeys.kMedicationOrders array:
  • medication_code: You must include both code_type and code.
  • linked_diagnosis_codes: You must include at least one item containing both code_type and code.
  • metadata.origin and metadata.encounter_relation: You must use only the approved values for these fields.
When you use optional fields that carry codes (medication_code.code_type, dosage.unit, frequency, medication_timing, status), the SDK checks them against its own supported lists. Use only values that your SDK already accepts to avoid validation errors.
Code example:
Swift
SukiAmbientConstant.kOrdersInfo: [
    MedicationOrderKeys.kMedicationOrders: [
        [
            MedicationOrderKeys.kDrugName: "Atorvastatin", // required
            MedicationOrderKeys.kMedicationCode: [
                SukiAmbientConstant.kCodeType: "<code_type>", // required
                SukiAmbientConstant.kCode: "<code>" // required
            ],
            MedicationOrderKeys.kStrength: "10 mg", // required
            MedicationOrderKeys.kFormat: "tablet", // required
            MedicationOrderKeys.kRoute: "oral", // required
            MedicationOrderKeys.kLinkedDiagnosisCodes: [
                [SukiAmbientConstant.kCodeType: "ICD-10", SukiAmbientConstant.kCode: "E78.5"]
            ],
            MedicationOrderKeys.kMetadata: [
                MedicationOrderKeys.kOrigin: "EMR",
                MedicationOrderKeys.kEncounterRelation: "CURRENT_ENCOUNTER"
            ]
        ]
    ]
]

Best practices

Follow these practices to ensure reliable session management:
  • Always initialize the SDK first: Make sure SukiAmbientCore.shared.initialize() has been called successfully before creating a session.
  • Store the session ID: Save the sessionId returned from createSession immediately. You’ll need it for all subsequent operations.
  • Handle errors properly: Use the completion handler’s result to check for success or failure. Display appropriate error messages to users.
  • Provide context when available: Call setSessionContext with any clinical information you have. Even partial context improves note quality.
  • Medication orders: If you send MedicationOrderKeys.kMedicationOrders under kOrdersInfo, include every required field per order and valid metadata values, or the SDK can reject the update.
  • Call setSessionContext after createSession: Wait for createSession to succeed before calling setSessionContext.
  • Handle background limitations: On iOS, you cannot start a recording while the app is in the background. Ensure your app is active before starting a recording.

FAQs

Session creation can fail for several reasons:Common causes:
  • SDK not initialized: Make sure you’ve called initialize() before creating a session
  • Invalid partner information: Check that your partner ID and provider information are correct
  • Network connectivity issues: Ensure the device has an active internet connection
  • Authentication token problems: Verify your token provider is returning valid tokens
  • Missing microphone permissions: Ensure your app has microphone access permissions
How to debug: Check the error returned in the completion handler’s .failure case. The error will indicate the specific reason for failure.
The session context may not update if:
  • Session not created: You must call createSession first and wait for it to succeed
  • Method not called: Ensure you’re actually calling setSessionContext after session creation
  • Invalid parameters: Check that specialty strings and codes match the expected formats. For medication orders, confirm every required field per order, valid metadata values, and at least one linked diagnosis code object
  • Network error: The update request may have failed due to connectivity issues
How to verify: Check the completion handler result. If it returns .failure, examine the error to understand what went wrong.
Yes, once createSession succeeds and returns a sessionId, you can start recording. However, it’s recommended to call setSessionContext first if you have clinical context available, as this improves note quality.The typical flow is:
  1. Create session → Get sessionId
  2. Set session context (optional but recommended)
  3. Start recording

Next steps

After you create a session and optionally set context, proceed to the Recording controls guide to learn how to start recording and manage the recording lifecycle.
Last modified on April 20, 2026