{"openapi":"3.0.3","info":{"title":"AEM Medical Assistance API","version":"0.1.0","description":"Draft OpenAPI specification for the AEM proof of concept. It supports the member mobile app, the web platform for operators, doctors, medical coordinators and supervisors, AI-assisted pre-triage, chat, resource assignment, geolocation, notifications and auditability.\n"},"servers":[{"url":"https://api.aem-poc.local/v1"}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Auth"},{"name":"Members"},{"name":"Medical Requests"},{"name":"AI Triage"},{"name":"Chats"},{"name":"Staff"},{"name":"Resources"},{"name":"Notifications"},{"name":"Audit"}],"paths":{"/auth/member/first-access":{"post":{"tags":["Auth"],"summary":"Request temporary credentials for a member first access","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FirstAccessRequest"}}}},"responses":{"202":{"description":"Temporary credentials requested","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OperationAccepted"}}}}}}},"/auth/login":{"post":{"tags":["Auth"],"summary":"Login for members and internal users","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}}},"responses":{"200":{"description":"Authenticated session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthTokenResponse"}}}}}}},"/auth/password/forgot":{"post":{"tags":["Auth"],"summary":"Request password recovery email","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForgotPasswordRequest"}}}},"responses":{"202":{"description":"Recovery requested"}}}},"/auth/password/reset":{"post":{"tags":["Auth"],"summary":"Reset password with token","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResetPasswordRequest"}}}},"responses":{"204":{"description":"Password reset"}}}},"/auth/password/change":{"post":{"tags":["Auth"],"summary":"Change authenticated user's password","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChangePasswordRequest"}}}},"responses":{"204":{"description":"Password changed"}}}},"/auth/me":{"get":{"tags":["Auth"],"summary":"Get authenticated user profile","responses":{"200":{"description":"Current user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CurrentUser"}}}}}}},"/members/me":{"get":{"tags":["Members"],"summary":"Get current member profile","responses":{"200":{"description":"Member profile","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberProfile"}}}}}}},"/members/me/addresses":{"get":{"tags":["Members"],"summary":"List current member frequent addresses","responses":{"200":{"description":"Frequent addresses","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FrequentAddress"}}}}}}},"post":{"tags":["Members"],"summary":"Create current member frequent address","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FrequentAddressCreate"}}}},"responses":{"201":{"description":"Created address","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FrequentAddress"}}}}}}},"/members/me/addresses/{addressId}":{"put":{"tags":["Members"],"summary":"Update frequent address","parameters":[{"$ref":"#/components/parameters/AddressId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FrequentAddressCreate"}}}},"responses":{"200":{"description":"Updated address","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FrequentAddress"}}}}}},"delete":{"tags":["Members"],"summary":"Delete frequent address","parameters":[{"$ref":"#/components/parameters/AddressId"}],"responses":{"204":{"description":"Deleted"}}}},"/medical-requests":{"post":{"tags":["Medical Requests"],"summary":"Create emergency, medical consultation or non-urgent mobile request","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequestCreate"}}}},"responses":{"201":{"description":"Created request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequest"}}}}}},"get":{"tags":["Medical Requests"],"summary":"List medical requests visible to current user","parameters":[{"name":"type","in":"query","schema":{"$ref":"#/components/schemas/RequestType"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/RequestStatus"}},{"name":"triageCode","in":"query","schema":{"$ref":"#/components/schemas/TriageCode"}}],"responses":{"200":{"description":"Medical requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequestList"}}}}}}},"/medical-requests/{requestId}":{"get":{"tags":["Medical Requests"],"summary":"Get medical request detail","parameters":[{"$ref":"#/components/parameters/RequestId"}],"responses":{"200":{"description":"Medical request detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequestDetail"}}}}}}},"/medical-requests/{requestId}/status":{"patch":{"tags":["Medical Requests"],"summary":"Update request status","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestStatusUpdate"}}}},"responses":{"200":{"description":"Updated request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequest"}}}}}}},"/medical-requests/{requestId}/location":{"put":{"tags":["Medical Requests"],"summary":"Update or confirm request location","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationUpdate"}}}},"responses":{"200":{"description":"Updated location","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestLocation"}}}}}}},"/medical-requests/{requestId}/cancel":{"post":{"tags":["Medical Requests"],"summary":"Cancel request","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string"}}}}}},"responses":{"200":{"description":"Cancelled request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequest"}}}}}}},"/medical-requests/{requestId}/triage-sessions":{"post":{"tags":["AI Triage"],"summary":"Start AI-assisted pre-triage for a request","parameters":[{"$ref":"#/components/parameters/RequestId"}],"responses":{"201":{"description":"Started triage session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageSession"}}}}}}},"/triage-sessions/{triageSessionId}/messages":{"post":{"tags":["AI Triage"],"summary":"Send member message to AI-assisted pre-triage","parameters":[{"$ref":"#/components/parameters/TriageSessionId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageMessageCreate"}}}},"responses":{"200":{"description":"AI response and updated session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageTurnResponse"}}}}}}},"/triage-sessions/{triageSessionId}/summary":{"get":{"tags":["AI Triage"],"summary":"Get structured triage summary","parameters":[{"$ref":"#/components/parameters/TriageSessionId"}],"responses":{"200":{"description":"Triage summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageSummary"}}}}}}},"/triage-sessions/{triageSessionId}/escalate":{"post":{"tags":["AI Triage"],"summary":"Escalate triage session to human staff","parameters":[{"$ref":"#/components/parameters/TriageSessionId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EscalationCreate"}}}},"responses":{"200":{"description":"Escalated triage session","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageSession"}}}}}}},"/chats":{"post":{"tags":["Chats"],"summary":"Create or open chat thread for a request","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatThreadCreate"}}}},"responses":{"201":{"description":"Chat thread","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatThread"}}}}}}},"/chats/{chatThreadId}/messages":{"get":{"tags":["Chats"],"summary":"List chat messages","parameters":[{"$ref":"#/components/parameters/ChatThreadId"}],"responses":{"200":{"description":"Chat messages","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"}}}}}}}}},"post":{"tags":["Chats"],"summary":"Send chat message","parameters":[{"$ref":"#/components/parameters/ChatThreadId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatMessageCreate"}}}},"responses":{"201":{"description":"Sent message","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatMessage"}}}}}}},"/chats/{chatThreadId}/assign":{"post":{"tags":["Chats"],"summary":"Assign a staff user to a chat thread","parameters":[{"$ref":"#/components/parameters/ChatThreadId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["staffUserId"],"properties":{"staffUserId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Updated chat thread","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatThread"}}}}}}},"/staff/requests/queue":{"get":{"tags":["Staff"],"summary":"List requests pending staff action","parameters":[{"name":"type","in":"query","schema":{"$ref":"#/components/schemas/RequestType"}},{"name":"triageCode","in":"query","schema":{"$ref":"#/components/schemas/TriageCode"}},{"name":"assignedToMe","in":"query","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Staff request queue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequestList"}}}}}}},"/staff/requests/{requestId}/assign-staff":{"post":{"tags":["Staff"],"summary":"Assign operator, doctor or medical coordinator to a request","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["staffUserId","role"],"properties":{"staffUserId":{"type":"string","format":"uuid"},"role":{"$ref":"#/components/schemas/Role"}}}}}},"responses":{"200":{"description":"Updated request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequest"}}}}}}},"/staff/requests/{requestId}/classify":{"post":{"tags":["Staff"],"summary":"Confirm or change triage classification","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriageClassificationUpdate"}}}},"responses":{"200":{"description":"Updated request classification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalRequest"}}}}}}},"/staff/requests/{requestId}/assign-resource":{"post":{"tags":["Staff"],"summary":"Assign ambulance or non-urgent vehicle","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResourceAssignmentCreate"}}}},"responses":{"201":{"description":"Resource assignment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResourceAssignment"}}}}}}},"/staff/requests/{requestId}/medical-decision":{"post":{"tags":["Staff"],"summary":"Record doctor or medical coordinator decision","parameters":[{"$ref":"#/components/parameters/RequestId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalDecisionCreate"}}}},"responses":{"201":{"description":"Medical decision","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MedicalDecision"}}}}}}},"/staff/dashboard/overview":{"get":{"tags":["Staff"],"summary":"Get operational overview for supervisors","responses":{"200":{"description":"Operational overview","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OperationalOverview"}}}}}}},"/staff/users":{"get":{"tags":["Staff"],"summary":"List internal users","responses":{"200":{"description":"Staff users","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StaffUser"}}}}}}},"post":{"tags":["Staff"],"summary":"Create internal user","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StaffUserCreate"}}}},"responses":{"201":{"description":"Created staff user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StaffUser"}}}}}}},"/staff/users/{userId}":{"patch":{"tags":["Staff"],"summary":"Update internal user","parameters":[{"$ref":"#/components/parameters/UserId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StaffUserUpdate"}}}},"responses":{"200":{"description":"Updated staff user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StaffUser"}}}}}}},"/staff/users/{userId}/deactivate":{"post":{"tags":["Staff"],"summary":"Deactivate internal user","parameters":[{"$ref":"#/components/parameters/UserId"}],"responses":{"200":{"description":"Deactivated staff user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StaffUser"}}}}}}},"/staff/users/{userId}/reset-password":{"post":{"tags":["Staff"],"summary":"Reset internal user password","parameters":[{"$ref":"#/components/parameters/UserId"}],"responses":{"202":{"description":"Temporary credentials sent"}}}},"/resources":{"get":{"tags":["Resources"],"summary":"List ambulances and non-urgent vehicles","parameters":[{"name":"type","in":"query","schema":{"$ref":"#/components/schemas/ResourceType"}},{"name":"status","in":"query","schema":{"$ref":"#/components/schemas/ResourceStatus"}}],"responses":{"200":{"description":"Resources","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Resource"}}}}}}},"post":{"tags":["Resources"],"summary":"Create resource","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResourceCreate"}}}},"responses":{"201":{"description":"Created resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Resource"}}}}}}},"/resources/{resourceId}/status":{"patch":{"tags":["Resources"],"summary":"Update resource status","parameters":[{"$ref":"#/components/parameters/ResourceId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"$ref":"#/components/schemas/ResourceStatus"}}}}}},"responses":{"200":{"description":"Updated resource","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Resource"}}}}}}},"/resources/{resourceId}/location":{"put":{"tags":["Resources"],"summary":"Update resource location","parameters":[{"$ref":"#/components/parameters/ResourceId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LocationUpdate"}}}},"responses":{"200":{"description":"Updated resource location","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GeoLocation"}}}}}}},"/notifications":{"get":{"tags":["Notifications"],"summary":"List current user's notifications","responses":{"200":{"description":"Notifications","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}}}}}}}}}},"/notifications/{notificationId}/read":{"post":{"tags":["Notifications"],"summary":"Mark notification as read","parameters":[{"$ref":"#/components/parameters/NotificationId"}],"responses":{"204":{"description":"Marked as read"}}}},"/audit-logs":{"get":{"tags":["Audit"],"summary":"List audit logs","parameters":[{"name":"requestId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"actorUserId","in":"query","schema":{"type":"string","format":"uuid"}},{"name":"action","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Audit logs","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/AuditLog"}}}}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"UserId":{"name":"userId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"AddressId":{"name":"addressId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"RequestId":{"name":"requestId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"TriageSessionId":{"name":"triageSessionId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"ChatThreadId":{"name":"chatThreadId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"ResourceId":{"name":"resourceId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"NotificationId":{"name":"notificationId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}},"schemas":{"Role":{"type":"string","enum":["MEMBER","OPERATOR","DOCTOR","MEDICAL_COORDINATOR","SUPERVISOR","ADMIN"]},"UserStatus":{"type":"string","enum":["PENDING_FIRST_ACCESS","ACTIVE","TEMPORARILY_LOCKED","INACTIVE"]},"RequestType":{"type":"string","enum":["EMERGENCY","MEDICAL_CONSULTATION","NON_URGENT_MOBILE"]},"TriageCode":{"type":"string","enum":["CODE_1","CODE_2","CODE_3","UNKNOWN"],"description":"CODE_1 emergency, CODE_2 urgency, CODE_3 non-urgent consultation."},"RequestStatus":{"type":"string","enum":["DRAFT","ACTIVE","WAITING_FOR_OPERATOR","WAITING_FOR_DOCTOR","IN_AI_TRIAGE","IN_HUMAN_TRIAGE","RESOURCE_PENDING","RESOURCE_ASSIGNED","EN_ROUTE","ON_SITE","RESOLVED","CANCELLED","CLOSED"]},"ResourceType":{"type":"string","enum":["AMBULANCE","NON_URGENT_VEHICLE"]},"ResourceStatus":{"type":"string","enum":["AVAILABLE","BUSY","OUT_OF_SERVICE"]},"SenderType":{"type":"string","enum":["MEMBER","STAFF","AI_ASSISTANT","SYSTEM"]},"OperationAccepted":{"type":"object","properties":{"accepted":{"type":"boolean","example":true},"message":{"type":"string"}}},"FirstAccessRequest":{"type":"object","required":["nationalId"],"properties":{"nationalId":{"type":"string"}}},"LoginRequest":{"type":"object","required":["username","password"],"properties":{"username":{"type":"string","description":"National ID or email"},"password":{"type":"string","format":"password"}}},"AuthTokenResponse":{"type":"object","required":["accessToken","refreshToken","expiresIn","user"],"properties":{"accessToken":{"type":"string"},"refreshToken":{"type":"string"},"expiresIn":{"type":"integer","example":3600},"user":{"$ref":"#/components/schemas/CurrentUser"}}},"ForgotPasswordRequest":{"type":"object","required":["username"],"properties":{"username":{"type":"string"}}},"ResetPasswordRequest":{"type":"object","required":["token","newPassword"],"properties":{"token":{"type":"string"},"newPassword":{"type":"string","format":"password"}}},"ChangePasswordRequest":{"type":"object","required":["currentPassword","newPassword"],"properties":{"currentPassword":{"type":"string","format":"password"},"newPassword":{"type":"string","format":"password"}}},"CurrentUser":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"email":{"type":"string","format":"email"},"nationalId":{"type":"string"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/Role"}},"status":{"$ref":"#/components/schemas/UserStatus"}}},"MemberProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"memberNumber":{"type":"string"},"fullName":{"type":"string"},"phoneNumber":{"type":"string"},"emergencyContactName":{"type":"string"},"emergencyContactPhone":{"type":"string"},"status":{"type":"string","enum":["ACTIVE","SUSPENDED","CANCELLED"]}}},"StaffUser":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"fullName":{"type":"string"},"nationalId":{"type":"string"},"email":{"type":"string","format":"email"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/Role"}},"status":{"$ref":"#/components/schemas/UserStatus"}}},"StaffUserCreate":{"type":"object","required":["fullName","nationalId","email","roles"],"properties":{"fullName":{"type":"string"},"nationalId":{"type":"string"},"email":{"type":"string","format":"email"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/Role"}}}},"StaffUserUpdate":{"type":"object","properties":{"fullName":{"type":"string"},"email":{"type":"string","format":"email"},"roles":{"type":"array","items":{"$ref":"#/components/schemas/Role"}},"status":{"$ref":"#/components/schemas/UserStatus"}}},"GeoLocation":{"type":"object","required":["latitude","longitude"],"properties":{"latitude":{"type":"number","format":"double"},"longitude":{"type":"number","format":"double"},"accuracyMeters":{"type":"number","format":"double","nullable":true},"capturedAt":{"type":"string","format":"date-time","nullable":true}}},"LocationUpdate":{"type":"object","required":["source","latitude","longitude"],"properties":{"source":{"type":"string","enum":["GPS","MANUAL","FREQUENT_ADDRESS"]},"latitude":{"type":"number","format":"double"},"longitude":{"type":"number","format":"double"},"accuracyMeters":{"type":"number","format":"double","nullable":true},"addressText":{"type":"string"},"frequentAddressId":{"type":"string","format":"uuid","nullable":true}}},"RequestLocation":{"allOf":[{"$ref":"#/components/schemas/LocationUpdate"},{"type":"object","properties":{"id":{"type":"string","format":"uuid"}}}]},"FrequentAddress":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"label":{"type":"string","example":"Home"},"addressText":{"type":"string"},"latitude":{"type":"number","format":"double"},"longitude":{"type":"number","format":"double"},"isDefault":{"type":"boolean"},"isValidated":{"type":"boolean"}}},"FrequentAddressCreate":{"type":"object","required":["label","addressText","latitude","longitude"],"properties":{"label":{"type":"string"},"addressText":{"type":"string"},"latitude":{"type":"number","format":"double"},"longitude":{"type":"number","format":"double"},"isDefault":{"type":"boolean","default":false}}},"MedicalRequestCreate":{"type":"object","required":["type","symptomDescription"],"properties":{"type":{"$ref":"#/components/schemas/RequestType"},"symptomDescription":{"type":"string"},"location":{"$ref":"#/components/schemas/LocationUpdate"},"initialTriageCode":{"$ref":"#/components/schemas/TriageCode"},"source":{"type":"string","enum":["MOBILE_APP","PHONE_CALL","BACKOFFICE"],"default":"MOBILE_APP"}}},"MedicalRequest":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"memberId":{"type":"string","format":"uuid"},"type":{"$ref":"#/components/schemas/RequestType"},"triageCode":{"$ref":"#/components/schemas/TriageCode"},"status":{"$ref":"#/components/schemas/RequestStatus"},"symptomDescription":{"type":"string"},"currentLocation":{"$ref":"#/components/schemas/RequestLocation"},"assignedOperatorId":{"type":"string","format":"uuid","nullable":true},"assignedDoctorId":{"type":"string","format":"uuid","nullable":true},"assignedCoordinatorId":{"type":"string","format":"uuid","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"MedicalRequestList":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/MedicalRequest"}},"total":{"type":"integer"}}},"MedicalRequestDetail":{"allOf":[{"$ref":"#/components/schemas/MedicalRequest"},{"type":"object","properties":{"statusHistory":{"type":"array","items":{"$ref":"#/components/schemas/RequestStatusHistory"}},"triageSummary":{"$ref":"#/components/schemas/TriageSummary"},"activeChatThread":{"$ref":"#/components/schemas/ChatThread"},"resourceAssignments":{"type":"array","items":{"$ref":"#/components/schemas/ResourceAssignment"}},"medicalDecisions":{"type":"array","items":{"$ref":"#/components/schemas/MedicalDecision"}}}}]},"RequestStatusUpdate":{"type":"object","required":["status"],"properties":{"status":{"$ref":"#/components/schemas/RequestStatus"},"reason":{"type":"string"}}},"RequestStatusHistory":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"previousStatus":{"$ref":"#/components/schemas/RequestStatus"},"newStatus":{"$ref":"#/components/schemas/RequestStatus"},"changedByUserId":{"type":"string","format":"uuid"},"reason":{"type":"string"},"changedAt":{"type":"string","format":"date-time"}}},"TriageSession":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["ACTIVE","ESCALATED","COMPLETED","CANCELLED"]},"preliminaryCode":{"$ref":"#/components/schemas/TriageCode"},"escalationRequired":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"}}},"TriageMessageCreate":{"type":"object","required":["message"],"properties":{"message":{"type":"string"}}},"TriageTurnResponse":{"type":"object","properties":{"assistantMessage":{"type":"string"},"detectedRedFlags":{"type":"array","items":{"type":"string"}},"suggestedAction":{"type":"string","enum":["CONTINUE_TRIAGE","CALL_OPERATOR_NOW","ESCALATE_TO_DOCTOR","WAIT_FOR_STAFF_REVIEW"]},"session":{"$ref":"#/components/schemas/TriageSession"}}},"TriageSummary":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"symptomMain":{"type":"string"},"onset":{"type":"string"},"intensity":{"type":"string"},"location":{"type":"string"},"radiation":{"type":"string"},"evolution":{"type":"string"},"associatedSymptoms":{"type":"array","items":{"type":"string"}},"relevantHistory":{"type":"array","items":{"type":"string"}},"detectedRedFlags":{"type":"array","items":{"type":"string"}},"preliminaryCode":{"$ref":"#/components/schemas/TriageCode"},"confidence":{"type":"number","format":"double"},"generatedAt":{"type":"string","format":"date-time"}}},"EscalationCreate":{"type":"object","required":["reason"],"properties":{"reason":{"type":"string","enum":["POSSIBLE_CODE_1","CLINICAL_RISK","INSUFFICIENT_INFORMATION","MEMBER_REQUEST","STAFF_DECISION","AI_UNCERTAINTY"]},"notes":{"type":"string"},"targetRole":{"$ref":"#/components/schemas/Role"}}},"ChatThreadCreate":{"type":"object","required":["requestId"],"properties":{"requestId":{"type":"string","format":"uuid"},"initialStaffRole":{"$ref":"#/components/schemas/Role"}}},"ChatThread":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["OPEN","WAITING_FOR_MEMBER","WAITING_FOR_STAFF","CLOSED"]},"assignedStaffUserId":{"type":"string","format":"uuid","nullable":true},"createdAt":{"type":"string","format":"date-time"},"closedAt":{"type":"string","format":"date-time","nullable":true}}},"ChatMessageCreate":{"type":"object","required":["body"],"properties":{"body":{"type":"string"}}},"ChatMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"chatThreadId":{"type":"string","format":"uuid"},"senderType":{"$ref":"#/components/schemas/SenderType"},"senderUserId":{"type":"string","format":"uuid","nullable":true},"body":{"type":"string"},"sentAt":{"type":"string","format":"date-time"},"readAt":{"type":"string","format":"date-time","nullable":true}}},"TriageClassificationUpdate":{"type":"object","required":["triageCode","reason"],"properties":{"triageCode":{"$ref":"#/components/schemas/TriageCode"},"reason":{"type":"string"}}},"Resource":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"code":{"type":"string"},"type":{"$ref":"#/components/schemas/ResourceType"},"status":{"$ref":"#/components/schemas/ResourceStatus"},"currentLocation":{"$ref":"#/components/schemas/GeoLocation"}}},"ResourceCreate":{"type":"object","required":["code","type"],"properties":{"code":{"type":"string"},"type":{"$ref":"#/components/schemas/ResourceType"}}},"ResourceAssignmentCreate":{"type":"object","required":["resourceId"],"properties":{"resourceId":{"type":"string","format":"uuid"},"notes":{"type":"string"}}},"ResourceAssignment":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","format":"uuid"},"resourceId":{"type":"string","format":"uuid"},"assignedByUserId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["ACTIVE","REASSIGNED","COMPLETED","CANCELLED"]},"assignedAt":{"type":"string","format":"date-time"},"releasedAt":{"type":"string","format":"date-time","nullable":true}}},"MedicalDecisionCreate":{"type":"object","required":["action","notes"],"properties":{"action":{"type":"string","enum":["REMOTE_RESOLUTION","FOLLOW_UP","DISPATCH_AMBULANCE","DISPATCH_NON_URGENT_VEHICLE","REQUEST_MORE_INFORMATION","RECLASSIFY_AS_EMERGENCY","CLOSE_CASE"]},"notes":{"type":"string"},"resultingTriageCode":{"$ref":"#/components/schemas/TriageCode"}}},"MedicalDecision":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"requestId":{"type":"string","format":"uuid"},"doctorUserId":{"type":"string","format":"uuid"},"action":{"type":"string"},"notes":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"OperationalOverview":{"type":"object","properties":{"activeEmergencies":{"type":"integer"},"activeMedicalConsultations":{"type":"integer"},"activeNonUrgentMobileRequests":{"type":"integer"},"availableAmbulances":{"type":"integer"},"busyAmbulances":{"type":"integer"},"availableNonUrgentVehicles":{"type":"integer"},"averageEmergencyResponseMinutes":{"type":"number","format":"double"},"lastUpdatedAt":{"type":"string","format":"date-time"}}},"Notification":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"requestId":{"type":"string","format":"uuid","nullable":true},"title":{"type":"string"},"body":{"type":"string"},"channel":{"type":"string","enum":["PUSH","EMAIL","IN_APP"]},"readAt":{"type":"string","format":"date-time","nullable":true},"createdAt":{"type":"string","format":"date-time"}}},"AuditLog":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"actorUserId":{"type":"string","format":"uuid","nullable":true},"requestId":{"type":"string","format":"uuid","nullable":true},"entityType":{"type":"string"},"entityId":{"type":"string","format":"uuid"},"action":{"type":"string"},"previousValue":{"type":"object","nullable":true},"newValue":{"type":"object","nullable":true},"createdAt":{"type":"string","format":"date-time"}}}}}}