# Doctors

In the Doctors API, hospitals associated with a doctor are presented as nested objects in GET responses (retrieval and listing), providing comprehensive information about each associated hospital. However, when creating or updating a doctor, only the hospital_ids field (a list of hospital unique_ids) should be used to associate the doctor with specific hospitals. This distinction ensures that users manage relationships by specifying only the necessary unique_ids of related hospitals, while receiving full details of associated hospitals in retrieval operations.

# Get Doctor List

Retrieve a list of all doctors, with associated hospitals displayed as nested objects.

  • URL: resources/doctors/
  • Method: GET
  • Response Example:
    [
      {
        "unique_id": "12345",
        "doctor_name": "Dr. John Doe",
        "doctor_description": "Cardiologist with 10 years of experience.",
        "doctor_practice_number": "DOC12345",
        "doctor_org_code": "ORG67890",
        "doctor_type": "Specialist",
        "doctor_physical_address": "123 Health St, Wellness City",
        "doctor_postal_address": "P.O. Box 7890",
        "doctor_town": "Wellness City",
        "doctor_region": "Central",
        "doctor_province": "Province A",
        "doctor_country": "Country X",
        "doctor_postal_code": "1001",
        "doctor_phone_number": "123-456-7890",
        "doctor_phone_number_alt": "123-456-7891",
        "doctor_emergency_number": "123-456-7899",
        "doctor_fax_number": "123-456-7892",
        "doctor_email_address": "john.doe@hospital.com",
        "doctor_website_url": "https://www.johndoe.com",
        "doctor_image_url": "https://images.com/12345",
        "doctor_latitude": "-25.12345",
        "doctor_longitude": "28.12345",
        "hospitals": [
          {
            "unique_id": "98765",
            "hospital_name": "General Hospital",
            "hospital_description": "A primary healthcare hospital.",
            "hospital_practice_number": "GH123456",
            "hospital_type": "Private"
          }
        ],
        "date_created": "2023-01-01T12:00:00Z",
        "last_updated": "2023-01-05T08:30:00Z"
      },
      ...
    ]
    

# Create a Doctor

Create a new doctor entry, associating them with specific hospitals using the hospital_ids list (a list of hospital unique_ids).

  • URL: resources/doctors/

  • Method: POST

  • Request Example:

    {
      "doctor_name": "Dr. John Doe",
      "doctor_description": "Cardiologist with 10 years of experience.",
      "doctor_practice_number": "DOC12345",
      "doctor_org_code": "ORG67890",
      "doctor_type": "Specialist",
      "doctor_physical_address": "123 Health St, Wellness City",
      "doctor_postal_address": "P.O. Box 7890",
      "doctor_town": "Wellness City",
      "doctor_region": "Central",
      "doctor_province": "Province A",
      "doctor_country": "Country X",
      "doctor_postal_code": "1001",
      "doctor_phone_number": "123-456-7890",
      "doctor_phone_number_alt": "123-456-7891",
      "doctor_emergency_number": "123-456-7899",
      "doctor_fax_number": "123-456-7892",
      "doctor_email_address": "john.doe@hospital.com",
      "doctor_website_url": "https://www.johndoe.com",
      "doctor_image_url": "https://images.com/12345",
      "doctor_latitude": "-25.12345",
      "doctor_longitude": "28.12345",
      "hospital_ids": ["98765", "87654"]
    }
    
  • Response Example:

    {
      "unique_id": "12345",
      "doctor_name": "Dr. John Doe",
      "doctor_description": "Cardiologist with 10 years of experience.",
      "doctor_practice_number": "DOC12345",
      "doctor_org_code": "ORG67890",
      "doctor_type": "Specialist",
      "doctor_physical_address": "123 Health St, Wellness City",
      "doctor_postal_address": "P.O. Box 7890",
      "doctor_town": "Wellness City",
      "doctor_region": "Central",
      "doctor_province": "Province A",
      "doctor_country": "Country X",
      "doctor_postal_code": "1001",
      "doctor_phone_number": "123-456-7890",
      "doctor_phone_number_alt": "123-456-7891",
      "doctor_emergency_number": "123-456-7899",
      "doctor_fax_number": "123-456-7892",
      "doctor_email_address": "john.doe@hospital.com",
      "doctor_website_url": "https://www.johndoe.com",
      "doctor_image_url": "https://images.com/12345",
      "doctor_latitude": "-25.12345",
      "doctor_longitude": "28.12345",
      "hospitals": [
        {
          "unique_id": "98765",
          "hospital_name": "General Hospital",
          "hospital_description": "A primary healthcare hospital.",
          "hospital_practice_number": "GH123456",
          "hospital_type": "Private"
        },
        {
          "unique_id": "87654",
          "hospital_name": "City Clinic",
          "hospital_description": "Community health clinic.",
          "hospital_practice_number": "CC789012",
          "hospital_type": "Public"
        }
      ],
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-05T08:30:00Z"
    }
    

