Sunteți pe pagina 1din 78

2018

SMART AGENT FOR MEDICAL


DIAGNOSIS (DIA ME)
Team Members:

 Mohamed Ehab Mahmoud El-Assal.


 Ahmed El-Shafey Mohamed.
 Bishoy Maged Farouk.
 Hassan Sayed Hassan.
 Mohamed Mahmoud Ahmed Hassan.
 Liqaa Ahmed Mahmoud.

Project Supervisor: Dr. Safia Abbas


Associate Professor
Computer Science Department
Faculty of Computer and Information Sciences
Ain Shams University, Egypt

Future Academy - Higher Future Institute for Specialized Technological Studies


School of Computer Science

Project report submitted to the Future Academy


for the degree of Bachelor of Science
June 2018
Acknowledgment

First and foremost, we are grateful to Almighty Allah for His immense blessings
and graciously helping us to complete this project.

This project owes its existence to the help, support, and inspiration of many people.
In the first place, we owe my deepest gratitude to my main supervisor Prof. Dr. Safia
Abbas whose great knowledge, experience and sharp sense of research direction have
provided invaluable feedback to improve the quality of this project. This project would
not have been possible without her sound advice and encouragement. We would like to
express our sincere appreciation and gratitude to her tremendous amount of support,
guidance, insightful comments, and invaluable collaboration. It was our great pleasure
and honor to have such professor as our supervisor for her endless support and cooperation
during this project and research, in addition to her final revision of the documentation.

Last, but not least with all my appreciation and love that no words can express,
we would like to thank all our friends and family members for their endless love and
support. We offer my love and heartfelt thanks to our parents for their lifelong support in
all my endeavors. We dedicate this project to our dear parents who always provided us
with love, prayers, blessings, advice, and care. They are behind any success in our life.

i
Abstract

Nowadays computer technology has become a fact of life. Computer technology has
helped streamline management and serving whether a whole organization or even an
individual which made it a much-needed tool for every domain in life: Business,
Entertainment, Education, Industry, Medicine and many others. The importance of the
computer technology to the mentioned domains and specifically in the Medical or the
Biological areas enabled the inspiration of our project idea to become a real one. Introducing
a system is capable of giving a primary diagnosis for a patient who is unable for some reason
to see a doctor and needs to take a primary treatment if available or for somebody planning
to see a doctor and for saving time he will get prepared by being identified with maybe some
and not all of the tests required to be done. Moreover, the patient can measure his heart rate
pulses and blood pressure. Such type of systems presents new medical advantages for both
the doctor and the patient by letting the patient aware of any disease of interest. On the other
hand, the user can gather different type of information about any disease of interest
depending on the type of user i.e. if the user is an ordinary user the system offers basic type
of information while if the user is a researcher it introduces high level of information. Also,
the patient is capable of knowing the precautions and the tests required for certain disease
which directly may help in minimizing the rate of exposure to diseases and thus increasing
the population production in any country.

ii
Table of Contents
Acknowledgment…………………………………………………………………………….. i

Abstract……………………………………………………………………………………….. ii

Table of content……………………………………………………………………………....iv

List of abbreviations………………………………………………………………………… v

List of figures…………………………………………………………………………………. vi

List of tables…………………………………………………………………………………. viii

Chapter1 Introduction and Background ......................................................... 1


Introduction................................................................................................................. 2
Problem definition ........................................................................................................ 3
What is the importance of this problem? ........................................................................ 3
What are the current solutions? .................................................................................... 4
How will your solution solve the problem? What is new? ................................................. 6
Scope .......................................................................................................................... 7
Summary…………………………………………………………………………………………………………………………….10
SummaryChapter 2 Analysis and Design ...................................................... 11
Introduction............................................................................................................... 12
User and System Requirements.................................................................................... 12
Functional requirements ............................................................................................. 14
Non – functional requirements .................................................................................... 15
Stakeholders .............................................................................................................. 15
System Design ............................................................................................................ 16
Block Diagram ........................................................................................................... 16
Use Cases .................................................................................................................. 17
Class Diagram ............................................................................................................ 17
Design Patterns.......................................................................................................... 18
Sequence Diagrams .................................................................................................... 19
Database Design ........................................................................................................ 20
System Architecture ………………………………………………………………...22

Used Technologies and tools........................................................................................ 22


Summary ................................................................................................................... 23
iii
Chapter 3 Deliverables and Evaluation ......................................................... 24
Introduction............................................................................................................... 25
User Manual .............................................................................................................. 26
Testing ...................................................................................................................... 31
Evaluation (User experiment)....................................................................................... 38
Summary ................................................................................................................... 41
Chapter 4 Discussion and Conclusion ........................................................... 42
Introduction............................................................................................................... 43
Main Findings ............................................................................................................ 43
Why is this project important ...................................................................................... 45
Practical Implementations........................................................................................... 46
Limitations................................................................................................................. 66
Future Recommendation ............................................................................................. 66
Conclusion Summary .................................................................................................. 67
References .................................................................................................... 68

iv
List of abbreviations

DiaMe Diagnose Me

UML Unified modeling language

DB database

SDLC System development life cycle

SAMD Smart agent for medical diagnosis

UA User Agent

MA Master Agent

SDA Specialist Doctor Agent

GKB Global Knowledge Base

SKB Solution Knowledge Base

LKB Local Knowledge Base

ERD Entity Relationship Diagram

DBMS Database management systems

EHR Electronic Health Recording

BPM Beat Per Minute

v
Table of Figures
Figure 1: HER system ...........................................................................................................5

Figure 2: NueMD system ......................................................................................................5

Figure 3: Medical Diagnosis System ....................................................................................6

Figure 4: Gantt Chart (Bar Chart)………………………………………………….. ……...9

Figure 5: Block Diagram of proposed system (DiaMe) ......................................................16

Figure 6: Use case diagram of DiaMe system .....................................................................17

Figure 7: Class Diagram ......................................................................................................17

Figure 8: Design Pattern ......................................................................................................18

Figure 9: Sequence Diagram ...............................................................................................19

Figure 10: Database Design (ERD) .....................................................................................21

Figure 11: Database Design (Schema) ................................................................................21

Figure 12: System Architecture of DiaMe ..........................................................................22

Figure 13: Web Crawling Architecture ...............................................................................27

Figure 14: System Option ...................................................................................................29

Figure 15: Male or Female Models .....................................................................................30

Figure 16: Starting Window ................................................................................................31

Figure 17: Result less than 50% and no diseases found ......................................................32

Figure 18: Diseases greater than 50% .................................................................................32

Figure 19: Crawling with a determined percentage ............................................................33

Figure 20: Crawling without retrieving the result ...............................................................33

Figure 21: Result shows by the histogram ..........................................................................34

Figure 22: Search by Symptoms name ................................................................................34

Figure 23: Crawl result of identified Symptoms .................................................................35

Figure 24: Search by disease name .....................................................................................35

Figure 25: Crawl result including the description of disease ..............................................36


vi
Figure 26: Scientific paper with the date ............................................................................36

Figure 27: Scientific paper with relevance ..........................................................................37

Figure 28: Normal Heart Beat from Sensor ........................................................................38

Figure 29: Male or Female Models .....................................................................................38

Figure 30: Heart Pulse Sensors ...........................................................................................39

Figure 31: Normal Heart Rate .............................................................................................39

vii
List of tables

Table 1: Stages of the project on timeline .............................................................................8

Table 2: Cost summary of the project ...................................................................................8

Table 3: Disease classification ............................................................................................44

viii
Smart Agent for Medical Diagnosis (DiaMe)

Chapter 1
Introduction and Background

Main points

 This chapter presents the overview of the medical diagnosis system.

 The problem definition of medical diagnosis systems.

 Background (survey) of current systems was introduced.

 How will the proposed system solve the determined problem?

 New approaches to the new system (DiaMe).

1
Smart Agent for Medical Diagnosis (DiaMe)

Introduction

As it was mentioned above there are several domains interacting with the computer
science field and among these areas the medical area as it concerns the most valuable
resource in the whole world which is the human.

This concept invented the cooperation and the integration between the two
mentioned domains assisting the doctors, the researchers and the patients. it is aiding the
doctors to diagnose and analyze the disease early and prescribe treatment or medicine for
their patients which may help in saving time. also, it is aiding the people to gain more
information and knowledge about many diseases which were not defined simply previously
that is affect the results in decreasing the rate of exposure to diseases. Finally supporting the
researchers in many related fields from the point of view of the research, analysis, and
applications such as drug design, clinical research, cancer research, genetics research and
genome biology...Etc. This system will be designed to immediately diagnose by providing
tools to assist the patient, which would otherwise have to be performed manually. By This
Smart Agent for Medical Diagnosis, we will be able to quickly diagnose a person and give
reports about that person that is easy to understand and use.

Our project Smart Agent for Medical Diagnosis (DiaMe) is a representative of a


medical agent diagnosis system and consequently from its characteristics providing better
healthcare. DiaMe is a tool which mainly aims to apply a diagnostic, Information provider,
Analytical (processing) and Research Support workflows by integrating these pipelines in
only one project.

