Keywords

1 Introduction

A Chatbot is the software that basically interacts with the users using natural language, process it and yields the result as per the trained model. It is an artificial intelligence program which retrieves queries from the users, tries to understand the question, and provides optimal solution. It involves converting a simple English sentence into a machine understandable language, then going through the relevant data to find the necessary information and finally returning the answer in natural language sentence [1]. It provides answers to the queries like human does, instead of giving the list of websites that may contain the answer.

The proposed model is designed in such a way that it motivates the users to discuss their health conditions and symptoms and the bot extracts these symptoms provided by them to return a suitable diagnosis [2]. This conversational agent or Chatbot generates response based on given input to emulate human conversations. It uses an appropriate interface for input and output and makes the model user friendly. With the use of AI techniques, it can provide realistic answers accurately. This model uses Natural language processing (NLP) techniques to process user inputs and generates a suitable response. Also, an advantage of using this model is that it can help people book appointments online and a confirmation email will be sent to the user about the details of the appointment.

Medical Chatbots have a high impact on the health culture of the society. Nowadays, people do not have time to take care of their health and keep track on their health conditions due to the busy schedules. So this proposed system helps people to track down their health conditions and take care of them. Maintaining a healthy life style also has huge impact on economic condition of the country as it is important for people to maintain their health in order to have a stable work environment. Executing this proposed model helps in spreading awareness to people about how important is to maintain one’s health. Hence the objective of this model is to increase the service capability and decrease the operational cost of medical consultant service using online chatbots.

2 Literature Survey

This section gives a brief account of the works related to our Chatbot model. The referred papers provide us with knowledge regarding the chatbot, it’s working procedure and has been a great help to us. All these works justify our model to greater extent.

The proposed idea of the paper “A novel approach for medical assistant using trained chatbot” by Divya Madhu and team [3] is to build up a model using Artificial Intelligence which can predict the diseases based on the symptoms and give the list of available treatments. It believes that if a person’s body is analyzed periodically, it is possible to predict any possible problem even before they start to cause any damage to the body. In this model, artificial intelligence takes up the main role of providing the list of treatments based on the symptoms. This system helps people to have a basic idea of their health status and encourages them to take up proper treatments.

In the paper “A self-diagnosis medical chatbot” by Divya S and team [4] have built a medical chatbot which will classify the health condition into two classes’ namely major disease and minor disease based on the symptoms provided by the user. If it is a major disease, system suggests a specialist for the patient to visit and if it is a minor disease, it suggests an appropriate remedy.

In the paper by Saurav Kumar Mishra and team [5] proposed a model in which chatbot acted as a virtual doctor. It was possible for the patient to interact with the virtual doctor. Natural language processing and pattern matching algorithm are used for the development of this chatbot. Based on the survey, it is found that the number of correct answers given by the chatbot is 80%. From the survey of MAT journals 2018, analysis of result suggested that the software can be used for teaching and as a virtual doctor for awareness and primary care.

The proposed idea of the paper “Companion Chatbot using Deep Learning “by GongChen [6] was to design a framework which enables the user to nurture the chatbot on a daily basis. The model used three buttons in the chat window named as ‘Change’, ‘Like’, and ‘Ruminate’. This framework was specially designed for non-professional users. If the user wants to increase the standard of the output given by the bot, then he can click the ‘Like’ button to improve the learning standard. By clicking the ‘Ruminate’ button the bot learns by going through the whole conversation history. Hence this system was built in such a way that it could learn from the experience and improve its efficiency.

In the paper by Amiya Kumar Tripathy [7] it mentions the need of advanced technology which provides people with a proper health care management system. It emphasizes the need of the system to be accurate and portable so that people can rely on this system instead of doctor. The proposed system consists of a mobile heart rate measurement where it can record the heart rate and used on this record, a proper diagnosis was suggested on the click of a button.

3 Design and Methodology