# Get a Doctor

Retrieve details of a specific doctor by unique ID, displaying associated hospitals as nested objects.

  • URL: resources/doctors/<str:unique_id>/

  • Method: GET

  • Response Example:

    {
      "unique_id": "12345",
      "doctor_name": "Dr. John Doe",
      "doctor_description": "Cardiologist with 10 years of experience.",
      "doctor_practice_number": "DOC12345",
      "doctor_org_code": "ORG67890",
      "doctor_type": "Specialist",
      "doctor_physical_address": "123 Health St, Wellness City",
      "doctor_postal_address": "P.O. Box 7890",
      "doctor_town": "Wellness City",
      "doctor_region": "Central",
      "doctor_province": "Province A",
      "doctor_country": "Country X",
      "doctor_postal_code": "1001",
      "doctor_phone_number": "123-456-7890",
      "doctor_phone_number_alt": "123-456-7891",
      "doctor_emergency_number": "123-456-7899",
      "doctor_fax_number": "123-456-7892",
      "doctor_email_address": "john.doe@hospital.com",
      "doctor_website_url": "https://www.johndoe.com",
      "doctor_image_url": "https://images.com/12345",
      "doctor_latitude": "-25.12345",
      "doctor_longitude": "28.12345",
      "hospitals": [
        {
          "unique_id": "98765",
          "hospital_name": "General Hospital",
          "hospital_description": "A primary healthcare hospital.",
          "hospital_practice_number": "GH123456",
          "hospital_type": "Private"
        }
      ],
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-05T08:30:00Z"
    }
    

# Update a Doctor

Update an existing doctor by unique ID, associating or updating associated hospitals using hospital_ids.

  • URL: resources/doctors/<str:unique_id>/

  • Method: PUT

  • Request Example:

    {
      "doctor_name": "Dr. Jane Doe",
      "hospital_ids": ["98765"]
    }
    
  • Response Example:

    {
      "unique_id": "12345",
      "doctor_name": "Dr. Jane Doe",
      "doctor_description": "Cardiologist with 10 years of experience.",
      "doctor_practice_number": "DOC12345",
      "doctor_org_code": "ORG67890",
      "doctor_type": "Specialist",
      "doctor_physical_address": "123 Health St, Wellness City",
      "doctor_postal_address": "P.O. Box 7890",
      "doctor_town": "Wellness City",
      "doctor_region": "Central",
      "doctor_province": "Province A",
      "doctor_country": "Country X",
      "doctor_postal_code": "1001",
      "doctor_phone_number": "123-456-7890",
      "doctor_phone_number_alt": "123-456-7891",
      "doctor_emergency_number": "123-456-7899",
      "doctor_fax_number": "123-456-7892",
      "doctor_email_address": "john.doe@hospital.com",
      "doctor_website_url": "https://www.johndoe.com",
      "doctor_image_url": "https://images.com/12345",
      "doctor_latitude": "-25.12345",
      "doctor_longitude": "28.12345",
      "hospitals": [
        {
          "unique_id": "98765",
          "hospital_name": "General Hospital",
          "hospital_description": "A primary healthcare hospital.",
          "hospital_practice_number": "GH123456",
          "hospital_type": "Private"
        }
      ],
      "date_created": "2023-01-01T12:00:00Z",
      "last_updated": "2023-01-06T08:30:00Z"
    }
    

# Delete a Doctor

Delete a doctor by unique ID.

  • URL: resources/doctors/<str:unique_id>/
  • Method: DELETE
  • Response: 204 No Content