This is a Django-based API for managing hospital operations, including doctors, patients, departments, and patient records.
- User authentication (login, signup, logout) for both doctors and patients
- CRUD operations for doctors, patients, departments, and patient records
- Role-based access control (staff vs non-staff users)
- Department-wise listing of doctors and patients
-
Pull the Docker image:
docker pull arjunksoni/hospital_account:dev
-
Run the Docker container:
docker run -p 10000:10000 arjunksoni/hospital_account:dev
-
Clone the repository:
git clone https://github.com/ArjunKSoni/Hospital_Accounts.git cd Hospital_Accounts cd hospital
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Apply migrations:
python manage.py migrate
-
Create a superuser (admin):
python manage.py createsuperuser
-
Run the development server:
python manage.py runserver 10000
After starting the server, you can access the API at http://localhost:10000/
.
- Login:
POST /
- Signup (Patient):
POST /signup_patient/
- Signup (Doctor):
POST /signup_doctor/
- Logout:
GET /logout
- List all doctors:
GET /api/v1/accounts/doctors/
- Create a doctor:
POST /api/v1/accounts/doctors/
- Get, update, or delete a specific doctor:
GET/PUT/DELETE /api/v1/accounts/doctors/<id>/
- List all patients:
GET /api/v1/accounts/patients/
- Create a patient:
POST /api/v1/accounts/patients/
- Get, update, or delete a specific patient:
GET/PUT/DELETE /api/v1/accounts/patients/<id>/
- List all patient records:
GET /api/v1/accounts/patient_records/
- Create a patient record:
POST /api/v1/accounts/patient_records/
- Get, update, or delete a specific patient record:
GET/PUT/DELETE /api/v1/accounts/patient_records/<id>/
- List all departments:
GET /api/v1/accounts/departments/
- Create a department:
POST /api/v1/accounts/departments/
- Get doctors in a department:
GET /api/v1/accounts/department/<did>/doctors/
- Get patients in a department:
GET /api/v1/accounts/department/<did>/patients/
This API uses session-based authentication. Users must log in to access protected endpoints. Different views have different access levels based on whether the user is staff (doctor) or non-staff (patient).
- Patients can only view their own records.
- Doctors (staff) can view and manage all data.
Make sure to include proper authentication headers when making requests to protected endpoints.