Skip to main content

Overview

Update the markdown content of an existing doctor letter in MediSync. This endpoint allows manual editing of AI-generated doctor letters, enabling healthcare providers to customize or correct the letter content before sending.
Manual Letter Editing: This endpoint enables manual editing of doctor letter content. When updated, the letter status is set to “editing” and any previous errors are cleared.

Authentication

curl -X PUT \
  'https://api.medisync.com/doctor-letters/letter_def456?uid=doc_xyz789' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "markdown_content": "# Updated Medical Referral Letter\n\n**Date:** 2024-01-15\n\n**To:** Dr. Sarah Johnson, Cardiology Specialist\n**From:** Dr. Michael Chen, Internal Medicine\n\n**Re:** John Smith (DOB: 1975-08-15)\n\n## Updated Clinical Summary\n\nI am referring Mr. Smith for urgent cardiology evaluation...\n\nThank you for your prompt attention.\n\nDr. Michael Chen, MD"
  }'

Path Parameters

letter_id
string
required
The unique ID of the doctor letter to update

Query Parameters

uid
string
required
The doctor ID (user ID) of the healthcare provider updating the letter (must match the letter owner)

Body Parameters

markdown_content
string
The updated markdown content for the doctor letter. If not provided, the existing content is preserved.

Response

success
boolean
Indicates if the operation was successful
data
object
The updated doctor letter object
error
string
Error message if the operation failed

Example Response

{
  "success": true,
  "data": {
    "_id": "letter_def456",
    "appointment_id": "apt_abc123",
    "patient_id": "pat_ghi789",
    "doctor_id": "doc_xyz789",
    "status": "editing",
    "markdown_content": "# Updated Medical Referral Letter\n\n**Date:** 2024-01-15\n\n**To:** Dr. Sarah Johnson, Cardiology Specialist\n**From:** Dr. Michael Chen, Internal Medicine\n\n**Re:** John Smith (DOB: 1975-08-15)\n\n## Updated Clinical Summary\n\nI am referring Mr. Smith for urgent cardiology evaluation...\n\nThank you for your prompt attention.\n\nDr. Michael Chen, MD",
    "generation_inputs": {
      "current_date": "2024-01-15",
      "patient_name": "John Smith",
      "date_of_birth": "1975-08-15",
      "appointment_notes": "Patient presented with chest pain...",
      "diagnosis": "Atypical chest pain",
      "recipient_doctor": "Dr. Sarah Johnson, Cardiology Specialist",
      "referring_doctor": "Dr. Michael Chen, Internal Medicine",
      "language": "en"
    },
    "error": null,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T14:20:00.000Z"
  }
}

Behavior Notes

  • Ownership Verification: The letter must belong to the doctor specified in the uid query parameter
  • Status Update: When content is updated, the status is automatically set to “editing”
  • Error Clearing: Any previous error is cleared (set to null) when the update is successful
  • Partial Update: If markdown_content is not provided, the existing content is preserved
  • Automatic Timestamps: The updatedAt field is automatically updated when changes are made

Status Codes

  • 200 - Letter updated successfully
  • 400 - Invalid request data or database error
  • 404 - Letter not found or not owned by the specified doctor