The Analytical workflow works by the measurement of the heart rate pulses and the
blood pressure. This option is available to the user (patient). If the user (patient) wants to
measure the blood pressure or heart rate, then the user (patient) will put the sensors in the
corrected place. The hearting draw will appear. There is a four point in normal heart function
(P, (Q, R, S), T). These mean that atrial depolarization, ventricular depolarization, and
repolarization respectively.

Finally, the Research support workflow assists the researcher by providing him with
the most recent publications related to certain disease which may help the researcher with
supplementary and valuable information.

2
Smart Agent for Medical Diagnosis (DiaMe)

Problem definition
1. According to some circumstances, an individual could feel pain and is not able to
see a doctor so there is an urgent need for taking temporary effective treatment or
performing some medical tests.
2. Again, due to the absence of the doctor some people may advise a patient feeling
certain symptoms with improper medicine leading to mistreatment and complicated
medical problems.
3. In the remote places there is a huge problem which is the rarity of the pharmacies or
the hospitals and suddenly a patient may need to measure the rate of the heart pulses
or the blood pressure.
4. A researcher doing research or writing some scientific paper about certain disease
possibly requires a complete overview of that disease and the publications related to
that disease of interest.
5. For an individual or even for an important organization in the country preparing for
an event or seminar about a disease which begun to propagate and the organization
is informing the people of the symptoms, required precautions and the causes of such
disease to avoid it.

What is the importance of this problem?

Treatment miss prescribing can cause serious problems on an individual and on a


national basis.

On an individual basis: medical misdiagnosis or receiving the mistaken or


damaging treatments can lead to health complications which may lead to death. So, the
system is crucial in such problem for making sure that the selected drug is suitable for the
current pathological case.

On a national basis: Receiving the mistaken treatment wastes precious medical


resources which may be beneficial or seriously required for another patient. One more thing,
misdiagnosis and the increase of the diseases propagation can result in the decrease of the
overall production in a certain area. Also, as soon as the medical problem or specifically the
disease is discovered, the patient can be treated more rapidly and the problem doesn’t
proceed.

3
Smart Agent for Medical Diagnosis (DiaMe)

What are the current solutions?

The system is assisting in medical diagnosis and classification of disease based on


symptoms and signs, it also prescribes treatment for patients having a medical condition, by
performing medical measurements of heart rate pulses and blood pressure using sensors.
The symptoms, causes, appropriate medication and laboratory investigation will be
represented by using the web crawling to get all the possible medication sites and retrieving
data from them.

We will predict what kind of disease the patients are suffering from based on the
analysis drugs that bought by each patient. The dataset that used is containing details such
as sex, age, the name of the drug for each patient. Applying different data mining techniques
such as k-nearest neighbor (KNN), naïve Bayes and decision tree comparing performance
for predicting diseases. We detected that the proposed model has higher accuracy rather than
KNN, decision tree, and naïve Bayes.

Diagnosis support system has the following function. Firstly, the human computer
interface for doctors and clients. Counselors and clients must be able to access the system
at remote locations through the internet. The system must also have data mining function to
extract the unknown relationship between test items for medical advancement. The
prototype system is evaluated through usability and impression. This system is better than
printed materials and not only for diagnosis prevention but also for improving continuous
lifestyle.

EHR System is an integrated electronic health recording (EHR) solution offering


collective benefits of EMR, practice management, and medical billing services. Figure 1
shows EHR system.

4
Smart Agent for Medical Diagnosis (DiaMe)

Figure 1: HER system.

NueMD is an integrated appointment scheduling, practice management/medical


billing, electronic health recording, and medical billing solution in figure 2.

Figure 2: NueMD system.

Multi-agent system based medical diagnosis system in which an agent called User
Agent (UA) is responsible for taking the user inputs i.e. symptoms from the patients with
the help of a user interface. The Master Agent (MA) has the responsibility to give the task
and to provide the proper knowledge from the Global Knowledgebase (G KB) to the
specialist doctor agents (SDA). For each SDA, there are individual local knowledge bases

5
Smart Agent for Medical Diagnosis (DiaMe)

(LKB) associated with them. After having the solution, SDA will give the solution to the
(MA) and that solution will be stored in the Solution knowledge base (S KB).

The Medical Diagnosis System takes input in the form of symptoms and gives output
in the form of a particular disease. The medical diagnosis system shows in Figure 3. The
importance of this system to help medical practitioners in the analysis of some extreme
diseases. It also gives easier ways decrease the doctor's burden. It offers many advantages
both to the medical practitioners and patients. Because of this, the system really is supposed
to be a trusted system. It is user friendly and most importantly can be utilized by users to
obtain self-notified without the assistant.

Figure 3: Medical Diagnosis System.

How will your solution solve the problem? What is new?

Our solution, a smart agent for medical diagnosis (DiaMe), aids users and novice
doctors with the diagnostic process using cloud-based services for medical record keeping,
provides integrated consulting services, symptom analysis, and electronic health
monitoring. Using heuristic information, the system monitors the progress of each patient
and provides a report analyzing the patient's condition making notes on where improvement
could be achieved.

The new system (DiaMe) differs from the previous systems via the presented
options. Firstly, the system enables the user (patient) to choose two options (measurement
or models). The measurement option enables the user (patient) to measure blood pressure
or heart rate. When the user select model, the user (patient) should select the part in which
he is suffering from and choose the symptoms that exist in the created database. The
system shows all possible diseases with percentage based on an apriori algorithm. If the
percentage less than 50%, no result appears. Otherwise, the result appears. Crawling begin

6
Smart Agent for Medical Diagnosis (DiaMe)

to work when the user determines maximum value as long as the percentage of crawl
should be greater than retrieved percentage form database.

Secondly, the system enables novice doctors to choose the option he needs. The
options presented in this systems are searching for disease name or symptoms name as
well. The doctor writes the disease name then crawl retrieves description with the disease
name, and also when the novice doctor writes symptoms, crawl retrieves all available
diseases related to the entered symptoms. When the novice doctor selects any disease, a
new form appears to contain a description of this disease.

Scope:

The scope has two parts. First, project scope is concerned with work-based,
implementation details and rework. It can change by any stakeholders. Second, product
scope is concerned with features, functionality, and requirements. It can be changed by the
customer. To define the scope, the following things should be identified:

 Objectives and Goals: there are many impacts on this system from various
perspectives (social, commercial, environment…. etc.).

▪ From social perspective: a healthy person tends to be a more productive,


happier member of society.
▪ From commercial perspective: rather than a drain on the country’s death
care system, a healthy person will spend their money on many products,
encouraging economic growth.
▪ From environment perspective: by reducing misdiagnosis, medical
resource use is reduced thus medical waste and the need to dispose of it, is
reduced.

7
Smart Agent for Medical Diagnosis (DiaMe)

 Tasks:

Table1: Stages of the project on the timeline


Task number Tasks name Duration Dependencies
T1 Gathering data 1 weeks ____
T2 Classify data 1 weeks T1
T3 Implementing web crawling 1 weeks T1
T4 Collecting hardware component 1 weeks ____
T5 Implementing Arduino (heart rate 2 weeks T4
and blood pressure) measurements
T6 Searching symptoms 2 weeks T1, T2, T3
T7 Testing 1 weeks T5, T6

 Budget: the total cost for the project is estimated as follows in table 2:

Table 2: Cost summary of the project

8
Smart Agent for Medical Diagnosis (DiaMe)

 Schedule:

Figure 4: Gantt Chart (Bar Chart)

Deliverables

▪ Is the most sufficient diagnosis of symptoms and diseases It's also choosing the most
appropriate disease for selected symptoms.

▪ DiaMe represents an approach to provide Smart Agent Diagnostic System by


enabling users to use sensors connected through Arduino kit to measure their heart
rate beats and show cases of HRB if it is Normal, Fast and Slow.

▪ DiaMe system enables the user (patient) to select the model (male, female) and
select the part suffer from.

▪ DiaMe is a good choice for novice doctors. It enables novice doctors to search with
disease name and the description of the disease will appear. So, the diagnosis is
easier for them.

▪ DiaMe also enhancing the Health awareness processes with patients by making an
interactive & interesting diseases phase.

9
Smart Agent for Medical Diagnosis (DiaMe)

Summary

 Medical diagnoses: is the process of determining which disease or condition


explains a person's symptoms.

 Current systems are presented with only one option “symptoms checker”.

 Proposed system (DiaMe) present three option rather than current systems.

 The first option, sensors that connected with Arduino kit to measure heart rate and
blood pressure. secondly, symptoms checker by the user through selected model and
part. Finally, for novice doctors to make search with disease name or symptoms
name as well. Also, crawl to retrieve description when the novice doctors search for
disease or symptoms.

10
Smart Agent for Medical Diagnosis (DiaMe)

Chapter 2
Analysis and Design

Main points

 System development life cycle (SDLC) phases such as (analysis and design)
were presented in this chapter

 In system analysis phase:

▪ User requirements
▪ System requirements
▪ Hardware and software requirements
▪ Functions and Non-functions

 In system design phase:

▪ Block diagram
▪ Use case diagram
▪ Class diagram
▪ Sequence diagram
▪ Database design (ERD, Shema)
▪ System Architecture