The chatbot is a web application which is designed in such a way that it can be used by all type of users. The user chats with the chatbot similar to the way he converses with human. Basically, the design is divided into two processes namely input design and output design. The design of input focuses on controlling the amount of input required, controlling the errors, avoiding delay, avoiding extra steps and keeping the process simple. It mainly involves conversion of user-oriented description of the input into a computer-based system. Also we decide on what input must be given. In our project we have used conversational datasets as the input to the chatbot which are stored in YAML format. In output design, it is determined how the information is to be displayed for immediate need. Designing computer output should proceed in an organized, well thoughtout manner. The right output must be developed while ensuring that each output element is designed so that people will find the system easy to use and effective.

It is achieved by creating user-friendly screens for the data entry. For GUI it makes use of “html” and for backend “SQLyog”. We have made use of four important packages which are os, flask, session, chatterbot. OS module in python provides functions for interacting with the operating system. The application program is written in python language and within it makes use of the advanced framework “Flask”. Basically, flask is a flexible open source micro-web program written in python that supports for secure cookies. One major aspect of flask is, it is more python than Django and most importantly it is a light weight and modular designed framework. Session object is used to track the session data which is a dictionary object that contains key-value pairs of the session variables and their associated values. “Chatterbot” is a Python library that makes it easy to generate automated responses to user’s input. Using this module we have automated the conversation with users.

Fig. 1.
figure 1

Process flow diagram of Chatbot

Figure 1 shows the process flow diagram of the chatbot. The user can login to the application with the email-id and password after the successful registration. When the data is entered it will check for its validity. The interface is designed in such a way that it provides security and ease of use with retaining the privacy. After he logs into the system, he can start his conversation with the chatbot. Appropriate messages are provided as when needed so that the user will not be in maize of instant. For this to happen smoothly, the chatbot will be trained with some possible questions and answers predefine, that the user can ask. When the user sends messages, text processing will be done. Text processing is done using natural language processing (NLP). NLP makes human to communicate with the machine easily [8].

NLP tries to understand the natural language spoken by humans and classifies it, analyses it as well if required responds to it. The model also uses deep reinforcement learning for dialogue generation and for developing long conversation chatbot. The model makes use of Recurrent Neural Network (RRN) which is special Deep Neural Network architecture used predominantly in NLP problems. Remembering the past decisions is one of the characteristics of the Recurrent Neural Network and this characteristic influences the RNN to make decisions based on the learned decisions of the past. Hence RRN algorithm is used so that it analyses the past conversations of user, stores it in memory and gives a suitable response. The similarity in learning between training the various input vectors and also remembering the things learned from prior inputs to predict an appropriate output can be found in RNN, which is a part of a network. We can feed multiple input vectors to the RNNs to produce multiple output vectors. Weights applied to the inputs are not the only parameters that influence an RNN it does in a regular Neural Network, instead it also depends on the hidden state which is used to indicate the prior inputs or outputs. So, if in the series, the previous input change, then there are chances that a different output can be obtained for the same input as shown in Fig. 2.

Fig. 2.
figure 2

A representation of an RNN

4 Experiment and Results

The newly developed chatbot acts as virtual medical assistant for users. People who are sick make use of this system and check their health status. The model is developed to diagnose general health issues such as cough, fever, cold, headache, stomach ache etc. A person having cold fever shows symptoms like dryness, cough, headache, and fatigue and body pain. Those symptoms were analyzed based on the dataset and the chatbot correctly predicted the disease as fever for the given symptoms. It also suggests a suitable general prescription for the disease predicted. If the person does not feel good after the prescription, he can ask the chatbot to book an appointment with the specialist using the chatbot platform as shown in the below Fig. 3.

Fig. 3.
figure 3

A Chatbot window

The administrator plays a major role for confirming the appointments, maintaining the dataset, and chat history.

Fig. 4.
figure 4

Appointment Confirmation window

