This project is a RESTful API designed to manage COVID-19 patient data for a government-allocated hospital. The API allows doctors to log in, register patients, create medical reports, and retrieve patient reports based on specific criteria.
-
Doctor Management: Doctors can register and log in to the system.
-
Patient Management: Doctors can register patients using their phone numbers.
-
Report Management: After each checkup, doctors can create reports with predefined statuses and list all reports for a patient.
-
Filtering: Reports can be filtered by their status.
Backend: Node.js, Express.js, Mongoose
Database: MongoDB
Authentication: JSON Web Token (JWT)
To run this project, you will need to add the following environment variables to your .env file
DB_URL=mongodb://localhost:27017/hospital_api
port=3000
SECRET=JWT_SECRET
Clone the project
git clone https://github.com/krishnathakur03/Hospital-api.git
Go to the project directory
cd hospital-api
Install dependencies
npm install
Start the server
npm start
-
Register a doctor
- Endpoint:
POST /api/doctors/register
- Request body:
{ "name": "doctor_name", "phone": doctor_phone_no, "password": "password" }
- Endpoint:
-
Doctor login
- Endpoint:
POST /api/doctors/login
- Request body:
{ "phone": doctor_phone_no, "password": "password" }
- Endpoint:
-
Register a patient
- Endpoint:
POST /api/patients/register
- Request body:
{ "name": "patient_name", "phone": patient_phone_no }
- Endpoint:
-
Create a report
- Endpoint:
POST /api/patients/:id/create_report
- Request params:
id
(patientId) - Request body:
{ "status": "status" (eg. "positive-admit"), "date": (eg. "08/21/2024") // optional otherwise by default }
- Endpoint:
-
Get all reports of a patient
- Endpoint:
GET /api/patients/:id/all_reports
- Request params:
id
(patientId)
- Endpoint:
- Get reports by status
- Endpoint:
GET /api/reports/:status
- Request params:
status
(eg. negative)
- Endpoint:
This API uses JWT for authentication. Ensure the JWT_SECRET
is kept secure and never exposed publicly.
Node.js, MongoDB
Contributions are welcome! Please fork the repository and create a pull request with your changes.