11
Smart Agent for Medical Diagnosis (DiaMe)

Introduction

The analysis and examination of a problem is a step towards the complete


understanding of that problem and creating a solution to it.

Understanding such importance, we dedicate this chapter to analyze each of the


components of (DiaMe) system in details and design diagrams using unified modeling
language (UML).

User and System Requirements


1. The user (patient) shall start the system.
1.1. The user (patient) shall open the software.

2. The user(patient) select the option that he wants to do.


2.1. The user (patient) shall start the system.
2.2. The system has many options such as search, check the symptoms and measurement.

3. The user (patient) shall enter the prevailing symptoms, then system show disease with
a percentage.
3.1. The user (patient) shall start the system.
3.2. The system has many options such as search, check the symptoms and measurement.
3.3. The user (patient) shall select the checker symptoms.
3.4. The user (patient) shall select the model as well as.
3.5. The user (patient) shall select the part of the model (liver), the symptoms will appear
from the database.
3.6. The user (patient) shall check the symptoms and click the result.
3.7. The result contains the disease with the percentage of this disease.
3.8. If the user (patient) clicks any disease, it also shows the description of that disease,
required tests if available, and classification.

4. When The user (patient) select measure, the user (patient) shall use blood pressure
and heart sensors to allow the system to read the measurements.
4.1. The user (patient) shall start the system
4.2. The system has many options such as search, check the symptoms and measurement.
4.3. The user (patient) shall select the measurements.
4.4. The user (patient) shall put the sensors.
4.5. The sensors shall start to measure heart and pulse rate and show diagram on the screen.

12
Smart Agent for Medical Diagnosis (DiaMe)

5. When The user (patient) making search after login.


5.1. The user (patient) shall start the system.
5.2. The system has many options such as search, check the symptoms and measurement.
5.3. The user (patient) select search option.
5.4. The user (patient) shall enter the symptoms and click search.
5.5. Web crawling work to retrieve the diseases related to entered symptoms.

Hardware and Software requirements:


Hardware requirements:
 CPU: core I7.
 RAM: 6 GHz
 Disk Space: 500 GHz
 Heart rate pulse and blood pressure sensors
 Arduino UNO kit.

Software requirements:
 Operating System: Microsoft Windows 10 or 8.
 Visual Studio 2017.
 SQL server 2016.
 Internet access.
 Arduino.

13
Smart Agent for Medical Diagnosis (DiaMe)

Functional requirements
Function Name: measure heart rate beats
Primary Actor Senor
Secondary Actor User
Flow of Event 1. The user (patient) shall be start the system.
2. The system has many options such as search, diagnose,
scientific papers and measurements.
3. The user (patient) select the measurements.
Pre-condition Users (patients) put the sensor in the correct place.
Post-condition Report with heart rate beats (Normal, Fast, Slow)
Alternative solution NONE

Function Name: search symptoms/ disease


Primary Actor User / doctor
Secondary Actor Web crawling
Flow of Event 1. The user (doctor) shall start.
2. The system has many options such as search, diagnose,
Scientific papers and measurements.
3. The user (doctor) shall enter the symptoms and click search.
4. Web crawling work to retrieve the diseases related to entered
symptoms.

Pre-condition 1. Doctor shall start the system and choose the search
feature. This feature includes search by symptoms name
and disease name.
2. Doctor should be select one of them.

Post-condition Data retrieved about searching symptoms.

Alternative solution NONE

14
Smart Agent for Medical Diagnosis (DiaMe)

Non – functional requirements

1. Security: the system will be more secure through.

▪ The user will save his data in private account by using username and
password that no one should know them.

▪ Every patient will get a unique code (barcode) encrypted well to avoid
anyone from guessing it or used only by permissions of the patient.

▪ Patient while registering must give permissions to 2 or more persons (close


friends or relatives) to access his account and control it by sending invitation
barcode.

2. Privacy: the system should provide high privacy through.

▪ Communication with the patient.

▪ The report was written to a patient.

▪ The details of the consultation for the patient including all test results will be
only accessed by the patient.

3. Availability:

▪ The system will be available 24 hours in 7 days a week.

4. Throughput:
▪ The System will be on a server with high-speed Internet capability.
▪ Better component design to get better performance.
▪ There will be flexible service for future extension.

Stakeholders

Stakeholder: is a person, group, organization or system who affects and can be


affected by an organizational action. There are many types of them such as external, internal
and interface. The following are the stakeholder in medical systems:

 Government.
 Medical professionals and other healthcare providers.
 Patients.
 Medical schools.
 Students of health care and Labor unions.

15
Smart Agent for Medical Diagnosis (DiaMe)

System Design

Why UML?

UML is a standard for specifying, visualizing, constructing and documenting the


aircraft of software systems, as well as for business modeling and other non-software
systems.

UML represents a collection of best engineering practices that have proven success
in the modeling of large and complex systems. The UML is a very important part in
developing object-oriented software and the software development process. It uses mostly
graphical notations to express the design of software projects. Using it helps project teams
communicate, explore potential design and validate the architectural design of the software.

Block Diagram

Block diagram: is a diagram of the system in which functions are represented by


blocks connected by lines. It is used in software design and hardware design. It is used for
high level, less detailed description to clarify concepts without considering the details of
implementation. Block diagram of the medical system (DiaMe) shows in figure 5.

Figure 5: Block Diagram of proposed System (DiaMe).

16
Smart Agent for Medical Diagnosis (DiaMe)

Use Cases

Use case diagram: it is the simplest representation of user interaction. It has many
components such as actors, boundary, functions, and relationship (include, extend). Figure
6 shows use case of DiaMe system.

Figure 6: Use Case Diagram of DiaMe.

Class Diagram

Class diagram: it is a static diagram. It is representing a static view of the application. It is


used for constructing code not for visualizing, describing and documenting different
systems. It is also known as a structural diagram. It describes attributes and operations of
class and also constraints. It shows a collection of classes, interfaces, associations,
collaborations, and constraints. Figure 7 shows the class diagram of DiaMe system.

17
Smart Agent for Medical Diagnosis (DiaMe)

Figure 7: Class Diagram of DiaMe.

Design Patterns

Design pattern: it is the best practices used by experienced developers. It is a solution


to general problems that faced developers during software development. There are many
types of design patterns such as:

 creational patterns: it is used while hiding creation logic rather than instantiating
objects.
 structural patterns: it is concerned with class and object composition.
 behavioral patterns: it is concerned with communication between objects.
 J2EE patterns: it is concerned with the presentation tier.

Figure 8 shows design pattern of DiaMe system.

18
Smart Agent for Medical Diagnosis (DiaMe)

Figure 8: Pattern design

Sequence Diagrams

Sequence diagram: describe interactions among classes to exchange messages over time. It
is a good way to visualize and validate runtime scenarios. It can help to predict how the
system will behave and discover responsibilities. Figure 9 shows the sequence diagram of
DiaMe System.

19
Smart Agent for Medical Diagnosis (DiaMe)

Figure 9: Sequence Diagram of DiaMe.

Database Design

Database: is a collection of information that is organized to easily be accessed,


managed and updated. Data is organized into rows, columns, and tables to make it easier to
find relevant information. Designing database to store retrieved data from crawling and find
relevant information depend on selected symptoms. DiaMe database contains six tables
named as (classification, disease, symptoms, tests, disease _symptoms, disease test). Entity
Relationship Diagram (ERD) shows in figure 10.

20
Smart Agent for Medical Diagnosis (DiaMe)

Figure 10: Database design (ERD).

Database Schema:

Figure 11: Database Schema.

21
Smart Agent for Medical Diagnosis (DiaMe)

System Architecture:

System architecture: is a conceptual model that defines the structure of the system.
It can comprise system component. The system architecture of DiaMe show in figure 12.

Figure 12: system architecture of DiaMe.

Used Technologies and tools

 Signal processing: when the hardware component of Arduino is used to measure


heart rate or blood pressure. The data gathered from the sensor is signal and should
be digitized to be understood with the computer.
 Data acquisition: gathering data from different resources and classifying it.
 Apriori algorithm: used to find the maximum percentage of disease by the frequent
number of symptoms.

22
Smart Agent for Medical Diagnosis (DiaMe)

Summary
 In this chapter, all system designs were discussed. In the first part, system analysis
was introduced including user and system requirement of DiaMe system. Also, it
contains Function and Non-function of DiaMe system.

 In the second part, system design was introduced including all system diagrams. The
diagrams are classified into structural and dynamic diagrams.

 Structural diagrams are use case diagram and class diagram, Entity relationship
diagram, schema and system architecture while Dynamic diagram is sequence
diagram.

 The use case that represents system functionality, the requirements of the system
from user's perspective.

 Class diagram is an essential step that helps the developers see and plan the structure
of the system before the code is written also help to ensure that the system is well
designed from the beginning.

 Entity relationship diagram (ERD): contains different symbols and connectors that
visualize two important information: The major entities within the system scope,
and the inter-relationships among these entities.

 Database schema: supported by the database management system (DBMS). The


