0% found this document useful (0 votes)
176 views106 pages

499B Final Journal

The document outlines a senior design project to develop a web and mobile based online healthcare system in Bangladesh that allows patients to register, store health information, search for doctors, message or video call doctors, set medicine reminders, and make online payments, and also allows doctors to register, view patient medical histories, and provide remote treatment through the platform. The system aims to improve healthcare access in remote areas and help doctors better serve patients nationwide using technology.

Uploaded by

Muhi hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views106 pages

499B Final Journal

The document outlines a senior design project to develop a web and mobile based online healthcare system in Bangladesh that allows patients to register, store health information, search for doctors, message or video call doctors, set medicine reminders, and make online payments, and also allows doctors to register, view patient medical histories, and provide remote treatment through the platform. The system aims to improve healthcare access in remote areas and help doctors better serve patients nationwide using technology.

Uploaded by

Muhi hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

1

Department of Electrical and Computer Engineering


North South University

Senior Design Project

Development of Web And Mobile Based Online Healthcare


System

Sayed Mudasshir Hossain ID # 1610046042


Fahim Ahmed Shakil ID # 1610736042
Mustafa Zenhar Jalal ID # 1521428642

Faculty Advisor:
Dr. Mohammad Monirujjaman Khan
Associate Professor
ECE Department
Fall’ 2019
2

DECLARATION
This is to certify that this project is our original work. No part of this work has been submitted
elsewhere partially or fully for the award of any other degree or diploma. Any material
reproduced in this project has been properly acknowledged.

Students’ names & Signatures

1. Sayed Mudasshir Hossain

___________________

2. Fahim Ahmed Shakil

___________________

3. Mustafa Zenhar Jalal

___________________
3

APPROVAL
We, ​Sayed Mudasshir Hossain (ID- 1610046042)​, ​Fahim Ahmed Shakil (ID-1610736042)​,
Mustafaa Zenhar Jalal (ID-1521428642)​, members of CSE: 499 (Senior Design) from the
Electrical and Computer Engineering department of North South University; have worked on the
project titled “​Development of Web And Mobile Based Online Healthcare System​” under the
supervision of ​Mohammad Monirujjaman Khan as a partial fulfillment of the requirement for
the degree of Bachelor of Science in Engineering and has been accepted as satisfactory.

Supervisor’s Signature

Dr. Mohammad Monirujjaman Khan


Associate Professor
​Department of Electrical and Computer Engineering
North South University
Dhaka, Bangladesh.

Department Chair’s Signature

Dr. K. M. A. Salam
Professor & Chair
Department of Electrical and Computer Engineering
North South University
Dhaka, Bangladesh.
4

ACKNOWLEDGEMENT
By the mercy of the Almighty we have completed our senior design capstone project entitled
“Development of Web and Mobile Based Online Healthcare System”​.

We are deeply grateful to our advisor ​Dr. Mohammad Monirujjaman Khan​, Associate
Professor, Department of Electrical and Computer Engineering, North South University for his
endless support, inspiration, encouragement and constructive criticism throughout this work. His
guidance helped us in the time of research, writing and completion of this project.

Our sincere thanks also go to North South University, Dhaka, Bangladesh for providing an
opportunity in our curriculum which enabled us to have an industrial level experience as part of
our academics.

Last but not the least, we would like to thank our family members and our friends for constantly
motivating us which helped us to stay focused.
5

Abstract
Health care system is one of the fundamental parts of society. In this project, we have developed
web and smartphone applications for the people of Bangladesh where both patients and doctors
can register and patients can have medical treatment via video calling. Using the developed web
and smartphone applications, patients can register via their phone number, store information
concerning their health, search available doctors, send text messages or make video calls to the
available doctors, set alarm to take medicine on time and complete payment online. Doctors can
also register to the system where the verification to ensure the authenticity of the information
provided by the doctor is handled manually. Doctors can view a patient’s medical history
whenever a patient makes contact through text or video call and provide treatment accordingly.
The system has been deployed and verified. The applications provide a faster and enhanced way
to get treatment and will ensure the availability of treatments in remote areas. The system will
help to spread health care services nationwide and provide doctors with the opportunity to help
in improving the health conditions of the citizens of Bangladesh.

Keywords​-​ ​Online health care, Remote medical treatment, Doctor, NodeJS, Android, Twilio,
Firebase.
6

DECLARATION 2

APPROVAL 3

ACKNOWLEDGEMENT 4

Abstract 5

1 Introduction 9
1.1 Problems 9
1.2 Existing Solutions 12
1.3 Literature Review 14
1.3.1 History of Telemedicine in Bangladesh 16
1.3.2 Influencing Factors 18
1.4 Our Solution And Objectives 20
1.4.1 Our Solution 20
1.4.2 Objectives 21

2 Methodology 24
2.1 Workflow 24
2.2 Implementation And Usage 25
2.2.1 Usage For The Doctor 25
2.2.2 Usage For The Patient 26
2.3 Used Technologies 27
2.3.1 Technologies Used In The Web Application 27
2.3.1.1 ReactJS 27
2.3.1.2 Twilio 28
2.3.1.3 Socket.IO 28
2.3.1.4 MongoDB 28
2.3.1.5 MongoDB Atlas 28
2.3.1.6 Node.js 28
2.3.2 Technologies Used In The Android Application 29
2.3.2.1 Android Operating System 29
2.3.2.2 Java 30
2.3.2.3 Firebase Realtime Database 30
2.3.2.4 Sinch 30
2.4 Cost 30
2.5 Targeted Population 30
2.6 Innovation Of Our System 31
7

3 Android Application 33
3.1 Registration 33
Cloud Synced Alarm 34
3.3 Profiles 36
3.4 Doctor And Patient Communication 37
3.5 Video Call 39

4 Web Application 42
4.1 Registration 42
4.2 List Of Doctors 43
4.3 Review 44
4.4 Payment System 45
4.5 Video Call 46
4.6 Online Chatting 47
4.7 User Dashboard 48

5 Market Analysis 51
5.1 Unit Cost 51
5.2 Users 51
5.3 Demography 51
5.4 Existing Solutions vs Our Solution 56
5.5 Impact Factor 57

6 Conclusion 60
6.1 Future works 60
6.1.1 Our Shortcomings 60
6.1.2 Future Plans 61

7 References 62

8 Appendix 64
8

Chapter 1
Introduction
9

1 Introduction
Healthcare is of basic commodities. By natural process, we fall ill of one way or another so we
need medical attention almost like we need food or other basic commodities. With that in mind,
we wanted to make this very essential commodity easily accessible by the help of modern
technologies. Luckily we did not have to look further and found out that there is no platform
available with easy accessibility all over the country. So proceed to build a platform that will
help both doctor and patient by making their interaction much easier. So we decided to build a
Web application and an Android application where doctors and patients can interact and
exchange information easily with minimum effort. This will only require a standard internet
connection and a device to use the applications with. So we build the remote healthcare system
which is a cross-platform solution for remote healthcare services. Smart Telemedicine will let
people get medical treatment from doctors remotely via video calling and online chatting service
which will be provided as both web and smartphone applications.
Currently, to get treatment, people need to visit doctors. But there are many cases where the
disease is not severe and can be treated remotely. But there are very few platforms in our country
through which a person can get medical treatment remotely.

1.1 Problems
In Bangladesh, not all of the population live in urban areas. In fact, most of the people live in
remote village areas where the basic necessity of medicine is a luxury to them. The distribution
of doctors and medical facilities are very poor in our country. ​Figure 1 ​illustrates the reality of it.
It is clear from this figure that the distribution is not even close to being enough. Which is very
sad and also surprising considering that we are living in the 21st century. Also, one thing is clear
that not every place has the same density as the medical facilities. For example, Dhaka as being
the capital of our country enjoys the most density of the medical facilities also urban areas have
more doctors that in rural areas. For some reason, doctors and nurses are deciding to come to
urban areas. Which left the rural areas susceptible to ill healthcare services through these areas
10

needed more attention regarding this yet the reality is unfortunate. This is the core problem we
started working with. Also, there are other problems like affordability and availability, which are
the same for both rural and urban areas; meaning that most of the time the proper medical
attention is too costly to reach for and along with that not available when it is needed most.
There are many problems people faces to get treatment from doctors. First of all, the number of
specialized doctors available in our country is relatively low compared to the population.
Sometimes it takes up to 2-3 months to get an appointment to a specialized doctor. Therefore, it
prevents from getting proper treatment at the right time. Moreover, in the big cities of
Bangladesh such as Dhaka or Chittagong, life activities are greatly affected by the colossal
traffic jam. As a result, it also affects people adversely from getting proper treatment. Next, most
of the renowned doctors of the country carry out their profession in the capital city of
Bangladesh - Dhaka. Therefore, it is troublesome to get proper treatment for people who live
outside the city. To get proper medical treatment, people living outside of Dhaka and especially
people living in rural areas have to travel to Dhaka. It is bothersome to travel such a long
11

