This project involves designing a Node.js-based API for managing COVID-19 patients and doctor interactions within a hospital setting. The API allows doctors to register and log in, register patients, create patient reports after checkups, and retrieve patient reports based on various criteria.
There can be 2 types of Users
- Doctors & Patients
- Doctors can log in
- Each time a patient visits, the doctor will follow 2 steps:
- Register the patient in the app (using phone number, if the patient already exists, just return the patient info in the API)
- After the checkup, create a Report.
- Patient Report will have the following fields
- Created by doctor
- Status: Can be either of: [0 :Negative, 1:Travelled-Quarantine, 2:Symptoms-Quarantine, 3:Positive-Admit]
- Date
- Clone the Repository:
git clone https://github.com/bharatlal124/Hospital_API
cd Hospital_API-
Install Dependencies: npm install
-
Start the Server: node index.js
-
Server running at: http://localhost:8000/api/v1
- Path :
http://localhost:8000/api/v1/doctors/register - INPUT:
{
"name":"Doctor1",
"email":"doctor12@gmail.com",
"password":"doc12345"
}- OUTPUT
{
"data": {
"doctor": {
"_id": "6607cb2be8f81656f4459d5c",
"name": "Doctor1",
"email": "doctor12@gmail.com",
"createdAt": "2024-03-30T08:19:55.285Z",
"updatedAt": "2024-03-30T08:19:55.285Z",
"__v": 0
}
},
"message": "Successfully registered"
}- Path :
http://localhost:8000/api/v1//doctors/login - INPUT:
{
"email":"doctor12@gmail.com",
"password":"doc12345"
}- OUTPUT(Generate JWT Token)
{
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NjA3Y2IyYmU4ZjgxNjU2ZjQ0NTlkNWMiLCJuYW1lIjoiRG9jdG9yMSIsImVtYWlsIjoiZG9jdG9yMTJAZ21haWwuY29tIiwicGFzc3dvcmQiOiJkb2MxMjM0NSIsImNyZWF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsInVwZGF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsIl9fdiI6MCwiaWF0IjoxNzExNzg2ODc1LCJleHAiOjE3MTI3ODY4NzV9.nEPy9isilOn7st0IEf1Aff-7mOf0OSQGurivYR8bm_I"
}
}- Path :
http://localhost:8000/api/v1/patients/register
{
"Authorization" : "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NjA3Y2IyYmU4ZjgxNjU2ZjQ0NTlkNWMiLCJuYW1lIjoiRG9jdG9yMSIsImVtYWlsIjoiZG9jdG9yMTJAZ21haWwuY29tIiwicGFzc3dvcmQiOiJkb2MxMjM0NSIsImNyZWF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsInVwZGF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsIl9fdiI6MCwiaWF0IjoxNzExNzg2ODc1LCJleHAiOjE3MTI3ODY4NzV9.nEPy9isilOn7st0IEf1Aff-7mOf0OSQGurivYR8bm_I"
}- INPUT:
{
"name": "Patient1",
"phone":7856253984
}- OUTPUT
{
"data": {
"patient": {
"reports": [],
"_id": "6607cc4be8f81656f4459d5d",
"name": "Patient1",
"phone": 7856253984,
"createdAt": "2024-03-30T08:24:43.050Z",
"updatedAt": "2024-03-30T08:24:43.050Z",
"__v": 0
}
},
"message": "Patient Successfully Registered"
}- Path :
http://localhost:8000/api/v1/patients/:id/create_report
{
"Authorization" : "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NjA3Y2IyYmU4ZjgxNjU2ZjQ0NTlkNWMiLCJuYW1lIjoiRG9jdG9yMSIsImVtYWlsIjoiZG9jdG9yMTJAZ21haWwuY29tIiwicGFzc3dvcmQiOiJkb2MxMjM0NSIsImNyZWF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsInVwZGF0ZWRBdCI6IjIwMjQtMDMtMzBUMDg6MTk6NTUuMjg1WiIsIl9fdiI6MCwiaWF0IjoxNzExNzg2ODc1LCJleHAiOjE3MTI3ODY4NzV9.nEPy9isilOn7st0IEf1Aff-7mOf0OSQGurivYR8bm_I"
}- INPUT:send status([0:Negative, 1:Travelled-Quarantine, 2:Symptoms-Quarantine, 3:Positive-Admit]) and doctor id
{
"status": 3,
"doctor":"6607cb2be8f81656f4459d5c"
}- OUTPUT
{
"data": {
"report": {
"patient": "Patient1",
"status": "Positive-Admit",
"doctor": "Doctor1",
"date": "2024-03-30T08:28:16.761Z"
}
},
"message": "Report successfully Created"
}- Path :
http://localhost:8000/api/v1/patients/:id/all_reports - OUTPUT
{
"data": {
"report": [
{
"_id": "6607cd20e8f81656f4459d5e",
"status": "Positive-Admit",
"doctor": {
"_id": "6607cb2be8f81656f4459d5c",
"name": "Doctor1",
"email": "doctor12@gmail.com",
"password": "doc12345",
"createdAt": "2024-03-30T08:19:55.285Z",
"updatedAt": "2024-03-30T08:19:55.285Z",
"__v": 0
},
"patient": {
"reports": [
"6607cd20e8f81656f4459d5e"
],
"_id": "6607cc4be8f81656f4459d5d",
"name": "Patient1",
"phone": 7856253984,
"createdAt": "2024-03-30T08:24:43.050Z",
"updatedAt": "2024-03-30T08:28:16.879Z",
"__v": 1
},
"createdAt": "2024-03-30T08:28:16.761Z",
"updatedAt": "2024-03-30T08:28:16.761Z",
"__v": 0
}
]
},
"message": "All reports of the patient"
}- Path :
http://localhost:8000/api/v1/reports/3 - OUTPUT
{
"data": {
"reportstatus": [
{
"_id": "6607cd20e8f81656f4459d5e",
"status": "Positive-Admit",
"doctor": {
"_id": "6607cb2be8f81656f4459d5c",
"name": "Doctor1",
"email": "doctor12@gmail.com",
"password": "doc12345",
"createdAt": "2024-03-30T08:19:55.285Z",
"updatedAt": "2024-03-30T08:19:55.285Z",
"__v": 0
},
"patient": {
"reports": [
"6607cd20e8f81656f4459d5e"
],
"_id": "6607cc4be8f81656f4459d5d",
"name": "Patient1",
"phone": 7856253984,
"createdAt": "2024-03-30T08:24:43.050Z",
"updatedAt": "2024-03-30T08:28:16.879Z",
"__v": 1
},
"createdAt": "2024-03-30T08:28:16.761Z",
"updatedAt": "2024-03-30T08:28:16.761Z",
"__v": 0
}
]
},
"message": "All report of this status"
}- Entry point : index.js.
- config : Contains configuration files of Mongoose,Passport JWT Strategies and Status.
- controllers : The controllers for various urls like Doctor API or Patient API or Report API.
- models : Mongoose Schemas for the Doctors, Patients and reports.
- routes : Different routes for different request urls.
- Node.js : A runtime environment for executing JavaScript code server-side.
- MongoDB : A NoSQL database used for storing data in JSON-like documents.
- Express.js : A web application framework for Node.js used for creating RESTful APIs.
- JWT (JSON Web Tokens) : Used for authentication purposes to secure certain routes.