Create a Session
Before recording, create a session with patient and section information:- Include patient name, birthdate, and gender.
- Specify sections for which you want content generated (defaults are provided if omitted).
- Optionally, provide a session ID or let the SDK generate one.
- You can pass the multilingual parameter (Boolean) to indicate whether the session should be processed in multilingual mode:
true
: Enables multilingual processing for this session.false
: Defaults to English.- This setting applies per session and does not change mid-session.
- Handle errors using
SukiAmbientCoreError
.
Set Session Context (Optional but Recommended)
ThesetSessionContext
method allows setting patient, provider context and LOINC codes for section generation and (newly added) diagnosis information for an already created session.
All such data should instead be passed using the new setSessionContext
method.
context
: A dictionary of type[String: AnyHashable]
that may contain the following keys:SukiAmbientConstant.kPatientInfo
: Dictionary containing:SukiAmbientConstant.kBirthdate
: DateSukiAmbientConstant.kGender
: String
SukiAmbientConstant.kProviderContext
: Dictionary containing:SukiAmbientConstant.kSpeciality
: String
SukiAmbientConstant.kSections
: Array of dictionaries: Each withSukiAmbientConstant.kCode
andSukiAmbientConstant.kCodeType
(e.g., “loinc”)
SukiAmbientConstant.kDiagnosisInfo
: An Array of Dictionaries used to pass structured diagnosis context for the session.- Each dictionary may include:
SukiAmbientConstant.kDiagnosisNote
: String (Optional note related to the diagnosis)SukiAmbientConstant.kCodes
: [Dictionary] (Array of dictionaries) — must contain at least one valid diagnosis code.- Each dictionary may include:
SukiAmbientConstant.kCodeType
: String (e.g., “ICD-10”, “IMO”, “SNOMED”) (Required)SukiAmbientConstant.kCode
: String (Required)SukiAmbientConstant.kCodeDescription
: String (Optional)
- Each dictionary may include:
- Each dictionary may include:
- Can only be called after a session is successfully created.
- Pass only valid Specialities and LOINC codes.
- The session context dictionary should contain patient information such as birthdate (in yyyy-mm-dd format) and gender.
diagnosisNote
is optional.- Each code entry must include
codeType
andcode
. codeDescription
is optional but recommended for clarity.- Sections are no longer required, LOINC codes alone are sufficient, and the SDK will automatically generate the appropriate clinical sections based on the provided codes.
- The
setSessionContext
function now internally uses a PATCH API that supports partial updates.
Recording Controls
Start Recording- Always ensure the SDK is initialized and a session is created before calling these methods.
- Handle all errors using
SukiAmbientCoreError
. - iOS does not allow starting a recording in the background; handle
appIsNotActive
errors with user notifications if needed.
Session Status & Content Retrieval
Get Suggestion Generation Status
Get Generated Suggestions
Get Audio Transcript
Get Structured Data
ThegetStructuredData(for:onCompletion:)
method retrieves structured output data for a given recording ID. This includes structured diagnoses and other generated entities from the session.
Submit User Feedback
New
You can now submit user feedback for the AI-generated content.submitFeedback(_:for:onCompletion:)
to collect and submit user feedback on AI-generated content by using the QuantitativeFeedback
and QualitativeFeedback
structs.
This allows you to capture both quantitative (ratings) and qualitative (comments) feedback. Your feedback helps Suki improve the quality of its AI-generated content.
Function Signature
Required Data Structures
Submitting feedback requires you to construct aFeedbackSubmission
object. This object uses the FeedbackEntity
and QuantitativeFeedback
data structures.
Implementation Example
To submit feedback, you first create theFeedbackSubmission
object and then pass it to the submitFeedback
method along with the recordingId
.
The method is asynchronous. The completion handler returns a Result
containing either a success message with the unique feedbackId or an error if the submission failed.
- You can only provide feedback for each entity type once per session. The only currently supported entity is
.content
. - Submitting feedback for the same entity type a second time in the same session will be considered invalid.
Rating System
-
The
maxRating
must be greater than theminRating
. -
The rating must be within the inclusive range of
minRating
andmaxRating
. -
The
comments
string is optional and has a maximum length of 2000 characters.
-
You can configure any integer rating scale. For example, you can create a 1 to 5 scale by setting
minRating
to 1 andmaxRating
to 5, or a binary scale by setting the values to 0 and 1. - Suki recommends using a scale of 1 to 5 for ratings.
Key Points to Note:
- This code asynchronously fetches the content of the generated suggestions for the specified recording ID.
- The completion block contains either the generated suggestions or an error in case there’s an issue while fetching the content.
- Ensure that the SDK is initialized and the recording ID is valid before calling this method.
- All methods are asynchronous and require a valid recording ID.
- The completion block returns either the result or an error.
Clearing Sessions
Clear All Sessions- Use during user logout to clear all sessions.
- Do not call during an active session; this will throw an error.
Session Events & Delegates
Implement the delegate to listen for session events:Session Events enum:
Best Practices
- Always check SDK initialization and session state before calling methods.
- Handle all errors and provide user feedback, especially for background/foreground transitions.
- Use local notifications for important background errors.
- Store the unique session/recording ID for future operations.
Offline Mode
Network Buffer
New
:Instead of entering offline mode immediately when it detects a network issue, the mobile SDK now uses a 15-second buffer to handle temporary connection problems. This new mechanism gives you time to show a notification in your UI, like Connection unstable, before the session goes fully offline.- Continue recording audio locally on the device
- Store the audio and metadata securely on the device
- Automatically attempt to upload the stored data once the connection is restored
- Queue session events and sync them when connectivity returns
- Network interruptions or poor cellular/WiFi connectivity
- Temporary backend unavailability
- WebSocket connection drops during audio streaming
- Token-related authentication failures
- Device switching between networks (WiFi to cellular)
Important Notes:
- The SDK automatically manages offline/online transitions without manual intervention
- Audio quality and session integrity are maintained during offline periods
- Multiple offline sessions can be queued and uploaded when connectivity returns
- Local storage is encrypted and secure
- Battery optimization is considered during offline recording
Best Practices & Error Handling
- Always ensure the SDK is initialized and a session is created before calling recording methods.
- Handle
SukiAmbientCoreError
in all operations to provide robust error feedback. - For background recording, be aware of iOS limitations: recording cannot be started in the background, and background execution time is limited.
- Use local notifications to inform users if errors occur while the app is backgrounded.
- Store the unique recording/session ID for future operations such as status changes or retrieving content.