This is a REST API designed for a Hospital to manage the health records of COVID-19 patients. It allows the hospital staff (doctors) to register and log in, register patients, and create reports for each visit. It also provides endpoints to retrieve a patient's records and all reports filtered by status. The API is built using Node.js and MongoDB, and uses JSON Web Tokens (JWT) for authentication.
To install and run the application, follow the steps below:
- Clone the repository
- Navigate to the project directory
- Install the dependencies -
npm install
- Create a
.env
file in the root directory with the following environment variables: -PORT=5000
JWT_SECRET=<your_jwt_secret>
- Start the server:
npm start
- Open the app in your web browser at
http://localhost:5000
Requires the following dependencies:
dotenv
- Loads environment variables from a.env
fileexpress
- Web framework for Node.jsjsonwebtoken
- Generates and verifies JSON web tokens (JWTs)mongoose
- ODM (Object-Document Mapping) library for MongoDB and Node.jspassport
- Authentication middleware for Node.jspassport-jwt
- Passport strategy for authenticating with a JSON Web Token (JWT)
- POST
/doctors/register
- Register a new doctor with a username and password. - POST
/doctors/login
- Login with a username and password to receive a JWT.
- POST
/patients/register
- Register a new patient with a phone number. If the patient already exists, the existing patient info is returned. - POST
/patients/:id/create_report
- Create a new report for the patient with the given id, which includes the status and the date. The report is created by the doctor who is currently authenticated. - GET
/patients/:id/all_reports
- List all the reports for the patient with the given id, sorted from oldest to newest.
- POST
/reports/:status
- List all the reports for all patients with the given status. The reports are sorted from oldest to newest.