Cancels and permanently deletes a consultation from the system. This operation also cascades to remove associated diagnosis and payment records.
This is a destructive operation that cannot be undone. The consultation and all related records (diagnosis, payment) will be permanently deleted.
Path Parameters
UUID of the consultation to cancel (e.g., “550e8400-e29b-41d4-a716-446655440000”)
Cascading Deletions
When a consultation is deleted, the following related records are also removed:
- Diagnosis Records - Any diagnosis associated with the consultation is deleted
- Payment Records - The payment record linked to the consultation is deleted
- Consultation Record - The consultation itself is deleted
The deletions occur in this specific order to maintain referential integrity.
Response
Success Response
Returns a text message confirming the cancellation.
Success message: “Consulta cancelada com sucesso.”
curl -X DELETE https://api.medagenda.com/consultations/550e8400-e29b-41d4-a716-446655440000
Consulta cancelada com sucesso.
Implementation Details
The cancellation process follows these steps:
- Existence Check - Verifies the consultation exists in the database
- Diagnosis Deletion - Searches for and deletes any associated diagnosis record
- Payment Deletion - Searches for and deletes the associated payment record
- Consultation Deletion - Removes the consultation record itself
If the consultation doesn’t exist, the endpoint returns a 404 Not Found response without attempting any deletions.