term "schema" refers to the organization of data as a blueprint of how the database
is constructed (divided into database tables in the case of relational databases).

 System architecture: focuses on the internal interface between system component


and the interface between external component and environment.

 The sequence diagram is an interaction diagram. It represents one of the flow


through a use case.
23
Smart Agent for Medical Diagnosis (DiaMe)

Chapter 3
Deliverables and Evaluation

Main points

 This chapter will discuss the following:

▪ Introduction to crawling and Arduino.


▪ Arduino UNO Kit component.
▪ Why was web crawl used?
▪ Apriori algorithm.
▪ Testing using all components (Arduino, retrieving using crawl,
retrieving using apriori).

24
Smart Agent for Medical Diagnosis (DiaMe)

Introduction

Evaluations can also be an important tool you use to monitor your project. Although
final evaluations are often mandated by a funding agency or required by a sponsor, Mid-
term evaluations offer the advantage of answering many of the same questions posed
through final evaluations, while providing the opportunity to supply suggestions to improve
the project efficiency and impact while the activities are still being executed.

Common evaluation questions might include:

 Did the project succeed at accomplishing the outcomes, goals, and impact desired?
 Was the project relevant, effective and efficient?
 Does the project have the potential to be sustainable in its operations and impact?
 Is the theory expressed in the logical framework upheld?

A deliverable is something produced or provided as a result of a process. The input to


the process can be anything, such as:

 Information

 Documents

 Plan

 Equipment

 Money

 Software

While the output can include:

 Consultation

 Project Plan

 Tools

 Apps

 Software

 Test Results

 Contracts

25
Smart Agent for Medical Diagnosis (DiaMe)

There is a difference between project deliverables and product deliverables.

Project management deliverables include:

 Project Plan

 Reports

 Minutes

Whereas product deliverables might be things like:

 Hardware

 Software

 Apps

 Contracts

 Assessment Results

User Manual

The user’s manual consists of five sections: General information, system summary,
getting started, using the system, and reporting.

1. General Information

Crawling refers to dealing with large datasets while Web crawling is internet crawler
which systematically browses the World Wide Web for purpose of web indexing. Web
search engines and other sites use web crawling or spidering software to update web content
or indexes. Figure 13 is the architecture of web crawling shows as follow:

26
Smart Agent for Medical Diagnosis (DiaMe)

Figure 13: web crawling architecture.

Arduino is an open-source electronics platform based on easy-to-use hardware and


software. Arduino boards are able to read inputs and turn it into an output.

Why Arduino?

Arduino has been used in thousands of different projects and applications. The
Arduino software is easy-to-use for beginners and flexible enough for advanced users. It
runs on Mac, Windows, and Linux. Arduino is a key tool to learn new things. Anyone
(children, hobbyists, artists, programmers) can start tinkering just following the step by step
instructions of a kit. Arduino also simplifies the process of working with microcontrollers,
but it offers some advantage for teachers, students, and interested amateurs over other
systems:

 Inexpensive - Arduino boards are relatively inexpensive compared to other


microcontroller platforms.

 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX,


and Linux operating systems. Most microcontroller systems are limited to Windows.

27
Smart Agent for Medical Diagnosis (DiaMe)

 Open source and extensible software - The Arduino software is published as open
source tools, available for extension by experienced programmers.

2. System Summary:

DiaMe system is a medical system. It is used to diagnose the disease through


checking the symptoms from the database, search by the symptoms or disease name
and searching for scientific papers. The system has another extension of a hardware
component called Arduino kit using heart rate and blood pressure sensors.

2.1.System configuration:

DiaMe system operates on personal computers and also on cloud computing


with windows as an operating system. The application requires connection to the
internet in order to retrieve data from sites using web crawling, SQL server 2016 in
order to save data that retrieved from crawling, search for the check symptoms and
also need visual studio 2017 to start up the application. After installation on the
device, DiaMe system can be used immediately without any further configuration.

2.2.User level:

Everyone (novice doctor, patient) can use application.

3. Getting Started:
3.1.System menu:

DiaMe system consists of many functions such as searching that


include (search by disease name, symptoms name, and scientific papers) and
select any type of the models (male or female) and select any part of it to
show the symptoms. The system option is shown in figure 14. After checking
the symptoms, the result becomes from the database with the possible disease
and with the percentage of it. It also gives a description of the disease and
possible tests. The system shows the percentage greater than or equal to 50.
There is another option for crawling by entering the maximum value of
search. This value should be greater than the calculated percentage to retrieve
using crawling.

28
Smart Agent for Medical Diagnosis (DiaMe)

Another option of this system is measurements. If the patient or


novice doctors want to measure heart rate pulse or blood pressure. The sensor
starting work and showing the result on the screen.

Figure 14: System options.

3.2.Exist system:

DiaMe can be closed by selecting close in the application.

4. Using the System:

DiaMe system consists of a lot of functions. The main function is


searching. The searching process (function) is done by disease name,
symptoms name, and specific paper. There is another function for the patient.
It chooses one of the displayed models. The patient should select the part of
the model. The symptoms will be displayed. The patient should check the
symptoms that he is suffering from. By using apriori algorithm the
percentage of disease will be calculated. There are many restrictions. One of

29
Smart Agent for Medical Diagnosis (DiaMe)

them is when the percentage is less than 50%, no outcome results i.e. disease
does not appear. Another one is to make crawl when determining the
maximum value for the crawl. This value should be greater than the
calculated percentage. The crawl returns with the result. The result contains
selected symptoms, another symptom added after crawling and new diseases
as well.

Search by disease name or symptom name is done when the novice


doctor fills the search text with the targeted one. Crawling process is done.
The retrieved data is containing disease name, description of it, causes and
available test.

The measurement process is done by using Arduino UNO kit. Sensors of


heart rate and blood pressure were used.

5. Reporting:
5.1. Report capabilities:

There are two models (male, female). Figure 15 shows that. The
patient should select a specific part of the model. The symptoms of this part
will appear.

Figure 15: Male or Female Models.

30
Smart Agent for Medical Diagnosis (DiaMe)

5.2.Report procedures:

The searching process needs connection to the internet. This process


is available for novice doctors or for researchers for articles or scientific
papers for specific diseases, or searching for the disease name. The result
contains a description of the disease, possible treatments, and causes.

Testing

In this phase, we will provide an information about the software product and
services.

First: starting windows shows in figure 16:

Figure 16: Starting window

Second: Diagnosis

There are two models. The patient (the user) should select one of them. There are
many cases will be discussed.

Case 1: if the percentage of selected symptoms less than 50%, then no diseases
found. Figure 17 shows that:

31
Smart Agent for Medical Diagnosis (DiaMe)

Figure 17: result less than 50% and no diseases found.

Case 2: Figure 18 shows that if the percentage of selected symptoms greater than
or equal 50%, then diseases found and it determines the percentage of the crawl. Crawl
may return the result as in Figure 19 and may not retrieve result as in figure 20:

Figure 18: diseases greater than 50%.

32
Smart Agent for Medical Diagnosis (DiaMe)

Figure 19: crawling with a determined percentage.

Figure 20: crawling without retrieving the result.

33
Smart Agent for Medical Diagnosis (DiaMe)

Figure 21: Result shows by the histogram

Third: search (symptoms name, disease name):

Case 1: search by symptoms name

The novice doctors or researcher should select the search with the symptoms name,
and then enter the symptoms. Figure 22 shows that and the result in figure 23.

Figure 22: search by symptoms name

34
Smart Agent for Medical Diagnosis (DiaMe)

Figure 23: crawl result of identified symptoms.

Case 2: search by disease name

The novice doctors or researcher should select the search with the disease name,
and then enter the disease. Figure 24 shows that and the result in figure 25.

Figure 24: search by disease name

35
Smart Agent for Medical Diagnosis (DiaMe)

Figure 25: crawl result including a description of the disease.

Case 3: search for scientific paper

The scientific paper option is available for only novice doctor or researcher. In this
option, the novice doctor or researcher determines that result retrieved by date in figure 26
or relevance in figure 27.

Figure 26: scientific paper with the date

36
Smart Agent for Medical Diagnosis (DiaMe)

Figure 27: scientific paper with relevance

Fourth: measurement
This feature was used by the novice doctor. The patient should catch the sensor.
The sensor begins to start with sending data. Data should be signal and beat per minute
(BPM). In other words, the analog reads from the sensor(signal) followed by comma (,)
then the beats per minute (BPM) followed by newline. the app separates the two numbers
and plots them, then it decides the status of the signal if it is normal or not according to the
given BPM to 3 states as follows:
 <60: Slow Beats
 60-100: Normal
 >100: Fast Beats

Figure 28 shows everything when it is Normal.

37
Smart Agent for Medical Diagnosis (DiaMe)

Figure 28: Normal Heart Beat from Sensor

Evaluation (User experiment)

How the system meets the specific requirements?

DiaMe system will be evaluated and verified by making tests to some people
(patients) that suffer from any types of diseases and take their tests and medical record and
compare it with our system and see if it meets the appropriate result.

First: Measurement phase

It includes the heart pulse sensor to measure the heart rate. Figure 29 shows the
shape of heart pulse sensors. we will test it on sets of people that have normal heart rate
shows in figure 30, and also abnormal heart rate shows in figure 31.

