The Prescripto system has the following doctor APIs:
-
Authentication
POST /doctor/login- Doctor login
-
Appointment Management
GET /doctor/appointments- Get doctor's appointmentsPOST /doctor/cancel-appointment- Cancel an appointmentPOST /doctor/complete-appointment- Mark appointment as completed
-
Profile Management
GET /doctor/profile- Get doctor's profilePOST /doctor/update-profile- Update doctor's profilePOST /doctor/change-availability- Change availability status
-
Dashboard
GET /doctor/dashboard- Get doctor's dashboard data
-
Public Access
GET /doctor/list- Get list of all doctors (public endpoint)
- Create a new collection named "Prescripto Doctor APIs"
- Set up environment variables:
baseUrl:http://localhost:5000(adjust if your server runs on a different port)doctorToken: To store the doctor authentication token
Endpoint: POST {{baseUrl}}/doctor/login
Request Body:
{
"email": "<DOCTOR_EMAIL>",
"password": "<DOCTOR_PASSWORD>"
}Response:
{
"success": true,
"token": "<JWT TOKEN>"
}Important: After successful login, save the token to your Postman environment variable:
- In the Tests tab of your request, add this script:
if (pm.response.json().success) {
pm.environment.set("doctorToken", pm.response.json().token);
}Endpoint: GET {{baseUrl}}/doctor/dashboard
Headers:
dtoken: {{doctorToken}}
Response:
{
"success": true,
"dashData": {
"earnings": 150,
"appointments": 10,
"patients": 8,
"latestAppointments": [...]
}
}Endpoint: GET {{baseUrl}}/doctor/profile
Headers:
dtoken: {{doctorToken}}
Response:
{
"success": true,
"profileData": {
"_id": "<DOCTOR_ID>",
"name": "Dr. John Smith",
"email": "john.smith@example.com",
"image": "https://res.cloudinary.com/...",
"speciality": "Cardiologist",
"degree": "MBBS, MD",
"experience": "10 years",
"about": "...",
"available": true,
"fees": 50,
"slots_booked": {...},
"address": {...},
"date": 1620000000000
}
}Endpoint: GET {{baseUrl}}/doctor/appointments
Headers:
dtoken: {{doctorToken}}
Response:
{
"success": true,
"appointments": [...]
}Endpoint: POST {{baseUrl}}/doctor/update-profile
Headers:
dtoken: {{doctorToken}}
Request Body:
{
"fees": 60,
"address": {
"street": "456 Main Street",
"city": "New York",
"state": "NY",
"country": "USA",
"pincode": "10001"
},
"available": true
}Response:
{
"success": true,
"message": "Profile Updated"
}Endpoint: POST {{baseUrl}}/doctor/change-availability
Headers:
dtoken: {{doctorToken}}
Response:
{
"success": true,
"message": "Availability Changed"
}Endpoint: POST {{baseUrl}}/doctor/cancel-appointment
Headers:
dtoken: {{doctorToken}}
Request Body:
{
"appointmentId": "<APPOINTMENT_ID>"
}Response:
{
"success": true,
"message": "Appointment Cancelled"
}Endpoint: POST {{baseUrl}}/doctor/complete-appointment
Headers:
dtoken: {{doctorToken}}
Request Body:
{
"appointmentId": "<APPOINTMENT_ID>"
}Response:
{
"success": true,
"message": "Appointment Completed"
}Endpoint: GET {{baseUrl}}/doctor/list
Response:
{
"success": true,
"doctors": [...]
}-
Authentication Issues:
- Make sure the
dtokenheader is properly set for all authenticated endpoints - If you get "Not Authorized Login Again" message, your token might be invalid or expired - try logging in again
- Make sure the
-
Missing Appointment ID:
- For operations that require an Appointment ID, make sure to use a valid ID
- You can get valid appointment IDs from the
/doctor/appointmentsendpoint
-
Getting Doctor Credentials:
- You'll need valid doctor credentials to test most of these APIs
- You can either use an existing doctor's credentials or create a new doctor through the Admin API
-
Testing Workflow:
- Start by logging in and getting the doctor token
- View the dashboard and profile to verify authentication works
- Test profile update operations
- Test appointment operations (view, cancel, complete)
You can create a script to help test the doctor APIs. Here's an example script that fetches doctor credentials and appointment IDs:
// test-doctor-apis.js
import mongoose from 'mongoose';
import * as dotenv from 'dotenv';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
dotenv.config();
mongoose.connect(process.env.MONGODB_URI).then(() => {
// Get doctor credentials
const doctorModel = mongoose.model('doctor', new mongoose.Schema({}));
doctorModel.find({}, '_id name email').then(doctors => {
console.log("Available doctors for testing:");
console.log(JSON.stringify(doctors, null, 2));
if (doctors.length > 0) {
const testDoctorId = doctors[0]._id;
// Get appointments for this doctor
const appointmentModel = mongoose.model('appointment', new mongoose.Schema({}));
appointmentModel.find({ docId: testDoctorId }, '_id userId docId date time isCompleted cancelled payment').then(appointments => {
console.log(`Appointments for doctor ${doctors[0].name} (${testDoctorId}):`);
console.log(JSON.stringify(appointments, null, 2));
mongoose.connection.close();
});
} else {
console.log("No doctors found in the database.");
mongoose.connection.close();
}
});
}).catch(err => {
console.error('Error connecting to database:', err);
process.exit(1);
});