Figure 4 shows snapshot of appointment confirmation screen through which admin can confirm the appointment of a user by allotting him a doctor and specify the time for appointment. After booking an appointment, the details will be sent to the user provided email only after confirmation from the administrator and this is one of the privileged task of admin. Different algorithms require different dataset and training. So accuracy can vary in different algorithm. Continuous training of the model improves the accuracy of the proposed system. The input is expected to be given in proper English sentences. It cannot detect the short forms and slang words.

For the symptoms entered by the user, the correct disease was predicted and hence, it is reliable and can be used for keeping track of health status. A reliable system is the one needed in a hectic-scheduled life of people. With the proper results being displayed, people can have a hope in this new system [10].

5 Performance Analysis and Comparison

Chatbots are still at a relatively early stage of development but because of their versatility, it’s likely that we will continue to see an expanding role for them in the health care sector. Experts believe that advances in machine learning, computer vision, virtual faces, and natural language processing abilities will enhance chatbot capability to recognize and analyze human conversations, screen medical conditions, and appeal to humans even more. The designed chatbot model accepts the requests made by the user analyses them and provide beneficial information as a reply. The use of RNN algorithm increases the performance of the model as compared to ANN and CNN which is shown in Fig. 5. Our Chatbot developed using chatterbot module provides an accuracy of 88%, which depends on the data given as input to the bot, meaning chatbot can be made more accurate by improvising the dataset and training it accordingly. This accuracy is obtained using the Eq. 1. Given below.

$$accuracy=\frac{truePositive+trueNegative}{totalPredictions}$$
(1)

In the above equation, correct predictions (true predictions) are those that give desired reply that matches with the dataset, where as in correct predictions (false predictions) that did not. General testing against our own dataset yielded validation accuracies up to 88.3%. Since the model is self-learning it is easy to train it to identify various diseases. The distinguishable feature of our bot is it also provides an option to book appointments for the user so that he can consult a medical expert and get medications; this is not available in any of the existing medical chatbots.

Fig. 5.
figure 5

Accuracy obtained for ANN, CNN, RNN

6 Conclusion, Future Scope and Limitations

6.1 Conclusion

The usage of Chatbot is user friendly and can be used by any person who knows how to type the language. A medical chatbot provides personalized diagnoses based on symptoms. When we have bird view over the history of chatbots in medical applications, there is no option for users to book an appointment. But this chatbot has that advanced feature that makes the user’s work much simpler than before. It reduces the burden over users dramatically. Using this chatbot one can interact to know his/her health status, prescription, suggestion to maintain good health, books an appointment if the condition is critical as well. The implementation of Personalized Medical assistant heavily relies on AI algorithms as well as the training data. In future, this chatbot may become the most interesting and highly recommended application in medical field that will make the diagnosis much simpler as the future era is the era of the messaging application because people spend more time in messaging applications than any other applications. Chatbot has the capability to bring the revolution in medical field.

6.2 Future Scope

No application is perfect and will always require continuous updating with the advancement in technology. In the future, the bot’s symptom recognition and diagnosis performance could be greatly improved by adding support for more medical features, such as location, duration, and intensity of symptoms, and more detailed symptom description. Adding quality data will further improve performance and also, the model should be trained with hyper parameters and different dataset for future experimentation. This was an attempt to experiment with Deep Neural Network for dialogue generation in order to develop intelligent chatbot. The efficiency of the chatbot can be improved by adding more combination of words and increasing the use of database so that the medical chatbot could handle all types of diseases. The developed model is a web application and hence there is always a scope for developing this web application into a mobile application.

6.3 Limitations

Chatbot conversations between the patient and a bot has to be in a complete sentence and avoid short phrases and clauses. Initially while diagnosing, a patient is given regular general tabs irrespective of the side effects it has on the patient. Chatbot responds well to the queries posed by the user only when it is correctly scripted on a YAML file. Comorbidity cannot be easily diagnosed for chatting with the bot as the underlying cause of a disease is not easily determined. Internet connectivity is always a need which makes it difficult for the user to interact always.