In a time where a major pandemic has covered all the world we need a system which can track patients data and generate reports for them. This is a very basic API which exactly do this.
- Register Doctor with username, password and name.
- Login(authenticate) User using passport-local and returns a jwt-token to be to access(authorize) protected routes.
- After logging-in the doctor can do various things such as : register patient, generate a report of patient, view all reports of a particular patient, filter all the reports by status.
- Generation of report(protecte by jwt) : A doctor has to enter enter the status for a particular patient and can generate the report according to it.
- View all reports of a patient(protected by jwt) : A doctor can view all the reports of a patient.
- View all the reports filtered by status(protected by jwt) : A doctor can view all reports present in database filtered by status.
- Unit testing integrated.
- Clone this project
- Start by installing npm and mongoDB if you don't have them already.
- Run the Mongo Server.
- Navigate to Project Directory by :
cd Hospital-API
- run following commands :
npm install
npm start or node index.js
- Install Mocha(Testing enviornment used by Node.js) by running
sudo npm install --global mocha
- Navigate to project directory and run
npm test
- You'll be able to verify if the API is performing as intended.
-
/doctor/register
(POST) : Register a new doctor using 'name', 'username', 'password' and 'confirm-password' (all mandatory).
Example input : (send name, username, password and confirm-password)
Example output : -
/doctor/login
(POST) : login doctor using 'username' and 'password'.Example input : (send username and password)
Example output : (Recieve jwt token in response)input headers: (send jwt tokens in Authorization header)
-
/patients/register
(POST) :register patient using 'phone_number' and 'name' (phone number becomes id and will be used as it is).
Example input :
input form body: (send phone_number and name)
Example output : (phone_number is treated as patient id) -
/patients/:id/create_report
(POST) : create a report of a patient using ID (phone_number) sent in params and status.Example input :
input form body: (send status, it is an enum which includes : [N,TQ,SQ,PA] which maps to [Negative, Travelled-Quarantine, Symptoms-Quarantine, Positive-Admit]
Example output : -
/patients/:id/all_reports
(GET) : Generate all reports of a patient by ID (phone_number) sent in params.
Example output : (all reports of a particluar patient) -
/reports/:status
(GET) : Generate all reports in DB filtered by status sent in params.
status is an enum which includes : [N,TQ,SQ,PA] which maps to [Negative, Travelled-Quarantine, Symptoms-Quarantine, Positive-Admit]
This code follows MVC pattern and hence everything is differentiated and well managed:
/routes
- containes all the routes.
/routes/api
- containes api files
/assets
- static js css and image files.
/controller
- contains functions to connect to different routes.
/controller/api
- contains functions to connect to different end points of api.
/model
- to store data in db we need models.
/config
- contains config files for mongoose, passport or any other configs such as middlewares.
/test
- contains files to test the code.
Feel free to use and contribute! :)