Command Handlers
Na tej stronie
Organizacja komend
Dział zatytułowany „Organizacja komend”Vista eksponuje 250 komend Tauri zorganizowanych domenowo:
src-tauri/src/commands/├── mod.rs # Re-exports├── auth.rs # 6 komend auth├── patients.rs # 8 komend pacjentów├── visits.rs # 10 komend wizyt├── appointments.rs # 7 komend kalendarza├── tasks.rs # 5 komend zadań├── reminders.rs # 4 komendy przypomnień├── settings.rs # 5 komend ustawień├── audio/│ ├── mod.rs│ ├── recording.rs # 4 komendy nagrywania│ └── stt/│ └── api.rs # 3 komendy STT├── ai/│ ├── mod.rs│ ├── chat.rs # 3 komendy czatu│ └── soap.rs # 2 komendy SOAP└── mlx_commands.rs # 3 komendy MLXAuthentication Commands
Dział zatytułowany „Authentication Commands”#[tauri::command]pub async fn login( db: State<'_, Database>, email: String, password: String,) -> Result<LoginResponse, String>| Param | Type | Description |
|---|---|---|
email | String | Email użytkownika |
password | String | Hasło (plain text → bcrypt verify) |
Returns: LoginResponse z user data i session token.
#[tauri::command]pub async fn logout( db: State<'_, Database>, session_id: String,) -> Result<(), String>login_biometric
Dział zatytułowany „login_biometric”#[tauri::command]pub async fn login_biometric( db: State<'_, Database>, user_id: String,) -> Result<LoginResponse, String>get_active_session
Dział zatytułowany „get_active_session”#[tauri::command]pub async fn get_active_session( db: State<'_, Database>,) -> Result<Option<Session>, String>refresh_session
Dział zatytułowany „refresh_session”#[tauri::command]pub async fn refresh_session( db: State<'_, Database>, session_id: String,) -> Result<Session, String>change_password
Dział zatytułowany „change_password”#[tauri::command]pub async fn change_password( db: State<'_, Database>, user_id: String, current_password: String, new_password: String,) -> Result<(), String>Patient Commands
Dział zatytułowany „Patient Commands”get_patient
Dział zatytułowany „get_patient”#[tauri::command]pub async fn get_patient( db: State<'_, Database>, patient_id: String,) -> Result<Patient, String>list_patients
Dział zatytułowany „list_patients”#[tauri::command]pub async fn list_patients( db: State<'_, Database>, page: i64, limit: i64, sort_by: Option<String>, sort_order: Option<String>,) -> Result<PaginatedPatients, String>search_patients
Dział zatytułowany „search_patients”#[tauri::command]pub async fn search_patients( db: State<'_, Database>, query: String,) -> Result<Vec<Patient>, String>Search logic:
- Szuka w
name,owner_name,chip_number - Case-insensitive
- Minimum 2 znaki
create_patient
Dział zatytułowany „create_patient”#[tauri::command]pub async fn create_patient( db: State<'_, Database>, data: CreatePatientRequest,) -> Result<Patient, String>| Field | Type | Required |
|---|---|---|
name | String | ✅ |
species | String | ✅ |
breed | Option<String> | |
owner_name | Option<String> | |
owner_phone | Option<String> | |
chip_number | Option<String> |
update_patient
Dział zatytułowany „update_patient”#[tauri::command]pub async fn update_patient( db: State<'_, Database>, patient_id: String, updates: PatientUpdate,) -> Result<Patient, String>delete_patient
Dział zatytułowany „delete_patient”#[tauri::command]pub async fn delete_patient( db: State<'_, Database>, patient_id: String,) -> Result<(), String>get_patient_visits
Dział zatytułowany „get_patient_visits”#[tauri::command]pub async fn get_patient_visits( db: State<'_, Database>, patient_id: String,) -> Result<Vec<Visit>, String>find_duplicate_patients
Dział zatytułowany „find_duplicate_patients”#[tauri::command]pub async fn find_duplicate_patients( db: State<'_, Database>, identity: PatientIdentity,) -> Result<Vec<Patient>, String>Visit Commands
Dział zatytułowany „Visit Commands”get_visit
Dział zatytułowany „get_visit”#[tauri::command]pub async fn get_visit( db: State<'_, Database>, visit_id: String,) -> Result<Visit, String>list_user_visits
Dział zatytułowany „list_user_visits”#[tauri::command]pub async fn list_user_visits( db: State<'_, Database>, user_id: String, filters: Option<VisitFilters>,) -> Result<Vec<Visit>, String>Filters:
| Field | Type | Description |
|---|---|---|
visit_type | Option<String> | consultation, emergency, etc. |
visit_status | Option<String> | draft, finalized, sent |
start_date | Option<String> | ISO date |
end_date | Option<String> | ISO date |
create_visit
Dział zatytułowany „create_visit”#[tauri::command]pub async fn create_visit( db: State<'_, Database>, patient_id: String, user_id: String, visit_data: CreateVisitRequest,) -> Result<Visit, String>update_visit_soap
Dział zatytułowany „update_visit_soap”#[tauri::command]pub async fn update_visit_soap( db: State<'_, Database>, visit_id: String, soap_data: SOAPUpdate, expected_version: i32,) -> Result<Visit, String>finalize_visit
Dział zatytułowany „finalize_visit”#[tauri::command]pub async fn finalize_visit( db: State<'_, Database>, visit_id: String,) -> Result<Visit, String>Zmienia visit_status z draft → finalized.
delete_visit
Dział zatytułowany „delete_visit”#[tauri::command]pub async fn delete_visit( db: State<'_, Database>, visit_id: String,) -> Result<(), String>export_visit_pdf
Dział zatytułowany „export_visit_pdf”#[tauri::command]pub async fn export_visit_pdf( db: State<'_, Database>, visit_id: String,) -> Result<String, String> // Returns file pathsend_visit_email
Dział zatytułowany „send_visit_email”#[tauri::command]pub async fn send_visit_email( db: State<'_, Database>, visit_id: String, recipient_email: String,) -> Result<(), String>get_visit_with_patient
Dział zatytułowany „get_visit_with_patient”#[tauri::command]pub async fn get_visit_with_patient( db: State<'_, Database>, visit_id: String,) -> Result<VisitWithPatient, String>share_visit
Dział zatytułowany „share_visit”#[tauri::command]pub async fn share_visit( db: State<'_, Database>, visit_id: String, shared_with_user_id: String, permissions: SharePermissions,) -> Result<VisitShare, String>Audio Commands
Dział zatytułowany „Audio Commands”save_audio_file
Dział zatytułowany „save_audio_file”#[tauri::command]pub async fn save_audio_file( db: State<'_, Database>, visit_id: String, audio_data: String, // Base64 encoded format: String, // "audio/webm", "audio/wav") -> Result<RecordingMetadata, String>get_audio_file
Dział zatytułowany „get_audio_file”#[tauri::command]pub async fn get_audio_file( db: State<'_, Database>, recording_id: String,) -> Result<Vec<u8>, String>delete_recording
Dział zatytułowany „delete_recording”#[tauri::command]pub async fn delete_recording( db: State<'_, Database>, recording_id: String,) -> Result<(), String>list_visit_recordings
Dział zatytułowany „list_visit_recordings”#[tauri::command]pub async fn list_visit_recordings( db: State<'_, Database>, visit_id: String,) -> Result<Vec<Recording>, String>STT Commands
Dział zatytułowany „STT Commands”start_transcription
Dział zatytułowany „start_transcription”#[tauri::command]pub async fn start_transcription( db: State<'_, Database>, recording_id: String, provider: String, // "auto", "libraxis", "mlx", "openai" language: String, // "pl", "en") -> Result<TranscriptionJob, String>get_transcription_status
Dział zatytułowany „get_transcription_status”#[tauri::command]pub async fn get_transcription_status( db: State<'_, Database>, job_id: String,) -> Result<TranscriptionStatus, String>Status values:
| Status | Description |
|---|---|
queued | W kolejce |
processing | Przetwarzanie |
completed | Gotowe |
failed | Błąd |
detect_best_stt_endpoint
Dział zatytułowany „detect_best_stt_endpoint”#[tauri::command]pub async fn detect_best_stt_endpoint() -> Result<SttEndpoint, String>Testuje dostępność providerów w kolejności: LibraxisAI → MLX → OpenAI.
AI Commands
Dział zatytułowany „AI Commands”chat_completion
Dział zatytułowany „chat_completion”#[tauri::command]pub async fn chat_completion( db: State<'_, Database>, messages: Vec<ChatMessage>, model: Option<String>, temperature: Option<f32>,) -> Result<ChatResponse, String>generate_soap
Dział zatytułowany „generate_soap”#[tauri::command]pub async fn generate_soap( db: State<'_, Database>, visit_id: String, transcript: String, patient_context: PatientContext, preferences: UserPreferences,) -> Result<SOAPNote, String>get_ai_suggestions
Dział zatytułowany „get_ai_suggestions”#[tauri::command]pub async fn get_ai_suggestions( db: State<'_, Database>, visit_id: String,) -> Result<Vec<AISuggestion>, String>Calendar Commands
Dział zatytułowany „Calendar Commands”list_vet_appointments
Dział zatytułowany „list_vet_appointments”#[tauri::command]pub async fn list_vet_appointments( db: State<'_, Database>, vet_id: String, start_date: String, end_date: String,) -> Result<Vec<Appointment>, String>create_appointment
Dział zatytułowany „create_appointment”#[tauri::command]pub async fn create_appointment( db: State<'_, Database>, data: CreateAppointmentRequest,) -> Result<Appointment, String>update_appointment_status
Dział zatytułowany „update_appointment_status”#[tauri::command]pub async fn update_appointment_status( db: State<'_, Database>, appointment_id: String, status: String, // "scheduled", "confirmed", "completed", "cancelled") -> Result<Appointment, String>check_appointment_conflicts
Dział zatytułowany „check_appointment_conflicts”#[tauri::command]pub async fn check_comprehensive_staff_conflicts( db: State<'_, Database>, veterinarian_id: String, date: String, start_time: String, duration_minutes: i32,) -> Result<ConflictResult, String>Conflict detection:
- Sprawdza istniejące appointments
- Sprawdza working hours
- Sprawdza time blocks (spotkania, przerwy)
- Sugeruje alternatywne sloty
convert_appointment_to_visit
Dział zatytułowany „convert_appointment_to_visit”#[tauri::command]pub async fn convert_appointment_to_visit( db: State<'_, Database>, appointment_id: String,) -> Result<Visit, String>get_user_working_hours
Dział zatytułowany „get_user_working_hours”#[tauri::command]pub async fn get_user_working_hours( db: State<'_, Database>, user_id: String,) -> Result<Vec<WorkingHours>, String>update_user_working_hours
Dział zatytułowany „update_user_working_hours”#[tauri::command]pub async fn update_user_working_hours( db: State<'_, Database>, user_id: String, hours: Vec<WorkingHoursUpdate>,) -> Result<(), String>MLX Commands
Dział zatytułowany „MLX Commands”get_mlx_health_detailed
Dział zatytułowany „get_mlx_health_detailed”#[tauri::command]pub async fn get_mlx_health_detailed() -> Result<MLXHealthReport, String>Returns:
struct MLXHealthReport { llm_status: ServiceStatus, llm_response_time: Option<u64>, llm_model: Option<String>, stt_status: ServiceStatus, stt_response_time: Option<u64>, tts_status: ServiceStatus, tts_response_time: Option<u64>, overall_health: bool,}check_mlx_llm
Dział zatytułowany „check_mlx_llm”#[tauri::command]pub async fn check_mlx_llm() -> Result<bool, String>check_mlx_stt
Dział zatytułowany „check_mlx_stt”#[tauri::command]pub async fn check_mlx_stt() -> Result<bool, String>Settings Commands
Dział zatytułowany „Settings Commands”get_user_preferences
Dział zatytułowany „get_user_preferences”#[tauri::command]pub async fn get_user_preferences( db: State<'_, Database>, user_id: String,) -> Result<UserPreferences, String>update_user_preferences
Dział zatytułowany „update_user_preferences”#[tauri::command]pub async fn update_user_preferences( db: State<'_, Database>, user_id: String, updates: UserPreferencesUpdate,) -> Result<UserPreferences, String>batch_update_user_preferences_session
Dział zatytułowany „batch_update_user_preferences_session”#[tauri::command]pub async fn batch_update_user_preferences_session( db: State<'_, Database>, user_id: String, preferences: BatchPreferencesUpdate,) -> Result<(), String>Używane przy onboardingu - zapisuje wszystkie preferencje naraz.
get_clinic_settings
Dział zatytułowany „get_clinic_settings”#[tauri::command]pub async fn get_clinic_settings( db: State<'_, Database>,) -> Result<ClinicSettings, String>update_clinic_settings
Dział zatytułowany „update_clinic_settings”#[tauri::command]pub async fn update_clinic_settings( db: State<'_, Database>, settings: ClinicSettingsUpdate,) -> Result<ClinicSettings, String>Error Handling Pattern
Dział zatytułowany „Error Handling Pattern”Wszystkie komendy używają spójnego wzorca obsługi błędów:
#[tauri::command]pub async fn example_command( db: State<'_, Database>, param: String,) -> Result<ResponseType, String> { // 1. Validation if param.is_empty() { return Err("Parameter cannot be empty".to_string()); }
// 2. Database operation with error mapping let result = sqlx::query_as!(/* ... */) .fetch_one(&db.pool) .await .map_err(|e| match e { sqlx::Error::RowNotFound => "Record not found".to_string(), _ => format!("Database error: {}", e), })?;
// 3. Return success Ok(result)}