From 2890751531024bedad04007b38b7a1ad7f6d3307 Mon Sep 17 00:00:00 2001 From: AntonioRodriguezRuiz Date: Mon, 6 Jan 2025 19:50:37 +0100 Subject: [PATCH] chore: updated openapi --- docs/alert-openapi.yaml | 80 - src/config/openapi.rs | 4 +- static/openapi.html | 2 +- static/openapi.yaml | 3854 +++++++++++++++++++++------------------ sync-openapi.sh | 1 - 5 files changed, 2034 insertions(+), 1907 deletions(-) delete mode 100644 docs/alert-openapi.yaml diff --git a/docs/alert-openapi.yaml b/docs/alert-openapi.yaml deleted file mode 100644 index b279268..0000000 --- a/docs/alert-openapi.yaml +++ /dev/null @@ -1,80 +0,0 @@ -openapi: 3.0.0 -info: - title: Microservicio Template - version: 1.0.0 - description: Template para microservicios - -servers: - - url: http://localhost:3004/api/v1 - description: Development server - - url: /api/v1 - description: Production server - -paths: - /alert/alert-appointment: - post: - summary: Enviar alerta de cita médica - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - email: - type: string - format: email - clinic: - type: string - dateAppointment: - type: string - format: date-time - doctorName: - type: string - responses: - '200': - description: Correo enviado y programado exitosamente - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: Email sent and scheduled successfully - '400': - description: Campos requeridos faltantes - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: Missing required fields - '500': - description: Error interno del servidor - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: Failed to send email - '503': - description: Servicio de correo temporalmente no disponible - content: - application/json: - schema: - type: object - properties: - fallback: - type: boolean - example: true - message: - type: string - example: Email service temporarily unavailable. Please try again later. - -components: - # Aquí irán tus componentes reutilizables diff --git a/src/config/openapi.rs b/src/config/openapi.rs index a0f0af0..f1ff9bc 100644 --- a/src/config/openapi.rs +++ b/src/config/openapi.rs @@ -112,7 +112,7 @@ impl OpenApiMerger {
diff --git a/static/openapi.html b/static/openapi.html index cd2c3d5..1e50212 100644 --- a/static/openapi.html +++ b/static/openapi.html @@ -25,4 +25,4 @@ - + \ No newline at end of file diff --git a/static/openapi.yaml b/static/openapi.yaml index 5cc7c80..9d696a2 100644 --- a/static/openapi.yaml +++ b/static/openapi.yaml @@ -6,208 +6,63 @@ info: servers: - url: / paths: - /api/v1/users: + /api/v1/staff/register: post: tags: - - Users - summary: Create User - description: Creates a new user with specified roles, email, and associated IDs for doctor or patient. + - staff + summary: Register a new doctor requestBody: content: application/json: schema: type: object properties: - email: - example: new_user@example.com - description: Email address of the user. + name: type: string - password: - example: securepassword123 - description: User's password. + surname: type: string - roles: - example: - - admin - - doctor - description: List of roles assigned to the user. - type: array - items: - type: string - doctorid: - nullable: true - example: doctor123 - description: Unique ID if the user is a doctor. + specialty: type: string - patientid: - nullable: true - example: patient456 - description: Unique ID if the user is a patient. + dni: + type: string + clinicId: + type: string + password: + type: string + email: type: string - required: - - email - - password required: true responses: '201': - description: User created successfully - content: - application/json: - schema: - type: object - properties: - email: - example: new_user@example.com - type: string - roles: - example: - - admin - - doctor - type: array - items: - type: string - doctorid: - nullable: true - example: doctor123 - type: string - patientid: - nullable: true - example: patient456 - type: string + description: Doctor created successfully '400': - description: Bad request - missing fields or user already exists - content: - application/json: - schema: - example: - email: Email is required - password: Password is required - type: object - additionalProperties: - type: string - '401': - description: Unauthorized - token missing or invalid - content: - application/json: - schema: - type: object - properties: - message: - example: No token provided - type: string - '403': - description: Forbidden - insufficient permissions - content: - application/json: - schema: - type: object - properties: - message: - example: Forbidden - type: string - '500': - $ref: '#/components/responses/ServerError' + description: Bad request security: - cookieAuth: [] - /api/v1/users/{id}: + /api/v1/staff/{doctorId}: get: tags: - - Users - summary: Retrieve user information - description: Retrieve user details by user ID. Requires the user to be the owner or have specific roles. + - staff + summary: Get doctor by ID parameters: - in: path - name: id - description: ID of the user to retrieve + name: doctorId required: true schema: type: string style: simple responses: '200': - description: User retrieved successfully - content: - application/json: - schema: - type: object - properties: - _id: - type: string - email: - type: string - username: - type: string - roles: - type: array - items: - type: string - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - example: - _id: 617f1f77bcf86cd799439011 - createdAt: 2023-01-01T12:00:00Z - email: user@example.com - roles: - - user - updatedAt: 2023-01-10T12:00:00Z - username: johndoe - '401': - description: Unautenticated - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Token not valid - '403': - description: Unauthorized access - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Forbidden + description: Doctor retrieved successfully '404': - description: User not found - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: User not found - '500': - description: Internal server error - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Internal server error + description: Doctor not found put: tags: - - Users - summary: Update user information - description: Update user details by user ID. Requires the user to be the owner or have specific roles. + - staff + summary: Update doctor speciality parameters: - in: path - name: id - description: ID of the user to update + name: doctorId required: true schema: type: string @@ -218,123 +73,64 @@ paths: schema: type: object properties: - email: - example: user@example.com - description: Email address of the user. - type: string - password: - example: securepassword123 - description: User's password. + specialty: type: string - roles: - example: - - admin - - doctor - description: List of roles assigned to the user. - type: array - items: - type: string required: true responses: '200': - description: User updated successfully - content: - application/json: - schema: - type: object - properties: - _id: - type: string - email: - type: string - roles: - type: array - items: - type: string - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - example: - _id: 617f1f77bcf86cd799439011 - createdAt: 2023-01-01T12:00:00Z - email: user@example.com - roles: - - doctor - updatedAt: 2023-01-10T12:00:00Z - '400': - description: Bad request - missing fields or user already exists - content: - application/json: - schema: - example: - email: Email is required - password: Password is required - type: object - additionalProperties: - type: string - '401': - description: Unautenticated - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Token not valid - '403': - description: Unauthorized access - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Forbidden + description: Speciality updated successfully '404': - description: User not found - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: User not found - '500': - description: Internal server error - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Internal server error + description: Doctor not found + security: + - cookieAuth: [] delete: tags: - - Users - summary: Deletes user - description: Delete user by user ID. Requires the user to have specific roles. + - staff + summary: Delete a doctor parameters: - in: path - name: id - description: ID of the user to update + name: doctorId required: true schema: type: string style: simple responses: '204': - description: User deleted successfully + description: Doctor deleted successfully + '404': + description: Doctor not found + security: + - cookieAuth: [] + /api/v1/staff/clinic/{clinicId}/speciality/{speciality}: + get: + tags: + - staff + summary: Get doctors by speciality in a clinic + parameters: + - in: path + name: clinicId + required: true + schema: + type: string + style: simple + - in: path + name: speciality + schema: + type: string + style: simple + responses: + '200': + description: List of doctors + '404': + description: No doctors found + /api/v1/staff/me: + get: + tags: + - staff + summary: Get authenticated doctor + responses: + '200': + description: Authenticated doctor retrieved successfully content: application/json: schema: @@ -342,120 +138,611 @@ paths: properties: _id: type: string - example: - _id: 617f1f77bcf86cd799439011 - '401': - description: Unautenticated - content: - application/json: - schema: - type: object - properties: - message: + name: type: string - example: - message: Token not valid - '403': - description: Unauthorized access - content: - application/json: - schema: - type: object - properties: - message: + surname: + type: string + specialty: + type: string + dni: + type: string + clinicId: + type: string + email: + type: string + userId: type: string - example: - message: Unauthorized '404': - description: User not found + description: Authenticated doctor not found + '400': + description: Error retrieving authenticated doctor + security: + - cookieAuth: [] + /api/v1/appointments: + get: + tags: + - Appointments + summary: Get all appointments + description: Retrieve a list of all appointments in the system. + responses: + '200': + description: List of appointments content: application/json: schema: - type: object - properties: - message: - type: string - example: - message: User not found + type: array + items: + $ref: '#/components/schemas/Appointment' '500': - description: Internal server error - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: Internal server error - /api/v1/users/change-password: + description: Error retrieving appointments + security: + - cookieAuth: [] post: tags: - - Users - summary: Change user password - description: Allows authenticated users to change their password. + - Appointments + summary: Create a new appointment + description: Schedule a new appointment for a patient with specified details. requestBody: content: application/json: schema: - type: object - properties: - currentPassword: - example: oldPassword123 - description: The current password of the user. - type: string - newPassword: - example: newPassword456 - description: The new password to set. - type: string - required: - - currentPassword - - newPassword + $ref: '#/components/schemas/AppointmentCreate' required: true responses: - '200': - description: Password changed successfully + '201': + description: Appointment created successfully content: application/json: schema: - type: object - properties: - message: - example: Password changed successfully - type: string - '400': - description: Invalid request + $ref: '#/components/schemas/Appointment' + '500': + description: Error creating the appointment + security: + - cookieAuth: [] + /api/v1/appointments/available: + get: + tags: + - Appointments + summary: Get available appointment slots + description: Retrieve available appointment slots for a specific clinic, doctor, and date. + parameters: + - in: query + name: clinicId + description: The ID of the clinic to check for available appointments + required: true + schema: + type: string + style: form + - in: query + name: doctorId + description: The ID of the doctor to check for available appointments + required: true + schema: + type: string + style: form + - in: query + name: date + description: The date to check for available appointments (in YYYY-MM-DD format) + required: true + schema: + type: string + format: date + style: form + responses: + '200': + description: List of available appointment slots content: application/json: schema: - type: object - properties: - message: - example: '' - type: string - '401': - description: Unauthorized + type: array + items: + type: object + properties: + startTime: + description: Start time of the available appointment slot + type: string + format: time + endTime: + description: End time of the available appointment slot + type: string + format: time + '500': + description: Error obtaining clinic appointments content: application/json: schema: type: object properties: - message: - example: Unauthorized + error: + example: Error obtaining clinic appointments type: string - '403': - description: Unauthorized access - content: - application/json: - schema: - type: object - properties: + message: + example: Detailed error message + type: string + security: + - cookieAuth: [] + /api/v1/appointments/{id}: + get: + tags: + - Appointments + summary: Get appointment by ID + description: Retrieve details of a specific appointment by its ID. + parameters: + - in: path + name: id + description: The ID of the appointment to retrieve + required: true + schema: + type: string + style: simple + responses: + '200': + description: Appointment details retrieved successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Appointment' + '404': + description: Appointment not found + '500': + description: Error retrieving the appointment + security: + - cookieAuth: [] + put: + tags: + - Appointments + summary: Update an appointment + description: Modify details of an existing appointment by ID. + parameters: + - in: path + name: id + description: The ID of the appointment to update + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AppointmentUpdate' + required: true + responses: + '200': + description: Appointment updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Appointment' + '404': + description: Appointment not found + '500': + description: Error updating the appointment + security: + - cookieAuth: [] + delete: + tags: + - Appointments + summary: Delete an appointment + description: Remove an appointment from the system by its ID. + parameters: + - in: path + name: id + description: The ID of the appointment to delete + required: true + schema: + type: string + style: simple + responses: + '200': + description: Appointment deleted successfully + content: + application/json: + schema: + type: object + properties: + message: + example: Appointment deleted successfully + type: string + '404': + description: Appointment not found + '500': + description: Error deleting the appointment + security: + - cookieAuth: [] + /api/v1/appointments/{id}/weather: + get: + tags: + - Appointments + summary: Get weather forecast for appointment + description: Retrieve weather forecast for the location and date of a specific appointment by ID. + parameters: + - in: path + name: id + description: The ID of the appointment for which to retrieve weather information + required: true + schema: + type: string + style: simple + responses: + '200': + description: Weather forecast for the appointment date and location + '404': + description: Appointment or weather data not found + '500': + description: Error retrieving the weather information + /api/v1/appointments/{id}/cancel: + put: + tags: + - Appointments + summary: Cancel an appointment + description: Change the status of an appointment to "cancelled" by its ID. + parameters: + - in: path + name: id + description: The ID of the appointment to cancel + required: true + schema: + type: string + style: simple + responses: + '200': + description: Appointment cancelled successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Appointment' + '400': + description: Appointment ID not provided + '404': + description: Appointment not found + '500': + description: Error cancelling the appointment + security: + - cookieAuth: [] + /api/v1/appointments/{id}/complete: + put: + tags: + - Appointments + summary: Complete an appointment + description: Change the status of an appointment to "completed" by its ID. + parameters: + - in: path + name: id + description: The ID of the appointment to complete + required: true + schema: + type: string + style: simple + responses: + '200': + description: Appointment completed successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Appointment' + '400': + description: Appointment ID not provided + '404': + description: Appointment not found + '500': + description: Error completing the appointment + security: + - cookieAuth: [] + /api/v1/appointments/{id}/noshow: + put: + tags: + - Appointments + summary: Mark an appointment as no_show + description: Change the status of an appointment to "no_show" by its ID. + parameters: + - in: path + name: id + description: The ID of the appointment to mark as no_show + required: true + schema: + type: string + style: simple + responses: + '200': + description: Appointment marked as no_show successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Appointment' + '400': + description: Appointment ID not provided + '404': + description: Appointment not found + '500': + description: Error marking appointment as no_show + security: + - cookieAuth: [] + /api/v1/appointments/patient/{patientId}: + get: + tags: + - Appointments + summary: Get all appointments for a patient + description: Retrieve a list of all appointments for a specific patient by their ID. + parameters: + - in: path + name: patientId + description: The ID of the patient whose appointments to retrieve + required: true + schema: + type: string + style: simple + responses: + '200': + description: List of appointments for the patient + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Appointment' + '500': + description: Error retrieving appointments for the patient + security: + - cookieAuth: [] + /api/v1/appointments/doctor/{doctorId}: + get: + tags: + - Appointments + summary: Get all appointments for a doctor + description: Retrieve a list of all appointments for a specific doctor by their ID. + parameters: + - in: path + name: doctorId + description: The ID of the doctor whose appointments to retrieve + required: true + schema: + type: string + style: simple + responses: + '200': + description: List of appointments for the doctor + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Appointment' + '500': + description: Error retrieving appointments for the doctor + security: + - cookieAuth: [] + /api/v1/appointments/clinic/{clinicId}: + get: + tags: + - Appointments + summary: Get all appointments for a clinic + description: Retrieve a list of all appointments for a specific clinic by its ID. + parameters: + - in: path + name: clinicId + description: The ID of the clinic whose appointments to retrieve + required: true + schema: + type: string + style: simple + responses: + '200': + description: List of appointments for the clinic + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Appointment' + '500': + description: Error retrieving appointments for the clinic + security: + - cookieAuth: [] + /api/v1/histories: + get: + summary: Get all clinical histories + responses: + '200': + description: Returns a list of all clinical histories + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ClinicalHistory' + '500': + description: Error retrieving clinical histories + security: + - jwt: [] + post: + summary: Create a new clinical history + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateClinicalHistory' + required: true + responses: + '201': + description: Clinical history created + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Patient ID is required or validation error + '500': + description: Error creating clinical history + security: + - jwt: [] + /api/v1/histories/{id}: + get: + summary: Get a clinical history by its ID + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + responses: + '200': + description: Returns the requested clinical history + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required + '403': + description: Access denied + '404': + description: Clinical history not found + '500': + description: Error retrieving clinical history + security: + - jwt: [] + delete: + summary: Delete a clinical history by its ID + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + responses: + '204': + description: Clinical history deleted successfully + '400': + description: Clinical history ID is required + '500': + description: Error deleting clinical history + security: + - jwt: [] + /api/v1/histories/{id}/report: + get: + summary: Get a clinical history report by its ID + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + responses: + '200': + description: Returns the requested clinical history report + content: + application/pdf: + schema: + type: string + format: binary + '400': + description: Clinical history ID is required + '403': + description: Access denied + '404': + description: Clinical history not found + '500': + description: Error generating clinical history report + security: + - jwt: [] + /api/v1/histories/patient/{patientId}: + get: + summary: Get a clinical history by patient ID + parameters: + - in: path + name: patientId + required: true + schema: + type: string + style: simple + responses: + '200': + description: Returns the clinical history for the requested patient + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Patient ID is required + '403': + description: Access denied + '404': + description: Clinical history not found + '500': + description: Error retrieving clinical history for patient + security: + - jwt: [] + delete: + summary: Delete a clinical history by patient ID + parameters: + - in: path + name: patientId + required: true + schema: + type: string + style: simple + responses: + '204': + description: Clinical history for the patient deleted successfully + '400': + description: Patient ID is required + '500': + description: Error deleting clinical history for patient + security: + - jwt: [] + /api/v1/histories/{id}/allergy: + post: + summary: Add an allergy to a clinical history + description: Adds an allergy to the allergies set in a specific clinical history. + parameters: + - in: path + name: id + description: The ID of the clinical history. + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + type: object + properties: + allergy: + description: The name of the allergy to add. + type: string + required: + - allergy + required: true + responses: + '200': + description: Allergy successfully added to the clinical history. + content: + application/json: + schema: + type: object + properties: + _id: + type: string + allergies: + type: array + items: + type: string + '400': + description: Missing clinical history ID or allergy in the request. + content: + application/json: + schema: + type: object + properties: message: type: string - example: - message: Forbidden '404': - description: User not found + description: Clinical history not found. content: application/json: schema: @@ -463,333 +750,604 @@ paths: properties: message: type: string - example: - message: User not found '500': - description: Internal server error + description: Internal server error while adding the allergy. + content: + application/json: + schema: + type: object + properties: + message: + type: string + security: + - jwt: [] + /api/v1/histories/{id}/allergy/{allergy}: + delete: + summary: Remove an allergy from a clinical history + description: Removes an allergy from the allergies set in a specific clinical history. + parameters: + - in: path + name: id + description: The ID of the clinical history. + required: true + schema: + type: string + style: simple + - in: path + name: allergy + description: The name of the allergy to remove. + required: true + schema: + type: string + style: simple + responses: + '200': + description: Allergy successfully removed from the clinical history. + content: + application/json: + schema: + type: object + properties: + _id: + type: string + allergies: + type: array + items: + type: string + '400': + description: Missing clinical history ID or allergy in the request. + content: + application/json: + schema: + type: object + properties: + message: + type: string + '404': + description: Clinical history not found. + content: + application/json: + schema: + type: object + properties: + message: + type: string + '500': + description: Internal server error while removing the allergy. + content: + application/json: + schema: + type: object + properties: + message: + type: string + security: + - jwt: [] + /api/v1/histories/{id}/treatment: + post: + summary: Add a new treatment to a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Treatment' + required: true + responses: + '200': + description: Treatment added successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required or validation error + '404': + description: Clinical history not found + '500': + description: Error adding treatment + security: + - jwt: [] + /api/v1/histories/{id}/treatment/{treatmentId}: + put: + summary: Update a treatment in a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + - in: path + name: treatmentId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Treatment' + required: true + responses: + '200': + description: Treatment updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID or Treatment ID is required, or validation error + '404': + description: Clinical history or treatment not found + '500': + description: Error updating treatment + security: + - jwt: [] + delete: + summary: Delete a treatment from a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + - in: path + name: treatmentId + required: true + schema: + type: string + style: simple + responses: + '200': + description: Treatment deleted successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID or Treatment ID is required + '404': + description: Clinical history or treatment not found + '500': + description: Error deleting treatment + security: + - jwt: [] + /api/v1/histories/{id}/condition: + post: + summary: Add a new current condition to a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CurrentCondition' + required: true + responses: + '200': + description: Current condition added successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required or validation error + '404': + description: Clinical history not found + '500': + description: Error adding current condition + security: + - jwt: [] + /api/v1/histories/{id}/condition/{currentConditionId}: + put: + summary: Update a current condition in a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + - in: path + name: currentConditionId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CurrentCondition' + required: true + responses: + '200': + description: Current condition updated successfully + content: + application/json: + schema: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID or Current condition ID is required, or validation error + '404': + description: Clinical history or current condition not found + '500': + description: Error updating current condition + security: + - jwt: [] + delete: + summary: Delete a current condition from a clinical history + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + - in: path + name: currentConditionId + required: true + schema: + type: string + style: simple + responses: + '200': + description: Current condition deleted successfully content: application/json: schema: - type: object - properties: - message: - example: Error when authenticating - type: string - /api/v1/users/enable-2fa: + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID or Current condition ID is required + '404': + description: Clinical history or current condition not found + '500': + description: Error deleting current condition + security: + - jwt: [] + /api/v1/histories/{id}/image: post: - tags: - - Users - summary: Enable two-factor authentication - description: Allows authenticated users to enable two-factor authentication. + summary: Upload an image to a clinical history record + description: Allows uploading an image to an existing clinical history record. + parameters: + - in: path + name: id + description: The ID of the clinical history record. + required: true + schema: + type: string + style: simple + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + file: + description: The image file to upload. + type: string + format: binary + required: true responses: - '200': - description: 2FA successfully enabled + '201': + description: Image uploaded successfully content: application/json: schema: type: object properties: message: - example: 2FA enabled successfully - type: string - qrCodeUrl: - example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... + example: Image uploaded successfully type: string - format: uri - secret: - example: JBSWY3DPEHPK3PXP + imageUrl: + description: URL of the uploaded image. type: string '400': - description: Invalid request + description: Bad Request - Missing required headers or Clinical History ID. content: application/json: schema: type: object properties: message: - example: Bad request + example: clinicalHistoryId is required type: string - '401': - description: Unauthorized + '404': + description: Clinical History record not found. content: application/json: schema: type: object properties: message: - example: Unauthorized + example: Clinical history not found type: string '500': - description: Internal server error + description: Internal Server Error content: application/json: schema: type: object properties: message: - example: Internal server error + example: Internal server error occurred. type: string - /api/v1/users/verify-2fa: - post: - tags: - - Users - summary: Verify two-factor authentication - description: Allows authenticated users to verify two-factor authentication. - requestBody: - content: - application/json: - schema: - type: object - properties: - userId: - example: 550e8400-e29b-41d4-a716-446655440000 - description: The user's unique ID. - type: string - totpToken: - example: '123456' - description: The two-factor authentication token. - type: string - required: - - userId - - totpToken + security: + - jwt: [] + /api/v1/histories/{id}/image/{imageId}: + delete: + summary: Delete an image from a clinical history record + description: Deletes a specific image associated with a clinical history record by its ID. Also removes the file from Azure Blob Storage. + parameters: + - in: path + name: id + description: The ID of the clinical history record. + required: true + schema: + type: string + style: simple + - in: path + name: imageId + description: The ID of the image to delete. required: true + schema: + type: string + style: simple responses: '200': - description: 2FA token verified successfully + description: Image deleted successfully content: application/json: schema: type: object properties: message: - example: Login successful + example: Image deleted successfully type: string '400': - description: Invalid request + description: Bad Request - Missing or invalid parameters. content: application/json: schema: type: object properties: message: - example: 2FA not enabled for this user + example: clinicalHistoryId and imageId are required type: string - '403': - description: Unauthorized access + '404': + description: Not Found - Clinical history or image not found. content: application/json: schema: type: object properties: message: + example: Clinical history or image not found type: string - example: - message: Invalid 2FA token '500': - description: Internal server error + description: Internal Server Error content: application/json: schema: type: object properties: message: - example: Internal server error + example: Error deleting image type: string - /api/v1/login: + error: + example: Detailed error message. + type: string + security: + - jwt: [] + /api/v1/histories/{id}/analytic: post: - tags: - - Authentication - summary: User Login - description: Authenticates a user with their email and password. + summary: Upload an analytic to a clinical history record + description: Allows uploading an analytic to an existing clinical history record. + parameters: + - in: path + name: id + description: The ID of the clinical history record. + required: true + schema: + type: string + style: simple requestBody: content: - application/json: + multipart/form-data: schema: type: object properties: - email: - example: admin@email.com - description: The user's unique email. - type: string - password: - example: admin123 - description: The user's password. + file: + description: The analytic file to upload. type: string - required: - - email - - password + format: binary required: true responses: - '200': - description: Successful login + '201': + description: Analytic uploaded successfully content: application/json: schema: type: object properties: message: - example: Login successful + example: Analytic uploaded successfully type: string - '401': - description: Unauthorized - invalid credentials + analyticUrl: + description: URL of the uploaded analytic. + type: string + '400': + description: Bad Request - Missing required headers or Clinical History ID. content: application/json: schema: type: object properties: message: - example: Invalid credentials + example: clinicalHistoryId is required type: string - '500': - $ref: '#/components/responses/ServerError' - /api/v1/logout: - post: - tags: - - Authentication - summary: User Logout - description: Logs out a user by clearing authentication tokens. - responses: - '200': - description: Successful logout + '404': + description: Clinical History record not found. content: application/json: schema: type: object properties: message: - example: Logout successful + example: Clinical history not found type: string - '401': - description: Unauthorized - user is not logged in + '500': + description: Internal Server Error content: application/json: schema: type: object properties: message: - example: Not logged in + example: Internal server error occurred. type: string - '500': - $ref: '#/components/responses/ServerError' - /api/v1/token/refresh: - get: - tags: - - Authentication - summary: Refreshes the user's token. - description: Refreshes the user's auth and refresh tokens and sets new values in cookies. - operationId: validateAuthToken + security: + - jwt: [] + /api/v1/histories/{id}/analytic/{analyticId}: + delete: + summary: Delete an analytic from a clinical history record + description: Deletes a specific analytic associated with a clinical history record by its ID. Also removes the file from Azure Blob Storage. + parameters: + - in: path + name: id + description: The ID of the clinical history record. + required: true + schema: + type: string + style: simple + - in: path + name: analyticId + description: The ID of the analytic to delete. + required: true + schema: + type: string + style: simple responses: '200': - description: Tokens refreshed. + description: Analytic deleted successfully content: application/json: schema: type: object properties: message: - example: Tokens refreshed + example: Analytic deleted successfully type: string - '401': - description: Unauthorized - Token is missing, expired, or invalid. + '400': + description: Bad Request - Missing or invalid parameters. content: application/json: schema: type: object properties: message: - example: Token expired or invalid. + example: clinicalHistoryId and analyticId are required type: string - /api/v1/token/validate: - get: - tags: - - Authentication - summary: Validates the user's token. - description: Checks the validity of the token provided in the user's cookies. - operationId: validateAuthToken - responses: - '200': - description: Token is valid. + '404': + description: Not Found - Clinical history or analytic not found. content: application/json: schema: type: object properties: message: - example: Token is valid + example: Clinical history or analytic not found type: string - '401': - description: Unauthorized - Token is missing, expired, or invalid. + '500': + description: Internal Server Error content: application/json: schema: type: object properties: message: - example: Token expired or invalid. + example: Error deleting analytic type: string - /api/v1/plans: + error: + example: Detailed error message. + type: string + security: + - jwt: [] + /api/v1/patients/: get: tags: - - Plan - summary: Retrieve all plans + - Patients + summary: Retrieve all patients + description: Fetch a list of all patients. responses: '200': - description: A list of plans + description: List of patients retrieved successfully. content: application/json: schema: type: array items: - $ref: '#/components/schemas/Plan' - examples: - example1: - value: - - features: - - Feature A - - Feature B - id: '1' - name: Basic Plan - price: 10.0 - /api/v1/payments: - get: - tags: - - Payment - summary: Retrieve all payments - responses: - '200': - description: A list of payments + $ref: '#/components/schemas/Patient' + '500': + description: Internal server error. content: application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Payment' + example: + message: An unexpected error occurred security: - cookieAuth: [] post: tags: - - Payment - summary: Process a new payment + - Patients + summary: Register a new patient + description: Creates a new patient record in the system. requestBody: content: application/json: schema: - $ref: '#/components/schemas/PaymentRequest' + $ref: '#/components/schemas/Patient' required: true responses: '201': - description: Payment successfully processed + description: Patient created successfully. content: application/json: schema: - $ref: '#/components/schemas/Payment' + $ref: '#/components/schemas/Patient' + '400': + description: Missing fields in the request body. + content: + application/json: + example: + message: Missing fields + '500': + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred security: - cookieAuth: [] - /api/v1/payments/{id}: + /api/v1/patients/{id}: get: tags: - - Payment - summary: Retrieve a payment by ID + - Patients + summary: Get patient by ID + description: Fetch a specific patient using their unique ID. parameters: - in: path name: id @@ -799,73 +1357,30 @@ paths: style: simple responses: '200': - description: Details of a specific payment + description: Patient retrieved successfully. content: application/json: schema: - $ref: '#/components/schemas/Payment' + $ref: '#/components/schemas/Patient' '404': - description: Payment not found - security: - - cookieAuth: [] - /api/v1/clinics: - get: - tags: - - Clinic - summary: Retrieve all clinics - responses: - '200': - description: A list of clinics + description: Patient not found. content: application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Clinic' - post: - tags: - - Clinic - summary: Register a new clinic - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicRequest' - required: true - responses: - '201': - description: Clinic successfully registered + example: + message: Patient not found + '500': + description: Internal server error. content: application/json: - schema: - $ref: '#/components/schemas/Clinic' + example: + message: An unexpected error occurred security: - cookieAuth: [] - /api/v1/clinics/{id}: - get: - tags: - - Clinic - summary: Retrieve a clinic by ID - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - responses: - '200': - description: Details of a specific clinic - content: - application/json: - schema: - $ref: '#/components/schemas/Clinic' - '404': - description: Clinic not found put: tags: - - Clinic - summary: Update a clinic by ID + - Patients + summary: Update a patient by ID + description: Modify the details of a specific patient. parameters: - in: path name: id @@ -877,99 +1392,35 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/ClinicRequest' - required: true - responses: - '200': - description: Clinic successfully updated - content: - application/json: - schema: - $ref: '#/components/schemas/Clinic' - security: - - cookieAuth: [] - delete: - tags: - - Clinic - summary: Delete a clinic by ID - parameters: - - in: path - name: id + type: object + additionalProperties: true required: true - schema: - type: string - style: simple - responses: - '204': - description: Clinic successfully deleted - security: - - cookieAuth: [] - /api/v1/histories: - get: - summary: Get all clinical histories responses: '200': - description: Returns a list of all clinical histories + description: Patient updated successfully. content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/ClinicalHistory' - '500': - description: Error retrieving clinical histories - security: - - jwt: [] - post: - summary: Create a new clinical history - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CreateClinicalHistory' - required: true - responses: - '201': - description: Clinical history created + $ref: '#/components/schemas/Patient' + '404': + description: Patient not found. content: application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Patient ID is required or validation error + example: + message: Patient not found '500': - description: Error creating clinical history - security: - - jwt: [] - /api/v1/histories/{id}: - get: - summary: Get a clinical history by its ID - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - responses: - '200': - description: Returns the requested clinical history + description: Internal server error. content: application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID is required - '403': - description: Access denied - '404': - description: Clinical history not found - '500': - description: Error retrieving clinical history + example: + message: An unexpected error occurred security: - - jwt: [] + - cookieAuth: [] delete: - summary: Delete a clinical history by its ID + tags: + - Patients + summary: Delete a patient by ID + description: Remove a specific patient from the system. parameters: - in: path name: id @@ -978,176 +1429,272 @@ paths: type: string style: simple responses: - '204': - description: Clinical history deleted successfully - '400': - description: Clinical history ID is required + '200': + description: Patient deleted successfully. + content: + application/json: + schema: + $ref: '#/components/schemas/Patient' + '404': + description: Patient not found. + content: + application/json: + example: + message: Patient not found '500': - description: Error deleting clinical history + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred security: - - jwt: [] - /api/v1/histories/{id}/report: + - cookieAuth: [] + /logs: get: - summary: Get a clinical history report by its ID - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple + summary: Fetch list of log entries + description: Retrieves a list of logs stored in the S3 bucket, ordered by timestamp in descending order. Requires admin authentication. responses: '200': - description: Returns the requested clinical history report + description: A list of logs content: - application/pdf: + application/json: schema: - type: string - format: binary - '400': - description: Clinical history ID is required + type: object + properties: + logs: + type: array + items: + type: object + properties: + requestId: + description: Unique identifier for the request log. + type: string + timestamp: + description: The timestamp when the log was created. + type: string + format: date-time + '401': + description: Unauthorized - No token provided + content: + application/json: + schema: + type: object + properties: + error: + description: Error message indicating access was denied due to missing token. + type: string '403': - description: Access denied - '404': - description: Clinical history not found + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + type: object + properties: + error: + description: Error message indicating insufficient permissions. + type: string '500': - description: Error generating clinical history report + description: Internal server error + content: + application/json: + schema: + type: object + properties: + error: + description: Error message describing the issue. + type: string security: - - jwt: [] - /api/v1/histories/patient/{patientId}: + - cookieAuth: [] + /logs/{requestId}: get: - summary: Get a clinical history by patient ID + summary: Fetch logs for a specific request + description: Retrieves the logs for a specific request ID stored in the S3 bucket. Requires admin authentication. parameters: - in: path - name: patientId + name: requestId + description: The unique identifier of the request log to retrieve. required: true schema: type: string style: simple responses: '200': - description: Returns the clinical history for the requested patient + description: Logs for the specified request ID content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Patient ID is required + type: object + properties: + requestId: + description: The unique identifier of the request. + type: string + logs: + type: object + additionalProperties: + description: Log details for the request. + type: string + '401': + description: Unauthorized - No token provided + content: + application/json: + schema: + type: object + properties: + error: + description: Error message indicating access was denied due to missing token. + type: string '403': - description: Access denied + description: Forbidden - Insufficient permissions + content: + application/json: + schema: + type: object + properties: + error: + description: Error message indicating insufficient permissions. + type: string '404': - description: Clinical history not found - '500': - description: Error retrieving clinical history for patient - security: - - jwt: [] - delete: - summary: Delete a clinical history by patient ID - parameters: - - in: path - name: patientId - required: true - schema: - type: string - style: simple - responses: - '204': - description: Clinical history for the patient deleted successfully - '400': - description: Patient ID is required + description: Logs not found for the specified request ID + content: + application/json: + schema: + type: object + properties: + error: + description: Error message indicating the logs were not found. + type: string '500': - description: Error deleting clinical history for patient + description: Internal server error + content: + application/json: + schema: + type: object + properties: + error: + description: Error message describing the issue. + type: string security: - - jwt: [] - /api/v1/histories/{id}/allergy: + - cookieAuth: [] + /api/v1/users: post: - summary: Add an allergy to a clinical history - description: Adds an allergy to the allergies set in a specific clinical history. - parameters: - - in: path - name: id - description: The ID of the clinical history. - required: true - schema: - type: string - style: simple + tags: + - Users + summary: Create User + description: Creates a new user with specified roles, email, and associated IDs for doctor or patient. requestBody: content: application/json: schema: type: object properties: - allergy: - description: The name of the allergy to add. + email: + example: new_user@example.com + description: Email address of the user. + type: string + password: + example: securepassword123 + description: User's password. + type: string + roles: + example: + - admin + - doctor + description: List of roles assigned to the user. + type: array + items: + type: string + doctorid: + nullable: true + example: doctor123 + description: Unique ID if the user is a doctor. + type: string + patientid: + nullable: true + example: patient456 + description: Unique ID if the user is a patient. type: string required: - - allergy + - email + - password required: true responses: - '200': - description: Allergy successfully added to the clinical history. + '201': + description: User created successfully content: application/json: schema: type: object properties: - _id: + email: + example: new_user@example.com type: string - allergies: + roles: + example: + - admin + - doctor type: array items: type: string + doctorid: + nullable: true + example: doctor123 + type: string + patientid: + nullable: true + example: patient456 + type: string '400': - description: Missing clinical history ID or allergy in the request. + description: Bad request - missing fields or user already exists content: application/json: schema: + example: + email: Email is required + password: Password is required type: object - properties: - message: - type: string - '404': - description: Clinical history not found. + additionalProperties: + type: string + '401': + description: Unauthorized - token missing or invalid content: application/json: schema: type: object properties: message: + example: No token provided type: string - '500': - description: Internal server error while adding the allergy. + '403': + description: Forbidden - insufficient permissions content: application/json: schema: type: object properties: message: + example: Forbidden type: string + '500': + $ref: '#/components/responses/ServerError' security: - - jwt: [] - /api/v1/histories/{id}/allergy/{allergy}: - delete: - summary: Remove an allergy from a clinical history - description: Removes an allergy from the allergies set in a specific clinical history. + - cookieAuth: [] + /api/v1/users/{id}: + get: + tags: + - Users + summary: Retrieve user information + description: Retrieve user details by user ID. Requires the user to be the owner or have specific roles. parameters: - - in: path - name: id - description: The ID of the clinical history. - required: true - schema: - type: string - style: simple - - in: path - name: allergy - description: The name of the allergy to remove. + - in: path + name: id + description: ID of the user to retrieve required: true schema: type: string style: simple responses: '200': - description: Allergy successfully removed from the clinical history. + description: User retrieved successfully content: application/json: schema: @@ -1155,12 +1702,30 @@ paths: properties: _id: type: string - allergies: + email: + type: string + username: + type: string + roles: type: array items: type: string - '400': - description: Missing clinical history ID or allergy in the request. + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + example: + _id: 617f1f77bcf86cd799439011 + createdAt: 2023-01-01T12:00:00Z + email: user@example.com + roles: + - user + updatedAt: 2023-01-10T12:00:00Z + username: johndoe + '401': + description: Unautenticated content: application/json: schema: @@ -1168,8 +1733,10 @@ paths: properties: message: type: string - '404': - description: Clinical history not found. + example: + message: Token not valid + '403': + description: Unauthorized access content: application/json: schema: @@ -1177,8 +1744,10 @@ paths: properties: message: type: string - '500': - description: Internal server error while removing the allergy. + example: + message: Forbidden + '404': + description: User not found content: application/json: schema: @@ -1186,149 +1755,28 @@ paths: properties: message: type: string - security: - - jwt: [] - /api/v1/histories/{id}/treatment: - post: - summary: Add a new treatment to a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Treatment' - required: true - responses: - '200': - description: Treatment added successfully - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID is required or validation error - '404': - description: Clinical history not found - '500': - description: Error adding treatment - security: - - jwt: [] - /api/v1/histories/{id}/treatment/{treatmentId}: - put: - summary: Update a treatment in a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - - in: path - name: treatmentId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/Treatment' - required: true - responses: - '200': - description: Treatment updated successfully - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID or Treatment ID is required, or validation error - '404': - description: Clinical history or treatment not found - '500': - description: Error updating treatment - security: - - jwt: [] - delete: - summary: Delete a treatment from a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - - in: path - name: treatmentId - required: true - schema: - type: string - style: simple - responses: - '200': - description: Treatment deleted successfully - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID or Treatment ID is required - '404': - description: Clinical history or treatment not found + example: + message: User not found '500': - description: Error deleting treatment - security: - - jwt: [] - /api/v1/histories/{id}/condition: - post: - summary: Add a new current condition to a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/CurrentCondition' - required: true - responses: - '200': - description: Current condition added successfully + description: Internal server error content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID is required or validation error - '404': - description: Clinical history not found - '500': - description: Error adding current condition - security: - - jwt: [] - /api/v1/histories/{id}/condition/{currentConditionId}: + type: object + properties: + message: + type: string + example: + message: Internal server error put: - summary: Update a current condition in a clinical history + tags: + - Users + summary: Update user information + description: Update user details by user ID. Requires the user to be the owner or have specific roles. parameters: - in: path name: id - required: true - schema: - type: string - style: simple - - in: path - name: currentConditionId + description: ID of the user to update required: true schema: type: string @@ -1336,764 +1784,632 @@ paths: requestBody: content: application/json: - schema: - $ref: '#/components/schemas/CurrentCondition' - required: true - responses: - '200': - description: Current condition updated successfully - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID or Current condition ID is required, or validation error - '404': - description: Clinical history or current condition not found - '500': - description: Error updating current condition - security: - - jwt: [] - delete: - summary: Delete a current condition from a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - - in: path - name: currentConditionId - required: true - schema: - type: string - style: simple - responses: - '200': - description: Current condition deleted successfully - content: - application/json: - schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID or Current condition ID is required - '404': - description: Clinical history or current condition not found - '500': - description: Error deleting current condition - security: - - jwt: [] - /api/v1/histories/{id}/image: - post: - summary: Upload an image to a clinical history record - description: Allows uploading an image to an existing clinical history record. - parameters: - - in: path - name: id - description: The ID of the clinical history record. - required: true - schema: - type: string - style: simple - requestBody: - content: - multipart/form-data: schema: type: object properties: - file: - description: The image file to upload. + email: + example: user@example.com + description: Email address of the user. type: string - format: binary + password: + example: securepassword123 + description: User's password. + type: string + roles: + example: + - admin + - doctor + description: List of roles assigned to the user. + type: array + items: + type: string required: true responses: - '201': - description: Image uploaded successfully + '200': + description: User updated successfully content: application/json: schema: type: object properties: - message: - example: Image uploaded successfully + _id: type: string - imageUrl: - description: URL of the uploaded image. + email: + type: string + roles: + type: array + items: + type: string + createdAt: + type: string + format: date-time + updatedAt: type: string + format: date-time + example: + _id: 617f1f77bcf86cd799439011 + createdAt: 2023-01-01T12:00:00Z + email: user@example.com + roles: + - doctor + updatedAt: 2023-01-10T12:00:00Z '400': - description: Bad Request - Missing required headers or Clinical History ID. + description: Bad request - missing fields or user already exists + content: + application/json: + schema: + example: + email: Email is required + password: Password is required + type: object + additionalProperties: + type: string + '401': + description: Unautenticated + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: + message: Token not valid + '403': + description: Unauthorized access content: application/json: schema: type: object properties: message: - example: clinicalHistoryId is required type: string + example: + message: Forbidden '404': - description: Clinical History record not found. + description: User not found content: application/json: schema: type: object properties: message: - example: Clinical history not found type: string + example: + message: User not found '500': - description: Internal Server Error + description: Internal server error content: application/json: schema: type: object properties: message: - example: Internal server error occurred. type: string - security: - - jwt: [] - /api/v1/histories/{id}/image/{imageId}: + example: + message: Internal server error delete: - summary: Delete an image from a clinical history record - description: Deletes a specific image associated with a clinical history record by its ID. Also removes the file from Azure Blob Storage. + tags: + - Users + summary: Deletes user + description: Delete user by user ID. Requires the user to have specific roles. parameters: - in: path name: id - description: The ID of the clinical history record. - required: true - schema: - type: string - style: simple - - in: path - name: imageId - description: The ID of the image to delete. + description: ID of the user to update required: true schema: type: string style: simple responses: - '200': - description: Image deleted successfully + '204': + description: User deleted successfully + content: + application/json: + schema: + type: object + properties: + _id: + type: string + example: + _id: 617f1f77bcf86cd799439011 + '401': + description: Unautenticated content: application/json: schema: type: object properties: message: - example: Image deleted successfully type: string - '400': - description: Bad Request - Missing or invalid parameters. + example: + message: Token not valid + '403': + description: Unauthorized access content: application/json: schema: type: object properties: message: - example: clinicalHistoryId and imageId are required type: string + example: + message: Unauthorized '404': - description: Not Found - Clinical history or image not found. + description: User not found content: application/json: schema: type: object properties: message: - example: Clinical history or image not found type: string + example: + message: User not found '500': - description: Internal Server Error + description: Internal server error content: application/json: schema: type: object properties: message: - example: Error deleting image - type: string - error: - example: Detailed error message. type: string - security: - - jwt: [] - /api/v1/histories/{id}/analytic: + example: + message: Internal server error + /api/v1/users/change-password: post: - summary: Upload an analytic to a clinical history record - description: Allows uploading an analytic to an existing clinical history record. - parameters: - - in: path - name: id - description: The ID of the clinical history record. - required: true - schema: - type: string - style: simple + tags: + - Users + summary: Change user password + description: Allows authenticated users to change their password. requestBody: content: - multipart/form-data: + application/json: schema: type: object properties: - file: - description: The analytic file to upload. + currentPassword: + example: oldPassword123 + description: The current password of the user. type: string - format: binary + newPassword: + example: newPassword456 + description: The new password to set. + type: string + required: + - currentPassword + - newPassword required: true responses: - '201': - description: Analytic uploaded successfully + '200': + description: Password changed successfully content: application/json: schema: type: object properties: message: - example: Analytic uploaded successfully - type: string - analyticUrl: - description: URL of the uploaded analytic. + example: Password changed successfully type: string '400': - description: Bad Request - Missing required headers or Clinical History ID. + description: Invalid request + content: + application/json: + schema: + type: object + properties: + message: + example: '' + type: string + '401': + description: Unauthorized + content: + application/json: + schema: + type: object + properties: + message: + example: Unauthorized + type: string + '403': + description: Unauthorized access content: application/json: schema: type: object properties: message: - example: clinicalHistoryId is required type: string + example: + message: Forbidden '404': - description: Clinical History record not found. + description: User not found content: application/json: schema: type: object properties: message: - example: Clinical history not found type: string + example: + message: User not found '500': - description: Internal Server Error + description: Internal server error content: application/json: schema: type: object properties: message: - example: Internal server error occurred. + example: Error when authenticating type: string - security: - - jwt: [] - /api/v1/histories/{id}/analytic/{analyticId}: - delete: - summary: Delete an analytic from a clinical history record - description: Deletes a specific analytic associated with a clinical history record by its ID. Also removes the file from Azure Blob Storage. - parameters: - - in: path - name: id - description: The ID of the clinical history record. - required: true - schema: - type: string - style: simple - - in: path - name: analyticId - description: The ID of the analytic to delete. - required: true - schema: - type: string - style: simple + /api/v1/users/enable-2fa: + post: + tags: + - Users + summary: Enable two-factor authentication + description: Allows authenticated users to enable two-factor authentication. responses: '200': - description: Analytic deleted successfully + description: 2FA successfully enabled content: application/json: schema: type: object properties: message: - example: Analytic deleted successfully + example: 2FA enabled successfully + type: string + qrCodeUrl: + example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... + type: string + format: uri + secret: + example: JBSWY3DPEHPK3PXP type: string '400': - description: Bad Request - Missing or invalid parameters. + description: Invalid request content: application/json: schema: type: object properties: message: - example: clinicalHistoryId and analyticId are required + example: Bad request type: string - '404': - description: Not Found - Clinical history or analytic not found. + '401': + description: Unauthorized content: application/json: schema: type: object properties: message: - example: Clinical history or analytic not found + example: Unauthorized type: string '500': - description: Internal Server Error + description: Internal server error content: application/json: schema: type: object properties: message: - example: Error deleting analytic - type: string - error: - example: Detailed error message. + example: Internal server error type: string - security: - - jwt: [] - /api/v1/appointments: - get: - tags: - - Appointments - summary: Get all appointments - description: Retrieve a list of all appointments in the system. - responses: - '200': - description: List of appointments - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Appointment' - '500': - description: Error retrieving appointments - security: - - cookieAuth: [] + /api/v1/users/verify-2fa: post: tags: - - Appointments - summary: Create a new appointment - description: Schedule a new appointment for a patient with specified details. + - Users + summary: Verify two-factor authentication + description: Allows authenticated users to verify two-factor authentication. requestBody: content: application/json: schema: - $ref: '#/components/schemas/AppointmentCreate' - required: true - responses: - '201': - description: Appointment created successfully - content: - application/json: - schema: - $ref: '#/components/schemas/Appointment' - '500': - description: Error creating the appointment - security: - - cookieAuth: [] - /api/v1/appointments/available: - get: - tags: - - Appointments - summary: Get available appointment slots - description: Retrieve available appointment slots for a specific clinic, doctor, and date. - parameters: - - in: query - name: clinicId - description: The ID of the clinic to check for available appointments - required: true - schema: - type: string - style: form - - in: query - name: doctorId - description: The ID of the doctor to check for available appointments - required: true - schema: - type: string - style: form - - in: query - name: date - description: The date to check for available appointments (in YYYY-MM-DD format) + type: object + properties: + userId: + example: 550e8400-e29b-41d4-a716-446655440000 + description: The user's unique ID. + type: string + totpToken: + example: '123456' + description: The two-factor authentication token. + type: string + required: + - userId + - totpToken required: true - schema: - type: string - format: date - style: form responses: '200': - description: List of available appointment slots - content: - application/json: - schema: - type: array - items: - type: object - properties: - startTime: - description: Start time of the available appointment slot - type: string - format: time - endTime: - description: End time of the available appointment slot - type: string - format: time - '500': - description: Error obtaining clinic appointments + description: 2FA token verified successfully content: application/json: schema: type: object properties: - error: - example: Error obtaining clinic appointments - type: string message: - example: Detailed error message + example: Login successful type: string - security: - - cookieAuth: [] - /api/v1/appointments/{id}: - get: - tags: - - Appointments - summary: Get appointment by ID - description: Retrieve details of a specific appointment by its ID. - parameters: - - in: path - name: id - description: The ID of the appointment to retrieve - required: true - schema: - type: string - style: simple - responses: - '200': - description: Appointment details retrieved successfully + '400': + description: Invalid request content: application/json: schema: - $ref: '#/components/schemas/Appointment' - '404': - description: Appointment not found - '500': - description: Error retrieving the appointment - security: - - cookieAuth: [] - put: - tags: - - Appointments - summary: Update an appointment - description: Modify details of an existing appointment by ID. - parameters: - - in: path - name: id - description: The ID of the appointment to update - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AppointmentUpdate' - required: true - responses: - '200': - description: Appointment updated successfully + type: object + properties: + message: + example: 2FA not enabled for this user + type: string + '403': + description: Unauthorized access content: application/json: schema: - $ref: '#/components/schemas/Appointment' - '404': - description: Appointment not found + type: object + properties: + message: + type: string + example: + message: Invalid 2FA token '500': - description: Error updating the appointment - security: - - cookieAuth: [] - delete: - tags: - - Appointments - summary: Delete an appointment - description: Remove an appointment from the system by its ID. - parameters: - - in: path - name: id - description: The ID of the appointment to delete - required: true - schema: - type: string - style: simple - responses: - '200': - description: Appointment deleted successfully + description: Internal server error content: application/json: schema: type: object properties: message: - example: Appointment deleted successfully + example: Internal server error type: string - '404': - description: Appointment not found - '500': - description: Error deleting the appointment - security: - - cookieAuth: [] - /api/v1/appointments/{id}/weather: - get: - tags: - - Appointments - summary: Get weather forecast for appointment - description: Retrieve weather forecast for the location and date of a specific appointment by ID. - parameters: - - in: path - name: id - description: The ID of the appointment for which to retrieve weather information - required: true - schema: - type: string - style: simple - responses: - '200': - description: Weather forecast for the appointment date and location - '404': - description: Appointment or weather data not found - '500': - description: Error retrieving the weather information - /api/v1/appointments/{id}/cancel: - put: + /api/v1/login: + post: tags: - - Appointments - summary: Cancel an appointment - description: Change the status of an appointment to "cancelled" by its ID. - parameters: - - in: path - name: id - description: The ID of the appointment to cancel + - Authentication + summary: User Login + description: Authenticates a user with their email and password. + requestBody: + content: + application/json: + schema: + type: object + properties: + email: + example: admin@email.com + description: The user's unique email. + type: string + password: + example: admin123 + description: The user's password. + type: string + required: + - email + - password required: true - schema: - type: string - style: simple responses: '200': - description: Appointment cancelled successfully + description: Successful login content: application/json: schema: - $ref: '#/components/schemas/Appointment' - '400': - description: Appointment ID not provided - '404': - description: Appointment not found + type: object + properties: + message: + example: Login successful + type: string + '401': + description: Unauthorized - invalid credentials + content: + application/json: + schema: + type: object + properties: + message: + example: Invalid credentials + type: string '500': - description: Error cancelling the appointment - security: - - cookieAuth: [] - /api/v1/appointments/{id}/complete: - put: + $ref: '#/components/responses/ServerError' + /api/v1/logout: + post: tags: - - Appointments - summary: Complete an appointment - description: Change the status of an appointment to "completed" by its ID. - parameters: - - in: path - name: id - description: The ID of the appointment to complete - required: true - schema: - type: string - style: simple + - Authentication + summary: User Logout + description: Logs out a user by clearing authentication tokens. responses: '200': - description: Appointment completed successfully + description: Successful logout content: application/json: schema: - $ref: '#/components/schemas/Appointment' - '400': - description: Appointment ID not provided - '404': - description: Appointment not found + type: object + properties: + message: + example: Logout successful + type: string + '401': + description: Unauthorized - user is not logged in + content: + application/json: + schema: + type: object + properties: + message: + example: Not logged in + type: string '500': - description: Error completing the appointment - security: - - cookieAuth: [] - /api/v1/appointments/{id}/noshow: - put: + $ref: '#/components/responses/ServerError' + /api/v1/token/refresh: + get: tags: - - Appointments - summary: Mark an appointment as no_show - description: Change the status of an appointment to "no_show" by its ID. - parameters: - - in: path - name: id - description: The ID of the appointment to mark as no_show - required: true - schema: - type: string - style: simple + - Authentication + summary: Refreshes the user's token. + description: Refreshes the user's auth and refresh tokens and sets new values in cookies. + operationId: validateAuthToken responses: '200': - description: Appointment marked as no_show successfully + description: Tokens refreshed. content: application/json: schema: - $ref: '#/components/schemas/Appointment' - '400': - description: Appointment ID not provided - '404': - description: Appointment not found - '500': - description: Error marking appointment as no_show - security: - - cookieAuth: [] - /api/v1/appointments/patient/{patientId}: + type: object + properties: + message: + example: Tokens refreshed + type: string + '401': + description: Unauthorized - Token is missing, expired, or invalid. + content: + application/json: + schema: + type: object + properties: + message: + example: Token expired or invalid. + type: string + /api/v1/token/validate: get: tags: - - Appointments - summary: Get all appointments for a patient - description: Retrieve a list of all appointments for a specific patient by their ID. - parameters: - - in: path - name: patientId - description: The ID of the patient whose appointments to retrieve - required: true - schema: - type: string - style: simple + - Authentication + summary: Validates the user's token. + description: Checks the validity of the token provided in the user's cookies. + operationId: validateAuthToken responses: '200': - description: List of appointments for the patient + description: Token is valid. content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Appointment' - '500': - description: Error retrieving appointments for the patient - security: - - cookieAuth: [] - /api/v1/appointments/doctor/{doctorId}: + type: object + properties: + message: + example: Token is valid + type: string + '401': + description: Unauthorized - Token is missing, expired, or invalid. + content: + application/json: + schema: + type: object + properties: + message: + example: Token expired or invalid. + type: string + /api/v1/plans: get: tags: - - Appointments - summary: Get all appointments for a doctor - description: Retrieve a list of all appointments for a specific doctor by their ID. - parameters: - - in: path - name: doctorId - description: The ID of the doctor whose appointments to retrieve - required: true - schema: - type: string - style: simple + - Plan + summary: Retrieve all plans responses: '200': - description: List of appointments for the doctor + description: A list of plans content: application/json: schema: type: array items: - $ref: '#/components/schemas/Appointment' - '500': - description: Error retrieving appointments for the doctor - security: - - cookieAuth: [] - /api/v1/appointments/clinic/{clinicId}: + $ref: '#/components/schemas/Plan' + examples: + example1: + value: + - features: + - Feature A + - Feature B + id: '1' + name: Basic Plan + price: 10.0 + /api/v1/plans/{id}: get: tags: - - Appointments - summary: Get all appointments for a clinic - description: Retrieve a list of all appointments for a specific clinic by its ID. + - Plan + summary: Retrieve a plan by ID + description: Retrieves details of a specific plan by its unique ID. parameters: - in: path - name: clinicId - description: The ID of the clinic whose appointments to retrieve + name: id + description: The unique identifier for the plan required: true schema: type: string style: simple responses: '200': - description: List of appointments for the clinic + description: Plan successfully retrieved content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Appointment' - '500': - description: Error retrieving appointments for the clinic - security: - - cookieAuth: [] - /api/v1/patients/: - get: - tags: - - Patients - summary: Retrieve all patients - description: Fetch a list of all patients. - responses: - '200': - description: List of patients retrieved successfully. + $ref: '#/components/schemas/Plan' + '400': + description: Missing plan ID content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Patient' + type: object + properties: + message: + example: Missing plan ID + type: string + '404': + description: Plan not found + content: + application/json: + schema: + type: object + properties: + message: + example: Plan not found + type: string '500': - description: Internal server error. + description: Internal server error content: application/json: - example: - message: An unexpected error occurred + schema: + type: object + properties: + message: + example: An unexpected error occurred + type: string + /api/v1/payments: + get: + tags: + - Payment + summary: Retrieve all payments + responses: + '200': + description: A list of payments + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Payment' security: - cookieAuth: [] post: tags: - - Patients - summary: Register a new patient - description: Creates a new patient record in the system. + - Payment + summary: Process a new payment requestBody: content: application/json: schema: - $ref: '#/components/schemas/Patient' + $ref: '#/components/schemas/PaymentRequest' required: true responses: '201': - description: Patient created successfully. + description: Payment successfully processed content: application/json: schema: - $ref: '#/components/schemas/Patient' - '400': - description: Missing fields in the request body. - content: - application/json: - example: - message: Missing fields - '500': - description: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred + $ref: '#/components/schemas/Payment' security: - cookieAuth: [] - /api/v1/patients/{id}: + /api/v1/payments/{id}: get: tags: - - Patients - summary: Get patient by ID - description: Fetch a specific patient using their unique ID. + - Payment + summary: Retrieve a payment by ID parameters: - in: path name: id @@ -2103,155 +2419,103 @@ paths: style: simple responses: '200': - description: Patient retrieved successfully. + description: Details of a specific payment content: application/json: schema: - $ref: '#/components/schemas/Patient' + $ref: '#/components/schemas/Payment' '404': - description: Patient not found. - content: - application/json: - example: - message: Patient not found - '500': - description: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred + description: Payment not found security: - cookieAuth: [] - put: + /api/v1/payments/clinic/{clinicId}: + get: tags: - - Patients - summary: Update a patient by ID - description: Modify the details of a specific patient. + - Payment + summary: Retrieve all payments by clinic ID parameters: - in: path - name: id + name: clinicId required: true schema: type: string style: simple - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: true - required: true responses: '200': - description: Patient updated successfully. + description: A list of payments for the specified clinic content: application/json: schema: - $ref: '#/components/schemas/Patient' - '404': - description: Patient not found. - content: - application/json: - example: - message: Patient not found + type: array + items: + $ref: '#/components/schemas/Payment' + '400': + description: Clinic ID is required '500': - description: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred + description: Server error security: - cookieAuth: [] - delete: + /api/v1/clinics: + get: tags: - - Patients - summary: Delete a patient by ID - description: Remove a specific patient from the system. - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple + - Clinic + summary: Retrieve all clinics responses: '200': - description: Patient deleted successfully. + description: A list of clinics content: application/json: schema: - $ref: '#/components/schemas/Patient' - '404': - description: Patient not found. - content: - application/json: - example: - message: Patient not found - '500': - description: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred - security: - - cookieAuth: [] - /api/v1/staff/register: + type: array + items: + $ref: '#/components/schemas/Clinic' post: tags: - - staff - summary: Register a new doctor + - Clinic + summary: Register a new clinic requestBody: content: application/json: schema: - type: object - properties: - name: - type: string - surname: - type: string - specialty: - type: string - dni: - type: string - clinicId: - type: string - password: - type: string - email: - type: string + $ref: '#/components/schemas/ClinicRequest' required: true responses: '201': - description: Doctor created successfully - '400': - description: Bad request + description: Clinic successfully registered + content: + application/json: + schema: + $ref: '#/components/schemas/Clinic' security: - cookieAuth: [] - /api/v1/staff/{doctorId}: + /api/v1/clinics/{id}: get: tags: - - staff - summary: Get doctor by ID + - Clinic + summary: Retrieve a clinic by ID parameters: - in: path - name: doctorId + name: id required: true schema: type: string style: simple responses: '200': - description: Doctor retrieved successfully + description: Details of a specific clinic + content: + application/json: + schema: + $ref: '#/components/schemas/Clinic' '404': - description: Doctor not found + description: Clinic not found put: tags: - - staff - summary: Update doctor speciality + - Clinic + summary: Update a clinic by ID parameters: - in: path - name: doctorId + name: id required: true schema: type: string @@ -2260,91 +2524,31 @@ paths: content: application/json: schema: - type: object - properties: - specialty: - type: string + $ref: '#/components/schemas/ClinicRequest' required: true responses: '200': - description: Speciality updated successfully - '404': - description: Doctor not found + description: Clinic successfully updated + content: + application/json: + schema: + $ref: '#/components/schemas/Clinic' security: - cookieAuth: [] delete: tags: - - staff - summary: Delete a doctor - parameters: - - in: path - name: doctorId - required: true - schema: - type: string - style: simple - responses: - '204': - description: Doctor deleted successfully - '404': - description: Doctor not found - security: - - cookieAuth: [] - /api/v1/staff/clinic/{clinicId}/speciality/{speciality}: - get: - tags: - - staff - summary: Get doctors by speciality in a clinic - parameters: - - in: path - name: clinicId - required: true - schema: - type: string - style: simple - - in: path - name: speciality - schema: - type: string - style: simple - responses: - '200': - description: List of doctors - '404': - description: No doctors found - /api/v1/staff/me: - get: - tags: - - staff - summary: Get authenticated doctor - responses: - '200': - description: Authenticated doctor retrieved successfully - content: - application/json: - schema: - type: object - properties: - _id: - type: string - name: - type: string - surname: - type: string - specialty: - type: string - dni: - type: string - clinicId: - type: string - email: - type: string - userId: - type: string - '404': - description: Authenticated doctor not found - '400': - description: Error retrieving authenticated doctor + - Clinic + summary: Delete a clinic by ID + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + responses: + '204': + description: Clinic successfully deleted security: - cookieAuth: [] /api/v1/workshifts: @@ -2521,253 +2725,35 @@ paths: '500': description: Server error security: - - cookieAuth: [] - /api/v1/workshifts/doctor/{doctorId}: - get: - tags: - - Workshifts - summary: Get workshifts by doctor ID - parameters: - - in: path - name: doctorId - description: Doctor ID - required: true - schema: - type: string - style: simple - responses: - '200': - description: Lista de workshifts - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Workshift' - '500': - description: Error del servidor - security: - - cookieAuth: [] -components: - schemas: - User: - description: Schema for the User model, including fields for unique ID, email, password, role, and optional associations with patient and clinic. - type: object - properties: - _id: - example: 550e8400-e29b-41d4-a716-446655440000 - description: Unique identifier for the user. Defaults to a generated UUID. - type: string - format: uuid - email: - example: john_doe@email.com - description: Unique email for the user. - type: string - password: - description: Hashed password of the user. - type: string - roles: - example: - - doctor - - clinicadmin - description: List of roles assigned to the user. - default: - - patient - type: array - items: - type: string - enum: - - admin - - clinicadmin - - doctor - - patient - doctorid: - nullable: true - example: doctor12345 - description: Identifier of the doctor if the user is a clinic doctor. - type: string - patientid: - nullable: true - example: patient12345 - description: Identifier of the patient if the user is associated with a patient record. - type: string - createdAt: - example: 2023-10-25T08:40:51.620Z - description: Timestamp when the user was created. - type: string - format: date-time - updatedAt: - example: 2023-10-26T08:40:51.620Z - description: Timestamp when the user was last updated. - type: string - format: date-time - required: - - email - - password - - roles - Clinic: - type: object - properties: - id: - type: string - name: - type: string - city: - type: string - district: - type: string - plan: - type: string - active: - type: boolean - postalCode: - type: string - countryCode: - type: string - ClinicRequest: - type: object - properties: - name: - type: string - city: - type: string - district: - type: string - plan: - type: string - active: - type: boolean - postalCode: - type: string - countryCode: - type: string - Payment: - type: object - properties: - id: - type: string - date: - type: string - format: date-time - clinicId: - type: string - status: - type: string - planId: - type: string - PaymentRequest: - type: object - properties: - planId: - type: string - clinicId: - type: string - Plan: - type: object - properties: - id: - type: string - name: - type: string - price: - type: number - features: - type: array - items: - type: string - ClinicalHistory: - type: object - properties: - id: - type: string - patientId: - type: string - treatments: - type: array - items: - $ref: '#/components/schemas/Treatment' - currentConditions: - type: array - items: - $ref: '#/components/schemas/CurrentCondition' - images: - type: array - items: - $ref: '#/components/schemas/File' - analytics: - type: array - items: - $ref: '#/components/schemas/File' - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - CreateClinicalHistory: - type: object - properties: - patientId: - type: string - required: - - patientId - Treatment: - type: object - properties: - name: - description: Name of the treatment - type: string - startDate: - description: Start date of the treatment - type: string - format: date - endDate: - description: End date of the treatment - type: string - format: date - instructions: - description: Instructions for the treatment - type: string - required: - - name - - endDate - - instructions - CurrentCondition: - type: object - properties: - name: - description: Name of the current condition - type: string - details: - description: Additional details about the current condition - type: string - since: - description: When the condition started - type: string - format: date - until: - description: When the condition ended - type: string - format: date - required: - - name - - details - File: - type: object - properties: - name: - description: Name of the file - type: string - originalName: - description: Original name of the file - type: string - url: - description: URL of the file - type: string - date: - description: Date the file was uploaded + - cookieAuth: [] + /api/v1/workshifts/doctor/{doctorId}: + get: + tags: + - Workshifts + summary: Get workshifts by doctor ID + parameters: + - in: path + name: doctorId + description: Doctor ID + required: true + schema: type: string - format: date-time + style: simple + responses: + '200': + description: Lista de workshifts + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Workshift' + '500': + description: Error del servidor + security: + - cookieAuth: [] +components: + schemas: Appointment: type: object properties: @@ -2908,12 +2894,102 @@ components: - completed - cancelled - no_show - Patient: + ClinicalHistory: type: object properties: id: - description: Unique identifier of the patient. type: string + patientId: + type: string + treatments: + type: array + items: + $ref: '#/components/schemas/Treatment' + currentConditions: + type: array + items: + $ref: '#/components/schemas/CurrentCondition' + images: + type: array + items: + $ref: '#/components/schemas/File' + analytics: + type: array + items: + $ref: '#/components/schemas/File' + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + CreateClinicalHistory: + type: object + properties: + patientId: + type: string + required: + - patientId + Treatment: + type: object + properties: + name: + description: Name of the treatment + type: string + startDate: + description: Start date of the treatment + type: string + format: date + endDate: + description: End date of the treatment + type: string + format: date + instructions: + description: Instructions for the treatment + type: string + required: + - name + - endDate + - instructions + CurrentCondition: + type: object + properties: + name: + description: Name of the current condition + type: string + details: + description: Additional details about the current condition + type: string + since: + description: When the condition started + type: string + format: date + until: + description: When the condition ended + type: string + format: date + required: + - name + - details + File: + type: object + properties: + name: + description: Name of the file + type: string + originalName: + description: Original name of the file + type: string + url: + description: URL of the file + type: string + date: + description: Date the file was uploaded + type: string + format: date-time + Patient: + type: object + properties: name: type: string surname: @@ -2925,19 +3001,16 @@ components: type: string city: type: string - clinicHistoryId: - type: string - username: - type: string email: type: string + password: + type: string required: - name - surname - birthdate - dni - city - - clinicHistoryId - username - email ErrorResponse: @@ -2945,6 +3018,141 @@ components: properties: message: type: string + LogEntry: + type: object + properties: + requestId: + description: Unique identifier for the request log. + type: string + timestamp: + description: The timestamp when the log was created. + type: string + format: date-time + User: + description: Schema for the User model, including fields for unique ID, email, password, role, and optional associations with patient and clinic. + type: object + properties: + _id: + example: 550e8400-e29b-41d4-a716-446655440000 + description: Unique identifier for the user. Defaults to a generated UUID. + type: string + format: uuid + email: + example: john_doe@email.com + description: Unique email for the user. + type: string + password: + description: Hashed password of the user. + type: string + roles: + example: + - doctor + - clinicadmin + description: List of roles assigned to the user. + default: + - patient + type: array + items: + type: string + enum: + - admin + - clinicadmin + - doctor + - patient + doctorid: + nullable: true + example: doctor12345 + description: Identifier of the doctor if the user is a clinic doctor. + type: string + patientid: + nullable: true + example: patient12345 + description: Identifier of the patient if the user is associated with a patient record. + type: string + createdAt: + example: 2023-10-25T08:40:51.620Z + description: Timestamp when the user was created. + type: string + format: date-time + updatedAt: + example: 2023-10-26T08:40:51.620Z + description: Timestamp when the user was last updated. + type: string + format: date-time + required: + - email + - password + - roles + Clinic: + type: object + properties: + id: + type: string + name: + type: string + city: + type: string + district: + type: string + plan: + type: string + active: + type: boolean + postalCode: + type: string + countryCode: + type: string + ClinicRequest: + type: object + properties: + name: + type: string + city: + type: string + district: + type: string + plan: + type: string + active: + type: boolean + postalCode: + type: string + countryCode: + type: string + Payment: + type: object + properties: + id: + type: string + date: + type: string + format: date-time + clinicId: + type: string + status: + type: string + planId: + type: string + PaymentRequest: + type: object + properties: + planId: + type: string + clinicId: + type: string + Plan: + type: object + properties: + id: + type: string + name: + type: string + price: + type: number + features: + type: array + items: + type: string Workshift: type: object properties: diff --git a/sync-openapi.sh b/sync-openapi.sh index b517b9b..491f7c3 100755 --- a/sync-openapi.sh +++ b/sync-openapi.sh @@ -8,7 +8,6 @@ mkdir -p "$SPECS_DIR" # Just list services one per line services=( - alert appointment authorization history