-
Clone the Repository
git clone https://github.com/YOUR_USERNAME/vita-data-backend.git cd vita-data-backend -
Create and Activate Virtual Environment
# Using conda (recommended) conda create -n vitadata python=3.10 conda activate vitadata # Or using venv python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
-
Run Migrations
python manage.py migrate
-
Create Superuser
python manage.py createsuperuser
-
Run the Development Server
python manage.py runserver
The API will be available at http://localhost:8000/
- Superuser: admin@test.com / admin123
- Sample Doctor: doctor1@example.com (role: DOCTOR)
The API uses JWT (JSON Web Token) authentication. Most endpoints require authentication except for user registration and login.
POST /api/users/login/
Content-Type: application/json
{
"email": "user@example.com",
"password": "password123"
}Response:
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}Include the access token in the Authorization header:
Authorization: Bearer <your_access_token>POST /api/users/register/
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "password123",
"role": "RECEPTIONIST"
}Roles Available:
ADMIN: Full system accessDOCTOR: Can manage patients and appointmentsRECEPTIONIST: Can manage patients and appointmentsLAB: Can manage lab reports
GET /api/users/users/
Authorization: Bearer <token>GET /api/patients/
Authorization: Bearer <token>POST /api/patients/
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "John Doe",
"dob": "1990-01-01",
"gender": "Male",
"contact_number": "+1234567890",
"email": "john.doe@example.com",
"address": "123 Main St, City, State"
}Patient Model:
name: Patient's full namedob: Date of birth (YYYY-MM-DD)gender: Gender (Male/Female/Other)contact_number: Phone numberemail: Unique email addressaddress: Full address
GET /api/appointments/appointments/
Authorization: Bearer <token>Query Parameters:
doctor: Filter by doctor IDpatient: Filter by patient IDdate: Filter by date (YYYY-MM-DD)
POST /api/appointments/appointments/
Authorization: Bearer <token>
Content-Type: application/json
{
"patient": 1,
"doctor": 2,
"date": "2024-01-15",
"time": "14:30:00",
"issue": "Regular checkup"
}Appointment Model:
patient: Patient ID (required)doctor: Doctor ID (required, must be a user with DOCTOR role)date: Appointment date (YYYY-MM-DD)time: Appointment time (HH:MM:SS)status: Status (SCHEDULED/CANCELLED/COMPLETED)issue: Description of patient's issue
GET /api/lab-reports/reports/
Authorization: Bearer <token>Query Parameters:
report_date: Filter by report datestatus: Filter by status (pending/in_progress/completed/scheduled)patient: Filter by patient IDsearch: Search in patient name or test type
POST /api/lab-reports/reports/
Authorization: Bearer <token>
Content-Type: application/json
{
"patient": 1,
"test_type": "Blood Test",
"status": "scheduled",
"report_date": "2024-01-20"
}PUT /api/lab-reports/reports/{id}/
Authorization: Bearer <token>
Content-Type: application/json
{
"patient": 1,
"test_type": "Blood Test",
"status": "completed",
"result": "Normal",
"remarks": "All parameters within normal range",
"report_date": "2024-01-20"
}Lab Report Model:
patient: Patient ID (required)test_type: Type of lab teststatus: Status (pending/in_progress/completed/scheduled)result: Test resultsremarks: Additional notesreport_date: Date of reportreport_file: Uploaded report file
GET /api/billing/bills/
Authorization: Bearer <token>POST /api/billing/bills/
Authorization: Bearer <token>
Content-Type: application/json
{
"bill_number": "BILL-2024-001",
"patient": 1,
"bill_amount": "150.00",
"patient_status": "Unpaid"
}GET /api/billing/bills/{bill_number}/
Authorization: Bearer <token>PUT /api/billing/bills/{bill_number}/
Authorization: Bearer <token>
Content-Type: application/json
{
"bill_number": "BILL-2024-001",
"patient": 1,
"bill_amount": "150.00",
"patient_status": "Paid"
}Bill Model:
bill_number: Unique bill identifier (primary key)patient: Patient ID (required)bill_amount: Amount in decimalpatient_status: Status (Paid/Unpaid/Pending)bill_date: Date of bill generation
GET /api/dashboard/
Authorization: Bearer <token>| Role | Permissions |
|---|---|
| ADMIN | Full system access, can view all users |
| DOCTOR | Manage patients, create appointments |
| RECEPTIONIST | Manage patients, create appointments |
| LAB | Manage lab reports |
Appointment Status:
SCHEDULED: Appointment is scheduledCANCELLED: Appointment is cancelledCOMPLETED: Appointment is completed
Lab Report Status:
pending: Test is pendingin_progress: Test is being processedcompleted: Test is completedscheduled: Test is scheduled
Bill Status:
Paid: Bill has been paidUnpaid: Bill is unpaidPending: Bill is pending payment
The API returns standard HTTP status codes:
200: Success201: Created400: Bad Request401: Unauthorized403: Forbidden404: Not Found500: Internal Server Error
Error Response Format:
{
"error": "Error message description"
}- Create feature branches for development
- No direct pushes to main branch
- Submit pull requests for code review
git checkout -b feature/your-feature-name
# Make your changes
git add .
git commit -m "Your commit message"
git push -u origin feature/your-feature-namepython manage.py testpython manage.py makemigrations
python manage.py migrate- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.