Figure 29: Heart Pulse Sensors

38
Smart Agent for Medical Diagnosis (DiaMe)

Figure 30: Normal heart rate

Figure 31: Abnormal heart rate.

Second: Diagnose phase:

In this phase, there are many options such as diagnose by disease name,
symptoms name, and a scientific paper. Before evaluating these options. We will introduce
the algorithm that is applied.

 Apriori algorithm: It is used to match identical diseases based on the symptoms


related to each one and calculate the percentage.

39
Smart Agent for Medical Diagnosis (DiaMe)

1. Declare Dictionary<string,int> Result , diseases List<T>, Match Diseases


List<T>, int points=0, int max=0, double match Ratio ;
2. Select all diseases from the database into diseases List<T>
3. Select All symptoms Foreach disease in diseases List<T>
4. (foreach symptom in the SympsList) if the diseases List for a specific disease
contains this symptom points++;
5. When iteration ends for one disease, assign the disease name and the points
value into Result.
6. After finishing the last step for all diseases in diseases List calculates the max
value in Result.
7. Select keys corresponding to the max value from Result into Match Diseases
List<T>.
8. If Match Diseases list items Count = 1 and item >0 that’s mean there is a one
matched disease found for the selected symptoms and the match Ratio= item.
Points/SympsList.count *100 ;
9. If Match Diseases list items count >1 that’s mean there is more than a one
matched disease found for the selected symptoms and the match Ratio=
item.points/SympsList.count *100 ;
10. If Match Diseases list items count <1 that's mean there is no matched disease
found contains at least one symptom of the selected symptoms and the match
Ratio=Zero/SympsList.count *100 =Zero ;

Now we will discuss the options in details:

 Search by disease name:


This option is available for novice doctor or researcher not for patients
because of the novice doctor in known disease name, not patient.
 Search by symptoms name:
It is available for the novice doctor or researcher and also for the patient. In
this application, there are two ways for the patient. One of them by using diagnoses
using the male or female model to interact them. Another one using the search
option.
 Search for scientific papers:
This option is available only for novice doctor or researcher. The novice
doctor may want to know information about any disease so he accesses this option

40
Smart Agent for Medical Diagnosis (DiaMe)

to search for any scientific paper. Also, the novice doctor should determine the
search date if he wants recent researches. This option also is available.
 Diagnose:
This is available for patients (users). The patient should select the type of
model, then choose the part of the model (liver for example). The symptoms will
have displayed from the database. the patient should check the symptoms then the
result will have displayed after applying the algorithm and show possible diseases.
If the percentage is less than 50%, web crawling will work to retrieve the possible
diseases, new symptoms then storing it in the database. every disease retrieved will
have the description.

Summary

 There are two phases: Arduino phase and disease phase.


 Phases are divided into four options. These options are measurement, diagnose,
search and a scientific paper.
 There are phases are available to the novice doctors such as search (symptoms name
or disease name, measurements) and diagnosis is available for the end user (the
patient).
 Crawling is available when the percentage of retrieving diseases from the database
is less than the entered value (determine the value of crawling).
 If the percentage is less than 50%, no diseases found, otherwise the diseases will
show. When selecting each disease, description of it will appear.
 Search by the scientific paper is determined by date or relevance. the result includes
the title of paper, description, and citation.

41
Smart Agent for Medical Diagnosis (DiaMe)

Chapter 4
Discussion and Conclusion

Main points

 This chapter will include the following:

▪ Discussion of the proposed system compared with the existing


systems
▪ Implementation.
▪ Limitation in this system.
▪ Recommendation for future work.
▪ Conclusion.

42
Smart Agent for Medical Diagnosis (DiaMe)

Introduction

This chapter reflects on the main findings of the research in terms of its contributions
to the key issues of the medical diagnosis system (smart agent for medical diagnosis),
questions raised in the medical field and the methodology of agent-based modeling applied
to these issues.

Main Findings

 When starting to write the main findings, we should answer the following question.

1. What are the main features of smart agent for medical diagnosis system
(DiaMe) and how do they operate in practice?
2. What are the barriers and enablers to DiaMe?
3. What is the impact of DiaMe on doctor and patients?

 The project starts with gathering data about medical diagnosis system, medical
websites, diseases (liver) for example and its symptoms.
 After that classifying liver diseases. Classification of the diseases shows in table 3.

43
Smart Agent for Medical Diagnosis (DiaMe)

Table 3: Disease classification


Classification Disease
Viruses  Virus A
 Virus B
 Virus C
Parasites  Schistosomiasis
 Amoeba
 The Iskar
Acute liver failure
 Toxins
 nonalcoholic fatty liver disease (NAFLD)

Alcoholic liver disease  Alcoholic liver disease


Autoimmune-associated
 PBC (Primary biliary cirrhosis)
 PSC (Primary sclerosing cholangitis)
 Autoimmune hepatitis

Budd-Chiari syndrome
 Hypercoagulable disorders1.
 liver injury
 cancer
 parasitic infection

Cirrhosis
 chronic hepatitis
 alcoholism
 chronic bile duct obstruction

 The main features in this project are measurement, diagnosis, search and a
scientific paper. There are two features require internet while others not require.
Search, scientific paper, and diagnosis require internet because it depends on the
crawling from different sites. Measurement based on external hardware component
(pulse heart rate). The measurement option read pulse heart rate and drawing it to
show if the patient (user) is normal or abnormal heart rate. The search feature
includes two options, one for symptoms while other for the disease. The scientific
paper is available for the doctor to retrieve links to paper, definition, citation. It
also includes search with a specific date.
 In this project, there are some barriers and enablers. If the user (patient) selects
symptoms and the percentage of applying Apriori less than 50%, the system show
percentage only without related diseases of selected symptoms. If there is no
44
Smart Agent for Medical Diagnosis (DiaMe)

internet, the application not working because it depends on a search on the


websites. Cloud domain does not find for free, Microsoft Azure gives a limited
account with 200$ for a specific time.
 This project is most useful for patient and doctors. It saves time, money for the
patient. It also used in the far region to improve medical care. For a doctor, it helps
doctors to search for the new disease and read the scientific paper for it.

Why is this project important?

 DiaMe system allows the user (patient) to measure blood pressure and heart rate by
additional devices (Arduino, sensors) and discover if it is normal or he is suffering
from any problem.

 DiaMe system allows the user (patient) to do full services at home or anywhere
without going to the doctor. It provides some services which can help save time,
analyze and predict some medical issues. Among these services, it has the ability to
perform diagnosis for the patient based on the symptoms.

 DiaMe is a good choice for novice doctors because it is making the diagnoses Phase
easier by using two available options (search by disease name, symptoms name and
for scientific papers). if the user is a researcher it can provide a high level of
information about the disease of interest which includes the related published papers.

 DiaMe is enhancing the Health awareness processes with patients by making an


interactive & interesting diseases phase.
 Easy to deal with the application.
 DiaMe provides options such as crawling for scientific papers to help the novice
doctors. It also provides search for disease name and returns a description of it,
symptoms and available treatments or tests.
 DiaMe system monitors the progress of each patient and provides a report analyzing
the patient's condition making notes on where improvement could be achieved.

45
Smart Agent for Medical Diagnosis (DiaMe)

Practical Implementations:

It contains the implementation of the algorithm discussed, and also includes samples code
of feature in the project and Arduino code

The algorithm code shows below:


