Creating a Visit
Na tej stronie
Overview
Dział zatytułowany „Overview”Wizyty można tworzyć z kilku miejsc w aplikacji. Każda ścieżka prowadzi przez visitApi.create() → create_visit.
Entry Points
Dział zatytułowany „Entry Points”flowchart LR subgraph Sources Appointment[From Appointment] Patient[From Patient Profile] Quick[Quick Visit Button] Workspace[From Workspace] end
subgraph API create[visitApi.create] end
subgraph Backend cmd[create_visit] end
Appointment --> create Patient --> create Quick --> create Workspace --> create create --> cmdQuick Visit
Dział zatytułowany „Quick Visit”Szybkie tworzenie wizyty z dowolnego miejsca.
// onCreateNew callback z useVisitSelectiononCreateNew() → handleCreateNew()
// Flow1. Open patient selector modal2. Select existing patient OR create new3. Create visit with patient_id4. Open visit in editor tabPatient Selection
Dział zatytułowany „Patient Selection”// PatientSelector componentonPatientSelect(patient: Patient) { // Option 1: Existing patient createVisit({ patient_id: patient.patient_id });
// Option 2: New patient // Opens NewPatientView first}From Appointment
Dział zatytułowany „From Appointment”Konwersja appointment → visit po przyjściu pacjenta.
// CalendarDayView or AppointmentCardonStartVisit(appointment: Appointment) { // Create visit linked to appointment await visitApi.create({ patient_id: appointment.patient_id, appointment_id: appointment.appointment_id, visit_type: appointment.appointment_type, visit_date: new Date().toISOString(), user_id: currentUser.user_id, });}Appointment Status Update
Dział zatytułowany „Appointment Status Update”sequenceDiagram participant User participant Calendar participant API as visitApi participant BE as Backend
User->>Calendar: Click "Start Visit" Calendar->>API: create({ appointment_id }) API->>BE: create_visit BE->>BE: Update appointment status BE-->>API: Visit created API->>Calendar: Navigate to visit editorFrom Patient Profile
Dział zatytułowany „From Patient Profile”Tworzenie wizyty bezpośrednio z profilu pacjenta.
// PatientProfileSummaryonCreateVisit() { // patient already selected await visitApi.create({ patient_id: selectedPatient.patient_id, user_id: currentUser.user_id, visit_status: 'draft', visit_date: new Date().toISOString(), });
// Navigate to Visits workspace with new visit open}From Workspace
Dział zatytułowany „From Workspace”Tworzenie nowego draftu w Workspace (Pracownia).
// useWorkspaceDraftActionshandleCreateDraft(patientId?: string, template?: VisitTemplate) { const visit = await visitApi.create({ patient_id: patientId, visit_status: 'draft', visit_type: template?.visitType || 'consultation', // Pre-fill from template if provided soap_subjective: template?.defaultSubjective, soap_objective: template?.defaultObjective, });
// Add to workspace drafts list fetchVisits();}Create Visit Payload
Dział zatytułowany „Create Visit Payload”interface CreateVisitInput { patient_id: string; // Required user_id: string; // Current vet visit_date?: string; // ISO date, defaults to now visit_type?: string; // consultation, vaccination, etc. visit_status?: VisitStatus; // draft (default)
// Optional pre-fill appointment_id?: string; soap_subjective?: string; soap_objective?: string; soap_assessment?: string; soap_plan?: string; internal_notes?: string;}Visit Types
Dział zatytułowany „Visit Types”| Type | Polish | Use Case |
|---|---|---|
consultation | Konsultacja | Default, general visit |
vaccination | Szczepienie | Vaccine administration |
surgery | Zabieg | Surgical procedure |
followup | Kontrola | Follow-up visit |
emergency | Nagły przypadek | Emergency visit |
grooming | Pielęgnacja | Grooming services |
other | Inne | Custom type |
After Creation
Dział zatytułowany „After Creation”Po utworzeniu wizyty:
- Tab opens - nowa zakładka w VisitsHubView
- Editor ready - CenterPanel z pustymi polami SOAP
- Audio ready - możliwość nagrywania
- AI ready - przygotowanie do generowania SOAP
// Post-create flowvisitApi.create(payload) → tabsController.openTabWithVisit(newVisit) → handleSelectVisit(newVisit) → editedData initialized → UI ready for editingValidation
Dział zatytułowany „Validation”Przed utworzeniem wizyty:
| Check | Requirement |
|---|---|
patient_id | Must exist in patients table |
user_id | Must be valid vet/admin |
| Session | Active session required |
| Permissions | User can create visits |
Po utworzeniu wizyty emitowany jest event:
// Tauri event'visit_created' → payload: { visit_id, patient_id }
// Listeners refresh their datauseVisitsList.fetchVisits()useWorkspaceData.fetchVisits()Related
Dział zatytułowany „Related”- Visits Overview - Module architecture
- SOAP Notes - SOAP format
- Visit Templates - Pre-fill templates
- Visits Commands - API reference