A Swift package for voice-to-prescription functionality with floating UI components, audio recording, and real-time transcription capabilities for medical consultation applications.
EkaScribe empowers healthcare applications with advanced voice recording and transcription capabilities. It provides a seamless integration for medical consultation workflows, enabling doctors to record patient interactions and automatically generate prescriptions through AI-powered voice analysis.
Add the following permissions to your app’s Info.plist:
Copy
Ask AI
<key>NSMicrophoneUsageDescription</key><string>This app needs microphone access to record medical consultations</string><key>NSLocalNetworkUsageDescription</key><string>This app needs network access to upload and process audio recordings</string>
The central view model that manages the entire voice recording and processing workflow.
Copy
Ask AI
public class VoiceToRxViewModel: ObservableObject { @Published public var screenState: RecordConsultationState @Published public var filesProcessed: Set<String> @Published public var uploadedFiles: Set<String> public var sessionID: UUID? public var contextParams: VoiceToRxContextParams?}
public enum RecordConsultationState { case retry // Ready to retry after error case startRecording // Initial state, ready to start case listening(conversationType: VoiceConversationType) // Currently recording case paused // Recording paused case processing // Processing audio/generating prescription case resultDisplay(success: Bool) // Showing results case deletedRecording // Recording deleted}
public enum VoiceConversationType: String, CaseIterable { case conversation = "consultation" // Doctor-patient conversation case dictation // Direct prescription dictation}
Provides a system-wide floating interface for recording control, similar to FaceTime’s picture-in-picture.
Copy
Ask AI
public class FloatingVoiceToRxViewController: UIViewController { public static let shared = FloatingVoiceToRxViewController() public func showFloatingButton( viewModel: VoiceToRxViewModel, conversationType: VoiceConversationType, liveActivityDelegate: LiveActivityDelegate? ) async public func hideFloatingButton()}
Central configuration object for session parameters:
Copy
Ask AI
public class V2RxInitConfigurations { public static let shared = V2RxInitConfigurations() public var modelContainer: ModelContainer? public var ownerName: String? // Doctor name public var ownerOID: String? // Doctor ID public var ownerUUID: String? // Doctor UUID public var subOwnerOID: String? // Patient ID public var appointmentID: String? // Appointment identifier public var subOwnerName: String? // Patient name}
// These are typically configured automatically through your app's backend integration// Contact your backend team for the proper endpoint configuration
// Start a consultation recordingawait viewModel.startRecording(conversationType: .conversation)// The floating UI will appear automatically// User can control recording through the floating interface### Dictation Mode```swift// For direct prescription dictationawait viewModel.startRecording(conversationType: .dictation)// This mode is optimized for single-speaker medical dictation// Less background noise filtering, more focused on medical terminology
// Published properties for UI binding@Published public var screenState: RecordConsultationState@Published public var filesProcessed: Set<String>@Published public var uploadedFiles: Set<String>// Session informationpublic var sessionID: UUID?public var contextParams: VoiceToRxContextParams?
public class V2RxInitConfigurations { public static let shared: V2RxInitConfigurations // Core identifiers public var ownerName: String? // Doctor name public var ownerOID: String? // Doctor OID public var ownerUUID: String? // Doctor UUID public var subOwnerOID: String? // Patient OID public var subOwnerName: String? // Patient name public var appointmentID: String? // Appointment ID // Data context public var modelContainer: ModelContainer?}
public class AuthTokenHolder { public static let shared: AuthTokenHolder public var authToken: String? public var refreshToken: String? public var bid: String?}
Symptoms: onCreateVoiceToRxSession not called or called with nil valuesSolutions:
Copy
Ask AI
// Verify all required configurations are setlet config = V2RxInitConfigurations.sharedassert(config.ownerOID != nil, "Doctor OID is required")assert(config.subOwnerOID != nil, "Patient OID is required")assert(config.appointmentID != nil, "Appointment ID is required")// Check authenticationassert(AuthTokenHolder.shared.authToken != nil, "Auth token is required")
We welcome contributions! Please see our contributing guidelines for details on how to submit pull requests, report issues, and suggest improvements.Made with ❤️ by the Eka.Care team