classSymptomChecker
{
publicstaticdouble Match_Disease(CheckedListBox.CheckedItemCollection selectedDiseases)
{
var db = new DiagnosisEntities();

int count = 0;
double diseaseRatio = 0;

var listItems = selectedDiseases;

Dictionary<int, int> result = new Dictionary<int, int>();

//select all diseases


var diseases = db.Diseases.ToList();

//for each disease check how many selected symptoms it has


foreach (var disease in diseases)
{
//foreach selected symptom
foreach (var item in listItems)
{
Symptom itemObject = db.Symptom.Where(a => a.symptom_name ==
item.ToString()).FirstOrDefault();
//if the disease contains this selected symptom
if (disease.Symptom.Contains(itemObject))
{
count++;
}

//add the disease with it's match points into dictionary


result.Add(disease.D_id, count);
count = 0;

//the max match points in the dictionary


var max = result.Values.Max();

diseaseRatio = ((double)max / selectedDiseases.Count) * 100;

//diseases which at least contains one selected symptom


//will be injected through instructor to Diseasesinfo

//dictionary<diseaseId,matchRatio>

46
Smart Agent for Medical Diagnosis (DiaMe)

Dictionary<int, double> validDiseases = new Dictionary<int, double>();


double dictDiseaseRatio;

foreach (KeyValuePair<int,int> disease in result)


{
//if only this disease has at least one match point with the selected symptoms

if (disease.Value>=1)
{
dictDiseaseRatio = ((double)disease.Value / selectedDiseases.Count) * 100;

//if this disease has at least a 50% percent match ratio of selected symptoms
//used in Disease info to get each disease matching by id
if (dictDiseaseRatio>=50)
{
validDiseases.Add(disease.Key, dictDiseaseRatio);

}
}

diseaseRatio = Math.Round(diseaseRatio,3);

if (max > 0)
{
//var diseaseIdList = result.Where(a => a.Value == max).Select(a => a.Key).ToList();

//this list contains diseases which only has at least 1 match point for the selected symps

//contains ids for diseases which has at least a 50% percent match ratio of selected symptoms
//used to initialize the listbox in localResult Form
var diseaseIdList = validDiseases.Select(a => a.Key).ToList();

//disease names corrosponding to the diseases ids


List<string> matchedDiseases = new List<string>();

string Names = "";

foreach (var id in diseaseIdList)


{
matchedDiseases.Add(db.Diseases.Where(a => a.D_id == id)
.Select(a => a.disease_name).FirstOrDefault());

foreach (string name in matchedDiseases)


{
Names += name + ',';

if (Names.Length > 2)
{
Names = Names.Remove(Names.Length - 1);

}
//MessageBox.Show($"The Disease is : {Names} with a match ratio of : {diseaseRatio}%");

47
Smart Agent for Medical Diagnosis (DiaMe)

LocalResult localResultForm = new LocalResult(selectedDiseases,


matchedDiseases,diseaseRatio,validDiseases
);
localResultForm.ShowDialog();

}
else
{
MessageBox.Show($"No Diseases found related to the selected symptoms with a match ratio of:
{diseaseRatio}%");

return diseaseRatio;

Scientific paper feature:

publicpartialclassScientific_Papers : Form
{
public Scientific_Papers()
{
InitializeComponent();
}

privatevoid Scientific_Papers_Load(object sender, EventArgs e)


{
DatePickerFrom.MaxDate = DateTime.Now;
DatePickerTo.MaxDate = DateTime.Now;

//linkLabel1.LinkArea = new LinkArea(0, 22);


//linkLabel1.Links.Add(23,24,link);
//linkLabel1.Text = link;

// linkLabel1.Links.Add(25, 26, link);


//linkLabel1.Links.Add(4, 5, link);

// int linkcount = linkLabel1.Links.Count;

privatevoid metroRadioButton1_CheckedChanged(object sender, EventArgs e)


{
DatePickerFrom.Enabled = true;
DatePickerTo.Enabled = true;

48
Smart Agent for Medical Diagnosis (DiaMe)

privatevoid metroRadioButton2_CheckedChanged(object sender, EventArgs e)


{
DatePickerFrom.Enabled = false;
DatePickerTo.Enabled = false;
}

privatevoid metroButton1_Click(object sender, EventArgs e)


{

if (txtbxSearch.Text != "")
{

bool complete = false;

this.webBrowser1.DocumentCompleted += delegate
{
if (complete)
return;

complete = true;

// DocumentCompleted is fired before window.onload and body.onload


this.webBrowser1.Document.Window.AttachEventHandler("onload", delegate
{
// Defer this to make sure all possible onload event handlers got fired
System.Threading.SynchronizationContext.Current.Post(delegate
{

GoogleScholarScraper GoogleScraper = new GoogleScholarScraper();

HashSet<ScientificPaper> SearchResult=
GoogleScraper.SearchForPaper(webBrowser1.Document);

dataGridView1.Style = MetroFramework.MetroColorStyle.Purple;
dataGridView1.ForeColor = Color.Black;

var dataSource = new BindingList<ScientificPaper>(SearchResult.ToList());

dataGridView1.DataSource = dataSource;

lblpapersCount.Text = SearchResult.Count.ToString();

// dataGridView1.Refresh();

}, null);
});
};

webBrowser1.ScriptErrorsSuppressed = true;

string queryStringParams = "";


queryStringParams = txtbxSearch.Text;

49
Smart Agent for Medical Diagnosis (DiaMe)

queryStringParams = Regex.Replace(queryStringParams, @"\s+", "+");

//queryStringParams = queryStringParams.Remove(queryStringParams.Length - 1);


// &as_ylo = 2014 & as_yhi = 2016

string url="";
if (rdbtnCustomDate.Checked)
{
int dateFrom, dateTo;

dateFrom = DatePickerFrom.Value.Year;
dateTo = DatePickerTo.Value.Year;

if (rdbtnSortByRelevance.Checked)
{

url =
$"https://scholar.google.com.eg/scholar?q={queryStringParams}&as_ylo={dateFrom}&as_yhi={dateTo}";

elseif (rdbtnSortByDate.Checked)
{

url =
$"https://scholar.google.com.eg/scholar?q={queryStringParams}&scisbd=1&as_ylo={dateFrom}&as_yhi={
dateTo}";

elseif(rdbtnNoFilters.Checked)
{
if (rdbtnSortByRelevance.Checked)
{

url = $"https://scholar.google.com.eg/scholar?q={queryStringParams}";

elseif (rdbtnSortByDate.Checked)
{

url = $"https://scholar.google.com.eg/scholar?q={queryStringParams}&scisbd=1";

}
}

webBrowser1.Navigate(url);

else
{
MessageBox.Show("Search Query Cannot Be Empty");

50
Smart Agent for Medical Diagnosis (DiaMe)

privatevoid btnClose_Click(object sender, EventArgs e)


{
this.Close();
}

privatevoid txtbxSearch_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Enter)
{
metroButton1_Click(this, new EventArgs());
}
}

Diagnose feature :
publicpartialclassfemale: MetroFramework.Forms. MetroForm
{
bool checklistFilled = false;

DiagnosisEntities db = new DiagnosisEntities();

HashSet<string> diseases;

HashSet<string> symptoms;

public female()
{
InitializeComponent();
}
privatevoid button3_Click(object sender, EventArgs e)
{
this.Close();
Form1 main = new Form1();
main.ShowDialog();
}

privatevoid button1_Click(object sender, EventArgs e)


{
label1.Visible = true;
label2.Visible = false;
checkedListBox1.Visible = false;
}

privatevoid button2_Click(object sender, EventArgs e)


{

if (checklistFilled==false)
{

51
Smart Agent for Medical Diagnosis (DiaMe)

//fill the checked listbox


foreach (var symptom in db.Symptom)
{

checkedListBox1.Items.Add(symptom.symptom_name);

//Get All Current Diseases and symptoms from db


//used to check existance of the new found disease from crawling process
diseases = new HashSet<string>(db.Diseases.Select(a => a.disease_name));
symptoms = new HashSet<string>(db.Symptom.Select(a => a.symptom_name));
label2.Visible = true;
label1.Visible = false;
checkedListBox1.Visible = true;

checklistFilled = true;
}

//private void button4_Click(object sender, EventArgs e)


//{

// SymptomChecker.Match_Disease(checkedListBox1.CheckedItems);

//}

privatevoid female_Load(object sender, EventArgs e)


{

privatevoid button5_Click(object sender, EventArgs e)


{
this.Hide();
Form1 main = new Form1();
main.ShowDialog();
this.Close();

privatevoid button6_Click(object sender, EventArgs e)


{
double LocalMatchRatio = SymptomChecker.Match_Disease(checkedListBox1.CheckedItems);

if (txtRatio.Text.Length > 0)
{

if (LocalMatchRatio <int.Parse(txtRatio.Text) || LocalMatchRatio == int.Parse(txtRatio.Text))


{

bool complete = false;

52
Smart Agent for Medical Diagnosis (DiaMe)

this.webBrowser1.DocumentCompleted += delegate
{
if (complete)
return;

complete = true;

// DocumentCompleted is fired before window.onload and body.onload


this.webBrowser1.Document.Window.AttachEventHandler("onload", delegate
{
// Defer this to make sure all possible onload event handlers got fired
System.Threading.SynchronizationContext.Current.Post(delegate
{
// try webBrowser1.Document.GetElementById("id") here

Crawler crawler = new Crawler();

crawler.Crawl(webBrowser1, checkedListBox1.CheckedItems, diseases,


symptoms);

}, null);
});
};

webBrowser1.ScriptErrorsSuppressed = true;

//webBrowser1.Visible = false;

if (checkedListBox1.CheckedItems.Count > 0)
{
string queryStringParams = "";

foreach (var item in checkedListBox1.CheckedItems)


{
queryStringParams += $"addterm={item.ToString()}&";

queryStringParams = Regex.Replace(queryStringParams, @"\s+", " ");


queryStringParams = queryStringParams.Remove(queryStringParams.Length - 1);

string url = $"http://healthtools.aarp.org/symptomsearch?{queryStringParams}";

webBrowser1.Navigate(url);

}
else
{
MessageBox.Show("Please Choose Sypmtoms !");
}

}
}

else
{

53
Smart Agent for Medical Diagnosis (DiaMe)

MessageBox.Show("Please Spicify Minimum Match Ratio For Crawling");


}

privatevoid webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs


e)
{

privatevoid female_FormClosing(object sender, FormClosingEventArgs e)


{

Search feature:
publicpartialclassSearch: MetroFramework.Forms. MetroForm
{
DiagnosisEntities db = new DiagnosisEntities();

HashSet<string> diseases;

HashSet<string> symptoms;
public Search()
{
InitializeComponent();
}

privatevoid searchbutton_Click(object sender, EventArgs e)


{
//Get All Current Diseases and symptoms from db
//used to check existance of the new found disease from crawling process
diseases = new HashSet<string>(db.Diseases.Select(a => a.disease_name));
symptoms = new HashSet<string>(db.Symptom.Select(a => a.symptom_name));

if (txtbxSearch.Text.Length > 0)
{

bool complete = false;

if (rdbtnDisease.Checked)
{
this.webBrowser1.DocumentCompleted += delegate

54
Smart Agent for Medical Diagnosis (DiaMe)

{
if (complete)
return;

complete = true;

// DocumentCompleted is fired before window.onload and body.onload


this.webBrowser1.Document.Window.AttachEventHandler("onload", delegate
{
// Defer this to make sure all possible onload event handlers got fired
System.Threading.SynchronizationContext.Current.Post(delegate
{
// try webBrowser1.Document.GetElementById("id") here

WikipediaScraper WikiScrapper = new WikipediaScraper();


WikiScrapper.ExtractDiseaseInfo(webBrowser1, txtbxSearch.Text);

}, null);
});
};
}

elseif (rdbtnSymptom.Checked)
{

this.webBrowser1.DocumentCompleted += delegate
{
if (complete)
return;

complete = true;

// DocumentCompleted is fired before window.onload and body.onload


this.webBrowser1.Document.Window.AttachEventHandler("onload", delegate
{
// Defer this to make sure all possible onload event handlers got fired
System.Threading.SynchronizationContext.Current.Post(delegate
{
// try webBrowser1.Document.GetElementById("id") here

CheckedListBox listbox = new CheckedListBox();


listbox.Items.Add(txtbxSearch.Text);
listbox.SetItemChecked(0, true);

CheckedListBox.CheckedItemCollection chkd = listbox.CheckedItems;

Crawler crawler = new Crawler();


crawler.Crawl(webBrowser1, listbox.CheckedItems, diseases, symptoms);

}, null);
});
};
}

55
Smart Agent for Medical Diagnosis (DiaMe)

webBrowser1.ScriptErrorsSuppressed = true;

//webBrowser1.Visible = false;

string queryStringParams = "";

if (rdbtnDisease.Checked)
{
queryStringParams = txtbxSearch.Text;

queryStringParams = Regex.Replace(queryStringParams, @"\s+", " ");

//queryStringParams = queryStringParams.Remove(queryStringParams.Length - 1);

string url = $"https://en.wikipedia.org/wiki/{queryStringParams}";

webBrowser1.Navigate(url);
}
else
{
queryStringParams = $"addterm={txtbxSearch.Text}";

queryStringParams = Regex.Replace(queryStringParams, @"\s+", " ");

//queryStringParams = queryStringParams.Remove(queryStringParams.Length - 1);

string url = $"http://healthtools.aarp.org/symptomsearch?{queryStringParams}";

webBrowser1.Navigate(url);
}

}
else
{
MessageBox.Show("Please Write A Sypmtom !");
}

privatevoid searchbutton_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Enter)
{
searchbutton_Click(this, new EventArgs());
}
}

privatevoid back_Click(object sender, EventArgs e)


{
this.Hide();
First f = new First();

56
Smart Agent for Medical Diagnosis (DiaMe)

f.ShowDialog();
}

privatevoid txtbxSearch_KeyDown(object sender, KeyEventArgs e)


{
if (e.KeyCode == Keys.Enter)
{
searchbutton_Click(this, new EventArgs());
}
}

Measurement feature: it has two parts, one for Arduino while other for C#
application.

Arduino code: Pulse sensor Arduino 1.5.0

/* Pulse Sensor Amped 1.5 by Joel Murphy and Yury Gitman http://www.pulsesensor.com

---------------------- Notes ---------------------- ----------------------

This code:

1) Blinks an LED to User's Live Heartbeat PIN 13

2) Fades an LED to User's Live Heartbeat PIN 5

3) Determines BPM

4) Prints All of the Above to Serial

Read Me:

https://github.com/WorldFamousElectronics/PulseSensor_Amped_Arduino/blob/master/README.
md

---------------------- ---------------------- ----------------------

*/

// Variables

int pulsePin = 0; // Pulse Sensor purple wire connected to analog pin 0

int blinkPin = 13; // pin to blink led at each beat

int fadePin = 5; // pin to do fancy classy fading blink at each beat

57
Smart Agent for Medical Diagnosis (DiaMe)

int fadeRate = 0; // used to fade LED on with PWM on fadePin

// Volatile Variables, used in the interrupt service routine!

volatile int BPM; // int that holds raw Analog in 0. updated every 2mS

volatile int Signal; // holds the incoming raw data

volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!

volatile boolean Pulse = false; // "True" when User's live heartbeat is detected. "False" when not
a "live beat".

volatile boolean QS = false; // becomes true when Arduoino finds a beat.

// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS

// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer

// https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer

// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter

// run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L

void setup(){

pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!

pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!

Serial.begin(115200); // we agree to talk fast!

interruptSetup(); // sets up to read Pulse Sensor signal every 2mS

// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD
VOLTAGE,

// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN

// analogReference(EXTERNAL);

// Where the Magic Happens

58
Smart Agent for Medical Diagnosis (DiaMe)

void loop(){

serialOutput() ;

if (QS == true){ // A Heartbeat Was Found

// BPM and IBI have been Determined

// Quantified Self "QS" true when arduino finds a heartbeat

fadeRate = 255; // Makes the LED Fade Effect Happen

// Set 'fadeRate' Variable to 255 to fade LED with pulse

serialOutput(); // A Beat Happened, Output that to serial.

QS = false; // reset the Quantified Self flag for next time

ledFadeToBeat(); // Makes the LED Fade Effect Happen

delay(20); // take a break

void ledFadeToBeat(){

fadeRate -= 15; // set LED fade value

fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative
numbers!

analogWrite(fadePin,fadeRate); // fade LED

Interrupt:

volatile int rate[10]; // array to hold last ten IBI values

volatile unsigned long sampleCounter = 0; // used to determine pulse timing

volatile unsigned long lastBeatTime = 0; // used to find IBI

59
Smart Agent for Medical Diagnosis (DiaMe)

volatile int P =512; // used to find peak in pulse wave, seeded

volatile int T = 512; // used to find trough in pulse wave, seeded

volatile int thresh = 530; // used to find instant moment of heart beat, seeded

volatile int amp = 0; // used to hold amplitude of pulse waveform, seeded

volatile boolean firstBeat = true; // used to seed rate array so we startup with reasonable BPM

volatile boolean secondBeat = false; // used to seed rate array so we startup with reasonable
BPM

void interruptSetup(){ // CHECK OUT THE Timer_Interrupt_Notes TAB FOR MORE ON


INTERRUPTS

// Initializes Timer2 to throw an interrupt every 2mS.

TCCR2A = 0x02; // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC
MODE

TCCR2B = 0x06; // DON'T FORCE COMPARE, 256 PRESCALER

OCR2A = 0X7C; // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE

TIMSK2 = 0x02; // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A

sei(); // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED

// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE.

// Timer 2 makes sure that we take a reading every 2 miliseconds

ISR(TIMER2_COMPA_vect){ // triggered when Timer2 counts to 124

cli(); // disable interrupts while we do this

Signal = analogRead(pulsePin); // read the Pulse Sensor

sampleCounter += 2; // keep track of the time in mS with this variable

int N = sampleCounter - lastBeatTime; // monitor the time since the last beat to avoid noise

60
Smart Agent for Medical Diagnosis (DiaMe)

// find the peak and trough of the pulse wave

if(Signal < thresh && N > (IBI/5)*3){ // avoid dichrotic noise by waiting 3/5 of last IBI

if (Signal < T){ // T is the trough

T = Signal; // keep track of lowest point in pulse wave

if(Signal > thresh && Signal > P){ // thresh condition helps avoid noise

P = Signal; // P is the peak

} // keep track of highest point in pulse wave

// NOW IT'S TIME TO LOOK FOR THE HEART BEAT

// signal surges up in value every time there is a pulse

if (N > 250){ // avoid high frequency noise

if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){

Pulse = true; // set the Pulse flag when we think there is a pulse

digitalWrite(blinkPin,HIGH); // turn on pin 13 LED

IBI = sampleCounter - lastBeatTime; // measure time between beats in mS

lastBeatTime = sampleCounter; // keep track of time for next pulse

if(secondBeat){ // if this is the second beat, if secondBeat == TRUE

secondBeat = false; // clear secondBeat flag

for(int i=0; i<=9; i++){ // seed the running total to get a realisitic BPM at startup

rate[i] = IBI;

61
Smart Agent for Medical Diagnosis (DiaMe)

if(firstBeat){ // if it's the first time we found a beat, if firstBeat == TRUE

firstBeat = false; // clear firstBeat flag

secondBeat = true; // set the second beat flag

sei(); // enable interrupts again

return; // IBI value is unreliable so discard it

// keep a running total of the last 10 IBI values

word runningTotal = 0; // clear the runningTotal variable

for(int i=0; i<=8; i++){ // shift data in the rate array

rate[i] = rate[i+1]; // and drop the oldest IBI value

runningTotal += rate[i]; // add up the 9 oldest IBI values

rate[9] = IBI; // add the latest IBI to the rate array

runningTotal += rate[9]; // add the latest IBI to runningTotal

runningTotal /= 10; // average the last 10 IBI values

BPM = 60000/runningTotal; // how many beats can fit into a minute? that's BPM!

QS = true; // set Quantified Self flag

// QS FLAG IS NOT CLEARED INSIDE THIS ISR

if (Signal < thresh && Pulse == true){ // when the values are going down, the beat is over

digitalWrite(blinkPin,LOW); // turn off pin 13 LED

Pulse = false; // reset the Pulse flag so we can do it again

62
Smart Agent for Medical Diagnosis (DiaMe)

amp = P - T; // get amplitude of the pulse wave

thresh = amp/2 + T; // set thresh at 50% of the amplitude

P = thresh; // reset these for next time

T = thresh;

if (N > 2500){ // if 2.5 seconds go by without a beat

thresh = 530; // set thresh default

P = 512; // set P default

T = 512; // set T default

lastBeatTime = sampleCounter; // bring the lastBeatTime up to date

firstBeat = true; // set these to avoid noise

secondBeat = false; // when we get the heartbeat back

sei(); // enable interrupts when youre done!

}// end isr

All serial port:

//////////

///////// All Serial Handling Code,

///////// It's Changeable with the 'outputType' variable

///////// It's declared at start of code.

/////////

63
Smart Agent for Medical Diagnosis (DiaMe)

void serialOutput()

{ // Decide How To Output Serial.

Serial.print(Signal);

Serial.print(",");

Serial.println(BPM);

Measurement feature in C# using Arduino kit:


namespace Plotter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
// get available com ports to the combobox
comboBox1.Items.Clear();
string[] names = SerialPort.GetPortNames();
foreach (string x in names)
comboBox1.Items.Add(x);

// setting the chart


chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false;
chart1.ChartAreas[0].AxisX.ScaleView.Zoom(2, 200);
chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = false;
chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
chart1.ChartAreas[0].AxisX.ScaleView.SizeType = DateTimeIntervalType.Number;
chart1.ChartAreas[0].AxisY2.Enabled = AxisEnabled.True;

chart1.ChartAreas[0].CursorX.AutoScroll = true;
chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;

chart1.Series.Clear();
chart1.Series.Add("Signal");
chart1.Series.Add("BPM");
chart1.Series["Signal"].ChartType = SeriesChartType.FastLine;
chart1.Series["BPM"].ChartType = SeriesChartType.FastLine;
}

int i = 0;
// timer function that gets activated every time interval (50 ms)
private void timer1_Tick(object sender, EventArgs e)
{
if (comboBox1.Text.Length > 0)
{
if (!serialPort1.IsOpen)

64
Smart Agent for Medical Diagnosis (DiaMe)

serialPort1.Open();
//serialPort1.BaudRate = 9600;
//serialPort1.PortName = comboBox1.Text;
//serialPort1.Open();
string read = serialPort1.ReadLine();
read = serialPort1.ReadLine().TrimEnd();
if (read.Split(',').Length == 2)
{
try
{
int y0 = int.Parse(read.Split(',')[0]);
int y1 = int.Parse(read.Split(',')[1]);
if (y0 > 1000)
y0 = 1000;
if (y1 > 150)
y1 = 150;

bpmLbl.Text = $"{y1.ToString()} BPM";


if (y1 > 100)
{
stateLbl.Text = "Fast Beats";
stateLbl.ForeColor = Color.DarkRed;
}
else if (y1 > 60)
{
stateLbl.Text = "Normal";
stateLbl.ForeColor = Color.Green;
}
else if (y1 < 60)
{
stateLbl.Text = "Slow Beats";
stateLbl.ForeColor = Color.DarkRed;
}
chart1.Series[0].Points.AddXY(i++, y0);
chart1.Series[1].Points.AddXY(i++, y1);

if (i > 200)
{
chart1.ChartAreas[0].AxisX.ScaleView.Position = i-190;
}

}
catch (Exception ex)
{
//MessageBox.Show(read);
}
}
//serialPort1.Close();
}
}

private void refreshBtn_Click(object sender, EventArgs e)


{
comboBox1.Items.Clear();
string[] names = SerialPort.GetPortNames();
foreach (string x in names)
comboBox1.Items.Add(x);
}

private void sendBtn_Click(object sender, EventArgs e)


{
if (timer1.Enabled == false)

65
Smart Agent for Medical Diagnosis (DiaMe)

{
timer1.Enabled = true;
sendBtn.ForeColor = Color.Green;
serialPort1.BaudRate = 9600;
serialPort1.PortName = comboBox1.Text;
serialPort1.Open();
}
else
{
timer1.Enabled = false;
sendBtn.ForeColor = Color.Red;
serialPort1.Close();
}
}
}

Limitations

This study looked at the efficacy of diagnosing the diseases based on symptoms,
crawling for disease name and also for searching about scientific paper for the novice doctor.
The results were very positive; however, because we only looked at liver part of the patients,
these findings may translate to other parts of the body. A statement to this effect could be
declared in the limitations section of the manuscript, followed up by a comment about how
the results might still be widely applicable as they will help with patient-specific treatment
in all parts of the world.

Although the system has reached its aims, there were unavoidable limitations. First,
because of the internet, the appropriate disease for diagnosis can't be identified when it isn't
found in the database. And also, when the doctor search for disease name or scientific paper.
The slow network might discourage doctors interest and motivation in joining peer feedback
so The internet is very important in this project. Second, rent of the cloud is very costly.

Future Recommendation

There are a number of gaps in our knowledge around the smart agent medical
diagnosis that follows from our findings, and would benefit from further research, including
realist evaluation to extend and further test We have developed here:

66
Smart Agent for Medical Diagnosis (DiaMe)

Gaps in measurement:

Limited evidence of measure to assess patient safety in primary care. It measures


only heart rate, and also show if the patient is normal or abnormal based on the calculated
number of beats only but the system cannot discusses blood pressure and also cannot show
where the problem is.

Gaps in diagnosis:

The database includes some of the diseases and related symptoms. When applying
crawling and return with the result added it in DB. The problem found here is there is a
duplication of symptoms.

Gaps in crawling:

When applying crawl from different sites, we want to use the APIs but this still not
working yet.

Conclusion Summary

This project is considered a great support to health and life quality of the affected
communities. Many developing countries are facing the shortage of medical experts in the
medical field. Due to the shortage of medical expert, they are getting a huge queue of
patients in hospitals. Especially in rural areas we have a young medical expert or don't have
the medical expertise. Dime-Smart Agent for Medical Diagnosis can be a substitute for the
above problem. This is very useful to diagnose patient diseases and prescribe the good
prescription to the patients as a human medical expert. From the above study, it is concluded
that DiaMe-Smart Agent for Medical Diagnosis System can be applied any country for
improving medical diagnosis. Also, this system can be applied anytime, anyplace, to
provides a medical prescription for general diseases. The system adopts user-friendly
control interface and the usage of easy words makes the user operate the system without
doubts and difficulties.

67
Smart Agent for Medical Diagnosis (DiaMe)

References
[1] Shiva Kazempour Dehkordi and Hedieh Sajedi; “A Prescription-based Automatic
Medical Diagnosis System using a Stacking Method”;. IEEE 15th International
Symposium on Intelligent Systems and Informatics, September 14-16, 2017 •
Subotica, Serbia.

[2] Preety Dagar, Aman Jatain and Dr. Deepti Gaur; “MEDICAL DIAGNOSIS
SYSTEM USING FUZZY LOGIC TOOLBOX"; International Conference on
Computing, Communication, and Automation (CCCA); 2015, ISBN:978-1-4799-
8890-7/15/$31.00 ©2015 IEEE.

[3] Minoru Mori, Tetsuo Tsukahara, Kazuhiko Shinozawa, Norihiro Hagita and
Michiko Furutani; “Medical Diagnosis Support System for Disease Prevention and
Its Interface”; 978-1-4244-4713-8/10/$25.00 ©2010 IEEE.

[4] NueMD Medical Billing Software app:


https://www.softwareadvice.com/medical/nuesoft-nuemd-complete-profile/ (Last
accesses on 3/10/2016).

[5] Athena healthEHR Software app:

https://www.softwareadvice.com/medical/athenacollector-athenaclinicals-profile/
(Last accesses on 4/10/2016).

[6] Manoj M,Dr. L. Padma Suresh and Dr. S V MurugaPrasasd; “PERFORMANCE


IMPROVEMENT FOR A REAL TIMEMEDICAL DIAGNOSIS SYSTEM”; 2012
International Conference on Computing, Electronics and Electrical Technologies
[ICCEET].

[7] Cássio R. S. Souza, Guilherme F. Ribeiro, Lorenzo L. Rizzini, Tiago Martines, Lucia V. L.
Filgueiras; “Adaptive assisted medical diagnosis system for mobile devices

(UrHealth)”; 978-1-4799-4823-9/14/$31.00 ©2014 IEEE.

68

S-ar putea să vă placă și