From e18f194041eac0058134c9ceb55b115386dcc7f3 Mon Sep 17 00:00:00 2001 From: AntonioRodriguezRuiz Date: Mon, 6 Jan 2025 20:50:55 +0100 Subject: [PATCH] chore: updated openapi specs --- static/openapi.yaml | 3412 ++++++++++++++++++++++--------------------- 1 file changed, 1708 insertions(+), 1704 deletions(-) diff --git a/static/openapi.yaml b/static/openapi.yaml index 61d7fd6..f0778ce 100644 --- a/static/openapi.yaml +++ b/static/openapi.yaml @@ -387,131 +387,126 @@ paths: description: Error retrieving appointments for the clinic security: - cookieAuth: [] - /api/v1/staff/register: + /api/v1/users: post: tags: - - staff - summary: Register a new doctor + - 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: - name: - type: string - surname: - type: string - specialty: - type: string - dni: - type: string - clinicId: + email: + example: new_user@example.com + description: Email address of the user. type: string password: + example: securepassword123 + description: User's password. type: string - email: + 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: + - email + - password required: true responses: '201': - description: Doctor created successfully + 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 '400': - description: Bad request - security: - - cookieAuth: [] - /api/v1/staff/{doctorId}: - get: - tags: - - staff - summary: Get doctor by ID - parameters: - - in: path - name: doctorId - required: true - schema: - type: string - style: simple - responses: - '200': - description: Doctor retrieved successfully - '404': - description: Doctor not found - put: - tags: - - staff - summary: Update doctor speciality - parameters: - - in: path - name: doctorId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - type: object - properties: - specialty: + 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 - required: true - responses: - '200': - description: Speciality updated successfully - '404': - description: Doctor not found - 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 + '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' security: - cookieAuth: [] - /api/v1/staff/clinic/{clinicId}/speciality/{speciality}: + /api/v1/users/{id}: get: tags: - - staff - summary: Get doctors by speciality in a clinic + - 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: clinicId + name: id + description: ID of the user to retrieve 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 + description: User retrieved successfully content: application/json: schema: @@ -519,451 +514,731 @@ paths: properties: _id: type: string - name: - type: string - surname: + email: type: string - specialty: + username: type: string - dni: + roles: + type: array + items: + type: string + createdAt: type: string - clinicId: + format: date-time + updatedAt: type: string - email: + 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 - userId: + example: + message: Token not valid + '403': + description: Unauthorized access + content: + application/json: + schema: + type: object + properties: + message: type: string + example: + message: Forbidden '404': - description: Authenticated doctor not found - '400': - description: Error retrieving authenticated doctor - security: - - cookieAuth: [] - /api/v1/histories: - get: - summary: Get all clinical histories - responses: - '200': - description: Returns a list of all clinical histories + description: User not found content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/ClinicalHistory' + type: object + properties: + message: + type: string + example: + message: User not found '500': - description: Error retrieving clinical histories - security: - - jwt: [] + description: Internal server error + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: + message: Internal server error + 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. + parameters: + - in: path + name: id + description: ID of the user to update + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + type: object + properties: + email: + example: 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 + 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 + '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 + delete: + tags: + - Users + summary: Deletes user + description: Delete user by user ID. Requires the user to have specific roles. + parameters: + - in: path + name: id + description: ID of the user to update + required: true + schema: + type: string + style: simple + responses: + '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: + type: string + example: + message: Token not valid + '403': + description: Unauthorized access + content: + application/json: + schema: + type: object + properties: + message: + type: string + example: + message: Unauthorized + '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 + /api/v1/users/change-password: + post: + tags: + - Users + summary: Change user password + description: Allows authenticated users to change their password. + 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 + required: true + responses: + '200': + description: Password changed successfully + content: + application/json: + schema: + type: object + properties: + message: + example: Password changed successfully + type: string + '400': + 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: + type: string + example: + message: Forbidden + '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: + example: Error when authenticating + type: string + /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: 2FA successfully enabled + content: + application/json: + schema: + type: object + properties: + message: + example: 2FA enabled successfully + type: string + qrCodeUrl: + example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... + type: string + format: uri + secret: + example: JBSWY3DPEHPK3PXP + type: string + '400': + description: Invalid request + content: + application/json: + schema: + type: object + properties: + message: + example: Bad request + type: string + '401': + description: Unauthorized + content: + application/json: + schema: + type: object + properties: + message: + example: Unauthorized + type: string + '500': + description: Internal server error + content: + application/json: + schema: + type: object + properties: + message: + example: Internal server error + type: string + /api/v1/users/verify-2fa: post: - summary: Create a new clinical history + tags: + - Users + summary: Verify two-factor authentication + description: Allows authenticated users to verify two-factor authentication. requestBody: content: application/json: schema: - $ref: '#/components/schemas/CreateClinicalHistory' + 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 responses: - '201': - description: Clinical history created + '200': + description: 2FA token verified successfully content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' + type: object + properties: + message: + example: Login successful + type: string '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 + description: Invalid request content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID is required + type: object + properties: + message: + example: 2FA not enabled for this user + type: string '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 + description: Unauthorized access content: - application/pdf: + application/json: schema: - type: string - format: binary - '400': - description: Clinical history ID is required - '403': - description: Access denied - '404': - description: Clinical history not found + type: object + properties: + message: + type: string + example: + message: Invalid 2FA token '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 + description: Internal server error 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: + type: object + properties: + message: + example: Internal server error + type: string + /api/v1/login: 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: + - Authentication + summary: User Login + description: Authenticates a user with their email and password. requestBody: content: application/json: schema: type: object properties: - allergy: - description: The name of the allergy to add. + email: + example: admin@email.com + description: The user's unique email. + type: string + password: + example: admin123 + description: The user's password. type: string required: - - allergy + - email + - password 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. + description: Successful login content: application/json: schema: type: object properties: message: + example: Login successful type: string - '404': - description: Clinical history not found. + '401': + description: Unauthorized - invalid credentials content: application/json: schema: type: object properties: message: + example: Invalid credentials type: string '500': - description: Internal server error while adding the allergy. + $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 content: application/json: schema: type: object properties: message: + example: Logout successful 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 + '401': + description: Unauthorized - user is not logged in + content: + application/json: + schema: + type: object + properties: + message: + example: Not logged in + 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 responses: '200': - description: Allergy successfully removed from the clinical history. + description: Tokens refreshed. content: application/json: schema: type: object properties: - _id: + message: + example: Tokens refreshed type: string - allergies: - type: array - items: - type: string - '400': - description: Missing clinical history ID or allergy in the request. + '401': + description: Unauthorized - Token is missing, expired, or invalid. content: application/json: schema: type: object properties: message: + example: Token expired or invalid. type: string - '404': - description: Clinical history not found. + /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. content: application/json: schema: type: object properties: message: + example: Token is valid type: string - '500': - description: Internal server error while removing the allergy. + '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/workshifts: + get: + tags: + - Workshifts + summary: Get all workshifts + responses: + '200': + description: Retrieve a list of workshifts + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Workshift' + '500': + description: Server error security: - - jwt: [] - /api/v1/histories/{id}/treatment: + - cookieAuth: [] post: - summary: Add a new treatment to a clinical history - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple + tags: + - Workshifts + summary: Create a new workshift requestBody: content: application/json: schema: - $ref: '#/components/schemas/Treatment' + $ref: '#/components/schemas/WorkshiftInput' required: true responses: - '200': - description: Treatment added successfully + '201': + description: Workshift created content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' + $ref: '#/components/schemas/Workshift' '400': - description: Clinical history ID is required or validation error - '404': - description: Clinical history not found - '500': - description: Error adding treatment + description: Validation error 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 + - cookieAuth: [] + /api/v1/workshifts/week: + post: + tags: + - Workshifts + summary: Create a new workshift for a week requestBody: content: application/json: schema: - $ref: '#/components/schemas/Treatment' + type: object + properties: + doctorId: + description: Unique identifier for the doctor + type: string + clinicId: + description: Unique identifier for the clinic + type: string + duration: + example: 480 + description: Duration of each work shift in minutes + type: integer + periodStartDate: + description: Start date of the week, must be a Monday + type: string + format: date-time + periodEndDate: + description: End date of the week, must be a Sunday within the same week as weekStartDate + type: string + format: date + required: + - doctorId + - clinicId + - duration + - weekStartDate + - weekEndDate required: true responses: - '200': - description: Treatment updated successfully + '201': + description: Workshifts created successfully content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' + type: array + items: + $ref: '#/components/schemas/Workshift' '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 + description: Invalid input or validation error 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 + type: object + properties: + message: + example: weekStartDate must be a Monday and weekEndDate a Sunday of the same week + description: Error message explaining the issue + type: string security: - - jwt: [] - /api/v1/histories/{id}/condition: - post: - summary: Add a new current condition to a clinical history + - cookieAuth: [] + /api/v1/workshifts/{id}: + get: + tags: + - Workshifts + summary: Get a workshift by ID parameters: - in: path name: id + description: Workshift 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: Retrieve a workshift content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID is required or validation error + $ref: '#/components/schemas/Workshift' '404': - description: Clinical history not found + description: Workshift not found '500': - description: Error adding current condition + description: Server error security: - - jwt: [] - /api/v1/histories/{id}/condition/{currentConditionId}: + - cookieAuth: [] put: - summary: Update a current condition in a clinical history + tags: + - Workshifts + summary: Update a workshift by ID parameters: - in: path name: id - required: true - schema: - type: string - style: simple - - in: path - name: currentConditionId + description: Workshift ID required: true schema: type: string @@ -972,382 +1247,265 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CurrentCondition' + $ref: '#/components/schemas/WorkshiftInput' required: true responses: '200': - description: Current condition updated successfully + description: Workshift updated content: application/json: schema: - $ref: '#/components/schemas/ClinicalHistory' - '400': - description: Clinical history ID or Current condition ID is required, or validation error + $ref: '#/components/schemas/Workshift' '404': - description: Clinical history or current condition not found - '500': - description: Error updating current condition + description: Workshift not found + '400': + description: Validation error security: - - jwt: [] + - cookieAuth: [] delete: - summary: Delete a current condition from a clinical history + tags: + - Workshifts + summary: Delete a workshift by ID parameters: - in: path - name: id - required: true - schema: - type: string - style: simple - - in: path - name: currentConditionId + name: id + description: Workshift ID 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 + '204': + description: Workshift deleted '404': - description: Clinical history or current condition not found + description: Workshift not found '500': - description: Error deleting current condition + description: Server error 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. + - cookieAuth: [] + /api/v1/workshifts/doctor/{doctorId}: + get: + tags: + - Workshifts + summary: Get workshifts by doctor ID parameters: - in: path - name: id - description: The ID of the clinical history record. + name: doctorId + description: Doctor ID 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: - '201': - description: Image uploaded successfully - content: - application/json: - schema: - type: object - properties: - message: - example: Image uploaded successfully - type: string - imageUrl: - description: URL of the uploaded image. - type: string - '400': - description: Bad Request - Missing required headers or Clinical History ID. - content: - application/json: - schema: - type: object - properties: - message: - example: clinicalHistoryId is required - type: string - '404': - description: Clinical History record not found. + '200': + description: Lista de workshifts content: application/json: schema: - type: object - properties: - message: - example: Clinical history not found - type: string + type: array + items: + $ref: '#/components/schemas/Workshift' '500': - description: Internal Server Error + description: Error del servidor + security: + - cookieAuth: [] + /api/v1/plans: + get: + tags: + - Plan + summary: Retrieve all plans + responses: + '200': + description: A list of plans content: application/json: schema: - type: object - properties: - message: - example: Internal server error occurred. - type: string - 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. + 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/plans/{id}: + get: + tags: + - Plan + summary: Retrieve a plan by ID + description: Retrieves details of a specific plan by its unique ID. 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: The unique identifier for the plan required: true schema: type: string style: simple responses: '200': - description: Image deleted successfully + description: Plan successfully retrieved content: application/json: schema: - type: object - properties: - message: - example: Image deleted successfully - type: string + $ref: '#/components/schemas/Plan' '400': - description: Bad Request - Missing or invalid parameters. + description: Missing plan ID content: application/json: schema: type: object properties: message: - example: clinicalHistoryId and imageId are required + example: Missing plan ID type: string '404': - description: Not Found - Clinical history or image not found. + description: Plan not found content: application/json: schema: type: object properties: message: - example: Clinical history or image not found + example: Plan not found type: string '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. + 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: - - jwt: [] - /api/v1/histories/{id}/analytic: + - cookieAuth: [] 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: + - Payment + summary: Process a new payment requestBody: content: - multipart/form-data: + application/json: schema: - type: object - properties: - file: - description: The analytic file to upload. - type: string - format: binary + $ref: '#/components/schemas/PaymentRequest' required: true responses: '201': - description: Analytic uploaded successfully + description: Payment successfully processed content: application/json: schema: - type: object - properties: - message: - example: Analytic uploaded successfully - type: string - analyticUrl: - description: URL of the uploaded analytic. - type: string - '400': - description: Bad Request - Missing required headers or Clinical History ID. + $ref: '#/components/schemas/Payment' + security: + - cookieAuth: [] + /api/v1/payments/{id}: + get: + tags: + - Payment + summary: Retrieve a payment by ID + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + responses: + '200': + description: Details of a specific payment content: application/json: schema: - type: object - properties: - message: - example: clinicalHistoryId is required - type: string + $ref: '#/components/schemas/Payment' '404': - description: Clinical History record not found. - content: - application/json: - schema: - type: object - properties: - message: - example: Clinical history not found - type: string - '500': - description: Internal Server Error - content: - application/json: - schema: - type: object - properties: - message: - example: Internal server error occurred. - type: string + description: Payment not found 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. + - cookieAuth: [] + /api/v1/payments/clinic/{clinicId}: + get: + tags: + - Payment + summary: Retrieve all payments by clinic ID 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. + name: clinicId required: true schema: type: string style: simple responses: '200': - description: Analytic deleted successfully + description: A list of payments for the specified clinic content: application/json: schema: - type: object - properties: - message: - example: Analytic deleted successfully - type: string + type: array + items: + $ref: '#/components/schemas/Payment' '400': - description: Bad Request - Missing or invalid parameters. - content: - application/json: - schema: - type: object - properties: - message: - example: clinicalHistoryId and analyticId are required - type: string - '404': - description: Not Found - Clinical history or analytic not found. - content: - application/json: - schema: - type: object - properties: - message: - example: Clinical history or analytic not found - type: string + description: Clinic ID is required '500': - description: Internal Server Error - content: - application/json: - schema: - type: object - properties: - message: - example: Error deleting analytic - type: string - error: - example: Detailed error message. - type: string + description: Server error security: - - jwt: [] - /api/v1/patients/: + - cookieAuth: [] + /api/v1/clinics: get: tags: - - Patients - summary: Retrieve all patients - description: Fetch a list of all patients. + - Clinic + summary: Retrieve all clinics responses: '200': - description: List of patients retrieved successfully. + description: A list of clinics content: application/json: schema: type: array items: - $ref: '#/components/schemas/Patient' - '500': - description: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred - security: - - cookieAuth: [] + $ref: '#/components/schemas/Clinic' post: tags: - - Patients - summary: Register a new patient - description: Creates a new patient record in the system. + - Clinic + summary: Register a new clinic requestBody: content: application/json: schema: - $ref: '#/components/schemas/Patient' + $ref: '#/components/schemas/ClinicRequest' required: true responses: '201': - description: Patient created successfully. + description: Clinic successfully registered 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/Clinic' security: - cookieAuth: [] - /api/v1/patients/{id}: + /api/v1/clinics/{id}: get: tags: - - Patients - summary: Get patient by ID - description: Fetch a specific patient using their unique ID. + - Clinic + summary: Retrieve a clinic by ID parameters: - in: path name: id @@ -1357,30 +1515,17 @@ paths: style: simple responses: '200': - description: Patient retrieved successfully. + description: Details of a specific clinic content: application/json: schema: - $ref: '#/components/schemas/Patient' + $ref: '#/components/schemas/Clinic' '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: [] + description: Clinic not found put: tags: - - Patients - summary: Update a patient by ID - description: Modify the details of a specific patient. + - Clinic + summary: Update a clinic by ID parameters: - in: path name: id @@ -1392,35 +1537,21 @@ paths: content: application/json: schema: - type: object - additionalProperties: true + $ref: '#/components/schemas/ClinicRequest' required: true responses: '200': - description: Patient updated successfully. + description: Clinic successfully updated 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 + $ref: '#/components/schemas/Clinic' security: - cookieAuth: [] delete: tags: - - Patients - summary: Delete a patient by ID - description: Remove a specific patient from the system. + - Clinic + summary: Delete a clinic by ID parameters: - in: path name: id @@ -1429,28 +1560,14 @@ paths: type: string style: simple responses: - '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: Internal server error. - content: - application/json: - example: - message: An unexpected error occurred + '204': + description: Clinic successfully deleted security: - cookieAuth: [] - /logs: + /api/v1/logs: get: + tags: + - Logs 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: @@ -1505,8 +1622,10 @@ paths: type: string security: - cookieAuth: [] - /logs/{requestId}: + /api/v1/logs/{requestId}: get: + tags: + - Logs 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: @@ -1575,404 +1694,293 @@ paths: type: string security: - cookieAuth: [] - /api/v1/workshifts: + /api/v1/histories: get: - tags: - - Workshifts - summary: Get all workshifts + summary: Get all clinical histories responses: '200': - description: Retrieve a list of workshifts + description: Returns a list of all clinical histories content: application/json: schema: type: array items: - $ref: '#/components/schemas/Workshift' + $ref: '#/components/schemas/ClinicalHistory' '500': - description: Server error - security: - - cookieAuth: [] - post: - tags: - - Workshifts - summary: Create a new workshift - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/WorkshiftInput' - required: true - responses: - '201': - description: Workshift created - content: - application/json: - schema: - $ref: '#/components/schemas/Workshift' - '400': - description: Validation error + description: Error retrieving clinical histories security: - - cookieAuth: [] - /api/v1/workshifts/week: + - jwt: [] post: - tags: - - Workshifts - summary: Create a new workshift for a week + summary: Create a new clinical history requestBody: content: application/json: schema: - type: object - properties: - doctorId: - description: Unique identifier for the doctor - type: string - clinicId: - description: Unique identifier for the clinic - type: string - duration: - example: 480 - description: Duration of each work shift in minutes - type: integer - periodStartDate: - description: Start date of the week, must be a Monday - type: string - format: date-time - periodEndDate: - description: End date of the week, must be a Sunday within the same week as weekStartDate - type: string - format: date - required: - - doctorId - - clinicId - - duration - - weekStartDate - - weekEndDate + $ref: '#/components/schemas/CreateClinicalHistory' required: true responses: '201': - description: Workshifts created successfully - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Workshift' - '400': - description: Invalid input or validation error + description: Clinical history created content: application/json: schema: - type: object - properties: - message: - example: weekStartDate must be a Monday and weekEndDate a Sunday of the same week - description: Error message explaining the issue - type: string + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Patient ID is required or validation error + '500': + description: Error creating clinical history security: - - cookieAuth: [] - /api/v1/workshifts/{id}: + - jwt: [] + /api/v1/histories/{id}: get: - tags: - - Workshifts - summary: Get a workshift by ID + summary: Get a clinical history by its ID parameters: - in: path name: id - description: Workshift ID required: true schema: type: string style: simple responses: '200': - description: Retrieve a workshift + description: Returns the requested clinical history content: application/json: schema: - $ref: '#/components/schemas/Workshift' + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required + '403': + description: Access denied '404': - description: Workshift not found + description: Clinical history not found '500': - description: Server error + description: Error retrieving clinical history security: - - cookieAuth: [] - put: - tags: - - Workshifts - summary: Update a workshift by ID + - jwt: [] + delete: + summary: Delete a clinical history by its ID parameters: - in: path name: id - description: Workshift ID required: true schema: type: string style: simple - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/WorkshiftInput' - required: true responses: - '200': - description: Workshift updated - content: - application/json: - schema: - $ref: '#/components/schemas/Workshift' - '404': - description: Workshift not found + '204': + description: Clinical history deleted successfully '400': - description: Validation error + description: Clinical history ID is required + '500': + description: Error deleting clinical history security: - - cookieAuth: [] - delete: - tags: - - Workshifts - summary: Delete a workshift by ID + - jwt: [] + /api/v1/histories/{id}/report: + get: + summary: Get a clinical history report by its ID parameters: - in: path name: id - description: Workshift ID required: true schema: type: string style: simple responses: - '204': - description: Workshift deleted + '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: Workshift not found + description: Clinical history not found '500': - description: Server error + description: Error generating clinical history report security: - - cookieAuth: [] - /api/v1/workshifts/doctor/{doctorId}: + - jwt: [] + /api/v1/histories/patient/{patientId}: get: - tags: - - Workshifts - summary: Get workshifts by doctor ID + summary: Get a clinical history by patient ID parameters: - in: path - name: doctorId - description: Doctor ID + name: patientId required: true schema: type: string style: simple responses: '200': - description: Lista de workshifts + description: Returns the clinical history for the requested patient content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Workshift' + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Patient ID is required + '403': + description: Access denied + '404': + description: Clinical history not found '500': - description: Error del servidor + description: Error retrieving clinical history for patient security: - - cookieAuth: [] - /api/v1/plans: - get: - tags: - - Plan - summary: Retrieve all plans + - jwt: [] + delete: + summary: Delete a clinical history by patient ID + parameters: + - in: path + name: patientId + required: true + schema: + type: string + style: simple responses: - '200': - description: A list of plans - 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/plans/{id}: - get: - tags: - - Plan - summary: Retrieve a plan by ID - description: Retrieves details of a specific plan by its unique ID. + '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 unique identifier for the plan + 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: Plan successfully retrieved + description: Allergy successfully added to the clinical history. content: application/json: schema: - $ref: '#/components/schemas/Plan' + type: object + properties: + _id: + type: string + allergies: + type: array + items: + type: string '400': - description: Missing plan ID + description: Missing clinical history ID or allergy in the request. content: application/json: schema: type: object properties: message: - example: Missing plan ID type: string '404': - description: Plan not found + description: Clinical history 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 while adding the allergy. content: application/json: 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: - - Payment - summary: Process a new payment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PaymentRequest' - required: true - responses: - '201': - description: Payment successfully processed - content: - application/json: - schema: - $ref: '#/components/schemas/Payment' - security: - - cookieAuth: [] - /api/v1/payments/{id}: - get: - tags: - - Payment - summary: Retrieve a payment by ID - parameters: - - in: path - name: id - required: true - schema: - type: string - style: simple - responses: - '200': - description: Details of a specific payment - content: - application/json: - schema: - $ref: '#/components/schemas/Payment' - '404': - description: Payment not found security: - - cookieAuth: [] - /api/v1/payments/clinic/{clinicId}: - get: - tags: - - Payment - summary: Retrieve all payments by clinic ID + - 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: clinicId + 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: A list of payments for the specified clinic + description: Allergy successfully removed from the clinical history. content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Payment' + type: object + properties: + _id: + type: string + allergies: + type: array + items: + type: string '400': - description: Clinic ID is required - '500': - description: Server error - security: - - cookieAuth: [] - /api/v1/clinics: - get: - tags: - - Clinic - summary: Retrieve all clinics - responses: - '200': - description: A list of clinics + description: Missing clinical history ID or allergy in the request. 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 + type: object + properties: + message: + type: string + '404': + description: Clinical history not found. content: application/json: schema: - $ref: '#/components/schemas/Clinic' + 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: - - cookieAuth: [] - /api/v1/clinics/{id}: - get: - tags: - - Clinic - summary: Retrieve a clinic by ID + - jwt: [] + /api/v1/histories/{id}/treatment: + post: + summary: Add a new treatment to a clinical history parameters: - in: path name: id @@ -1980,19 +1988,30 @@ paths: schema: type: string style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Treatment' + required: true responses: '200': - description: Details of a specific clinic + description: Treatment added successfully content: application/json: schema: - $ref: '#/components/schemas/Clinic' + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required or validation error '404': - description: Clinic not found + description: Clinical history not found + '500': + description: Error adding treatment + security: + - jwt: [] + /api/v1/histories/{id}/treatment/{treatmentId}: put: - tags: - - Clinic - summary: Update a clinic by ID + summary: Update a treatment in a clinical history parameters: - in: path name: id @@ -2000,25 +2019,35 @@ paths: schema: type: string style: simple + - in: path + name: treatmentId + required: true + schema: + type: string + style: simple requestBody: content: application/json: schema: - $ref: '#/components/schemas/ClinicRequest' + $ref: '#/components/schemas/Treatment' required: true responses: '200': - description: Clinic successfully updated + description: Treatment updated successfully content: application/json: schema: - $ref: '#/components/schemas/Clinic' + $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: - - cookieAuth: [] + - jwt: [] delete: - tags: - - Clinic - summary: Delete a clinic by ID + summary: Delete a treatment from a clinical history parameters: - in: path name: id @@ -2026,732 +2055,707 @@ paths: schema: type: string style: simple + - in: path + name: treatmentId + required: true + schema: + type: string + style: simple responses: - '204': - description: Clinic successfully deleted + '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: - - cookieAuth: [] - /api/v1/users: + - jwt: [] + /api/v1/histories/{id}/condition: post: - tags: - - Users - summary: Create User - description: Creates a new user with specified roles, email, and associated IDs for doctor or patient. + 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: - type: object - properties: - 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: - - email - - password + $ref: '#/components/schemas/CurrentCondition' 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 - '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 + '200': + description: Current condition added successfully content: application/json: schema: - type: object - properties: - message: - example: Forbidden - type: string + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID is required or validation error + '404': + description: Clinical history not found '500': - $ref: '#/components/responses/ServerError' + description: Error adding current condition security: - - 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. + - jwt: [] + /api/v1/histories/{id}/condition/{currentConditionId}: + put: + summary: Update a current condition in a clinical history parameters: - in: path name: id - description: ID of the user to retrieve 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: 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 + description: Current condition updated successfully content: application/json: schema: - type: object - properties: - message: - type: string - example: - message: Forbidden + $ref: '#/components/schemas/ClinicalHistory' + '400': + description: Clinical history ID or Current condition ID is required, or validation error '404': - description: User not found - content: - application/json: - schema: - type: object - properties: - message: - type: string - example: - message: User not found + description: Clinical history or current condition not found '500': - description: Internal server error + 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: - type: string - example: - message: Internal server error - 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. + $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: ID of the user to update + 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: user@example.com - description: Email address of the user. - type: string - password: - example: securepassword123 - description: User's password. + file: + description: The image file to upload. type: string - roles: - example: - - admin - - doctor - description: List of roles assigned to the user. - type: array - items: - type: string + format: binary required: true responses: - '200': - description: User updated successfully + '201': + description: Image uploaded successfully content: application/json: schema: type: object properties: - _id: - type: string - email: - type: string - roles: - type: array - items: - type: string - createdAt: + message: + example: Image uploaded successfully type: string - format: date-time - updatedAt: + imageUrl: + description: URL of the uploaded image. 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 + description: Bad Request - Missing required headers or Clinical History ID. content: application/json: schema: type: object properties: message: + example: clinicalHistoryId is required type: string - example: - message: Forbidden '404': - description: User not found + description: Clinical History record 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 - example: - message: Internal server error + security: + - jwt: [] + /api/v1/histories/{id}/image/{imageId}: delete: - tags: - - Users - summary: Deletes user - description: Delete user by user ID. Requires the user to have specific roles. + 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: ID of the user to update + description: The ID of the clinical history record. required: true schema: type: string style: simple - responses: - '204': - description: User deleted successfully - content: - application/json: - schema: - type: object - properties: - _id: - type: string - example: - _id: 617f1f77bcf86cd799439011 - '401': - description: Unautenticated + - in: path + name: imageId + description: The ID of the image to delete. + required: true + schema: + type: string + style: simple + responses: + '200': + description: Image deleted successfully content: application/json: schema: type: object properties: message: + example: Image deleted successfully type: string - example: - message: Token not valid - '403': - description: Unauthorized access + '400': + description: Bad Request - Missing or invalid parameters. content: application/json: schema: type: object properties: message: + example: clinicalHistoryId and imageId are required type: string - example: - message: Unauthorized '404': - description: User not found + 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: 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 - example: - message: Internal server error - /api/v1/users/change-password: + error: + example: Detailed error message. + type: string + security: + - jwt: [] + /api/v1/histories/{id}/analytic: post: - tags: - - Users - summary: Change user password - description: Allows authenticated users to change their 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: - currentPassword: - example: oldPassword123 - description: The current password of the user. - type: string - newPassword: - example: newPassword456 - description: The new password to set. + file: + description: The analytic file to upload. type: string - required: - - currentPassword - - newPassword + format: binary required: true responses: - '200': - description: Password changed successfully - content: - application/json: - schema: - type: object - properties: - message: - example: Password changed successfully - type: string - '400': - description: Invalid request + '201': + description: Analytic uploaded successfully content: application/json: schema: type: object properties: message: - example: '' + example: Analytic uploaded successfully type: string - '401': - description: Unauthorized - content: - application/json: - schema: - type: object - properties: - message: - example: Unauthorized + analyticUrl: + description: URL of the uploaded analytic. type: string - '403': - description: Unauthorized access + '400': + description: Bad Request - Missing required headers or Clinical History ID. content: application/json: schema: type: object properties: message: + example: clinicalHistoryId is required type: string - example: - message: Forbidden '404': - description: User not found + description: Clinical History record 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: Error when authenticating + example: Internal server error occurred. type: string - /api/v1/users/enable-2fa: - post: - tags: - - Users - summary: Enable two-factor authentication - description: Allows authenticated users to enable two-factor authentication. + 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: 2FA successfully enabled + description: Analytic deleted successfully content: application/json: schema: type: object properties: message: - example: 2FA enabled successfully - type: string - qrCodeUrl: - example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA... - type: string - format: uri - secret: - example: JBSWY3DPEHPK3PXP + example: Analytic deleted successfully type: string '400': - description: Invalid request + description: Bad Request - Missing or invalid parameters. content: application/json: schema: type: object properties: message: - example: Bad request + example: clinicalHistoryId and analyticId are required type: string - '401': - description: Unauthorized + '404': + description: Not Found - Clinical history or analytic not found. content: application/json: schema: type: object properties: message: - example: Unauthorized + example: Clinical history or analytic 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: Error deleting analytic type: string - /api/v1/users/verify-2fa: + error: + example: Detailed error message. + type: string + security: + - jwt: [] + /api/v1/staff/register: post: tags: - - Users - summary: Verify two-factor authentication - description: Allows authenticated users to verify two-factor authentication. + - staff + summary: Register a new doctor requestBody: content: application/json: schema: type: object properties: - userId: - example: 550e8400-e29b-41d4-a716-446655440000 - description: The user's unique ID. + name: type: string - totpToken: - example: '123456' - description: The two-factor authentication token. + surname: type: string - required: - - userId - - totpToken + specialty: + type: string + dni: + type: string + clinicId: + type: string + password: + type: string + email: + type: string + required: true + responses: + '201': + description: Doctor created successfully + '400': + description: Bad request + security: + - cookieAuth: [] + /api/v1/staff/{doctorId}: + get: + tags: + - staff + summary: Get doctor by ID + parameters: + - in: path + name: doctorId + required: true + schema: + type: string + style: simple + responses: + '200': + description: Doctor retrieved successfully + '404': + description: Doctor not found + put: + tags: + - staff + summary: Update doctor speciality + parameters: + - in: path + name: doctorId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + type: object + properties: + specialty: + type: string + required: true + responses: + '200': + description: Speciality updated successfully + '404': + description: Doctor not found + 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: 2FA token verified successfully + 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: - message: - example: Login successful + _id: type: string - '400': - description: Invalid request - content: - application/json: - schema: - type: object - properties: - message: - example: 2FA not enabled for this user + name: type: string - '403': - description: Unauthorized access + 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 + 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. content: application/json: schema: - type: object - properties: - message: - type: string - example: - message: Invalid 2FA token + type: array + items: + $ref: '#/components/schemas/Patient' '500': - description: Internal server error + description: Internal server error. content: application/json: - schema: - type: object - properties: - message: - example: Internal server error - type: string - /api/v1/login: + example: + message: An unexpected error occurred + security: + - cookieAuth: [] post: tags: - - Authentication - summary: User Login - description: Authenticates a user with their email and password. + - Patients + summary: Register a new patient + description: Creates a new patient record in the system. 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 + $ref: '#/components/schemas/Patient' required: true responses: - '200': - description: Successful login + '201': + description: Patient created successfully. content: application/json: schema: - type: object - properties: - message: - example: Login successful - type: string - '401': - description: Unauthorized - invalid credentials + $ref: '#/components/schemas/Patient' + '400': + description: Missing fields in the request body. content: application/json: - schema: - type: object - properties: - message: - example: Invalid credentials - type: string + example: + message: Missing fields '500': - $ref: '#/components/responses/ServerError' - /api/v1/logout: - post: + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred + security: + - cookieAuth: [] + /api/v1/patients/{id}: + get: tags: - - Authentication - summary: User Logout - description: Logs out a user by clearing authentication tokens. + - Patients + summary: Get patient by ID + description: Fetch a specific patient using their unique ID. + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple responses: '200': - description: Successful logout + description: Patient retrieved successfully. content: application/json: schema: - type: object - properties: - message: - example: Logout successful - type: string - '401': - description: Unauthorized - user is not logged in + $ref: '#/components/schemas/Patient' + '404': + description: Patient not found. content: application/json: - schema: - type: object - properties: - message: - example: Not logged in - type: string + example: + message: Patient not found '500': - $ref: '#/components/responses/ServerError' - /api/v1/token/refresh: - get: + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred + security: + - cookieAuth: [] + put: 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 + - Patients + summary: Update a patient by ID + description: Modify the details of a specific patient. + parameters: + - in: path + name: id + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + type: object + additionalProperties: true + required: true responses: '200': - description: Tokens refreshed. + description: Patient updated successfully. content: application/json: schema: - type: object - properties: - message: - example: Tokens refreshed - type: string - '401': - description: Unauthorized - Token is missing, expired, or invalid. + $ref: '#/components/schemas/Patient' + '404': + description: Patient not found. content: application/json: - schema: - type: object - properties: - message: - example: Token expired or invalid. - type: string - /api/v1/token/validate: - get: + example: + message: Patient not found + '500': + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred + security: + - cookieAuth: [] + delete: tags: - - Authentication - summary: Validates the user's token. - description: Checks the validity of the token provided in the user's cookies. - operationId: validateAuthToken + - 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 responses: '200': - description: Token is valid. + description: Patient deleted successfully. content: application/json: schema: - type: object - properties: - message: - example: Token is valid - type: string - '401': - description: Unauthorized - Token is missing, expired, or invalid. + $ref: '#/components/schemas/Patient' + '404': + description: Patient not found. content: application/json: - schema: - type: object - properties: - message: - example: Token expired or invalid. - type: string + example: + message: Patient not found + '500': + description: Internal server error. + content: + application/json: + example: + message: An unexpected error occurred + security: + - cookieAuth: [] components: schemas: Appointment: @@ -2816,84 +2820,254 @@ components: description: ID of the patient for whom the appointment is created type: string clinicId: - description: ID of the clinic where the appointment will be held - type: string - doctorId: - description: ID of the doctor for the appointment + description: ID of the clinic where the appointment will be held + type: string + doctorId: + description: ID of the doctor for the appointment + type: string + specialty: + description: Medical specialty for the appointment + type: string + enum: + - family_medicine + - nursing + - physiotherapy + - gynecology + - pediatrics + - dermatology + - cardiology + - neurology + - orthopedics + - psychiatry + - endocrinology + - oncology + - radiology + - surgery + - ophthalmology + - urology + - anesthesiology + - otolaryngology + - gastroenterology + - other + appointmentDate: + description: Date and time of the appointment + type: string + format: date-time + required: + - patientId + - clinicId + - doctorId + - specialty + - appointmentDate + AppointmentUpdate: + type: object + properties: + specialty: + description: Updated medical specialty for the appointment + type: string + enum: + - family_medicine + - nursing + - physiotherapy + - gynecology + - pediatrics + - dermatology + - cardiology + - neurology + - orthopedics + - psychiatry + - endocrinology + - oncology + - radiology + - surgery + - ophthalmology + - urology + - anesthesiology + - otolaryngology + - gastroenterology + - other + appointmentDate: + description: Updated date and time of the appointment + type: string + format: date-time + status: + description: Updated status of the appointment + type: string + enum: + - pending + - completed + - cancelled + - no_show + 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 + Workshift: + type: object + properties: + id: + example: 850154d5-6617-4128-b76b-88979b1cbc44 + type: string + doctorId: + example: 850154d5-6617-4128-b76b-88979b1cbc46 + type: string + clinicId: + example: ea12fd3d-4d3c-4ba2-b871-673c29fb69d3 + type: string + startDate: + example: 2024-11-01T09:00:00Z + type: string + format: date-time + duration: + example: 120 + type: integer + WorkshiftInput: + type: object + properties: + doctorId: + example: 850154d5-6617-4128-b76b-88979b1cbc46 + type: string + clinicId: + example: ea12fd3d-4d3c-4ba2-b871-673c29fb69d3 + type: string + startDate: + example: 2024-11-01T09:00:00Z + type: string + format: date-time + duration: + example: 30 + type: integer + 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 - specialty: - description: Medical specialty for the appointment + Plan: + type: object + properties: + id: type: string - enum: - - family_medicine - - nursing - - physiotherapy - - gynecology - - pediatrics - - dermatology - - cardiology - - neurology - - orthopedics - - psychiatry - - endocrinology - - oncology - - radiology - - surgery - - ophthalmology - - urology - - anesthesiology - - otolaryngology - - gastroenterology - - other - appointmentDate: - description: Date and time of the appointment + name: type: string - format: date-time - required: - - patientId - - clinicId - - doctorId - - specialty - - appointmentDate - AppointmentUpdate: + price: + type: number + features: + type: array + items: + type: string + LogEntry: type: object properties: - specialty: - description: Updated medical specialty for the appointment + requestId: + description: Unique identifier for the request log. type: string - enum: - - family_medicine - - nursing - - physiotherapy - - gynecology - - pediatrics - - dermatology - - cardiology - - neurology - - orthopedics - - psychiatry - - endocrinology - - oncology - - radiology - - surgery - - ophthalmology - - urology - - anesthesiology - - otolaryngology - - gastroenterology - - other - appointmentDate: - description: Updated date and time of the appointment + timestamp: + description: The timestamp when the log was created. type: string format: date-time - status: - description: Updated status of the appointment - type: string - enum: - - pending - - completed - - cancelled - - no_show ClinicalHistory: type: object properties: @@ -3018,176 +3192,6 @@ 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 - Workshift: - type: object - properties: - id: - example: 850154d5-6617-4128-b76b-88979b1cbc44 - type: string - doctorId: - example: 850154d5-6617-4128-b76b-88979b1cbc46 - type: string - clinicId: - example: ea12fd3d-4d3c-4ba2-b871-673c29fb69d3 - type: string - startDate: - example: 2024-11-01T09:00:00Z - type: string - format: date-time - duration: - example: 120 - type: integer - WorkshiftInput: - type: object - properties: - doctorId: - example: 850154d5-6617-4128-b76b-88979b1cbc46 - type: string - clinicId: - example: ea12fd3d-4d3c-4ba2-b871-673c29fb69d3 - type: string - startDate: - example: 2024-11-01T09:00:00Z - type: string - format: date-time - duration: - example: 30 - type: integer - 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 - 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 securitySchemes: cookieAuth: type: apiKey