Important libraries used-
- multer - to perform image uploading
- cors - for cross origin access
- mysql2 - for mysql database
- joi - for form and json validation
- body-parser - to parse coming data, acts as a middleware
- express
-
psychiatrist/register - method accepted = "post json", registers psychiatrist. required fields : firstname, lastname, hospitalname, phonenumber
-
psychiatrist/register - patient : method accepted = "post form data", registers patients. required fields : token(of psychiatrist), (name, address, email, password, photo) (of patient)
-
psychiatrist/get-token - method accepted = "post json", required fields : phonenumber
-
psychiatrist/users - method accepted = "get", required params : token, gives all the users registered by the current psychiatrist
-
psychiatrist/users-on-each - method accepted = "get", required params : none, gives count of registered users by each psychiatrist
https://www.getpostman.com/collections/58ec7b053eaeb4e3d95c
- psychiatrist - id is primary key and AUTO INCREMENT, phonenumber is used as unique key to identify each psychiatrist.
- patient - id is primary key, patient is uniquely identified by email too, psychiatrist_id is foreign key here.
- token - token is primary key, id is foreign key referencing psychiatrist id. stores all current available/online tokens.
create table psychiatrist ( id int not null AUTO_INCREMENT , first_name varchar(20) not null , last_name varchar(20) not null,
hospital_name varchar(100) not null, phone_number varchar(12) not null unique , pincode varchar(6) , state varchar(100) , primary key (id) );
create table patient( id int not null AUTO_INCREMENT, psychiatrist_id int , name varchar(20) not null , address varchar(100) not null , email varchar(100) not null unique, phone_number varchar(12) ,
password varchar(100) not null , image varchar(200) not null , primary key(id), foreign key(psychiatrist_id) references psychiatrist(id) );
create table token (token varchar(100) not null , id int not null , primary key(token), foreign key(id) references psychiatrist(id) );