distance to get treatment which might have been possible to do remotely. Next, after getting the
diagnostic reports prescribed by the doctor, patients need to visit the doctor again to show the
reports. These multiple visits cause rather inconvenience to the patient and might have been
avoided by having a medium through which a patient could have submitted the reports for the
doctor to see. Furthermore, in Bangladesh, there are almost no qualified doctors in village areas
and so to meet just an MBBS qualified doctor, villagers have to travel to Upazilla.
Therefore, many villagers fall into early demise because of not being able to get proper medical
treatment.
As discussed above, there are many problems people face while trying to get medical treatment
from doctors. Even though these problems remain, there are some existing solutions that people
use to get on with them.
As it is difficult to get an appointment with a specialist doctor, people go to local doctors for
treatment. Again, as there is a massive traffic jam problem in the country and it is difficult for a
patient to spend hours on the road; people usually buy medicines from local pharmacies as a
treatment measure which is often prescribed by the pharmacist without consulting a doctor.
More to the point, people living in remote areas do the same that is they rather buy medicines
from their local pharmacies instead of visiting a doctor which results in improper treatment and
some cases to death.
According to the “World Health Organization (WHO)”, there are an estimated 3.05 physicians
per 10,000 population in Bangladesh[1]. Also, most health workers are concentrated in urban,
secondary and tertiary hospitals although 70% of the population lives in rural areas (Country
Case study (GHWA, 2008)[2].

Another study says, there is only 51,993 registered physician in the country with valid BMDC
number[3]. Which is quite low compared to the expanding population of the country.

Reliable and up-to-date health-related information is essential for developing an efficient health
system. Thus WHO has emphasized on it as one of the building blocks of any health system
12

The availability of a trusted health-related system is mostly absent here and WHO urged to focus
on that for developing the infrastructure of the medical system of the country. [4]

The number of unqualified doctors is high as well. There are about 12 unqualified doctors in the
village per 10 000.[5]

It can be seen that there is a massive shortage of doctors, especially for people living in remote
areas and so a medium that can connect these people to qualified doctors to get remote treatment
can be a huge solution to these problems.
Keeping all these in mind we proceeded with our project.

1.2 Existing Solutions


Our next step was to look for existing solutions that are already available in our country. The
remote health-care system is not a new concept; especially remote health consultancy has been in
existence in the first world countries for quite a long time. Though there have been few attempts
to bring remote medical consultancy in Bangladesh, it has failed in most cases to reach its
potential due to various factors.

In India, Apollo has established a remote medical and health consultancy service where a patient
can get online consultancy from a specialist doctor and can also book an appointment to visit the
doctor physically [6]. Using the website, a patient can choose any doctor according to their
problem and get consultation and prescription without visiting the doctor physically. They
charge very minimum fee e.g. 199 Rs. for consulting a regular doctor virtually and also has the
option to take consultation from a designated specialist with fees ranging from 50 to 70 USD.
There are also other remote health consultancy services such as “Live Health Online” which
provides all their services completely virtually [7]. There are few remote health consultancy
services available in Bangladesh too. “Tonic Doctor”, a partnered service of GrameenPhone, is
one of the most popular online medical consultancy services of Bangladesh [8]. They offer
13

remote health consultancy including diabetes, hypertension, and heart disease for a very cheap
price.

They offer a monthly plan of just “296 BDT” to get a consultation from MBBS certified doctor.
Even though their service is very cheap and available 24/7, they do not offer any specialized
doctor and also their service is limited to just GrameenPhone customers. In ​Figure 2 ​we can see
their website portal and the list of doctors. Tonic Doctor has been in the market for a few times
now and it has gained some popularity. That means that the demand for remote healthcare
services is existing in our country. That was another inspiration for working in this project. Since
people want this to happen we wanted to give it to them. With this in mind, we next proceed to
14

see the works that have been done in this field in the scientific and academic sectors in
Bangladesh’s hand worldwide. “PlexusD” is another remote health service in the country that
offers online medical consultancy but it is still in the development stage [9].

The currently existing online health consultancy services in Bangladesh discussed above are
inadequate. “Tonic Doctor” which provides remote medical consultancy does not offer any
specialist doctor. “PlexusD” which promises to offer specialist doctor is still in the developing
phase. Also, the online treatment service provided by “AskApollo” is limited to just doctors from
“Apollo Hospital” and the “Live Health Online” does not provide any service to have physical
meetings with a doctor.
The proposed project will work as a medium between patients and doctors, where the doctors
will not be limited to any particular hospital rather any doctor will be able to open up an account
and do consult remotely. It will also include specialist doctors for cardiology, psychiatry, general
medicine, etc. Also, anyone will be allowed to open up an account and get virtual consultation
which is not possible for “Tonic Doctor” as it only allows GrameenPhone customers to avail of
the service.

1.3 Literature Review


There has been some web-based remote health monitoring system development worldwide.
Bingchuan Yuan and his colleagues have worked on a remote health monitoring system [10].
Sekyoung Youm and his team have been promoting a healthy lifestyle via their works which is
also a remote healthcare solution [11]. Meanwhile, Al Mamun and his colleagues were working
on Parkinson’s disease specifically and approached to solve it via cloud-based framework [12].
There have been works regarding remote cardiovascular activity monitoring [13]. In the rural
areas of Bangladesh S Parvin has been working on m-Healthcare for Antenatal and Postnatal
Care [14] In the paper, it is stated that Bangladeshi women are suffering from unexpected death
during childbirth or after that because of the insufficiency of antenatal and postnatal care
especially in the rural areas. In Bangladesh, ICT is going to be included in every sector. Mobile
Communication is the most increasing and successful achievement in our country. So they
15

suggested and designed an m-health system for prenatal and postnatal care of women in rural
areas of Bangladesh. Their proposed system is based on the mobile SMS and the web interface.
It also ensures the neonatal care up to the age of complication within our limited resources.
On the topic of Ubiquitous future M-Health system including wireless 3G technologies in
Bangladesh Najnin Sultana and Md. Ashraful Islam has been working in Bangladesh [15].
They have proposed a modified health infrastructure using 3G in remote side and Optical
Fiber in backbone side with wide range of services like video conferencing through
VoIP and Skype, MMS diagnostic reports, drug prescriptions and mobile purchase and
home delivery etc. Analysis shows that 3G needs less transmission time of 4s for
medical image upload and transmit.
Raqibul Mostafa and his team have proposed a framework regarding the Deployment of
Telemedicine Centers in Rural Bangladesh [16]. Their framework is stated to be a valuable
guide to deploy effective and long-term telemedicine center at any given location. the paper
presents the framework along with a detailed discussion of the constituent elements, and
analyzes several case studies to demonstrate the application of the framework to provide
site-specific telemedicine solutions at some selected test sites. All the previous telemedicine
projects in Bangladesh suffered from a lack of sustainability and it is expected that deployments
based on the proposed framework proposed by them would be effective, scalable, and
long-lasting in bringing e-healthcare to the target population in Bangladesh.

Rakibul Haque, Fahmi Ahsan, Yakun Bao worked on a paper about the current status, challenges
and future status of the e-health in Bangladesh. They stated that although the e-Health in
Bangladesh remains somewhat problematic, the difficulties could be overcome. Based on the
current scenario and challenges of e-Health, the scope of some fields requires further
improvement. They showed the findings of their study would help the policy makers to make
effective decisions regarding e-Health services. [17] Also in their paper Ahasanun Nessa ; M. A.
Ameen ; Sana Ullah had showed how impactful tele medicine could be in the current situation in
Bangladesh. In this paper they mentioned the reasons why Bangladesh has to move for
telemedicine. Also the past and on-going telemedicine activities and projects in Bangladesh.
16

Analyzing the projects they have found out some factors which should be assessed carefully for
successful implementation of telemedicine application. They have further proposed a prototype
telemedicine network for Bangladesh that can improve health facilities through telemedicine by
making a connection between rural health facility providers and special hospitals.[20].

1.3.1 History of Telemedicine in Bangladesh


​Telemedicine in Bangladesh emerged before 1999. Many Bangladeshi physicians and surgeons
were practicing informal teleconsultation with their colleagues in different countries. The early
initiatives were sporadic and unorganized and most of them were based in store and forward
technologies such as telegram and e-mail basis. A more formal approach was taken only since
1999.
Timeline of Telemedicine in Bangladesh
1999: In Bangladesh first telemedicine link was established by a charitable trust named Swifne
Charitable. It established the link between the Centre for the Rehabilitation of the Paralysed
(CRP) in Dhaka (the capital of Bangladesh) and Royal Navy Hospital, Haslar, UK It was
email-based. It used a digital camera to capture still images that were then transmitted by email.
It was a very successful project. An evaluation of the 27 referrals made during the first year of
operation showed that tele-consultancy had been useful and cost-effective. Based on the success
of the Bangladesh project, the Swinfen Charitable Trust supplied: digital cameras and tripods to
more hospitals in other developing countries.
July 1999: ​Telemedicine Reference Center Ltd. (TRCL) Dhaka, Bangladesh a private company
launched his journey with an ambitious project to set up telemedicine project to help doctor
identify diseases early on. Dr Sikder M. Zakir, President & CEO of TRCL said “If we get the
diseases in early stage then it is possible to save 20 times more money that are being spent.'' At
beginning TRCL linked 200 specialists who will offer their expert opinion to rural doctor.
Although it is a privately funded project, Ministry of Health and Family Welfare of the
Government of the People's Republic of Bangladesh is playing a significant role in TRCL’s rural
telehealth care program implementation. TRCL started feasibility study and infrastructure
development to establish national and international telemedicine services.
17

Mid - 2000: Grameen Communications took rural tele-health initiatives using wireless
technology.
2001: TRCL demonstrated telemedicine system in the US Trade Show 2001 in Dhaka using
Icare software and normal Internet connection & started testrun of the system between US and
Bangladeshi physicians.
April 2001: The Bangladesh Telemedicine Association (BTA) is formed. But the lack of
government sector the technology remains out of reach to the majority of poor people of the
country ​2003: Sustainable Development Network Program (SDNP) Bangladesh began in January
2003. The e-HL project built two network segments (8Km; and 6Km) using point-to-point radio
with bi-directional bandwidth of 2 Mbps. Currently, SDNP has four regional nodes in different
parts of Bangladesh (Cox’s Bazar, Dinajpur and Satkhira), including Mymensingh. These nodes
are connected to satellite through VSAT 22(SCPC/MCPC) technology. Under this project every
Friday they arrange consultancy and diagnostic support to the physician at remote end, though
medical experts at the SDNP head office [21].
2003: Bangladesh University of Engineering & Technology (BUET) and Comfort Nursing
Home had started a Telemedicine project with the financial collaboration from European Union
(EU) via Email. Recently the project is not functional.
May 2004: Bangladesh. DNS diagnoses Centre, Gulshan-1 and Comfort Diagnoses & Nursing
Home’s started a Telemedicine center. The project was discontinued because of lack of financial
viability, patient disinterest and poor market promotion
2005: ​In August 16, 2005 Grameen Telecom (GTC) in cooperation with the Diabetic Association
of Bangladesh (DAB) launched telemedicine services, giving patients at Faridpur (one district of
Bangladesh) General Hospital access to specialist doctors of their choice in Dhaka. DAB’s
BIRDEM Hospital Dhaka, was connected via a video conferencing link to DAB’s Faridpur
General Hospital. Consultations now take place over video conference where patient and doctor
see each other on television screen. The cost per consultation for a new patient was 600 BDTaka
(10 US$), with repeat patients getting some discount [22].
2006 November: Telemedicine Reference centre Ltd. And Grameen phone has started a unique
telemedicine Service “HealthLine Dial 789” A GSM infrastructure based call centre for Grameen
18

phone 10 million subscribers. Providing different types of medical information facility,


emergency service (SMS based LAB report, ambulance) and real time medical consultation over
mobile phone [23].
2007 September: The project ‘ICT in rural Bangladesh’ is working for the development of
health care facilities in rural Bangladesh through ICT. The project is funded by SPIDER (The
Swidish Program for ICT in Developing Regions) for the period September 2007–December
2009 and is a collaboration with Grameen Communications, Bangladesh; Grameen Phone,
Bangladesh; Bangladesh Sheikh Mujib Medical University, Bangladesh; and International
Institute of Information Technology (IIIT), India. The overall goal of the project is to improve
the performance of rural health workers and increase access to healthcare services for rural poor
in the district of Magura in Bangladesh. More information about the project.[24].

1.3.2 Influencing Factors


The first project of telemedicine, between CRP in Dhaka and Royal Navy Hospital, Haslar, was
successful and it encouraged other developing country to take this type of initiative. At
beginning the outcome of DAB Pilot Project was satisfactory. In the first three months, there
were 52 new patients and 6 returning patients. The number of patient rate was not satisfactory
later. The patient rate was 1.3 to 1.5 till 2006. The project is still running but now days no patient
is seen for service. Later some technical problems had arisen that decreased the patient rate. The
performance of the camera was not satisfactory and picture would damage in rough weather due
to the last end Radio link connection. We think another reason of failure of this project is
implementing the project in a city which is very near to Dhaka. Faridpur is very near from
Dhaka. It took only 1.5-2 hours to go Dhaka from Faridpur by bas. So the patient may have
found it more convenient to come to Dhaka and physically meet doctor of their choice. SDNP
telehealth project is running now. They only provide tele-consultation with remote doctor on
every Friday that is not enough to support any emergency situation. Tele-psychiatry is another
application of Telemedicine. It is the most successful and low cost telemedicine applications,
because it needs only a good video conferencing between two endpoints. According to the
National Mental Health Survey in 2003-2005 about 16.05% of the adult population of
Bangladesh is suffering from mental disorders [25]. There is a high prevalence of psychiatric
19

disorders in rural Bangladesh. Money spends for mental services are less than 0.5% of the total
national health expenditure. There are 50 outpatient mental health facilities, 31 community-based
psychiatric inpatient units, 111 community residential facilities and one 500 bedded mental
hospital in the country. In past telemedicine projects tele-psychiatry did not get attention. It can
be considered as a way for providing mental health care. Although telemedicine is not a panacea
for all problems related of health care, it can help to minimize the problems that are related with
time in distant. Telemedicine activities are still in primary level in Bangladesh. There is no
support to meet the emergency medical need such as a stroke, severe injury for people in remote
areas. Many developing countries have implemented telemedicine networks which have made a
connection between remote hospitals and special hospitals. We can take India, China for
example [26]. China has three major telemedicine networks. The IMNC network is primarily
based on telephone line and Internet. To possible data transmission over low bandwidth they are
using powerful image compression algorithm that can reduce the file size dramatically.[27]. The
successful expansion of Telemedicine fully depends on the improvement of Information and
telecommunication structure. In past telemedicine implementation was not easy due to poor
telecommunication infrastructure. Now the situation is in favor of telemedicine.
Telecommunication sector in Bangladesh has been experiencing a huge boom in the last few
years. Several private and public telecommunication operators are expanding their operation to
the most rural areas; they are also dwelling to improve the network performance and inclined to
introduce latest technologies to the people. Government always patronizes past telemedicine
projects. Government has lots of responsibility in this aspect. Government should encourage
private organization to invest in telemedicine implementation. Since telemedicine practicing is
increasing day by day so it is very much needed to provide structured laws and regulations about
physician provided service, patients’ issues, licensing of physician and telemedicine providers.
There should be clear rules about reimbursement issues. Since in telemedicine system local
doctor or paramedic treats a patient and they consult with specialist who is far away, who will be
responsible for patient issues? Government also should create policies in favor of rural people so
that they can enjoy low cost telemedicine services. The success of any system depends on user
acceptance. Though there is no difference between conventional consultation and a
20

tele-consultancy, patient and doctors who are accustomed to personal visit may be reluctant to
alter the traditional methods of health care. May be IT savvy medical staffs and physician will
face difficulty in using new technology. To overcome this problem, sufficient training programs
should be offered to enable physician to adapt to this new technology. Media can play a
significant role to make telemedicine popular to user. They should broadcast the successful case
history considering the efficacy and cost effectiveness of telemedicine. There are many factors
influencing the diffusion of telemedicine as well as other new technology. The following factors
should be assessed before considering telemedicine implementation in a specific health care.
Medical Need: First we have to consider what kind of medical facilities can be provided by this
specific health centre. Establishing a high-end telemedicine cell in thana (sub-town) level would
not be significant because of the structure of health care.
Organization and Structure of Health care: According to the structure of health care,
telemedicine support can be different.
Location of the Health Centre: If the location of the health centre is in the same city of the
super or large hospital then people would prefer face to face consultancy rather than
tele-consultancy. We faced this problem in DAB project where the health centre is in Faridpur
and special hospital is in Dhaka, the capital of Bangladesh. The distance between the two
locations is one and a half hour by bus.

1.4 Our Solution And Objectives


Reviewing all the works and existing services currently available for the people we went on with
our own solution and objectives in mind. We did it because we thought that the existing works
have their failings and the more updated and robust solution we can offer.

1.4.1 Our Solution


Reviewing all the previous ideas we decided that our solution should be open and any limitation
free. Since nowadays the internet is available everywhere and easy to access we went for a
solution that involved the internet and web technology. This will make this system easily
accessible to everyone as well as it will be available everywhere in the country. Moreover, this
21

will be a cheap solution because the internet is nowadays very cheap to access. So we went on
making a website where doctors and patients can have their own accounts and different
privileges and they can interact very easily. Later on, we realize that smartphone applications are
very popular nowadays so it will be great if we make a smartphone application with the same
functionalities and results. So we also planned to build an Android application because this is the
most popular choice of smartphone in our country and it is also cheaper than the other options.
We decided that video chatting with the doctor would make the process of treatment much
easier. We have also developed a chatting service through which patients can send text messages
to the doctor before a video calling session. The experience with every doctor would not be the
same. So we have developed a review system where a patient can review the video calling
experience with the doctor.

1.4.2 Objectives
Right from the beginning, our core objective was to make medicine and healthcare accessible
and reliable and available to all the people of Bangladesh. Later on, to make the doctors
interested we added the online easy payment system this would help to attract doctors. There are
a large number of people living in rural areas who do not have the opportunity to make an
appointment with the reputed doctors. Most of the reputed doctors practice in Dhaka. So in order
to get treatment from them, people from rural areas need to come to Dhaka first. Sometimes they
don’t have a place to stay. That adds more problem and expenditure of the entire tour becomes
high. It is not affordable for them most of the time. Our proposed solution will help them to get
remote treatment sitting at home. To make the lives of the people easier has always been a core
objective for us.

Among the upcoming sections; ​Chapter 2 ​contains the ​Methodology ​we used to build our
system. We discussed about the workflow and how we implemented the system. We have further
discussed the technologies we have used in the time of developing both the website and android
application. ​Chapter 3 ​contains the details description and contents of the Android
Application. We discussed about each feature in details. Chapter 4 ​contains the details
description and contents of the ​Web Application, Chapter 5 ​is about Market Analysis ​where
22

we discussed about the unit costs, the demography and compared our solution with the existing
solutions ​and ​Chapter 6 ​is the Conclusion ​where we discussed about the shortcomings and also
included the future plans with this project.
23

Chapter 2
Methodology
24

2 Methodology
This section has the detailed description of our workflow and the methods and technologies we
used to solve our problems and achieve our goals.

2.1 Workflow
We developed a website and a smartphone application that will enable people to get medical
consultancy from renowned doctors over a virtual medium. This system focuses on solving the
problems discussed above to make the lives of people easier.

The system consists of two user profiles as shown in ​Figure 3​. There is a patient type account
and a doctor type account. Patients can access the Doctor's list after a successful registration
process. Patients can use video calling feature in order to remotely interact with the doctor. A
doctor type user can decide which patient to give treatment to. Once they start treating a patient,
they will have access to a certain part of the patient profile necessary for the treatment. All of
this happens after successful registration and login.
25

2.2 Implementation And Usage


As clear from the previous discussion and the figure our system has basically two views. One of
them is for the doctor and the other is for the patient. Both sides have different usage and
purposes. ​Figure 4 ​illustrates the usage and use cases for both patient and doctor.

2.2.1 Usage For The Doctor


The doctor type users are required to go through a registration process. In the time of
registration, a doctor type user will have to provide a valid Bangladesh Medical and Dental
26

Council (BM&DC) registration number and National Identification Card (NID) number. The
system admin will then check it manually and if valid, then approve it. Only after that, the doctor
type user's registration can proceed further.
After login into the system, a doctor type user will be directed to a ​Doctor's dashboard​. From
there, if a patient has contact with the doctor, then he/she will be able to see the patient's medical
history and will be able to communicate with the patient further via text messages or video
calling.
The prescription of the patient will be stored in the patient’s profile and all the medical histories
of the patient can be checked and monitored by the doctor. Patients can only see the prescription
given by the doctors while the doctors can edit it.

Whenever a doctor type user logs in, she/he will immediately go online. In order to go offline,
they need to log out of the system. Doctors will be able to see previously prescribed medicines
and all other medical histories of their patients.
Doctors will receive money from the patient type users from through mobile banking, visa card
and MasterCard.

2.2.2 Usage For The Patient


In the system, users will be able to consult doctors remotely by using the web or a smartphone
application. The users will need to go through an easy registration process first in order to get
services. After signing in, the user will be directed to the ​Patient dashboard from where she/he
will be able to get a consultation from any doctor of their choice. In the system, different
specialist doctors will be stored in a categorized format, thus users can easily find a doctor for
their need quickly. For example, if a patient wants to consult with a medical doctor, then she/he
can find all the medicine specialists by choosing a “medicine doctor” from the “category”
feature. Users will be able to start a video call immediately to any available doctor. Patient type
users can edit their user profile by putting necessary information concerning their health. They
can also send text messages to the available doctors, set alarm to take medicine on time and
complete the payment online.
27

Patients will be able to give feedback after a session with the doctor. There is also a rating
system, using which patient type users can provide their valuable opinions about their interaction
with doctors.

2.3 Used Technologies


We have tried to use the latest available technologies in the market right now. We were working
on a cross-platform goal so for the web and for the Android application we had to use different
technologies. In the next subsections, the specific description has been given and ​Figure 5
illustrates the bird’s eye view of the system and the technologies.

2.3.1 Technologies Used In The Web Application


For developing the web application we have used NodeJS as a backend framework and ReactJS
as frontend framework. For implementing video calling, we have used Twilio Programmable
API and for text chatting, we have used Socket.IO. For database management, MongoDB cloud
platform MongoDB Atlas has been used. For loading dynamic contents, the asynchronous
requests have been handled by NodeJS packages in the backend. React hooks and APIs have
been used to connect the frontend framework with backend.

2.3.1.1 ReactJS
React (also known as React.js or ReactJS) is a JavaScript library for building user interfaces. It is
maintained by Facebook and a community of individual developers and companies.
28

React can be used as a base in the development of single-page or mobile applications, as it is


optimal for fetching rapidly changing data that needs to be recorded. However, fetching data is
only the beginning of what happens on a web page, which is why complex React applications
usually require the use of additional libraries for state management, routing, and interaction with
an API; Redux, React Router and Axios are respective examples of such libraries.

2.3.1.2 Twilio
Twilio is a cloud communications platform as a service company based in San Francisco,
California. Twilio allows software developers programmatically to make and receive phone
calls, send and receive text messages, and perform other communication functions using its web
service APIs.

2.3.1.3 Socket.IO
Socket.IO is a JavaScript library for realtime web applications. It enables real time, bi-directional
communication between web clients and servers. It has two parts: a client-side library that runs
in the browser, and a server-side library for Node.js. Both components have a nearly identical
API.

2.3.1.4 MongoDB
MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL
database program, MongoDB uses JSON-like documents with a schema. MongoDB is developed
by MongoDB Inc. and licensed under the Server Side Public License.

2.3.1.5 MongoDB Atlas


MongoDB Atlas is a fully-managed cloud database developed by the same people that build
MongoDB. Atlas handles all the complexity of deploying, managing, and healing your
deployments on the cloud service provider of your choice (AWS, Azure, and GCP).

2.3.1.6 Node.js
Node.js is an open-source, cross-platform, JavaScript runtime environment that executes
JavaScript code outside of a browser. Node.js lets developers use JavaScript to write
29

command-line tools and for server-side scripting—running scripts server-side to produce


dynamic web page content before the page is sent to the user's web browser. Consequently,
Node.js represents a "JavaScript everywhere" paradigm, unifying web application development
around a single programming language, rather than different languages for server- and client-side
scripts.

Though .js is the standard filename extension for JavaScript code, the name "Node.js" does not
refer to a particular file in this context and is merely the name of the product. Node.js has an
event-driven architecture capable of asynchronous I/O. These design choices aim to optimize
throughput and scalability in web applications with many input/output operations, as well as for
real-time Web applications (e.g., real-time communication programs and browser games).

The Node.js distributed development project, governed by the Node.js Foundation, is facilitated
by the Linux Foundation's Collaborative Projects program.

Corporate users of Node.js software include GoDaddy, Groupon, IBM, LinkedIn, Microsoft,
Netflix, PayPal, Rakuten, SAP, Voxer, Walmart, and Yahoo!.

2.3.2 Technologies Used In The Android Application


The Android application has been developed by using Android Architecture Architecture
Component and JAVA. For handling the database and chatting, we have used Firebase Realtime
Database and for video calling, we have used Sinch.

2.3.2.1 Android Operating System


Android is a mobile operating system based on a modified version of the Linux kernel and other
open-source software, designed primarily for touchscreen mobile devices such as smartphones
and tablets.
30

2.3.2.2 Java
Java is a general-purpose programming language that is class-based, object-oriented, and
designed to have as few implementation dependencies as possible.

2.3.2.3 Firebase Realtime Database


Firebase is a mobile and web application development platform developed by Firebase, Inc. in
2011, then acquired by Google in 2014. As of October 2018, the Firebase platform has 18
products, which are used by 1.5 million apps.

2.3.2.4 Sinch
Sinch is a telecommunications and cloud communications platform as a service company.
Headquartered in Stockholm, Sweden, Sinch also has offices in over 30 cities worldwide,
including Atlanta, London, Madrid, San Francisco, Singapore, and Sydney.

2.4 Cost
The main cost we had to undergo is the cost of the domain and other things acquiring. The
details costing has been given in the table below. Since we have done the development works all
by ourselves therefore the cost was minimal. Still we had to give our time for this project so that
worth some costing. We have given that costing based on the average market price of a
developer per hour. So that is not the amount we have actually spent but that will cost someone if
someone wants to build a project like this. For domain, we spent 1100 BDT.

2.5 Targeted Population


The targeted use of this project is the mass population of Bangladesh. Anyone who has access to
the internet can use this service, and nowadays the internet can be accessed from anywhere in the
country. This project is for people of any age. As mentioned earlier, the goal of this project is to
ensure proper medical services remotely and make the whole medical service more accessible to
everyone.
31

2.6 Innovation Of Our System


This project is an innovation in the sense that no other services in Bangladesh have these
facilities like this one. There are few services available in the country in this sector but they
either arrange a physical meeting via online appointments or just provide consultation from
non-specialist doctors. On the other hand, in this proposed project, users will be able to get
online medical treatment from specialist doctors via video call using the web or smartphone
application which is not currently an available service in the country. Thus, the project is
innovative.
32

Chapter 3
Android Application
33

3 Android Application
Using the mentioned technologies in Chapter 2, we have developed an android application which
has dual authentication system, separate dashboards for patient and doctor type users, chatting
functionality, video calling functionality, setting up multiple alarms which is also synced with
the cloud and payment system.

3.1 Registration
The Registration and Login page for two types of users has been developed for the android
application. The platform now has a dual authentication system. Firebase was used for storing
user data. The development of the dual user authentication was done using the Java
programming language alongside Firebase, Firebase Realtime Database, and XML. For the
implementation of dual authentication system, a user table in Firebase Realtime Database has
been created in which a field has been added called “type”, in which for patient type user value
patient is stored and for doctor type user value doctor is stored.
In the android application, the system admin approval from the backend for the registration of
the doctor type user has also been implemented. For the implementation of manual verification
for doctor type user, a field named “approved” has been added to the user table in Firebase
Realtime Database. Whenever a doctor registers for a new account using the android application,
he/she provides information which includes name, Bangladesh Medical and Dental Council
(BM&DC) number and National Identification Number (NID). Using Firebase console, system
admin can check the provided information and verify the authenticity of the person. After
checking the authenticity of a new doctor account, system admin can change the value of
“approved” field to “true” in user table in Firebase Realtime Database. After the completion of
verification and approval process, doctors will be able to log in to their account and access their
designated dashboard. Also the newly created doctor account will become available in the doctor
list.
34

Figure-6 presents the logic which has been used for the implementation of dual authentication
system in the developed android application. When a new user registers to the system using the
android application, if the account is patient type, then the user will be directed to patient
dashboard. On the other hand, if the account type is doctor, then the user will be directed to
doctor dashboard with limited access if the doctor account is not verified. After the doctor
account is verified, the doctor type user will be directed to doctor dashboard with full access.

Cloud Synced Alarm


In the android application, an alarm setting system has been implemented. This feature of setting
alarm is only available for patient type accounts and not available for doctor type accounts.
Using the alarm setting feature, patients can set multiple alarms to take medicine on time. They
can update the list of undertaking medicines and using the alarm, they can set reminders for
35

taking medicine on time. Also, the alarm time set by user is synced with cloud database.
Therefore, patients can log into their account using the android application in any device and the
saved alarms will be synced to that device and notify the user to take his/her medicine on time.
Figure 7 ​illustrates the interface for the alarm.

In ​figure-7, ​the list of alarms set by a user is shown. Users can set alarms to notify on every day
of the week or in particular days of the week by using turning on/off the days name under alarm
time shown in ​figure-7. ​As alarms are synced to the cloud, the list of alarms will become
instantly available to users whenever they logic to their accounts on any device using the android
application.
36

3.3 Profiles
Patients and doctors will have seperate profiles. In the profile for patient type users, their name,
age, systolic blood pressure, diastolic blood pressure, heart rate, etc. information are shown and
whenever a patient communicate with a doctor; the doctor will be able to see these information
from patient profile which will help him/her to treat the patient properly. Whenever a patient
type user logs into his/her account he/she will be able to see the list of doctors available in the
system. By clicking on the list of available doctors, patients will be able to see doctors’ full
profiles and in which area a doctor has speciality. There is also edit option using which users will
be able to update their information such as names, phone numbers, emails, age, medical records
and upload profile images.
37

In figure-8, implemented dashboard for both patients and doctor type users have been shown.
From the ​figure-8, ​it can be seen that for two types of users the dashboard shows different
information such as for patient type user the dashboard displays information like name, email
and various medical records; on the other hand for doctor type user the dashboard displays
information like their name, email, speciality, etc.

3.4 Doctor And Patient Communication


Using the android application, doctor and patient type users will be able to communicate with
each other via the implemented chat or video calling system. Whenever a patient logs into his/her
account, he/she will be able to see the list of doctor available in the system.
38

Figure-9 shows the user interface for list of available doctors in the system which can be
accessed from android application by logging in as a patient user. The list is updated dynamically
and in real time. So whenever a new doctor register and his/her id gets verified and approved; the
list of doctors gets updated in real time. From the list, patients can click on any doctor and they
will be directed to chat interface. From the chat interface, user can click on doctor image to go to
doctor profile to see more information about him/her, click on video calling option or send a text
message to initiate chatting.

From ​figure-10​, the implemented chatting interface for android application can be seen. Using
the implemented chatting functionality, users can see whenever a message has been sent and
whether the message has been seen or not. By logging in, a doctor user can see the messages that
have been sent and reply to the messages at his/her convenience. Doctor user can not see the list
of available doctors and can not see the available patient type users in the system. Whenever a
39

patient sends a doctor message through the implemented chatting system, the doctor will be able
to see that patient profile and the patient’s medical history and respond to the message. A patient
user can not communicate with other patient type user in the system and doctor type users can
not communicate with other doctor type users in the system. Patients can only communicate with
doctor and a doctor will only be able to communicate with a patient if the patient send the doctor
a message first through the chatting system.

3.5 Video Call


Patients can make video calls to any doctor available on the system provided that the doctor is
online. Doctors can receive video calls and provide treatment remotely. The video calling system
for the android application has been developed by using Sinch - an WebRTC application
programming interface. Whenever a patient makes a video call to a doctor, the call request first
goes to Sinch server and then it establish connection with the requested doctor account. The
video calling data is passed through Sinch server which is encrypted to ensure that no one else
will be able to access the video data.

Figure-11​ briefly describes the flow diagram of video calling system. First a patient makes a
video call to a doctor and the request is then received by Sinch server which then sends the call
request to the receiver doctor account. If the doctor is not available/online, then Sinch server
40

sends a not available notification to the patient account. If the doctor is available and receives the
call, then two different token is automatically generated for patient and doctor account by Sinch
server and then video calling is established between the patient and doctor for which data traffic
is handled by Sinch server.

From ​figure-12, ​video calling interface for android application can be seen where the small
screen at the top right corner shows the live image/video of the caller and the large screen shows
the video of the receiver.
41

Chapter 4
Web Application
42

4 Web Application
A landing page of the website is developed with ReactJS and NodeJS. A dual authentication
system has been implemented and manual checking for the doctor type user's validation is added.
Using the mentioned technologies in Chapter 2, we have developed the web application which
has functionalities such as separate dashboards for patient and doctor type users, chatting service,
video calling service, doctor rating feature and payment system.

4.1 Registration
To register as patients, users need to provide their names, emails, and passwords. Registration
and login for the patient type user is easier and without much hassle. After a successful
registration process, patient type users can log in with their email and password. On the other
hand, to register as doctors, users will need to provide names, emails, passwords, Bangladesh
Medical and Dental Council (BMDC) registration number and National Identification Card
(NID) number. For doctors, verification is important. That is why they will need provide their
Bangladesh Medical and Dental Council (BMDC) registration number. Our system admin will
manually check it. Doctors will be able to login to their accounts only after the verification of
their information has been completed.
In the web app, the system admin approval from the backend for the registration of the doctor
type user has also been implemented. For the implementation of manual verification for doctor
type user, a field named “approved” has been added. Whenever a doctor registers for a new
account using the android application, he/she provides information which includes name,
Bangladesh Medical and Dental Council (BM&DC) number and National Identification Number
(NID). System admin can check the provided information and verify the authenticity of the
person. After checking the authenticity of a new doctor account, system admin can change the
value of “approved” field to “true” in user table in the Database. After the completion of
verification and approval process, doctors will be able to log in to their account and access their
designated dashboard. Also the newly created doctor account will become available in the doctor
list.
43

4.2 List Of Doctors


Patients can see the list of available doctors in the system. This list will help the patient type
users to consult with the suitable doctor of their choice. Along with the list, there will be a photo
of the doctor and the name of the area s/he is specialist at. For example, if a patient type user
needs a medicine specialist, from this doctor’s list, he or she can find the list of doctors who are
from the medicine department. If patients have a choice, they can choose the listed doctor. If
they don’t, they can decide based on the degree or available review of the doctor. The doctor’s
list will help the patient type users to easily identify the doctors they want to consult with.
44

4.3 Review
A review system has been implemented through which patients will be able to provide feedback
about their experiences with the doctors. This system will help the patients to get some idea
about the doctors they want to consult. Sometimes, patients don't have any particular doctor in
mind. They don’t know which psychologist to consult with for counseling session. This review
system will help them to get some idea about the doctor they are choosing. Patient type users can
review a doctor on a scale of 5 based on their experience with the doctor. System admin will
regularly monitor the reviews and check on them if their is any inconvenience.
45

Figure 15​: Review system for the web application

4.4 Payment System


A payment system has been implemented using Stripe API. Patients can complete their payments
by using a visa or MasterCard. After taking a video calling session with the doctor, patients will
need to make payment. There is a window for the payment which will pop up after clicking the
payment button. Users will then need to provide their email and make payment through the visa
or mastercard. With the payment system, doctors will get financial benefits which will inspire
them to stick with this remote healthcare system.
46

Figure 16​: payment system on the web application

4.5 Video Call


Patients can communicate with doctors through chat or video calls. Video calling has been
implemented by using Twilio Programmable Video. ​Figure 17 ​illustrates the video call in
progress in Web Application.
47

After selecting the doctor from the doctor’s list, patients will have to send text messages to the
doctor. If both parties agree for consultation, the video call may proceed. With the help of video
calling, the patients and the doctors will be able to see each other remotely which will enhance
the spectrum of giving treatment. With the video calling service, if there is something of a
patient’s body that a doctor needs to see, then he or she can see it. A video conference would
make the experience more authentic and humane.

4.6 Online Chatting


Doctors and patients can send text to each other using online chatting service. ​Figure 18
illustrates the chatting services in progress for the web app. We have used the API of socket.io in
order to implement the online chatting. Socket.IO is a JavaScript library for realtime web
applications. It enables real time, bi-directional communication between web clients and servers.
48

Figure 18​: Online chatting for the web application

With the help of chatting service, the doctor-patient communication would become easier. After
selecting the doctors from the doctor’s list, patients can send the doctors text messages. They can
use text messages to set up for the consultation through video calling and other issues. After the
communication through text messages, if the doctors agree, then things will proceed further.

4.7 User Dashboard


Two different user dashboards has been implemented for both the patient and the doctor type
users. These dashboards will provide at-a-glance views of key performance indicators for both
types of users. For example, a doctor’s profile will have a doctor’s photo and his/ her department
and degree. ​Figure 19​ illustrates the doctor’s dashboard.
49

Figure 19​: Doctor’s Dashboard on the web app

In the profile for patient type users, their name, age, systolic blood pressure, diastolic blood
pressure, heart rate, etc. information are shown and whenever a patient communicate with a
doctor; the doctor will be able to see these information from patient profile which will help
him/her to treat the patient properly. Whenever a patient type user logs into his/her account
he/she will be able to see the list of doctors available in the system. By clicking on the list of
available doctors, patients will be able to see doctors’ full profiles and in which area a doctor has
speciality. There is also edit option using which users will be able to update their information
such as names, phone numbers, emails, age, medical records and upload profile images.
50

Chapter 5
Market Analysis
51

5 Market Analysis
In the market, we have reached a lot of users.

5.1 Unit Cost


The main cost we had to undergo is the cost of the domain and other things acquiring. The
details costing has been given in the table below. Since we have done the development works all
by ourselves therefore the cost was minimal. Still we had to give our time for this project so that
worth some costing. We have given that costing based on the average market price of a
developer per hour. So that is not the amount we have actually spent but that will cost someone if
someone wants to build a project like this.

Domain 1100/-

Development Cost 100000/-

Database Subscription 1000/-

5.2 Users
Unlike previously existed services like ours, ours service is completely open for everyone to use.
So no extra condition applied or no hidden charges. So that makes all the people of Bangladesh
our user base. Which makes all the 158.9 million(2017)[17] people of our country our user base.
Anyone interested in our service can use it from anywhere in the Bangladesh. All they will need
is a stable internet service.

5.3 Demography
In 2017 according to Statistical Bureau of Bangladesh, the population of our country was 158.9
million. Which is a lot considering the size of the country. So that makes our country one of the
most densely populated countries of the world. ​Figure 20 ​confirms that matter and we can see
52

that we have 79.6 million Male and 74.5 million Female among our population. The growth rate
of the population is 1.37. The total fertile population ratio(15-49 years) is 2.10. From the data it
is clear that lots of people are still living under the poverty range. Bangladesh suffers from both a
shortage of and geographic mal-distribution of HRH. There are an estimated 3.05 physicians per
10,000 population and 1.07 nurses per 10,000 population (estimates based on MoHFW HRD
2011). There is a severe gap between sanctioned and filled health worker positions: 36% vacancy
in sanctioned health worker positions and only 32% of facilities have 75% or more of the
sanctioned staff working in the facilities (World Bank, 2009). 28% of treatment provided in
53

government health facilities is through alternative medicine (Ayurveda, Unani, and


Homeopathy), yet as of June 2011, there was a 50% vacancy rate for alternative medicine
providers (MoHFW AMC 2011).

Health workers are concentrated in urban secondary and tertiary hospitals, although 70% of the
population lives in rural areas (Country Case study (GHWA, 2008). Major challenges include: an
overly- centralized health system, weak governance structure and regulatory framework, weak
management and institutional capacity in the Ministry of Health and Family Welfare (MoHFW),
fragmented public service delivery, inefficient allocation of public resources, lack of regulation
of the private sector – which employs 58% of all physicians, shortage of HRH, high turnover and
absenteeism of health workers, and poor maintenance of health facilities and medical equipment.

Despite these challenges and the fact that HRH was not considered a priority in the current sector
program, there have been recent successes including: increase in the number of graduates and
health worker training facilities, and an increased number of rural health facilities. The MoHFW
prepared its new sector program - the Health, Population and Nutrition Sector Development
Program (HPNSDP) and is revising its draft National Health Policy, based on lessons learned
from previous programs. Goals include: developing an HRH plan, creating a functional HRH
Information System (HRIS), scaling up the production of critical health workers, introducing
incentive packages to deploy and retain critical health workers in remote and rural areas,
addressing the challenge of skilled birth attendance by training community-based SBAs and/or
nurse-midwives and family welfare visitors, and streamlining the recruitment and promotion of
nurses (PID, World Bank, 2011).
The first stakeholder dialogue on Human Resource for Health (HRH) in Bangladesh took place
on 28th March 2012. The dialogue was mainly to start advocacy on the need of adequate and
skilled health workforce for well functioning health system and advocate for the Country
Coordination and Facilitation (CCF) process as initiated by the Alliance.
54

A comprehensive HRH strategy is currently being developed by the Human Resource


Development Unit of the Ministry of Health & Family Welfare, Bangladesh Secretariat
(MOHFW).

The past Bangladesh Workforce Strategy (2008) focused on integrating the system of managing
and accreditation of HR across the public, private and NGO sectors. Included measures were:
● development of an HR master plan
● improved incentives to work in rural and remote areas
● increased community-focused aspects into training programs, and
● improved quality of health workforce education and planning, including improving the
capacity of teaching and training institutions with a shift from a more knowledge-based
to skills-based approach.
Other focuses were stewardship/regulation of health HR, recruitment and career development
and retention, performance management processes, leadership and coordination of HR functions,
public-private partnerships, effective financing and an Integrated Human Resource Management
Information System.
The Ministry of Health and Family Welfare is currently in the midst of a dialogue process with
the different stakeholders for finalizing the draft document of National Health Policy Health and
Family Welfare.There are currently 16 principals and 38 working strategies in the policy
including formulation of National Health Development Council to strengthen inter-ministerial
health related tasks and provide guidelines in implementing the policy.The specific goals of the
policy are ensuring primary and emergency health services for all, expanding equity based
quality health services and encouraging people to seek healthcare.
Our project will be very helpful since the scarcity of proper healthcare is evidently very high.
Since our goal is to provide healthcare for everyone from any place of the country this will be
very helpful for the elderly and other people who are physically unable to reach the healthcare
services. Since a lot of people among the population is either children or senior citizen it will be
especially very helpful for them to get the healthcare services from their home. From a published
paper about the rural healthcare situation in Bangladesh these findings has been come up[18]:
55

1. In rural health complex, they provide both curative and privative treatment.
2. They have few numbers of ambulances to pass on the Emergency patient.
3. They do not get sufficient medicine to provide the patient.
4. There is an extreme lack of Doctor, nurse, Medicine, Medical assistance, Family planning
worker in this system but in some cases there is enough but it is too rare.
5. In rural health complex, majority of the patient is women & children.
6. From our survey we came to know that some of the health complex is run by govt. and some
are run by both private organizations and NGO.
7. They find their necessary budget from both govt. and private sector.
8. Civil surgeon is responsible for the daily management regarding work schedule.
9. Director of General and ministry of health and upazila health officer take decision regarding
health activities.
10. The rural health care activities are not influenced by the local governments but in some cases
it also happened.
11. Medicine, check up, Consultation and food are free for the patient.
12. Medical and other fees are very reasonable for rural patients.
13. Respective authority is unconcerned about the patient satisfaction and they do not keep any
statistics about it.
14. We also saw that ‘illiteracy is the main barriers towards the improvement of health
system’15. Though health is one of the important needs of human being our country is not able
to make this facility available for our rural people.
16. Financial and technical support is also important for ensuring a high quality of health care
but the government’s allocation does not match the demand.
17. Most of the doctors’ say is that the public salary is not enough and that they are therefore
forced to go to the private sector.

So it is clear that our service will be very helpful for the people of Bangladesh.
56

5.4 Existing Solutions vs Our Solution


The Health care system in Bangladesh falls under the control of the Ministry of Health and
Family Planning. The government is responsible for building health facilities in urban and rural
areas. Health is a basic requirement to improve the quality of life. National economic and social
development depends on the status of a country’s health facilities. A health care system reflects
the socio economic and technological development of a country and is a measure of the
responsibilities a community or government assumes for its people’s health care. The
effectiveness of a health system depends on the availability and accessibility of services in a
form, which the people are able to understand, accept and utilize. In Bangladesh, the majority of
the country’s population lives in rural areas, while the majority of health professionals work in
urban centers. In addition, the rapid growth of the private medical system meant that fewer
professionals remained in the public sector to take care of the masses. Private systems are mostly
out of reach for poor people who can barely afford to live day by day. The Government of
Bangladesh is constitutionally committed to “the supply of basic medical requirements to all
levels of the people in the society” and the “improvement of nutrition status of the people and
public health status” (Bangladesh Constitution, Article- 18). The health service functions were
initially restricted to curative services. With the development of modern science and technology,
health services emphasize primitive and preventive rather than curative health care. Yet, a large
number of people of Bangladesh, particularly in rural areas, remain with no or little access to
health care facilities. It would be critical for making progress in Bangladesh’s health services to
improve the people’s participation in the health sector. The Government therefore seeks to create
conditions whereby the people of Bangladesh have the opportunity to reach and maintain the
highest attainable level of health. Bangladesh has a good infrastructure for delivering primary
health care, but the full potential of this infrastructure has due to lack of adequate logistics never
been utilized.
There are many services available in the market which are similar to our service. This fact has
been mentioned above. But we think our service is unique because we do not have any
restrictions for using our service. For other available services they have many kinds of
57

restrictions for example some services require to use the product of that company to be able to
use the service. We do not have any of these.
This project is an innovation in the sense that no other services in Bangladesh have these
facilities like this one. There are few services available in the country in this sector but they
either arrange a physical meeting via online appointments or just provide consultation from
non-specialist doctors. On the other hand, in this proposed project, users will be able to get
online medical treatment from specialist doctors via video call using the web or smartphone
application which is not currently an available service in the country. Thus, the project is
innovative.

5.5 Impact Factor


Telemedicine refers to the use of information and communication technology to provide and
support health care mainly for the purpose of providing consultation. It is also a way to provide
medical procedures or examinations to remote locations. It has the potential to improve both the
quality and the access to health care services delivery while lowering costs even in the scarcity of
resources. Understanding the potentiality of telemedicine, many developing countries are
implementing telemedicine to provide health care facility to remote areas where health care
facilities are deficient. Bangladesh is not an exception to this either. Bangladesh is one of the
most densely populated countries of the world. About 140 million people living within 144,000
sq. km of land (1045 person/km² ). There are only 663 Government hospitals in district
head-quarters and thana (sub-town) areas. Total number of beds available in both public and
private hospitals and clinics is 51,648.So the ratio of one hospital bed to citizen of Bangladesh is
around 1:2571. Table-1 gives an overview of existing health care facility of Bangladesh. From
this table it is easily visible the inadequate healthcare infrastructure of this highly populated
country. Around 80% of the total population of this country lives in rural areas. And rural health
centers are often ill-equipped for proper medical treatment. Moreover most of the doctors are
city based. After being selected as a cadre of Bangladesh Civil Service (BCS) usually get
employment in remote health centre of Bangladesh. Due to poor infrastructure of rural health
centre and poor infrastructure of villages most of them leave the rural areas within 1-2 years and
58

shift to city area. They feel that they become professionally isolated and outdated if stationed in
remote areas. As a result health staff in rural areas are usually young, have little work experience
and show high job rotation. In many cases rural Health Centers are headed by infirmary
technicians who are barely trained. In this situation rural people rarely get any specialist doctor’s
advice when they go to health centers in thana or Upazila level. To get better consultancy rural
people spend most of their money on travel to visit doctor in urban areas instead of meeting other
treatment expenses. Sometimes, it is not possible to transfer a patient to the suburbs or to the city
on time due to his/her critical health condition and poor communication facilities in those areas.
Under this circumstance to provide health care in rural area there are two options. One is,
building hospitals in rural areas and also improves the infrastructure so that doctors and other
staff feel convenient to stay that places. Another one, is to take any initiative so that it is easy to
access quality health care to rural areas. To implement first one needs huge investment and time.
So remaining is the second one. To implement the second one telemedicine is the best way to
provide better health care by using maximum utilization of limited resources.
With all that said it evident that our service will impact a great number of people of our country.
59

Chapter 6
Conclusion
60

6 Conclusion
Universal accessibility of modern healthcare is a problem in Bangladesh. Using modern
technologies we approached to solve this problem by making a web platform as well as an
application for smartphones so that interacting between doctor and patient gets easier. We have
successfully developed an application for both platforms though there are still a few
shortcomings. We are working to solve the issues. Even though the applications have been
developed for small user-base, in the future they can be scaled up for large user-base. This
system can help to ensure proper medicare in Bangladesh, especially in rural areas and as a
result, reduce the number of deaths due to the absence of treatment.

6.1 Future works


We will develop the project further. We have our shortcomings and some failings of the project.
We plan to work on those in future.

6.1.1 Our Shortcomings


Our product is not launched commercially. So we do not have use data to check whether there
are any bugs or something bad relating to the experiences of the users. Also the profiling system
for the doctor is currently limited we have to work on that. Also the payment system is very
basic, which would not work if launched in commercial basis. In the rural areas, not many people
have visa or mastercard. People from rural areas are one of our target users. If they fail to make
payment due to this issue, it would be difficult for us to have them as our customer. We need to
shift to the mobile banking applications such as Bkash, Nogod or rocket. Because these mobile
banking applications are available to the rural, suburban and urban parts of Bangladesh. If we
include them in the payment system along with the visa and mastercard, more people would be
eligible to use our system.
We have developed a web application and android application for this system. But there is no
IOS application. We have not developed any ios application for the system. So the people who
use iPhones would not be able to use our system. We consider it as our shortcoming.
61

6.1.2 Future Plans


In future we are planning to launch our service commercially. For that we are looking for
investors and interested parties. If we can launch our project in a broad market it will help a lot
of people and we hope that we can be in the service of the people of Bangladesh. For that, we
need to pitch our project to the right investors. We need to hire a lot of developers to run the
project after launching.
There are a lot of room for improvement. We need to improve both the patient and doctor’s
dashboard and make it more meaningful and effective. The payment section needs to be more
realistic as we need to include the mobile banking applications such as Bkash, Rocket and
Nogod.
In future we would like to add many other features and continue improving the video calling
feature for effortless service.
62

7 References
[1] WHO - Bangladesh (who.int/workforcealliance/countries/bgd/en)
[2] Country Case Study - Bangladesh Trains Health Workers to ReduceMaternal Mortality, World
Health Organization, 2008
[3] Foysal Ahmed, Health System of Bangladesh
[4] Islam, Anwar & Biswas, Tuhin. (2014). Health System in Bangladesh:Challenges and Opportunities.
American Journal of Health Research.
[5] Syed Masud Ahmed and Md Awlad Hossain, ”The health workforce crisis in Bangladesh:
shortage, inappropriate skill-mix and inequitable distribution”, Hum Resour Health, Vol. 9, Issue 3,
2011
[6] Ask Apollo (askapollo.com/online-doctors-consultation)
[7] Live Health Online (livehealthonline.com)
[8] Tonic Doctor - GrameenPhone (mytonic.com)
[9] PlexusD - Healthcare Network (plexusd.com)
[10] Yuan, Bingchuan, and John Herbert. ”Web-based real-time remote mon-itoring for pervasive
healthcare.” 2011 IEEE International Conferenceon Pervasive Computing and Communications
Workshops (PERCOMWorkshops). IEEE, 2011.
[11] Youm, Sekyoung, et al. ”Development of remote healthcare system for measuring and
promoting healthy lifestyle.” Expert Systems withApplications 38.3 (2011): 2828-2834.
[12] Al Mamun, Khondaker Abdullah, et al. ”Cloud based framework forParkinson’s disease
diagnosis and monitoring system for remote health-care applications.” Future Generation Computer
Systems 66 (2017): 36-47.
[13] Cronin, Edmond M., et al. ”Remote monitoring of cardiovascular devices: a time and
activity analysis.” Heart Rhythm 9.12 (2012): 1947-1951.
[14] Parvin, S. ”An Effective m-Health System for Antenatal and PostnatalCare in Rural Areas of
Bangladesh.” IOSR Journal of Computer Engi-neering 17.5 (2015): 15-19.
[15] Sultana, Najnin, and Md Ashraful Islam. ”Ubiquitous future M-Healthsystem including
wireless 3G technologies in Bangladesh.” Journal ofAdvances in Technology and Engineering
Research 1.1 (2015): 22-29.
[16] Mostafa, Raqibul, et al. ”Proposed framework for the deployment of telemedicine centers in
rural Bangladesh.” International Journal of E-Health and Medical Communications (IJEHMC) 2.1
(2011): 55-72.
[17] Hoque, Md & Mazmum, Fahami & Bao, Yukun. (2014). e-Health in Bangladesh: Current Status,
Challenges, and Future Direction. The International Technology Management Review.
[18] Bangladesh Bureau of Statistics (BBS)(2017) -
http://bbs.portal.gov.bd/sites/default/files/files/bbs.portal.gov.bd/page/a1d32f13_8553_44f1_92e6_8ff80a
4ff82e/Bangladesh%20%20Statistics-2017.pdf
63

[19] Ahmed Saiful -


https://www.academia.edu/8052357/A_Research_Article_on_Rural_Health_Care_System_Of_Banglades
h
[20] Nessa, Ahasanun, et al. "Applicability of telemedicine in Bangladesh: current status and future
prospects." 2008 Third International Conference on Convergence and Hybrid Information Technology.
Vol. 1. IEEE, 2008.
[21] Sustainable Development Network Program (SDNP) Bangladesh http://www.sdnbd.org/
[22] Istiak Al Mamoon, Shahriar Khan “ telemedicine e services at the Diabetic Association of
Bangladesh with technical Collaboration of Grameen Telecom”- 1st Annual Conf. on Prospect and
problem of mobile and Land Phones in Bangladesh.
[23] Telemedicine Reference Centre Ltd. http://www.trclcare.com
[24] Swidish South Asian Studies Network. http://www.sasnet.lu.se/2it.html
[25] Who-Aims Report on Mental Health System in Bangladesh
HThttp://www.who.int/mental_health/bangladesh_who_aims_re port.pdfTH.
[26] T TPal, A.; Mbarika, V.W.A.; Cobb-Payton,”Telemedicine diffusion in a developing Country:The
case of India (march 2004)” TInformation Technology in Biomedicine, IEEE Transactions, vol. 9,March
2005, pp.59-65.
[27] Yaijong Xue, Huigang Liang,“Analysis of Telemedicine Diffusion: The Case of China” Information
Technology in Biomedicine, IEEE Transactions, vol. 11, March 2007, pp.231-233.
64

8 Appendix

Codes Of The Web Application:


Main driver file of the React.js(App.js):

import​ React ​from​ ​'react'


import​ RegisterForm ​from​ ​'./components/RegisterForm'
import​ Login ​from​ ​'./components/Login'
import​ Home ​from​ ​'./components/Home'
import​ { Route } ​from​ ​'react-router-dom'
import​ Dashboard ​from​ ​'./components/DashboardComp'
import​ VideoRoom ​from​ ​'./components/VideoRoom'
import​ Profile ​from​ ​'./components/Profile/Profile'

function​ ​App​() {
​return​ (
<div className="App">
<Route path='/register' component={ RegisterForm } />
<Route exact path='/' component={Home} />
<Route path='/login' component={Login} />
<Route path="/dashboard/:did/:pid/:name" component={Dashboard}
/>
<Route path='/videoroom/:did/:pid/:name' component={VideoRoom}
/>
<Route path='/profile/:id' component={Profile} />
</div>
)
}

export default App


65

Doctor card file(DoctorCard.js):

import​ React, { useState, useEffect } ​from​ ​'react'


import​ Avatar ​from​ ​'./Avatar'
import​ axios ​from​ ​'axios'
import​ StarRatings ​from​ ​'react-star-ratings'
import​ ​'./DoctorCard.css'

import​ textIcon ​from​ ​'../../media/1.5x/[email protected]'


import​ videoIcon ​from​ ​'../../media/video.png'

export​ ​default​ ​function​ ​DoctorCard​(props) {


​const​ [doctors, setDoctors] = useState([ ])
​const​ [userdata, setUserdata] = useState({
​_id​: ​''​,
​name​: ​''​,
​email​: ​''
})
​const​ [rating, setRating] = useState(​0​)

useEffect(() => {
​//Load data
axios.get(​'/api/user/getdoctors'​)
.then( res=>res.data.map((doc)=>{
setDoctors( (doctors)=> ([...doctors, doc]) )

​return​ ​0
}) )
.catch( err => ​console​.log(err) )

axios.post(​'/api/user/getinfo'​, {
​token​: sessionStorage.getItem(​'authtoken'​)
})
.then(res=> {
setUserdata({ ​_id​: res.data._id, ​name​: res.data.name,
email​: res.data.email })
})
.catch(err => ​console​.log(err))
}, [])
66

​function​ ​contactDoc​(docId) {
​let​ patientId = userdata._id

props.props.history.push(​`/dashboard/​${docId}​/​${patientId}​/​${userdata
.name}​`​)
}

​function​ ​handleSeeProfile​(id) {
props.props.history.push(​`/profile/​${id}​`​)
}

​function​ ​changeRating​( newRating, id ) {

axios.put(​`/api/user/rate/​${id}​`​,{​rating​:newRating})
.then(res=> ​console​.log(​'ok'​))
.catch(err=> ​console​.log(err))
setRating(newRating)
​window​.location.reload()
}

​const​ handleClick = (docId) => {


​let​ patientId = userdata._id

props.props.history.push(​`/videoroom/​${docId}​/​${patientId}​/​${userdata
.name}​`​)
}

​return​ (
<div className='cards-wr'>

{doctors.map( (data, i) => {


return <div key={i} className='doc-card' >

<div style={{
width: '100%',
height: '250px',
background: '#ddd'
67

}}><Avatar path={data.profilePic} /></div>

<p><span>Name: </span> { data.name }</p>


<p className="departament"><span>Departament:
</span> { data.departament }</p>
<p className="degree"><span>Degree: </span> {
data.degree }</p>
<div className="contact-doc">
<button className="more-info" onClick={ e=>
handleSeeProfile(data._id) }>Profile</button>
<button className='text-doc' onClick={ e =>
contactDoc(data._id)}> <img src={textIcon} alt=""/> </button>
<button className="videocall-doc" onClick={
e=> handleClick(data._id) }> <img src={videoIcon} alt=""/> </button>
</div>
<div className='rating'>{
(data.rating/data.raters ).toFixed(2) }</div>
<StarRatings
className = 'stars'
rating={rating}
starRatedColor="light-grey"
changeRating={changeRating}
numberOfStars={5}
name={data._id}
starDimension="25px"
starSpacing="2px"
/>
</div>
})}
</div>
)
}

Lading page handler(Landing.js):

import​ React, { useEffect, useState } ​from​ ​'react'


​ rom​ ​'./landing.module.css'
import​ styles f
import​ { ReactComponent ​as​ SVG } ​from​ ​'./undraw_doctor.svg'
68

import​ axios ​from​ ​'axios'

export​ ​default​ ​function​ ​Landing​(props) {


​const​ [userdata, setUserdata] = useState({
​_id​: ​''​,
​name​: ​''​,
​email​: ​''
})

useEffect(() => {
axios.post(​'/api/user/getinfo'​, {
​token​: sessionStorage.getItem(​'authtoken'​)
})
.then(res=> {
setUserdata({ ​_id​: res.data._id, ​name​: res.data.name,
email​: res.data.email })
})
.catch(err => ​console​.log(err))
}, [])

​return​ (
<div className={styles.row}>
<div className={styles.is_7}>
<SVG className={styles.svg} />
</div>
<div className={styles.is_5}>
<div className={styles.tagLine}>
<h1 className='msgl'>We are providing remote<br
/>Health Care Services</h1>
</div>
</div>
<div className={styles.is_12}>
<div className={styles.mouse_icon} />
</div>
<div className={styles.block}>
<span>scroll</span>
</div>
69

<button className='find-doc-btn' > <a href='#dr'>Contact


Doctor</a> </button>
</div>
)
}
Input file(Input.js):

import​ React ​from​ ​'react'​;

import​ ​'./Input.css'​;

const​ Input = ({ setMessage, sendMessage, message }) => (


<​form​ ​className​=​"form"​>
<​input
​className​=​"input"
​type​=​"text"
​placeholder​=​"Type a message..."
​value​=​{message}
​onChange​=​{({​ ​target:​ { ​value​ } }) => setMessage(value)}
onKeyPress={event => event.key === 'Enter' ? sendMessage(event)
: null}
/>
<​button​ ​className​=​"sendButton"​ ​onClick​=​{e​ =>
sendMessage(e)}>Send</​button​>
</​form​>
)

export default Input;

Footer handler(Footer.js):
import​ React, { Component } ​from​ ​'react'​;
import​ styles ​from​ ​'./footer.module.css'​;
import​ { FaFacebookF } ​from​ ​'react-icons/fa'​;
import​ { FaFacebookMessenger } ​from​ ​'react-icons/fa'​;
import​ { FaTwitter } ​from​ ​'react-icons/fa'​;
import​ { FaWhatsapp } ​from​ ​'react-icons/fa'​;
class​ ​Footer​ ​extends​ ​Component​ {
handleSmoothScroll = () => {
70

​ ehavior​:
document​.querySelector(​'#TOP'​).scrollIntoView({ b
'smooth'​ });
console​.log(​'done'​);
}

render() {
return​ (
<​div​ ​className​=​{styles.Bottom}​>
{/* <​div​ ​className​=​{styles.firstFooterBox}​>
<​a​ ​href​=​"#TOP"​>About</​a​>
<​a​ ​href​=​"#TOP"​>Need Help?</​a​>
<​a​ ​href​=​"#TOP"​>Privacy</​a​>
</​div​> */}
<​div​ ​className​=​{styles.secondFooterBox}​>
<​div​>
<​p​>
RemoteHealthCare (c)2019
</​p​>
</​div​>
{/* <​ul​>
<​li​>
<​i​>
{''}
<​FaFacebookF​ />
</​i​>
<​a
onClick​=​{this.handleSmoothScroll}​ ​href​=​"#TOP"​>
Facebook
</​a​>
</​li​>
<​li​>
<​i​>
{''}
<​FaFacebookMessenger​ />
</​i​>
<​a
onClick​=​{this.handleSmoothScroll}​ ​href​=​"#TOP"​>
Messenger
71

</​a​>
</​li​>
<​li​>
<​i​>
{''}
<​FaTwitter​ />
</​i​>
<​a
onClick​=​{this.handleSmoothScroll}​ ​href​=​"#TOP"​>
Twitter
</​a​>
</​li​>
<​li​>
<​i​>
{''}
<​FaWhatsapp​ />
</​i​>
<​a
onClick​=​{this.handleSmoothScroll}​ ​href​=​"#TOP"​>
WhatsApp
</​a​>
</​li​>
</​ul​> */}
</​div​>
</​div​>
);
}
}

export​ ​default​ Footer;

Infobar Handler(InfoBar.js):
import​ React ​from​ ​'react'​;

import​ onlineIcon ​from​ ​'../../media/icons/onlineIcon.png'​;


​ rom​ ​'../../media/icons/closeIcon.png'​;
import​ closeIcon f

import​ ​'./InfoBar.css'​;
72

const​ InfoBar = ({ room }) => (


<div className="infoBar">
<div className="leftInnerContainer">
<img className="onlineIcon" src={onlineIcon} alt="online icon"
/>
<h3>{room}</h3>
</div>
<div className="rightInnerContainer">
<a href="/"><img src={closeIcon} alt="close icon" /></a>
</div>
</div>
);

export default InfoBar;

Message.js:
import​ React ​from​ ​'react'​;

import​ ​'./Message.css'

const​ Message = ({ message: { text, user }, name }) => {


​let​ isSentByCurrentUser = ​false​;

​const​ trimmedName = name.trim().toLowerCase();

​if​(user === trimmedName) {


isSentByCurrentUser = ​true​;
}

​return​ (
isSentByCurrentUser
? (
<​div​ ​className​=​"messageContainer justifyEnd"​>
<​p​ ​className​=​"sentText pr-10"​>{trimmedName}</​p​>
<​div​ ​className​=​"messageBox backgroundBlue"​>
<​p​ ​className​=​"messageText colorWhite"​>{ text }</​p​>
</​div​>
73

</​div​>
)
: (
<​div​ ​className​=​"messageContainer justifyStart"​>
<​div​ ​className​=​"messageBox backgroundLight"​>
<​p​ ​className​=​"messageText colorDark"​> { text }</​p​>
</​div​>
<​p​ ​className​=​"sentText pl-10 "​>{user}</​p​>
</​div​>
)
);
}

export​ ​default​ Message

Profile Handler(Profile.js):
import​ React,{ useState, useEffect } ​from​ ​'react'
import​ ​'./Profile.css'
import​ axios ​from​ ​'axios'
import​ Avatar ​from​ ​'../DoctorCard/Avatar'
import​ bg ​from​ ​'../../media/bg.svg'
import​ { Link } ​from​ ​'react-router-dom'

export​ ​default​ ​function​ ​Profile​(props) {


​const​ [user, setUser] = useState([])
​const​ [path, setPath] = useState(​' '​)
​const​ [name, setName] = useState(​''​)
​const​ [degree, setDegree] = useState(​''​)
​const​ [addDegree, setAddDegree] = useState(​''​)
​const​ [dep, setDep] = useState( )
​const​ [addDep, setAddDep] = useState(​''​)
​const​ [title, setTitle] = useState(​''​)
​const​ [text, setText] = useState(​''​)
​const​ [info, setInfo] = useState([])
​const​ [id, setId] = useState(​''​)
​const​ [type, setType] = useState(​''​)

​const​ [userdata, setUserdata] = useState({


74

​_id​: ​''​,
​name​: ​''​,
​email​: ​''
})

useEffect(() => {
axios.post(​'/api/user/getinfo'​, {
​token​: sessionStorage.getItem(​'authtoken'​)
})
.then(res=> {
setUserdata({ ​_id​: res.data._id, ​name​: res.data.name,
email​: res.data.email })
})
.catch(err => ​console​.log(err))
}, [])

useEffect(() => {
axios.get(​`/api/user/getdoctor/​${props.match.params.id}​`​)
.then( res => setUser([res.data[​0​]]) )
.catch(err=> ​console​.log(err))

axios.post(​'/api/user/getinfo'​, {
​token​: sessionStorage.getItem(​'authtoken'​)
})
.then(res=> {
setType(res.data.type)
})
.catch(err => ​console​.log(err))
}, [])

useEffect(() => {
​if​(user.length>​0​) {
​console​.log(user[​0​].profileInfo)
user[​0​].profileInfo.map(data=> setInfo(info=>[...info,
data]))
setPath(user[​0​].profilePic)
setName(user[​0​].name)
75

setId(user[​0​]._id)
setDegree(user[​0​].degree)
setDep(user[​0​].departament)
}
}, [user])

​function​ ​addDegreeHandler​(e) {
e.preventDefault()

​if​( type === ​'doctor'​) {

axios.put(​`/api/user/add-degree/​${props.match.params.id}​`​, {
​degree​: addDegree
})
.then( res => ​console​.log(​'ok...'​) )
.catch( err => ​console​.log(err) )

​window​.location.reload()
}

​function​ ​addDepHandler​(e) {
e.preventDefault()

​if​( type===​'doctor'​) {
axios.put(​`/api/user/add-dep/​${props.match.params.id}​`​, {
​departament​: addDep
})
.then( res => ​console​.log(​'ok...'​) )
.catch( err => ​console​.log(err) )

​window​.location.reload()
}
}

​function​ ​addInfo​(e) {
e.preventDefault()
76

​if​(type===​'doctor'​) {
axios.put(​`/api/user/add-info/​${props.match.params.id}​`​,
{
​info​: {title, text}
})
.then(res => ​console​.log(​'ok...'​))
.catch(err => ​console​.log(err))

​window​.location.reload()
}
}

​function​ ​toChat​(e) {
e.preventDefault()

​if​( type === ​'doctor'​ ) {


props.history.push(​`/dashboard/​${id}​/z/​${name}​`​)
}
}

​function​ ​handleLogout​(e) {
e.preventDefault()

sessionStorage.removeItem(​'authtoken'​)
props.history.push(​`/login`​)
}

​function​ ​home​() {
props.history.push(​`/`​)
}

​function​ ​reload​(e) {
​window​.location.reload()
}

​return​ (
77

<div className='profile-wr'>
<nav className='desktop-nav'>
<div className='logo' >Remote Health Care</div>
<div className='nav-btns'>
<li></li>
<li onClick={e=>home()}>Home</li>
<li></li>
</div>
<div className="user-bar">

<div className={ userdata.name ?


'display-none' : 'auth-bar' }> <Link className='login-btn'
to='/login' >Login</ Link> <Link to='/register' >Sign Up</Link>
</div>
<div className={ userdata.name ? 'username' :
'display-none'}>
{userdata.name}
<div className="logout" onClick={ e =>
handleLogout(e) }>Log out</div>
</div>
</div>

</nav>
<div className="profile-bg">
<img src={bg} alt="nu este"/>
</div>

<h1>Profile</h1>
<div className="profile-pic">
<Avatar path={path} className='pic' />
<div className={ type==='patient' ? 'display-none' :
' ' }>
<form className={path ? 'display-none' : ''}
action={`/api/profile/${id}`} method="post"
encType="multipart/form-data">
<input type="file" name="avatar"
className='tests' />
78

<button type='submit'>Send Picture</button>


</form>
</div>

</div>

<div className="general-info">
<p className='profile-name'> <span>Name </span>
{name}</p>
<div>
<p className={ degree ? 'degree' : 'display-none'
} > <span>Degree</span> {degree}</p>
<form className={ degree ? 'display-none' :
'degree' }>
<input type="text" onChange={ e =>
setAddDegree(e.target.value) } />
<button onClick={ e => addDegreeHandler(e)
}>Add Degree</button>
</form>
</div>
<div>
<p className={ dep ? 'dep' : 'display-none' }>
<span>Departament</span> {dep}</p>
<form className={ dep ? 'display-none' : 'dep'
}>
<input type="text" onChange={ e =>
setAddDep(e.target.value) } />
<button onClick={ e => addDepHandler(e) }
>Add Departament</button>
</form>
<button onClick={ e=> toChat(e) }>Chat</button>
</div>
</div>
<h1 className='br'>Profile Info</h1>{console.log(type)}
<div className= 'profile-info' >
<div className='infos'> {info.map((data, i) => <div
key={i}><div className='info-title'>{data.title.toUpperCase()} </div>
<div className='info-text'> {data.text} </div></div> )} </div>
79

<form className= {type==='doctor' ? '' :


'display-none' } >
<input type="text" className='profile-title'
placeholder='Title' onChange={ e => setTitle(e.target.value) } />
<input type="text" className='profile-text'
placeholder='Text' onChange={ e=> setText(e.target.value) } />
<button onClick={ e => addInfo(e) }>Add</button>
</form>
</div>
</div>
)
}

Registration form:
import​ React, { useState } ​from​ ​'react'
import​ ​'../css/RegisterForm.css'
import​ axios f​ rom​ ​'axios'

export​ ​default​ ​function​ ​RegisterForm​(props) {


​const​ [email, setEmail] = useState(​''​)
​const​ [name, setName] = useState(​''​)
​const​ [password, setPassword] = useState(​''​)
​const​ [practiceNumber, setPN] = useState(​''​)
​const​ [idCardNr, setICN] = useState(​''​)
​const​ [registrationType, setRT] = useState(​'patient'​)

​function​ ​clickOnType​(type) {
​if​(type === ​'doc'​) {
​document​.getElementById(​"only-docs"​).style.display =
'block'
setRT(​'doc'​)
​const​ pbtn = ​document​.getElementById(​'patient-type-btn'​)
pbtn.style.border = ​' none'
pbtn.style.color = ​'#000'
pbtn.style.background = ​'#fff'

​const​ btn = ​document​.getElementById(​'doc-type-btn'​)


80

btn.style.border = ​' 3px solid #fff'


btn.style.color = ​'#fff'
btn.style.background = ​'#4D9AFF'
}​else​ {
​document​.getElementById(​"only-docs"​).style.display =
'none'
setRT(​'patient'​)
​const​ pbtn = ​document​.getElementById(​'doc-type-btn'​)
pbtn.style.border = ​' none'
pbtn.style.color = ​'#000'
pbtn.style.background = ​'#fff'

​const​ btn = ​document​.getElementById(​'patient-type-btn'​)


btn.style.border = ​' 3px solid #fff'
btn.style.color = ​'#fff'
btn.style.background = ​'#4D9AFF'
}

​function​ ​submitHandler​(e, type) {


e.preventDefault(props)
​if​(type === ​'patient'​) {
axios.post(​'/api/user/register/patient'​, {
​name​: name,
​email​: email,
​password​: password
})
.then(() => props.history.push(​'/login'​) )
.catch(error => {
​console​.log(error)
})
}​else​ {
axios.post(​'/api/user/register/doctor'​, {
​name​: name,
​email​: email,
​password​: password,
​practiceNumber​: practiceNumber,
81

​idCardNr​: idCardNr
})
.then(() => props.history.push(​'/login'​) )
.catch(error => {
​console​.log(error)
})
}

​return​ (
<div className="register-bg">
<div className='wr'>
<div className="register-form">
<div className="type-btns">
<button className='patient-type-btn'
id='patient-type-btn' onClick={ e => clickOnType('patient') }
>Patient</button>
<div>Or</div>
<button className='doc-type-btn'
id='doc-type-btn' onClick={ e => clickOnType('doc') }
>Doctor</button>
</div>

<form onSubmit={ e => submitHandler(e,


registrationType, props) } >
<label>
Name:
<input type="text" value={name} name='name'
onChange = { e => setName(e.target.value) } />
</label>

<label>
Email:
<input type="email" value={email}
name='email' onChange = { e => setEmail(e.target.value) }/>
</label>
82

<label>
Password:
<input type="password" value={password}
name='password' onChange = { e => setPassword(e.target.value) }/>
</label>

<div id="only-docs">
<label >
Practice Number
<input type="text" value={practiceNumber}
name='practiceNumber' onChange = { e => setPN(e.target.value) }/>
</label>
<label>
National ID card number
<input type="text" value={idCardNr}
name='idCardNr' onChange = { e => setICN(e.target.value) } />
</label>
</div>

<button type='submit'>Submit</button>
</form>
</div>
</div>
</div>

)
}

Home.js:
import​ React, { useState, useEffect } ​from​ ​'react'
import​ ​'../css/Home.css'
import​ { Link } ​from​ ​'react-router-dom'
import​ axios ​from​ ​'axios'
import​ Landing ​from​ ​'../components/Landing/landing'
import​ Footer ​from​ ​'../components/Footer/Footer'
import​ ReviewsSection ​from​ ​'../components/ReviewsSection'
import​ DocCard ​from​ ​'../components/DoctorCard/DoctorCard'
83

export​ ​default​ ​function​ ​Home​(props) {


​const​ [userdata, setUserdata] = useState({
​_id​: ​''​,
​name​: ​''​,
​email​: ​''
})

useEffect(() => {
axios.post(​'/api/user/getinfo'​, {
​token​: sessionStorage.getItem(​'authtoken'​)
})
.then(res=> {
setUserdata({ ​_id​: res.data._id, ​name​: res.data.name,
email​: res.data.email })
})
.catch(err => ​console​.log(err))
}, [])

​function​ ​handleLogout​(e) {
e.preventDefault()

sessionStorage.removeItem(​'authtoken'​)
props.history.push(​`/login`​)
}

​return​ (

<div >
<div className='home-wr'>
<nav className='desktop-nav'>
<div className='logo' >Remote Health Care</div>
<div className='nav-btns'>
<li></li>
<li></li>
<li></li>
</div>
<div className="user-bar">
84

<div className={ userdata.name ?


'display-none' : 'auth-bar' }> <Link className='login-btn'
to='/login' >Login</ Link> <Link to='/register' >Sign Up</Link>
</div>
<div className={ userdata.name ? 'username' :
'display-none'}>
{userdata.name}
<div className="logout" onClick={ e =>
handleLogout(e) }>Log out</div>
</div>
</div>

</nav>
<div className="landing-board">
<Landing />
</div>

<div className="doctors-wr" id='dr'>


<h1 className='h1-doc'>Our Doctors:</h1>
<DocCard props={props}/>

</div>
<h1 className='h1-review'>Reviews Section</h1>
<ReviewsSection />

<Footer />
</div>
</div>
)
}

Login Form:
import​ React, { useState } ​from​ ​'react'
import​ { Link } ​from​ ​'react-router-dom'
import​ ​'../css/LoginForm.css'
import​ axios ​from​ ​'axios'
85

export​ ​default​ ​function​ ​Login​(props) {


​const​ [password, setPassword] = useState(​''​)
​const​ [email, setEmail] = useState(​''​)
​const​ [registrationType, setRT] = useState(​'patient'​)

​// useEffect(() => {


​// if(sessionStorage.getItem('authtoken')) {
​// props.history.push('/home')
​// console.log(props)
​// }
​// }, [])

​function​ ​clickOnType​(type) {
​if​(type === ​'doc'​) {
setRT(​'doc'​)
​const​ pbtn = ​document​.getElementById(​'patient-type-btn'​)
pbtn.style.border = ​' none'
pbtn.style.color = ​'#000'
pbtn.style.background = ​'#fff'

​const​ btn = ​document​.getElementById(​'doc-type-btn'​)


btn.style.border = ​' 3px solid #fff'
btn.style.color = ​'#fff'
btn.style.background = ​'#4D9AFF'
}​else​ {
setRT(​'patient'​)
​const​ pbtn = ​document​.getElementById(​'doc-type-btn'​)
pbtn.style.border = ​' none'
pbtn.style.color = ​'#000'
pbtn.style.background = ​'#fff'

​const​ btn = ​document​.getElementById(​'patient-type-btn'​)


btn.style.border = ​' 3px solid #fff'
btn.style.color = ​'#fff'
btn.style.background = ​'#4D9AFF'
}
}
86

​function​ ​handleSubmit​(e, registrationType, props) {


e.preventDefault()
​if​(registrationType === ​'patient'​ ){
axios.post(​'/api/user/login/patient'​, {
​email​: email,
​password​: password
})
.then(res=> sessionStorage.setItem(​'authtoken'​,
res.headers.authtoken))
.then(() => props.history.push(​'/'​) )
.catch(err => ​console​.log(err))
}​else​{
axios.post(​'/api/user/login/doctor'​, {
​email​: email,
​password​: password
})
.then((res) => {
sessionStorage.setItem(​'authtoken'​,
res.headers.authtoken)
props.history.push(​`/profile/​${res.data._id}​`​)

})
.catch(err => ​console​.log(err))
}

​return​ (
<div className='login-bg'>
<div className='login-wr'>

<div className="type-btns">
<button className='patient-type-btn'
id='patient-type-btn' onClick={ e => clickOnType('patient') }
>Patient</button>
<div>Or</div>
87

<button className='doc-type-btn'
id='doc-type-btn' onClick={ e => clickOnType('doc') }
>Doctor</button>
</div>
<div className="login-form">
<form onSubmit={ e=> handleSubmit(e,
registrationType, props) }>
<label>
Email: <br />
<input type='email' name='email'
value={email} onChange={ e => setEmail( e.target.value) } /> <br />
</label>
<label>
Password: <br />
<input type="password" name='password'
value={password} onChange={ e => setPassword(e.target.value) } /> <br
/>
</label>
<div>
<button type='submit'>Log In</button>
<Link to='/register'>Register</Link>
</div>
</form>
</div>
</div>
</div>

)
}

Index file:
<!DOCTYPE html>
<​html​ ​lang​=​"en"​>
<​head​>
<​meta​ ​charset​=​"utf-8"​ />
<​meta​ ​name​=​"viewport"​ ​content​=​"width=device-width,
initial-scale=1"​ />
<​meta​ ​name​=​"theme-color"​ ​content​=​"#000000"​ />
88

<​meta​ ​name​=​"description"​ ​content​=​"Web site created using


create-react-app"
/>
<​link​ ​rel​=​"apple-touch-icon"​ ​href​=​"logo192.png"​ />
<​link​ ​rel​=​"manifest"​ ​href​=​"%PUBLIC_URL%/manifest.json"​ />
<​link
href​=​"https://fonts.googleapis.com/css?family=Great+Vibes&display=swa
p"​ ​rel​=​"stylesheet"​>
<​script​ ​src​=​"https://js.stripe.com/v3/"​></​script​>
<​title​>HealthCare</​title​>
</​head​>
<​body​>
<​noscript​>You need to enable JavaScript to run this
app.</​noscript​>
<​div​ ​id​=​"root"​></​div​>
<​script
src​=​"//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"​></​sc
ript​>

</​body​>
</​html​>

Main Driver File of the Node.js(Index.js):


const​ cookieParser = ​require​(​"cookie-parser"​)
const​ bodyParser =​require​(​'body-parser'​)
const​ path = ​require​(​'path'​)
const​ dotenv = ​require​(​'dotenv'​)
const​ cors = ​require​(​'cors'​)
const​ mongoose = ​require​(​'mongoose'​)
const​ express = ​require​(​'express'​)
const​ app = express()
const​ http = ​require​(​'http'​).createServer(app);
const​ io = ​require​(​'socket.io'​)(http)
const​ { Doctor } = ​require​(​'./models/user'​)
const​ { Room } = ​require​(​'./models/chat'​)
const​ multer = ​require​(​'multer'​)
89

const​ storage = multer. diskStorage({


​destination​: ​function​(req, file, cb) {
cb(​null​, ​'./uploads/'​)
},

​filename​: ​function​(req, file, cb) {


cb(​null​, file.originalname)
}
})

const​ fileFilter = (req, file, cb) => {


​if​( file.mimetype === ​'image/jpeg'​ || file.mimetype === ​'image/png'
) {
cb(​null​, ​true​)
} ​else​ {
cb(​null​, ​false​)
}
}

const​ upload = multer({ ​storage​: storage, ​fileFilter​: fileFilter})

//IMPORT ROUTES

​ equire​(​'./routes/auth'​)
const​ authRoute = r
const​ chatRoute = r​ equire​(​'./routes/chat'​)

dotenv.config()
app.use(express.json())
app.use((req, res, next) => {
res.header(​"Access-Control-Allow-Origin"​, ​"*"​);
res.header(​"Access-Control-Allow-Headers"​, ​"Content-Type"​);
res.header(​"Access-Control-Allow-Methods"​, ​"GET, POST"​);
next();
});
app.use(bodyParser.urlencoded({ ​extended​: ​false​ }))
app.use(​'/uploads/'​, express.static(​'uploads'​))
app.use(cookieParser())
app.use(cors())
90

//Route Middlewere

app.use(​'/api/user'​, authRoute)
app.use(​'/api/chat'​, chatRoute)

// DB CONNECTION

mongoose.connect(process.env.DB_CONNECT, { ​useNewUrlParser​: ​true​ },


console​.log(​'db connected...'​))

// UPLOAD PROFILE PICTURE

app.post(​'/api/profile/:id'​, upload.single(​'avatar'​), ​async​ ​function


(req, res, next) {

​ et​ doc = a
l ​ wait​ Doctor.findOneAndUpdate({​_id​: req.params.id}, {
profilePic​: req.file.path }, { ​new​:​true​ })

res.redirect(​`/profile/​${req.params.id}​`​)
})

// SOKET.IO
const​ { addUser, removeUser, getUser, getUsersInRoom } =
require​(​'./users'​)

io.on(​'connect'​, (socket) => {


socket.on(​'join'​, ({ name, room }, callback) => {
​const​ { error, user } = addUser({ ​id​: socket.id, name, room })

​if​(error) ​return​ callback(error)

socket.join(user.room)

io.to(user.room).emit(​'roomData'​, { ​room​: user.room, ​users​:


getUsersInRoom(user.room) })

callback()
91

})

socket.on(​'sendMessage'​, ​async​ (message, callback) => {


​const​ user = getUser(socket.id)

​const​ room = user.room


​const​ docId = room.slice(​0​, room.length/​2​)
​const​ patientId = room.slice(room.length/​2​, room.length)
​const​ msg = { ​user​: user.name, ​text​: message }

​ et​ newMsg = ​await​ Room.findOneAndUpdate({ ​docId​: docId,


l
patientId​: patientId },
{ ​$push​: { ​messages​: msg }},
{ ​new​: ​true​ }
)

io.to(user.room).emit(​'message'​, { ​user​: user.name, ​text​: message


})

callback()
})

socket.on(​'disconnect'​, () => {
​const​ user = removeUser(socket.id)

​if​(user) {
io.to(user.room).emit(​'message'​, { ​user​: ​'Admin'​, ​text​:
`​${user.name}​ has left.`​ })
io.to(user.room).emit(​'roomData'​, { ​room​: user.room, ​users​:
getUsersInRoom(user.room)})
}
})
})

// WEBRTC VIDEO STREAMING

let​ AccessToken = ​require​(​'twilio'​).jwt.AccessToken


let​ VideoGrant = AccessToken.VideoGrant
92

app.get(​'/api/token/:name'​, ​function​(request, response) {


​let​ identity = request.params.name

​ / Create an access token which we will sign and return to the


/
client, containing the grant we just created.

​let​ token = ​new​ AccessToken(


process.env.TWILIO_ACCOUNT_SID,
process.env.TWILIO_API_KEY,
process.env.TWILIO_API_SECRET
)

​// Assign the generated identity to the token.


token.identity = identity;

​// Grant the access token Twilio Video capabilities.


​let​ grant = ​new​ VideoGrant()
token.addGrant(grant)

​ / Serialize the token to a JWT string and include it in a JSON


/
response.
response.send({
​identity​: identity,
​token​: token.toJwt()
})
})

// STRIPE IMPLEMENTATION

const​ stripe =
require​(​"stripe"​)(​"sk_test_vIpqlRKSUEUbJNdpxBQcjcBI00VQHOf7TI"​)
const​ uuid = ​require​(​"uuid/v4"​)

app.post(​"/checkout"​, ​async​ (req, res) => {


​console​.log(​"Request:"​, req.body);

​let​ error;
93

​let​ status;
​try​ {
​const​ { token } = req.body;

​const​ customer = ​await​ stripe.customers.create({


​email​: token.email,
​source​: token.id
});

​const​ idempotency_key = uuid();


​const​ price = ​20
​const​ charge = ​await​ stripe.charges.create(
{
​amount​: price * ​100​,
​currency​: ​"usd"​,
​customer​: customer.id,
​receipt_email​: token.email,
​description​: ​`Purchased the service!`​,
​shipping​: {
​name​: token.card.name,
​address​: {
​line1​: token.card.address_line1,
​line2​: token.card.address_line2,
​city​: token.card.address_city,
​country​: token.card.address_country,
​postal_code​: token.card.address_zip
}
}
},
{
idempotency_key
}
);
​console​.log(​"Charge:"​, { charge });
status = ​"success"​;
} ​catch​ (error) {
​console​.error(​"Error:"​, error);
status = ​"failure"​;
94

res.json({ error, status });


});

if​ (process.env.NODE_ENV === ​"production"​) {


app.use(express.static(​'client/build'​))
app.get(​"*"​, (req, res) => {
res.sendFile(path.resolve(__dirname, ​'client'​, ​'build'​,
'index.html'​));
})
}

const​ PORT = process.env.PORT || ​3001


http.listen(PORT, ​function​(){
​console​.log(​'listening on *:3001'​);
})

Users.js:
const​ users = []

const​ addUser = ({ id, name, room }) => {


name = name.trim().toLowerCase()
room = room.trim().toLowerCase()

​ onst​ existingUser = users.find((user) => user.room === room &&


c
user.name === name)

​ f​(!name || !room) ​return​ { ​error​: ​'Username and room are


i
required.'​ }
​if​(existingUser) ​return​ { ​error​: ​'Username is taken.'​ }

​const​ user = { id, name, room }

users.push(user)
​return​ { user }
95

const​ removeUser = (id) => {


​const​ index = users.findIndex((user) => user.id === id);

​if​(index !== ​-1​) ​return​ users.splice(index, ​1​)[​0​];


}

const​ getUser = (id) => users.find((user) => user.id === id);

const​ getUsersInRoom = (room) => users.filter((user) => user.room ===


room);

module​.exports = { addUser, removeUser, getUser, getUsersInRoom };

Authentication Middleware:
const​ router = ​require​(​'express'​).Router()
const​ bcrypt = ​require​(​'bcryptjs'​)
const​ jwt = ​require​(​'jsonwebtoken'​)
const​ { User, Doctor, registerValidation, loginValidation,
docRegisterValidation } = ​require​(​'../models/user'​)

router.get(​'/getdoctor/:id'​, ​async​ (req, res)=> {


​const​ docId = req.params.id
​const​ doc = ​await​ Doctor.find({​_id​:docId})
res.send(doc)
})

router.get(​'/getdoctors'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.find()
res.send(doc)
})

router.get(​'/getusers'​, ​async​ (req, res)=> {


​const​ user = ​await​ User.find()
res.send(user)
})
96

router.post(​'/register/patient'​, ​async​ (req, res) => {


​const​ {error} = registerValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ check = ​await​ User.findOne({ ​email​: req.body.email })


​if​(check) ​return​ res.status(​400​).send(​'Email already
registrated'​)

​const​ salt = ​await​ bcrypt.genSalt(​10​)


​const​ hashedPass = ​await​ bcrypt.hash(req.body.password, salt)

​let​ user = ​new​ User({


​name​: req.body.name,
​email​: req.body.email,
​password​: hashedPass,
​type​: ​'patient'​,
​contactList​: []
})
user = ​await​ user.save()

res.send(user)
})

router.post(​'/register/doctor'​, ​async​ (req, res) => {


​const​ {error} = docRegisterValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ check = ​await​ Doctor.findOne({ ​email​: req.body.email })


​if​(check) ​return​ res.status(​400​).send(​'Email already
registrated'​)

​const​ salt = ​await​ bcrypt.genSalt(​10​)


​const​ hashedPass = ​await​ bcrypt.hash(req.body.password, salt)

​let​ doc = ​new​ Doctor({


​name​: req.body.name,
​email​: req.body.email,
​password​: hashedPass,
97

​practiceNumber​: req.body.practiceNumber,
​idCardNr​: req.body.idCardNr,
​type​: ​'doctor'​,
​approved​: ​false​,
​contactList​: [],
​profilePic​: ​''​,
​degree​: ​''​,
​departament​: ​''​,
​profileInfo​: [],
​raters​: ​0​,
​rating​: ​0
})
doc = ​await​ doc.save()

res.send(doc)
})

router.post(​'/login/patient'​, ​async​ (req, res) => {


​const​ {error} = loginValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ user = ​await​ User.findOne({ ​email​: req.body.email })


​if​(!user) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​ onst​ validPass = ​await​ bcrypt.compare(req.body.password,


c
user.password)
​if​(!validPass) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​ onst​ token = jwt.sign({​_id​: user._id, ​name​: user.name, ​email​:


c
user.email, ​type​: user.type, ​contactList​: user.contactList},
process.env.TOKEN_SECRET)
res.header(​'authToken'​, token).send(​'logged in'​)
})

router.post(​'/login/doctor'​, ​async​ (req, res)=> {


​const​ {error} = loginValidation(req.body)
98

​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ doc = ​await​ Doctor.findOne({ ​email​: req.body.email })


​if​(!doc) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​ onst​ validPass = ​await​ bcrypt.compare(req.body.password,


c
doc.password)
​if​(!validPass) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​if​(! doc.approved ) ​return​ res.status(​400​).send(​'Your account was


not approved yet!'​)

​ onst​ token = jwt.sign({​_id​: doc._id, ​name​: doc.name, ​email​:


c
doc.email, ​type​: doc.type,​contactList​: doc.contactList},
process.env.TOKEN_SECRET)
res.header(​'authToken'​, token).send(doc)

})

router.post(​'/getinfo'​, ​async​ (req, res)=> {


​const​ token = req.body.token
​const​ decoded = jwt.verify(token, process.env.TOKEN_SECRET)
res.send(decoded)
})

// UPDATE DOC INFO

router.put(​'/rate/:id'​, ​async​ (req, res)=> {


​let​ doc = ​await​ Doctor.findOne({​_id​: req.params.id})
​const​ raters = doc.raters+​1
​const​ rating = doc.rating + req.body.rating

doc = ​await​ Doctor.findOneAndUpdate({​_id​: req.params.id},{


rating​: rating, ​raters​: raters}, {​new​:​true​})

res.send(doc)
99

})

router.put(​'/add-degree/:id'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.findOneAndUpdate({ ​_id​: req.params.id },
{ ​degree​: req.body.degree }, { ​new​: ​true​ })

res.send(doc)
})

router.put(​'/add-dep/:id'​, ​async​ (req, res) => {


​const​ doc = ​await​ Doctor.findOneAndUpdate({ ​_id​: req.params.id },
{ ​departament​: req.body.departament }, { ​new​: ​true​ })

res.send(doc)
})

router.put(​'/add-info/:id'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.findByIdAndUpdate({ ​_id​: req.params.id
}, {​$push​: {​profileInfo​: req.body.info}}, {​new​: ​true​})

res.send(doc)
})

module​.exports = router

Chat Middleware(Chat.js):
const​ router = ​require​(​'express'​).Router()
const​ bcrypt = ​require​(​'bcryptjs'​)
const​ jwt = ​require​(​'jsonwebtoken'​)
const​ { User, Doctor, registerValidation, loginValidation,
docRegisterValidation } = ​require​(​'../models/user'​)

router.get(​'/getdoctor/:id'​, ​async​ (req, res)=> {


​const​ docId = req.params.id
​const​ doc = ​await​ Doctor.find({​_id​:docId})
res.send(doc)
})
100

router.get(​'/getdoctors'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.find()
res.send(doc)
})

router.get(​'/getusers'​, ​async​ (req, res)=> {


​const​ user = ​await​ User.find()
res.send(user)
})

router.post(​'/register/patient'​, ​async​ (req, res) => {


​const​ {error} = registerValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ check = ​await​ User.findOne({ ​email​: req.body.email })


​if​(check) ​return​ res.status(​400​).send(​'Email already
registrated'​)

​const​ salt = ​await​ bcrypt.genSalt(​10​)


​const​ hashedPass = ​await​ bcrypt.hash(req.body.password, salt)

​let​ user = ​new​ User({


​name​: req.body.name,
​email​: req.body.email,
​password​: hashedPass,
​type​: ​'patient'​,
​contactList​: []
})
user = ​await​ user.save()

res.send(user)
})

router.post(​'/register/doctor'​, ​async​ (req, res) => {


​const​ {error} = docRegisterValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ check = ​await​ Doctor.findOne({ ​email​: req.body.email })


101

​ f​(check) ​return​ res.status(​400​).send(​'Email already


i
registrated'​)

​const​ salt = ​await​ bcrypt.genSalt(​10​)


​const​ hashedPass = ​await​ bcrypt.hash(req.body.password, salt)

​let​ doc = ​new​ Doctor({


​name​: req.body.name,
​email​: req.body.email,
​password​: hashedPass,
​practiceNumber​: req.body.practiceNumber,
​idCardNr​: req.body.idCardNr,
​type​: ​'doctor'​,
​approved​: ​false​,
​contactList​: [],
​profilePic​: ​''​,
​degree​: ​''​,
​departament​: ​''​,
​profileInfo​: [],
​raters​: ​0​,
​rating​: ​0
})
doc = ​await​ doc.save()

res.send(doc)
})

router.post(​'/login/patient'​, ​async​ (req, res) => {


​const​ {error} = loginValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ user = ​await​ User.findOne({ ​email​: req.body.email })


​if​(!user) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​ onst​ validPass = ​await​ bcrypt.compare(req.body.password,


c
user.password)
​if​(!validPass) ​return​ res.status(​400​).send(​'Email or password is
102

incorrect'​)

​ onst​ token = jwt.sign({​_id​: user._id, ​name​: user.name, ​email​:


c
user.email, ​type​: user.type, ​contactList​: user.contactList},
process.env.TOKEN_SECRET)
res.header(​'authToken'​, token).send(​'logged in'​)
})

router.post(​'/login/doctor'​, ​async​ (req, res)=> {


​const​ {error} = loginValidation(req.body)
​if​ (error) ​return​ res.status(​400​).send(error.details[​0​].message)

​const​ doc = ​await​ Doctor.findOne({ ​email​: req.body.email })


​if​(!doc) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​ onst​ validPass = ​await​ bcrypt.compare(req.body.password,


c
doc.password)
​if​(!validPass) ​return​ res.status(​400​).send(​'Email or password is
incorrect'​)

​if​(! doc.approved ) ​return​ res.status(​400​).send(​'Your account was


not approved yet!'​)

​ onst​ token = jwt.sign({​_id​: doc._id, ​name​: doc.name, ​email​:


c
doc.email, ​type​: doc.type,​contactList​: doc.contactList},
process.env.TOKEN_SECRET)
res.header(​'authToken'​, token).send(doc)

})

router.post(​'/getinfo'​, ​async​ (req, res)=> {


​const​ token = req.body.token
​const​ decoded = jwt.verify(token, process.env.TOKEN_SECRET)
res.send(decoded)
})

// UPDATE DOC INFO


103

router.put(​'/rate/:id'​, ​async​ (req, res)=> {


​let​ doc = ​await​ Doctor.findOne({​_id​: req.params.id})
​const​ raters = doc.raters+​1
​const​ rating = doc.rating + req.body.rating

doc = ​await​ Doctor.findOneAndUpdate({​_id​: req.params.id},{


rating​: rating, ​raters​: raters}, {​new​:​true​})

res.send(doc)
})

router.put(​'/add-degree/:id'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.findOneAndUpdate({ ​_id​: req.params.id },
{ ​degree​: req.body.degree }, { ​new​: ​true​ })

res.send(doc)
})

router.put(​'/add-dep/:id'​, ​async​ (req, res) => {


​const​ doc = ​await​ Doctor.findOneAndUpdate({ ​_id​: req.params.id },
{ ​departament​: req.body.departament }, { ​new​: ​true​ })

res.send(doc)
})

router.put(​'/add-info/:id'​, ​async​ (req, res)=> {


​const​ doc = ​await​ Doctor.findByIdAndUpdate({ ​_id​: req.params.id
}, {​$push​: {​profileInfo​: req.body.info}}, {​new​: ​true​})

res.send(doc)
})

module​.exports = router

User Model(User.js):
const​ mongooose = ​require​(​'mongoose'​)
const​ Joi = ​require​(​'joi'​)
104

const​ userSchema = ​new​ mongooose.Schema({


​name​: {
​type​: ​String​,
​required​: ​true​,
},
​email​: {
​type​: ​String​,
​required​: ​true​,
},
​password​: {
​type​: ​String​,
​required​: ​true​,
},
​type​: {
​type​: ​String
},
​contactList​: {
​type​: ​Array
}
})

const​ docSchema = ​new​ mongooose.Schema({


​name​: {
​type​: ​String​,
​required​: ​true​,
},
​email​: {
​type​: ​String​,
​required​: ​true​,
},
​password​: {
​type​: ​String​,
​required​: ​true​,
},
​practiceNumber​: {
​type​: ​String​,
​required​: ​true​,
105

},
​idCardNr​: {
​type​: ​String​,
​required​: ​true​,
},
​type​: {
​type​: ​String
},
​approved​: {
​type​: ​Boolean
},
​contactList​: {
​type​: ​Array
},
​rating​: {
​type​: ​Number
},
​raters​: {
​type​: ​Number
},
​profilePic​: {
​type​: ​String
},
​degree​: {
​type​: ​String
},
​departament​: {
​type​: ​String
},
​profileInfo​: {
​type​: ​Array
}
})

const​ docRegisterValidation = user => {


​const​ schema = {
​name​: Joi.string().min(​6​).required(),
106

​email​: Joi.string().min(​6​).required().email(),
​password​: Joi.string().min(​8​).required(),
​idCardNr​: Joi.string().min(​6​).required(),
​practiceNumber​: Joi.string().min(​6​).required(),
}
​return​ Joi.validate(user, schema)
}

const​ registerValidation = user => {


​const​ schema = {
​name​: Joi.string().min(​6​).required(),
​email​: Joi.string().min(​6​).required().email(),
​password​: Joi.string().min(​8​).required()
}
​return​ Joi.validate(user, schema)
}

const​ loginValidation = user => {


​const​ schema = {
​email​: Joi.string().min(​6​).required().email(),
​password​: Joi.string().min(​8​).required()
}
​return​ Joi.validate(user, schema)
}

module​.exports.docRegisterValidation = docRegisterValidation
module​.exports.loginValidation = loginValidation
module​.exports.registerValidation = registerValidation
module​.exports.User = mongooose.model(​'User'​, userSchema)
module​.exports.Doctor = mongooose.model(​'Doctor'​, docSchema)

You might also like