Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Jay-byte389/AMS/llms.txt

Use this file to discover all available pages before exploring further.

The Doctors resource exposes two read-only endpoints that power the core browsing experience in AMS. GET /Doctors returns the full list of doctor profiles rendered on the Home screen and the Doctors list screen. GET /Doctors/:id returns a single profile and is used when deep-linking directly to a doctor’s detail view. Both endpoints are served by the shared Axios client configured in src/services/api.js.

GET /Doctors

Method: GET — Path: /Doctors
Fetches the complete list of doctor records from MockAPI. The Home screen dispatches this endpoint on mount to populate the scrollable doctor card list and make doctor data available to the appointments filter logic.

Service Function

Defined in src/services/doctorServices.js:
src/services/doctorServices.js
import api from './api';

export const fetchDoctorsAPI = async () => {
  const response = await api.get('/Doctors');
  return response.data;
};

Redux Thunk

fetchDoctors wraps fetchDoctorsAPI and dispatches the result to the doctors Redux slice. Defined in src/redux/thunk/doctorThunk.js:
src/redux/thunk/doctorThunk.js
import { createAsyncThunk } from '@reduxjs/toolkit';
import { fetchDoctorsAPI } from '../../services/doctorServices';

export const fetchDoctors = createAsyncThunk(
  'doctors/fetchDoctors',
  async (_, { rejectWithValue }) => {
    try {
      const data = await fetchDoctorsAPI();
      return data;
    } catch (error) {
      const errorMessage =
        error.response?.data || error.message || 'Failed to fetch doctors';
      return rejectWithValue(errorMessage);
    }
  }
);

Request Parameters

No query parameters or path parameters are required. The endpoint returns all doctor records.

Response

Returns a JSON array of doctor objects.

Doctor Object Schema

id
string
required
Unique identifier assigned by MockAPI. Used as the foreign key in appointment records (doctorId).
name
string
required
Doctor’s full name as displayed in the app (e.g. "Dr. Sarah Mitchell").
qualification
string
required
Professional qualification abbreviation displayed alongside the name (e.g. "MBBS", "MD").
department
string
required
Medical speciality or department (e.g. "Cardiology", "General Physician").
avatar
string
required
Fully-qualified URL to the doctor’s profile image. Rendered via React Native’s <Image source={{ uri: doctor.avatar }} />.
ratings
number
required
Aggregate star rating shown on doctor cards (e.g. 4.8).
comments
number
required
Total number of patient comments associated with the doctor profile.
reviews
number
required
Total number of written reviews. Displayed in the stats row on the DoctorInfo screen.
experience
number
required
Years of professional experience. Shown in the experience badge on the doctor detail card.
focus
string
required
Primary area of clinical focus displayed in the focus chip on the DoctorInfo screen (e.g. "Pediatric Heart Conditions").
profile
string
required
Biographical paragraph rendered under the Profile heading on the doctor detail view.
careerpath
string
required
Career history narrative shown under the Career Path heading on the doctor detail view.
highlights
string
required
Notable achievements or career highlights shown under the Highlights heading on the doctor detail view.

Example Response

[
  {
    "id": "1",
    "name": "Dr. Sarah Mitchell",
    "qualification": "MBBS",
    "department": "Cardiology",
    "avatar": "https://example.com/avatars/sarah-mitchell.jpg",
    "ratings": 4.8,
    "comments": 120,
    "reviews": 95,
    "experience": 12,
    "focus": "Pediatric Heart Conditions",
    "profile": "Dr. Mitchell is a board-certified cardiologist with over 12 years of experience...",
    "careerpath": "Graduated from Harvard Medical School in 2010, completed residency at...",
    "highlights": "Published 15 peer-reviewed papers, awarded Best Cardiologist 2022..."
  }
]

Usage in a Component

The Home screen dispatches fetchDoctors on mount inside a useEffect:
src/screens/HomeScreen.jsx
import { useDispatch, useSelector } from 'react-redux';
import { fetchDoctors } from '../redux/thunk/doctorThunk';

export default function HomeScreen() {
  const dispatch = useDispatch();
  const { doctorsList: doctors, loading } = useSelector(
    state => state.doctors,
  );

  useEffect(() => {
    dispatch(fetchDoctors());
  }, [dispatch]);

  // doctors is now populated with the full array from /Doctors
}

GET /Doctors/:id

Method: GET — Path: /Doctors/:id
Fetches a single doctor record by its unique identifier. Used when the app navigates to a doctor’s detail view and only the id is available rather than the full object.

Service Function

Defined in src/services/doctorServices.js:
src/services/doctorServices.js
import api from './api';

export const fetchDoctorByIdAPI = async (id) => {
  const response = await api.get(`/Doctors/${id}`);
  return response.data;
};

Path Parameter

id
string
required
The unique doctor identifier returned in the id field of a GET /Doctors response. Must be passed as a URL path segment (e.g. /Doctors/3).

Response

Returns a single doctor object with the same schema as described in the GET /Doctors section above.

Example Usage

import { fetchDoctorByIdAPI } from '../services/doctorServices';

// Fetch a specific doctor profile directly (outside of Redux):
const doctor = await fetchDoctorByIdAPI('3');
console.log(doctor.name); // "Dr. Sarah Mitchell"
In most AMS screens the full doctor object is passed via React Navigation’s route.params rather than fetching by ID a second time. Use fetchDoctorByIdAPI when you only have the doctor’s id available — for example, when reconstructing state after the app is backgrounded.

Build docs developers (and LLMs) love