Overview
Update or create a medical document for a specific appointment in MediSync. This endpoint replaces any existing document for the appointment with a new PDF file, or creates a new document if none exists.Authentication
Path Parameters
The appointment ID to update the document for
Query Parameters
The doctor/user ID performing the update
Request Body
Response
Whether the update was successful
The updated document information
Error message if the update failed
Response Examples
Successful Update (Existing Document Replaced)
Successful Creation (No Previous Document)
Error Response
Business Logic
- Replace or Create: If a document exists for the appointment, it will be completely replaced. If no document exists, a new one will be created.
- Complete Replacement: The old document is permanently deleted from both storage and database before the new one is uploaded.
- Atomic Operation: The update process ensures that either the entire operation succeeds or fails - you won’t be left with a partially updated state.
- New Document ID: Each update creates a completely new document record with a new ID.
Error Handling
- 400 Bad Request:
- Invalid file type (only PDF allowed)
- Missing file in request
- Error deleting old document
- Error uploading new document
- 401 Unauthorized: Invalid or missing authentication token
- 500 Internal Server Error: Storage or database error
Notes
- Only PDF files are currently supported
- The old document is completely removed from storage - this operation cannot be undone
- Maximum file size limit is 500MB
- A new document ID is generated for each update
- File naming follows the format:
{appointment_id}_{original_filename} - Use this endpoint both for updating existing documents and creating new ones