Sei sulla pagina 1di 123

AN EXPERT SYSTEM FOR DIABETES DIAGNOSIS

Submitted in partial fulfillment of the requirements for the award of the degree of

Master of Philosophy
By

SMITHA V
(Roll No: 0935014)

Supervisor

Mrs. Rohini V (Asst. Professor)

Department of Computer Science CHRIST UNIVERSITY BANGALORE 2010

DECLARATION
I hereby declare that the dissertation entitled An Expert System for Diabetes Diagnosis submitted for the M.Phill Degree is my original work and the dissertation has not formed the basis for the ward of any degree, associateship fellowship or any other similar titles.

Place: Bangalore Date:

SMITHA V Roll No.: 0935014 Signature:

CERTIFICATE
This is to certify that the dissertation work entitled An Expert System for Diabetes Diagnosis is a bonafide research work carried out by SMITHA V, student of M.Phill (Computer Science) Christ university, Bangalore, during the year 2009-2010, in partial fulfillment of the requirements for the award of the Degree of Master of philosophy and that the dissertation has not formed the basis for the award previously of any degree, diploma, associateship, fellowship or any other similar title.

Place: Bangalore Date:

Mrs. Rohini. V (Asst. Professor) Signature

II

APPROVAL SHEET
Thesis entitled An Expert System for Diabetes Diagnosis by Smitha V is approved for the degree of Master of Philosophy in Computer Science.

Examiners: 1. ___________________ 2. ___________________ 3. ___________________ ___________________ ___________________ ___________________

Supervisor (s) 1. ___________________ 2. ___________________ 3. ___________________ ___________________ ___________________ ___________________

Chairman: ___________________ (Seal) Date: ___________ Place: __________

III

Abstract
Expert system is a computer system that emulates the decision making ability of a human expert. That is it acts in all respects like a human expert. It uses human knowledge to solve problems that would require human intelligence. The expert system represents expertise knowledge as data or rules within the computer. These rules and data can be called upon when needed to solve problems. Diabetes is a knotty disease and very common in the modern world. Diabetes is a serious disease that affects almost every organ in the body like heart, eyes, kidney, skin, nerves, blood vassals, foot etc. If left the disease unchecked it will make serious complications including death. Though the disease can not possible to cure completely, it can be well managed or control and can lead a very healthy life. Early diabetes diagnosis plays a crucial role in diabetic control, and can prevent further medical complications. This paper presents the design and development of medical expert system for Diabetes disease and it support diagnosis, give information about complications and act as diabetes trainer. It used rule based approach to collect data and forward chaining inference technique. This system provides a user interactive, menu driven environment. Symptoms and risk factors associated with diabetes are taken as the basis of this study. In case of diagnosis the system will ask a bunch of questions about the symptoms and risk factors to the expert system user and user should give yes or no answer. According to the answer the system will make judgment about the possibility of illness, how much severe it is like slight chance, moderate chance, high chance, very high chance, diabetic or not. If the user wants to know the details of diabetes complications he can select the complication option from the menu. It can also used in teaching practice.

The system is drawn up with CLIPS expert system building tool version 6.3 and in Windows/Dos environment.

IV

List of Tables
Table.1: Relation between sugar level and HbA1C Table.2: Diabetic Personal Detail Table 3: Rules employed for ESDD 10 48 62

List of Figures
Figure 1: Main components of an expert system Figure 2: Structure of a rule based expert system Figure 3: Hierarchy of expert system development process Figure 4: Decision Flow diagram for Diabetes Diagnosis Expert System. Figure 5: Menu of an Expert System for Diabetes Diagnosis 15 16 46 56 63

Table of Contents
Abstract .................................................................................................................................... IV List of Tables ..............................................................................................................................V List of Figures .............................................................................................................................V 1 INTRODUCTION AND MOTIVATION OF RESEARCH ................................................. 1 1.1. 1.2. 2 INTRODUCTION ........................................................................................................ 1 MOTIVATION OF RESEARCH .................................................................................. 2

DIABETES MELLITUS ..................................................................................................... 3 2.1. 2.2. 2.3. 2.4. 2.5. 2.6. 2.7. DIABETES DISEASE- AN OVERVIEW..................................................................... 3 DIFFERENT TYPES OF DIABETES .......................................................................... 4 THE RISK FACTORS OF GETTING DIABETES....................................................... 5 MAIN SYMPTOMS OF DIABETES ........................................................................... 6 THE MAIN COMPLICATIONS OF DIABETES ......................................................... 8 DIABETES DIAGNOSIS ............................................................................................. 8 DIABETES TREATMENT ........................................................................................ 10

3. ARTIFICIAL INTELLIGENCE AND EXPERT SYSTEM................................................... 11 3.1. 3.2. 3.3. 3.4. 3.5. 3.6. 3.7. 3.8. ARTIFICIAL INTELLIGENCE ................................................................................. 11 EXPERT SYSTEMS .................................................................................................. 11 IMPORTANCE OF EXPERT SYSTEM ..................................................................... 12 MAIN COMPONENTS OF AN EXPERT SYSTEM .................................................. 14 RULE BASED EXPERT SYSTEMS .......................................................................... 16 THE NEED FOR EXPERT SYSTEM ........................................................................ 18 LIMITATIONS OF EXPERT SYSTEMS ................................................................... 18 EXPERT SYSTEM AND MEDICAL FIELD ............................................................. 20

4. EXPERT SYSTEM BUILDING TOOLS ............................................................................. 21 4.1. 4.2. PROGRAMMING LANGUAGES FOR EXPERT SYSTEM ..................................... 21 CLIPS- EXPERT SYSTEM TOOL............................................................................. 22 HISTORY ........................................................................................................... 22 FEATURES OF CLIPS ....................................................................................... 22 WORKING WITH CLIPS ................................................................................... 23 CLIPS PROGRAMMING ELEMENTS .............................................................. 24 GARBAGE COLLECTION ................................................................................ 39

4.2.1 4.2.2 4.2.3 4.2.4 4.2.5

5. LITERATURE REVIEW ...................................................................................................... 40 VI

5.1.

REVIEWED PAPERS ................................................................................................ 40

6. METHODOLOGY................................................................................................................ 45 6.1. 6.2. DESCRIPTION OF THE DEVELOPED SYSTEM .................................................... 45 EXPERT SYSTEM DEVELOPMENT PROCESS...................................................... 46

7. SUMMARY AND CONCLUSION....................................................................................... 65 7.1 FUTURE WORK........................................................................................................ 65

APPENDIX (I) ......................................................................................................................... 66 PROGRAMMING OF EXPERT SYSTEM FOR DIABETES DIAGNOSIS ......................... 66 LITERATURE CITED ............................................................................................................105 ACKNOWLEDGEMENT........................................................................................................107

VII

INTRODUCTION AND MOTIVATION OF RESEARCH

1 INTRODUCTION AND MOTIVATION OF RESEARCH


1.1. INTRODUCTION This paper deals with designing and building an Expert System for Diabetes Mellitus diagnosis which is a common health disorders in many people. This expert system interacts with user with plain English language where user needs to answer only yes or no. Internally the system classifies user input as primary symptoms, hereditary symptoms, complication symptoms, other symptoms to analysis. The expert system uses a score accumulation method to decide the level of impact of diabetes in individual. The different levels are classified as slight chance, moderate chance, high chance, very high chance, or already diabetic or not. Diabetes Mellitus (technical name of diabetes) is a metabolic disorder that affects more than 100 million people in the world. In India 19.4 million people are suffering with this chronic condition. Diabetes is a condition which associates with very high glucose level in the blood. A hormone called insulin, secreted by pancreas helps to move the glucose from the blood into liver, muscles and fat cells where it is used for fuel. The diabetic person does not produce enough insulin or the body could not use the insulin properly as it should. It causes to increase the blood sugar level. This not only harms the cells that need the glucose for fuel but also harm certain organs and tissues. Diabetes is a serious disease that affects almost every organ in the body like heart, eyes, kidney, skin, nerves, blood vassals, foot etc. If left the disease unchecked it will make serious complications including death. Some of these long-term complications of diabetes could be the damage of blood vessels and nerves, loss of functioning of the kidneys, blindness, heart disease and strokes, and loss of sensation. Most of the people, who have diabetes, do not know that they have it and hence do not treat it till it become very late. There are several symptoms of diabetes. Most of the people will get some of these symptoms before they know that they are diabetic. But some people not get any symptoms initially and they come to know that they are diabetic only after they get some complications. Some of the classical symptoms are excessive thirst, frequent urination, extreme hunger, feeling tired or fatigue, unexplained weight loss, sudden vision changes, tingling or numbness in hands or feet, slow healing and infections than usual, nausea, vomiting, abdominal pain etc. Though the disease can not possible to cure completely, it can be well managed or control and can lead a very healthy life. Early

Diabetes diagnosis plays a crucial role in diabetic control, and can prevent further medical complications. 1.2. MOTIVATION OF RESEARCH The main reason of this research was to introduce the design and development of an expert system which is able to fully diagnose the very knotty disease diabetes. The system An Expert system for Diabetes Diagnosis is a medical expert system for diagnosis of the disease Diabetes using rule based approach and it support diagnosis, give information about complications and act as diabetes trainer. This system, on the basis of particular knowledge or rules basis, draws conclusions, takes decisions, and its activity is similar to the human activity in that sphere. It uses the inference mechanism of forward chaining-reasoning from facts to the conclusion, resulting from those facts using CLIPS as the programming language. The expert system provides an interactive way to the user, ask questions about personnel details and symptoms, to answer whether the diabetes symptom is experienced by the individual or not. According to the answer given by the person, the system will make judgment about the possibility of illness, how much severe it is moderate chance or higher chance etc. This expert system is use to diagnosis for all types of diabetes because nowadays diabetes is a very common disease in children, youngsters, adults and old people due to a lot of factors like life style, obesity etc which may be type 1 diabetes or type 2 diabetes .The symptoms of both types of diabetes are almost similar. If a patient diagnosed as diabetic even the doctors cant predict from the very beginning that it is type 1 or type 2.They need to examine the patient for 2 to 3 months.(In some cases they can predict from the beginning stage whether type 1 or type 2). So this expert system is a general tool for diagnosis of all type of diabetes. Since, diabetes diseases are widely spreads in India, the expert system is not meant to replace the human endocrinologist but users those who are diabetic or under risk will get a thorough knowledge about diabetes that will help them to take proper treatment against this disease. This system can be used to help the physician in their work. This expert system initially evaluated with existing classical test cases. The result of the evaluation was accurate and promising.

DIABETES MELLITUS

2 DIABETES MELLITUS
2.1. DIABETES DISEASE- AN OVERVIEW Definition of disease Diabetes Mellitus: Diabetes Mellitus is a clinical syndrome characterizes by hyperglycemia due to absolute or relative deficiency of insulin. The lack of insulin affects the metabolism of the body. It causes to increase the blood sugar level. That is there is not enough insulin to reduce the percentage of glucose to its normal level. All the people with diabetes have one thing common. They have too much sugar or glucose in their blood. This is because a person who intake food is converted into glucose and the body is unable to remove glucose from the blood and deliver it to the cells as a source of energy in order to stay alive. A hormone called Insulin, secreted by the pancreas helps to convert glucose to energy. When a person has diabetes, the body either does not generate enough insulin or cannot use its own insulin as it should. This will cause sugar to rise in the blood. So insulin is a key regulator of the body's metabolism. It works in the following way:

During and immediately after a meal the process of digestion breaks down carbohydrates into sugar molecules (including glucose) and proteins into amino acids.

Right after the meal, glucose and amino acids are absorbed directly into the bloodstream, and blood glucose levels rise sharply.

The rise in blood glucose levels signals important cells in the pancreas, called beta cells, to secrete insulin, which pours into the bloodstream. Within 10 minutes after a meal, insulin rises to its peak level.

Insulin enables glucose and amino acids to enter cells in the body, particularly muscle and liver cells. Here, insulin and other hormones direct whether these nutrients will be burned for energy or stored for future use. As blood glucose levels reach their peak, the pancreas reduces the production of insulin.

About 2 to 4 hours after a meal, both blood glucose and insulin are at low levels, with insulin being slightly higher. The blood glucose levels are then referred to as fasting blood glucose concentrations.

2.2. DIFFERENT TYPES OF DIABETES There are three types of Diabetes. Type-1diabetes (Juvenile Diabetes or Insulin dependent diabetes):- In Type I diabetes, the immune system attacks insulin-producing beta cells in the pancreas and destroys them. With little or no insulin, the cells are prevented from taking up sugar from the blood. Patients with type 1 do not make enough insulin and they are treated with insulin to sustain life. Genetic and environment factors are involved in the development of type 1 diabetes such as unidentified virus, stimulating an immune attack against the beta cells of pancreas in some genetically predisposed people. This occurs in youngsters (below 18 years) and older people. This occurs in older people due to destruction of pancreas by alcohol, disease or removal by surgery or progressive failure of pancreatic beta cells which produce insulin. Type 2 diabetes: :( Adult onset Diabetes or Insulin independent diabetes):- Patients with type 2 do make insulin, but for some reason, the cells in their bodies are resistant to insulins action or they do not make enough insulin. 90% of all types of diabetes are type 2. It may involve the following three stages in most patients. The first stage in type 2 diabetes is the condition called insulin resistance. Certain mechanisms prevent insulin from moving glucose (blood sugar) into the cells where it can be used. Thus lowering the rate in which glucose is utilized. Most patients with type 2 diabetes produce variable, even normal or high, amounts of insulin. In the beginning, this amount is usually sufficient to overcome such resistance. Over time, the pancreas becomes unable to produce enough insulin to overcome resistance and in turn increasing the glucose in the blood leading to pre diabetes. It is the condition in which the blood sugar level is more than the normal level but not reach to the diabetic level. In type 2 diabetes, the initial effect of this stage is usually an abnormal rise in blood sugar right after a meal (called postprandial hyperglycemia). This effect is now believed to be particularly damaging to the body. Eventually, the cycle of elevated glucose further impairs and possibly destroys beta cells, thereby stopping insulin production completely and causing full-blown diabetes. This is made evident by fasting hyperglycemia, in which elevated glucose levels are present most of the time.

Gestational diabetes: This appears during pregnancy in some women with no previous type-1 or type-2 diabetes and usually goes away after pregnancy. But after pregnancy 5 to 10 percentage of women with gestational diabetes are diagnosed with type 2 diabetes within 10 years. Pregnant women have enough insulin, but the effect of insulin is partially blocked by other hormones produced in the placentas during pregnancy period. Around 13% of pregnant women were diagnosed with this form of diabetes, including many who did not have any risk factors. All pregnant women are tested for gestational diabetes between their 24th and 28th week. 2.3. THE RISK FACTORS OF GETTING DIABETES The main causes of diabetes are

Hereditary and genetics factors Infections caused by viruses Stress Obesity(A weight that is 20% more than ideal body weight) Increased cholesterol level (HDL (good) cholesterol less than 35 mg/dL or triglyceride level 250 mg/dL or higher)

High carbohydrate diet Nutritional deficiency Excess intake of oil and sugar No physical exercise Overeating Tension and worries High blood pressure(140/90 mm/Hg or higher) Insulin deficiency Insulin resistance Age 45 or older African American, Hispanic/Latin American, American Indian and Alaska Native, Asian American, or Pacific Islander ethnicity

Polycystic ovary syndrome (metabolic disorder that affects female reproductive system

If you are on high levels of prednisone for asthma or allergies or other autoimmune diseases, you are very much at risk for diabetes. A pregnant woman's risk factors include-: 5

Family history of diabetes African American, Hispanic, Asian, or Pacific Islander ethnicity Overweight Older than 25 years Gestational diabetes with past pregnancy Having given birth to a child weighing over 9 pounds Diagnosis of pre-diabetes

The Risk factors that cannot control The risk factors that cannot control include: Family history: If you have a parent, brother, or sister who has type 2 diabetes, you have a greater chance of developing the disease. Age. The risk for getting pre diabetes and type 2 diabetes increases with age and the number of children being diagnosed with type 2 diabetes is increasing. Usually, children who get type 2 diabetes have a family history of the disease, are overweight, and are physically inactive. Race and ethnicity. African Americans, Hispanics, Native Americans, Asian Americans, and Pacific Islanders are at higher risk than whites for type 2 diabetes. History of gestational diabetes or having a baby weighing more than 9 lb (4 kg). Women who have had gestational diabetes or who have had a large baby are at higher risk for developing type 2 diabetes later in life. Low birth weight. People who weighed less than 5.5 lb (2.5 kg) at birth are more likely to develop type 2 diabetes later in life. Polycystic ovary syndrome (PCOS), a hormone imbalance that interferes with normal ovulation. Metabolic syndrome, a group of abnormal physical findings related to the body's metabolism. 2.4. MAIN SYMPTOMS OF DIABETES The common symptoms areClassic Symptoms Frequent urination with large volume of urine (poly urea) Excessive thirst (polydipsia) Extreme Hunger (polyphagia) Unusual, sudden, unexplained weight loss 6

Increased fatigue Feeling very tired Feeling ill Sudden vision changes or Blurry vision Nausea Vomiting Stomach pain Other Symptoms Hair loss or thinning of hair Leg pain Sugar in urine Dry mouth Irritability Sleep disorder Dry or itchy skin Gestational diabetes Bladder, Skin, or vaginal infection (in female) Impotence (in male) Swollen red gums and loosing teeth Lethargy Over eating and rapid weight gain Taking steroid medicine for Asthma Loss of consciousness Complication Symptoms Delayed wound healing Bruises that wont go away Sores that wont heal Tingling or numbness in hands or legs A feeling of pins and needles in feet Unexplained aches and pains Burning pain in legs, feet, arms Fruity smell of breath and sweat

2.5.

THE MAIN COMPLICATIONS OF DIABETES Uncontrolled diabetes can harm the nerves in your body causing diabetic neuropathy. Heart disease, stroke, heart attack are all caused by blockage of blood vessels causing lack of oxygen in extreme case breakage of blood vessels may happen.

Diabetic retinopathy caused due to blood vessel damage in retina causing lack of blood circulation thus lack of oxygen to nourish retina and in extreme cause leakage of blood in retina.

Diabetic Gastroparesis is disorder of stomach that takes too long to empty its contents it is caused by vagus nerve damage.

Diabetes kidney disease are caused due to small blood vessel of kidney get damaged due to long run of high blood glucose.

Erectile dysfunction or impotence is due to over all nerve damage, and also may be nerves in penis.

Urinary incontinence, over active bladder, bladder problems are all caused by nerve damage due to prolonged high blood glucose.

Urinary tract infection is also caused by nerve damage, but it is not directly related with nerve cause. Due to Diabetic Gastroparesis the food emptying is delayed, thus bacteria start growing and on it way it causes urinary tract infection. Also due to long term diabetes immune system loss it capacity thus not able to fight the infection.

Diabetic ketoacidosis is a serious condition in which uncontrolled hyperglycemia overtime creates a buildup in the blood of acidic waste products called ketones. High level of ketones is very harmful. This is particularly happens in people with type 1 diabetes who do not have good blood glucose control. Diabetic ketoacidosis is caused by infections, stress, trauma, missing medications like insulin or medical emergencies like stroke and heart attack.

2.6. DIABETES DIAGNOSIS Some diabetic patients will not get any warning sign or symptoms. The only way to be sure is to have blood test for glucose. The diabetics diagnosis tests includeFasting Plasma Glucose: The fasting plasma glucose (FPG) test is the standard test for diabetes. It is a simple blood test taken after 8 hours of fasting. Results indicate:

FPG levels are considered normal up to 100 mg/dL

Levels between 100 and 125 mg/dL are referred to as impaired fasting glucose or pre-diabetes. These levels are considered to be risk factors for type 2 diabetes and its complications.

Diabetes is diagnosed when FPG levels are 126 mg/dL or higher on two or more tests on different days.

Postprandial blood glucose test (PPB): This test is followed by Fasting plasma glucose test. Take good amount of food after FPG wait 2 hours, and do the blood test again. Postprandial glucose level should be under 140 mg/dL. The value between 140 and 199mg/dL indicate prediabetes.200 and above value may indicate diabetes. Random blood glucose test: A random blood glucose test can also be used to diagnose diabetes. A blood glucose level of 200 mg/dl or higher indicates diabetes The Oral glucose tolerance test: This test is used for diagnosis of type 2. It is still commonly used for diagnosing gestational diabetes and in conditions of pre-diabetes. With an oral glucose tolerance test, the person fasts overnight (at least eight but not more than 16 hours). Then first, the fasting plasma glucose is tested. After this test, the person receives 75 grams of glucose (100 grams for pregnant women). Blood samples are taken at specific intervals to measure the blood glucose over a period of three hours. In a person without diabetes, the glucose levels rise and then fall quickly. In someone with diabetes, glucose levels rise higher than normal and fail to come back down as fast. People with glucose levels between normal and diabetic have impaired glucose tolerance (IGT). People with impaired glucose tolerance do not have diabetes, but are at high risk for progressing to diabetes. Glucose tolerance tests may lead to one of the following diagnoses:

Normal response: A person is said to have a normal response when the 2-hour glucose level is less than 140 mg/dl, and all values between 0 and 2 hours are less than 200 mg/dl.

Impaired glucose tolerance: A person is said to have impaired glucose tolerance when the fasting plasma glucose is less than 126 mg/dl and the 2-hour glucose level is between 140 and 199 mg/dl.

Diabetes: A person has diabetes when two diagnostic tests done on different days show that the blood glucose level is high.

Gestational diabetes: A woman has gestational diabetes when she has any two of the following: a 100g OGTT, a fasting plasma glucose of more than 95 mg/dl, a 1-hour 9

glucose level of more than 180 mg/dl, a 2-hour glucose level of more than 155 mg/dl, or a 3-hour glucose level of more than 140 mg/dl. Hemoglobin A1C In the body, sugar sticks with proteins. The red blood cells are a protein that circulates in the body live for about three months before they die off. When sugar sticks to these cells, it gives us an idea of how much sugar is around for the preceding three months. In most labs, the normal range is 4%-5.9 %. In poorly controlled diabetes, its 8.0% or above, and in well controlled patients it's less than 7.0% (optimal is <6.5%). it is used as a standard tool to determine blood sugar control in patients known to have diabetes.

HbA1C 6 7 8 9 10 11 12

Mean Blood sugar (mg/dl) 135 170 205 240 275 310 345

Table.1: Relation between sugar level and HbA1C 2.7. DIABETES TREATMENT Diabetes cannot cure completely. It is a chronic disease. Once the disease diagnose, patients can make it under control to keep blood glucose level near normal level. Type Diabetes is particularly very difficult to control. It is controlled mainly by proper calculated diet, physical exercise; multiple times home blood sugar testing and daily insulin injections. Type 2 Diabetes controlled by using proper diet, regular exercise, medication, yoga, weight reduction medication and in some cases insulin. Once in three months or yearly 2 times the patients should check their HBA1C test and its range should be below 6.

10

ARTIFICIAL INTELLIGENCE AND EXPERT SYSTEM

3. ARTIFICIAL INTELLIGENCE AND EXPERT SYSTEM 3.1. ARTIFICIAL INTELLIGENCE Definition of Artificial Intelligence (AI): AI is concerned with the design of intelligence in an artificial device or it is a branch of computer Science concerned with the automation of intelligent behavior. The term is coined by Mc. Carthy in 1956. Artificial intelligence has several areas of interest such as robotics, vision, natural language understanding and semantic modeling, speech, artificial neural system and parallel processing, automated reasoning and theorem proving, expert systems, game playing and human performance modeling. The term intelligence covers many cognitive skills, including the ability to solve problems, learn, and understand language; AI addresses all of those. But most progress to date in AI has been made in the area of problem solving -- concepts and methods for building programs that reason about problems rather than calculate a solution. The root of expert system lies in many disciplines. One of the major roots of expert systems is the area of human informational processing called cognitive science. Cognition is the study of how human process information or how people think especially when solving problems. 3.2. EXPERT SYSTEMS Expert system is a branch of Artificial intelligence. Definition of Expert System: It is an intelligent computer program that uses knowledge and inference procedures to solve problems at the level of a human expert. It emulates the decision making ability of a human expert. That is the expert system is intended to act in all respects like a human expert in a particular field. Building an expert system is known as knowledge engineering and its practitioners are called knowledge engineers. The knowledge engineer must make sure that the computer has all the knowledge needed to solve a problem. The knowledge engineer must choose a knowledge representation. He must also ensure that the computer can use the knowledge efficiently by selecting from a handful of reasoning methods. 11

Typically such a system contains a knowledge base containing accumulated experience and a set of rules for applying the knowledge base to each particular situation that is described to the program. The knowledge in expert system may be either expertise or knowledge that is available from books, journals conferences, magazines, knowledge persons, internet etc. Expert systems can be classified from different points of view. It can be the advisory systems, the ones that suggest the direction; systems taking decisions without the help and human interference; criticizing systems the ones which on the basis of a particular problem and the predicted solution by a man, analyze and comment the particular reasoning and action way. A human experts knowledge is specific to one problem domain. A problem domain is the special problem area such as medicine, finance, science, or engineering. The problem domain consist many problems. The experts knowledge about solving specific problems is called the knowledge domain of the expert. In the same way expert systems are designed to address specific problem in the problem domain, called knowledge domain. It is important that there is a close cooperation between a system engineer and experts on those interest fields when constructing the appropriate expert system. Nothing can replace the knowledge and experts experience. 3.3. IMPORTANCE OF EXPERT SYSTEM Expert systems have experienced tremendous growth and popularity in all fields like business, science, engineering, manufacturing, medicine and many other fields. Conventional computer programs make use of well structured algorithms, data structures for problem solving and use crisp reasoning strategies to find solutions. The implementation of algorithm in a program is called procedural program. So the terms algorithmic programming, procedural programming and conventional programming are often use interchangeably. Problems that cannot solve by conventional methods, use non conventional or AI method. Expert systems are designed for problems those have no efficient algorithmic solution and rely on inferences to achieve a reasonable solution. Such cases are called ill-structured problems that are difficult or impossible to do by using conventional or procedural or programming. The reasoning may offer the only hope of a good solution because there may so many possibilities or several possible inferences. Explanation facility is an integral part of an expert system. The expert system reasons or makes inferences in the same way that a human expert would infer the 12

solution of a problem. That is, given some facts, a conclusion that follows is inferred. It must be able to explain its reasoning to the user so that its reasoning can be checked. The process of developing an expert system has an indirect benefit also since the knowledge of human experts must be put into an explicit form for entering into the computer. Because the knowledge is then explicitly known instead of being implicit in the experts mind, it can be examined for correctness, consistency and completeness. The knowledge may then have to be adjusted or re-examined, which improve the quality of the knowledge. Expert systems have appropriate and inappropriate applications. Most applications of expert systems will fall into one of the following categories. Interpreting and identifying Predicting Diagnosing Designing Planning Monitoring Debugging and testing Instructing and training Controlling Conventional computer programs perform job using a decision making logic containing very little knowledge other than the basic algorithm for solving that specific problem. The basic knowledge is embedded as part of the programming code, so that as the knowledge changes the program has to be rebuilt. Knowledge based expert system collect small fragments of human knowledge into knowledge base, which is used to reason through the problem using the knowledge that is appropriate. An important advantage here is that within the domain of knowledge base, a different problem can be solved using the same program without reprogramming efforts. Moreover expert systems could explain the reasoning process and handle level of confidence and uncertainty which conventional algorithms do not handle. The expert system, having a written expert knowledge from a chosen field, can use many times in an economic and effective way because it does not need the presence of the expert. The special advantage of such systems is the possibility of solving the particular tasks without 13

the direct expert's participation, and also the possibility of knowledge aggregation in one system of the numerous experts team. 3.4. MAIN COMPONENTS OF AN EXPERT SYSTEM

Figure 1 shows the concept of a knowledge based expert system. The expert system receives facts from the user and provides expertise in return. The two main components of an expert system (invisible from outside) are the knowledge base and inference engine. The knowledge base: It contains the domain knowledge coded in the form of knowledge. It stores all relevant information, data, rules, cases and relationships used by the expert system. The knowledge base can combine the knowledge of multiple human experts. A knowledge base is the nucleus of an expert system structure. A knowledge base is not a data base. The knowledge base is created by the knowledge engineers who translate the knowledge of real human experts into rules. In a rule based expert system a knowledge base is usually stored in terms of if-then rules. The knowledge base of expert systems contains both factual and heuristic knowledge. Factual knowledge is that knowledge of the task domain that is widely shared, typically found in textbooks or journals, and commonly agreed upon by those knowledgeable in the particular field. Heuristic knowledge is the less rigorous, more experiential, more judgmental knowledge of performance. In contrast to factual knowledge, heuristic knowledge is rarely discussed, and is largely individualistic. It is the knowledge of good practice, good judgment, and plausible reasoning in the field. It is the knowledge that underlies the "art of good guessing." For the difficult problems with which expert system are concerned it uses heuristics: Strategies that often lead to correct solution, but that also sometime fail. The inference engine: The Inference engine may infer solutions or conclusions from the knowledge base, based on the facts supplied by the user. The inference engine acts as an interpreter or scheduler that interprets which rules matches with the facts. The word inference or reasoning is very important in expert system; because reasoning is the standard technique by which expert system solve problems. It makes inferences by deciding which rules are satisfied by facts, prioritizes the satisfied rules, and execute the rule with the highest priority. These conclusions are the expert systems response to the user queries, as the user supplies facts or other information to the expert system for getting the expertise or expert advice or 14

response. So the purpose of inference engine to seek information and relationship from the knowledge base and to provide answers, predictions and suggestions in the way a human expert would. The inference engine must find the right facts, interpretations and rules and assemble them correctly. Two types of inference methods are commonly used. Forward Chaining and backward chaining.

Figure 1: Main components of an expert system The other components areUser interface: The mechanism by which the user and the expert system communicate. There is specialized user interface software available, that can be use to designing, updating and using expert system. The purpose of user interface is to ease use of expert system for developers, users and administrators. Explanation facility: The explanation facility allows the user to understand how the expert system arrived at certain results. That is it explains the reasoning of the system to the user. Working memory: It is a global database of facts used by the rules. This data is supplied by the end user. Agenda: A prioritized list of rules created by the inference engine, whose patterns are satisfied by facts in working memory. Knowledge acquisition facility: The overall purpose of knowledge acquisition facility is to provide a convenient and efficient means for capturing and storing all components of a knowledge base. It also provides an automatic way for the user to enter knowledge in the system instead of having the knowledge engineer explicitly code the knowledge. The knowledge acquisition facility is an optional feature on many systems. Some expert system tools like KEE (Knowledge engineering Expert) can learn by rule induction through examples and can automatically generate rules. The examples are generally from tabular or spreadsheet type data better suited to decision trees. General rules constructed by knowledge engineer can be much more complex than the simple rules from rule induction. Figure 2 shows the structure of an expert system. 15

Figure 2 Structure of a rule based expert system 3.5. RULE BASED EXPERT SYSTEMS The main differences between the expert systems are how they capture and store knowledge in the knowledge base or knowledge representation in the knowledge base. Knowledge representation is of major importance in expert system for two reasons. First expert system shells are designed for certain type of knowledge representation. Second the way in which expert system represents knowledge affects the development, efficiency, speed and maintenance of the system. One of the most popular types of expert system today is the rule based or production rule system. A rule is conditional statement that links given conditions to actions or outcomes. Expert systems making use of rules to store knowledge are called rule based expert systems. It is based on an efficient algorithm called rete pattern matching algorithm for matching facts against the patterns in rules to determine which rules have had their conditions satisfied. Rete algorithm performance is theoretically independent of the number of rules in the system and requires less memory. Rule based expert system use human expert knowledge to solve real world problems that normally would require human intelligence. Experts knowledge is represented in the form of rules or as data within the computer. Depending upon the problem requirement these rules and data can be recalled to solve problems. Knowledge can easily grow incrementally in a rule based system. That is the knowledge base can grow little by little as rules are added so that the performance and correctness of the system can be continuously checked. The incremental growth of knowledge facilitates rapid prototyping so that the knowledge engineer can quickly show the expert a working prototype of the expert system. 16

This is an important feature because it maintains both the experts and managements interest in the project rapid prototyping also quickly exposes any gaps, inconsistencies or errors in the experts knowledge or the system so that corrections can be made immediately. Rule based expert system have played an important role in modern intelligent system and their applications in design, planning, scheduling, fault monitoring, diagnosis etc. A rule based expert system consists of if-then rules, a bunch of facts and an interpreter controlling the application of rules, given facts. A single if-then rule assumes the form if X is A then Y is B; if part of the rule X is A is called antecedent or premise and then part of the rule Y is B is called consequent or conclusion. Rule based expert systems are popular for a number of reasons. Modular nature: This makes it easy to encapsulate knowledge and expand the expert system by incremental development Explanation facilities: It is easy to build explanation facilities with rules because the antecedents of a rule specify exactly what is necessary to activate the rule. By keeping track of which rules have fired, an explanation facility can present the chain of reasoning that led to a certain conclusion. Similarity to the human cognitive process: Rules appear to be the natural way of modeling how humans solve problems. The simple IF.THEN representation of rules makes it easy to explain to experts the structure of knowledge the knowledge engineer trying to elicit from them and the process is called knowledge engineering. Inference Engines in Rule Based Systems The two broad kinds of inference engines used in rule based expert systems are forward chining and backward chaining system. Forward chaining: It starts with the facts and works forward to reach the conclusion. It involves checking the condition part of the rule to determine whether it is true or false. If the condition is true then the action part of the rule is also true. This procedure continues until the solution is found or a dead end is reached. Forward chaining is commonly referred to as data driven reasoning. Backward chaining: It is the process of starting with the conclusion and working backward to the supporting facts. It is the reverse of forward chaining. Backward chaining is very good when all the outcomes are known and the number of possible outcome is not large. In this case a goal is specified, and the expert system tries to determine what 17

conditions are needed to arrive at the specified goal. Thus backward chaining is also called goal-driven reasoning. 3.6. THE NEED FOR EXPERT SYSTEM Expert systems are necessitated by the limitations associated with conventional human decision-making processes, including: 1. Human expertise is very scarce. 2. Humans get tired from physical or mental workload. 3. Humans forget crucial details of a problem. 4. Humans are inconsistent in their day-to-day decisions. 5. Humans have limited working memory. 6. Humans are unable to comprehend large amounts of data quickly. 7. Humans are unable to retain large amounts of data in memory. 8. Humans are slow in recalling information stored in memory. 9. Humans are subject to deliberate or inadvertent bias in their actions. 10. Humans can deliberately avoid decision responsibilities. 11. Humans lie, hide, and die. Coupled with these human limitations are the weaknesses inherent in conventional programming and traditional decision-support tools. Despite the mechanistic power of computers, they have certain limitations that impair their effectiveness in implementing human-like decision processes. Conventional programs: 1. Are algorithmic in nature and depend only on raw machine power 2. Depend on facts that may be difficult to obtain 3. Do not make use of the effective heuristic approaches used by human experts 4. Are not easily adaptable to changing problem environments 5. Seek explicit and factual solutions that may not be possible 3.7. LIMITATIONS OF EXPERT SYSTEMS Lack of Causal Knowledge

A practical limitation of many expert systems today is lack of causal knowledge. That is, the expert systems do not really have an understanding of the underlying causes and effects in a system. The programming using causal knowledge would be an enormous task and even if 18

successful, the response time of the system would be extremely slow because the information the system has to process would be huge. So it is easy to build an expert system with shallow knowledge based on empirical and heuristic knowledge than with deep knowledge based on the basic structure, functions and behaviors of objects. Heuristic is a Greek word and it means to discover. Heuristics are not guaranteed to succeed in the same way that an algorithm is a guaranteed solution to a problem. Instead, heuristics are rules of thumb or empirical knowledge gained from experience that may aid in the solution but are not guaranteed to work. However, in many fields, such as medicine and engineering, heuristics play an essential role in some type of problem solving. Even if an exact solution is known, it may be impractical to use because of cost or time constraints. Heuristics can provide valuable shortcuts that can reduce both time and cost. Limited knowledge of the knowledge domain:

Another problem with expert system today is that their expertise is limited to the knowledge domain that the systems know about. Typical expert systems cannot generalize their knowledge by using analogy to reason about new situations the way people can. Some expert system allows the system to learn rules through rule induction, in which the system creates rules from tables of data. Only limited types of knowledge can be put into an expert system in this way. Knowledge acquisition

The knowledge of experts into rules is not simple, especially when the experts knowledge has never been systematically explored. There may be inconsistencies, ambiguities, duplications or other problems with the experts knowledge. The customary way of building an expert system, by having the knowledge engineer repeat the cycle of interviewing the expert, constructing a prototype, testing, interviewing and so on. It is a time consuming and labor intensive task. So the problem of transferring human knowledge into an expert system is so major task and is called knowledge acquisition bottle neck. That is building an expert system is like an ordinary bottle neck constricts fluid flow into a bottle. Limits of ignorance

An expert systems advice, like that of a human expert, should degrade gracefully at the boundaries of ignorance. Human expert know the extent of their knowledge and qualify their advice as the problem reaches their limits of ignorance. They also know how to break the rules. If the expert system not explicitly designed to deal with uncertainty, they will make

19

recommendations with the same confidence even if the data they are dealing with are inaccurate or incomplete. 3.8. EXPERT SYSTEM AND MEDICAL FIELD There already some expert systems are in medical field. Some of them areMYCIN: It was the first well known medical expert system developed by Shortliffe at Stanford University (Buchanan and Shortliffe, 1984) used for diagnosis and remedy bacterial infections. It uses backward chaining inference procedure. It helps doctors, not expert in antimicrobial drugs; prescribe such drugs for blood infections. The limitation of MYCIN was its knowledge base is incomplete since, it does not cover anything like the full spectrum of infectious diseases. Running it would have required more computing power than most hospitals could afford at that time (1976). Doctors do not relish typing at the terminal and require a much better user interface than that provided one. PERFEX: It is a medical expert system that support solving problems clinicians currently have in evaluating perfusion studies (Ezquerra et al., 1992). The heart of the PERFEX system is the knowledge base, containing over 250 rules. They were formulated using the expertise of clinicians and researchers at Emory University Hospital. PERFEX limitation resides in its output. It is mostly numerical. INTERNIST-I: It is a rule-based expert system designed at the University of Pittsburgh in 1974 (Kumar et al., 2009) for the diagnosis of complex problems in general internal medicine. ONCOCIN: It is a rule-based medical expert system for oncology protocol management (Wiederhold et al., 2001) developed at Stanford University. ONCOCIN was designed to assist physicians with the treatment of cancer patients receiving chemotherapy. Dxplain: It is a decision support system which uses a set of clinical findings (signs, symptoms, laboratory data) to produce a ranked list of diagnoses which might explain (or be associated with) the clinical manifestations (Elhanan et al., 1996). The Dxplain provides justification for why each of these diseases might be considered, suggests what further clinical information would be useful to collect for each disease and lists what clinical manifestations, if any, would be unusual or a typical for each of the specific diseases. PUFF: It is an expert system for the interpretation of pulmonary function tests for patients with lung disease. PUFF was probably the first AI system to have been used in clinical practice.

20

EXPERT SYSTEM BUILDING TOOLS

4. EXPERT SYSTEM BUILDING TOOLS

4.1. PROGRAMMING LANGUAGES FOR EXPERT SYSTEM Expert systems are typically written in special programming languages. An expert system language is higher order language than other languages like C or artificial languages like LISP (List Processing), PROLOG (Program logic) because it is easier to do certain things. Artificial intelligence languages are mainly used for symbolic processing, but also used for developing expert system. The specialized nature of expert system languages make them suitable for writing expert systems but not for general purpose programming. The major advantage of these languages, as compared to conventional programming languages, is the simplicity of the addition, elimination, or substitution of new rules and memory management capabilities. The primary functional difference between expert system language and procedural languages is the focus of representation. Procedural languages focus on providing flexible and robust techniques to represent data such as arrays, records, linked list, stack, queue etc that are easily create and manipulate. In contrast, expert system languages are providing flexible and robust ways to represent data. It allows two levels of abstraction-data abstraction and knowledge abstraction. Expert system languages specifically separate the data from the methods of manipulating the data. An example of this separation is that of facts (data abstraction) and rules (knowledge abstraction) in a rule based expert system language. So the expert system language requires less rigid control of the execution sequence. The inference engine is used to apply the knowledge to the data. But in procedural language there is a tight interleaving of data and knowledge and programmers must carefully describe the sequence of execution. In expert system the separation of knowledge and data allows a higher degree of parallelism and modularity. Some of the distinguishing characteristics of programming languages needed for expert systems work are: Efficient mix of integer and real variables Good memory-management procedures Extensive data-manipulation routines Incremental compilation Tagged memory architecture 21

Optimization of the systems environment Efficient search procedures. 4.2. CLIPS- EXPERT SYSTEM TOOL

4.2.1 HISTORY
CLIPS, an acronym for C Language Integrated Production System, are a computer language developed by NASAs Johnson Space Center for developing application in expert system. The origin of the CLIPS(C language integrated production system) was in 1984 and is designed using C programming language. CLIPS is a productive development and delivery expert system tool which provides a complete environment for the construction of rule and/or object based expert systems which includes features such as an integrated editor and a debugging tool. Because of its portability, extensibility, capabilities and low cost it accepted widely in all fields like government, academia, industry etc. The development of CLIPS has helped to improve the ability to deliver expert system technology throughout the public and private sections for a wide range of applications. CLIPS have being used by numerous users both in public and private sections include military, numerous federal bureaus, government contractors, universities and many private companies. Originally CLIPS support only rule based programming. 4.2.2 FEATURES OF CLIPS Knowledge Representation: CLIPS provides a cohesive tool for handling a wide variety of knowledge with support for three different programming paradigms: rule-based, objectoriented and procedural. Rule-based programming allows knowledge to be represented as heuristics, or "rules of thumb," which specify a set of actions to be performed for a given situation. Object-oriented programming allows complex systems to be modeled as modular components (which can be easily reused to model other systems or to create new components). The procedural programming capabilities provided by CLIPS are similar to capabilities found in languages such as C, Java, Ada, and LISP. So the different ways to represent in CLIPS are: Rules: Primarily intended for heuristic knowledge based on experience. Deffunctions and generic functions: for procedural knowledge. Object-oriented programming: Primarily for procedural knowledge. Portability: CLIPS is written in C for portability and speed and has been installed on many different operating systems without code changes. Operating systems on which CLIPS has 22

been tested include Windows 95/98/NT, MacOS X, and UNIX. CLIPS can be ported to any system which has an ANSI compliant C or C++ compiler. CLIPS come with all source code which can be modified or tailored to meet a users specific needs. Integration/Extensibility: CLIPS can be embedded within procedural code, called as a subroutine, and integrated with languages such as C, Java, FORTRAN and ADA. CLIPS can be easily extended by a user through the use of several well-defined protocols. Interactive Development: The standard version of CLIPS provides an interactive, text oriented development environment, including debugging aids, on-line help, and an integrated editor. Interfaces providing features such as pull down menus, integrated editors, and multiple windows have been developed for the MacOS, Windows 95/98/NT, and X Window environments. Verification/Validation: CLIPS includes a number of features to support the verification and validation of expert systems including support for modular design and partitioning of a knowledge base, static and dynamic constraint checking of slot values and function arguments, and semantic analysis of rule patterns to determine if inconsistencies could prevent a rule from firing or generate an error. Fully Documented: CLIPS comes with extensive documentation including a Reference Manual and a User's Guide. Low Cost: CLIPS is maintained as public domain software. 4.2.3 WORKING WITH CLIPS The CLIPS interface is a simple, interactive, text oriented, command prompt interface for high portability. The standard usage is to create or edit a knowledge base using any standard text editor, exit the editor and execute CLIPS, then load the knowledge base into the CLIPS. The primitive way of interacting with CLIPS is through CLIPS command prompt. The interface provides commands for viewing the current state of the system, tracing execution, adding or removing information, and clearing CLIPS. Comments can be included in CLIPS code using semicolon. Everything from the semicolon until the next return character will be ignored by CLIPS. To start CLIPS, double-click on the CLIPSWin.exe file. Then get a window with nothing in it but the command prompt CLIPS> comes. This mode is called top level. This is where type commands and programs. To exit CLIPS, type (exit) or shut down the program like any other

23

windows application. CLIPS commands are always encased in brackets. Here is a list of some important commands: (exit) Shuts down CLIPS (clear) Removes all rules and facts from memory or all constructs currently contained in CLIPS. Equivalent to shutting down and restarting CLIPS.

(reset) Removes facts information from memory (but not rules) and resets the agenda. (run) Starts executing a CLIPS program. The above commands can also be executed from the CLIPS menu bar. The primary method for interacting with CLIPS is through the CLIPS command prompt on top level. When CLIPS> prompt comes, commands can be entered in brackets. Whenever the user wants to exit from CLIPS type (exit) from the command prompt. 4.2.4 CLIPS PROGRAMMING ELEMENTS The basic components of CLIPS programming languages are different data types, functions for manipulating data, and constructs for adding to knowledge base. Data Types The different data types available in are float, integer, symbol, string, external-address, factaddress, instance-name and instance-address. Floats & Integer: A number consist only of digits (0-9), a decimal point (.), a sign (+ or -) and an e for exponential notation A number having only digits and its sign (optional) is called integer and all other numbers are called floats. Example: integers Floats 123 +98 -135

1.378 +1.09 33e7

Symbol: A symbol in CLIPS is a sequence of characters that starts with any printable ASCII character and is followed by zero or more characters. The end of the symbol is reached when a delimiter is encountered. That is non printable ASCII characters like space, line feed, tabs, carriage return etc Example: fire, a81Ad @-+= 2xyz

CLIPS are a case sensitive language. So the symbols fire, Fire, FIRE are considered different symbols by CLIPS. String: String is a set of characters that starts and ends with double quotes Example: a and b number 8 24

External Address: An external address is an address of an external data structure returned by a user defined function. That is a function written in language such as C and linked with CLIPS to add additional functionality. Fact-address: The fact in CLIPS as referred by facts index; facts index are called factaddress Example: <fact-xxx> where xxx is called index

Instance-name: An object is an instance of a class; an instance-name refers to an object of the Specified name which is an instance of a user-defined class, instance name is represented by a symbol enclosed within left and right brackets Example: [abc] [value-03]

Instance-address: An object is an instance of a class; the address of an instance of user defined class is called instance-address. It is obtained as the return value from a function. Example: The instance-address is represented by <Instance-XXX>

Function: Function in CLIPS is a piece of executable codes with specific name which return useful value or perform useful actions. Different types of function are user defined functions and system defined functions. System defined functions are functions internally defined in CLIPS and user defined functions are functions externally defined to CLIPS environment in C, FORTRAN or Ada etc. and linked with CLIPS environment. Using deffunction constructs user can create new functions in CLIPS; these user function acts like any other functions. Example: CLIPS> (+3 4) CLIPS> 7 Constructs: Constructs are defined in CLIPS to change CLIPS environment adding to

CLIPS language base. Constructs form the core of CLIPS program by adding the programmers knowledge to the CLIPS environment and are different from functions and commands. Function calls return value but commands never have a return value. Different constructs available in CLIPS are defmodule, defrule, deffacts, deftemplate, defglobal, defmethod. Facts: Facts are the first component of a CLIPS system and are made up of fields, which are symbols, strings, integers or floats. Facts are one of the basic high-level forms for representing information in CLIPS. The number of facts in the fact list and the amount of information that can be included in the fact is limited by the memory of computer. CLIPS 25 deffunction, defclass, definstances, defmessage-handler, defgeneric, and

operate by maintaining a list of facts and a set of rules which operate on them. A fact is a piece of information such as (risk_factor smoking) or (risk_factor alcoholic) Facts are created by asserting them onto the fact database using the assert command .The assert command return a value called fact index. Example: CLIPS> (assert (risk_factor smoking)) <Fact-0>CLIPS> (assert (risk_factor alcoholic)) <Fact-1> The facts command can be used to display the facts in the fact list. CLIPS> (facts) f-0 f-1 risk_factor smoking risk_factor alcoholic

For a total of 2 facts The term f-0 and f-1 are called fact identifiers assigned to the facts by CLIPS and the integers following the letter f is called fact index. The facts command can be used to display the facts in the fact list. Facts can be retracted from fact data base by using retract CLIPS command Example: CLIPS> (retract 0) CLIPS> (facts) f-1 (risk_factor alcoholic) for a total of 1 facts A single retract command can be used to retract multiple facts at once. (retract 0 1) Will retract facts 0 and 1. The symbol * with the retract command would remove all facts CLIPS>(retract *) Facts are used to store a chunk of information in CLIPS. In that case facts consist of a relation name, the first field of fact, is normally used to indicate the type of information stored in the fact. The relation name (symbolic field) followed by zero or more slots (symbolic fields) and their associated values. The following is an example of a fact. (Person (name George) (age 45) 26

(gender M) (height 175) (weight 80)) Deftemplate construct: It is analogous to the record structure in languages like C or Pascal. Deftemplate construct is used to assign slot names to specific fields of a fact beginning with a specified relation name. Before facts can be created, CLIPS must be informed of the list of valid slots for a given relation name. Group of facts that share the same relation name and contain common information can be described using the deftemplate construct. So the person fact can be described with the following deftemplate. (deftemplate person (multislot name) (slot age) (slot gender) (slot height) (slot weight) ) Slots of a fact that have been specified with the slot keyword in their corresponding deftemplates are allowed to contain only one value. These are referred to as single field slots. Slots of a fact that have been specified with the multislot keyword in their corresponding deftemplates are allowed to contain zero or more values and are referred to as multislot fields. Ordered facts: Facts with a relation name that has a corresponding deftemplate are called deftemplate facts. Facts with a relation name that does not have a corresponding deftemplate are called ordered facts. Ordered facts have a single implied multifield slot that is used to store all values following the relation name. That is whenever CLIPS encounters an ordered fact it automatically creates an implied deftemplate for that fact. Since an ordered fact has only one slot, the slot name is not required when defining the fact. (number-list 7 9 4 5 6) It is equivalent in defining the following deftemplate (deftemplate number-list (multislot values)) And then adding the fact as follos (number-list (values 7 9 4 5 6)) Normally deftemplate facts use more because the slot name makes the facts more readable and easier to work with. There are two cases in which ordered facts are useful. First facts 27

consist of just relation name and used as flags, second for facts containing a single slot, the slot name is usually synonymous with the relation name. Slot values of a deftemplate facts can be modified using modify command. (modify<fact-index><slot-modifier>+) Where <slot-modifier> is (<slot-name> <slot-value>) Eg: CLIPS>(modify 0 (age 24)) The modify command works by retracting the original fact and then asserting a new fact with the specified slot values modified. A new fact index is generated for a modified fact. The facts in the fact list would be deleted, inserted or modified frequently; some fact indexes would be missing in the fact list. So the fact identifiers may not be strictly sequential as a CLIPS program executes. The duplicate command works in the same way as modify command with the exception that it does not retract the original fact. (duplicate <fact-index><slot-modifier>+) The deffacts construct: It is used to assert a set of facts instead of typing in the same assertions from the top level. This is true for facts that are known to be true before running the program that is initial knowledge. Groups of facts that represent initial knowledge can be defined using the deffacts construct. The general format of deffacts construct is (deffacts <deffacts name> <facts>) The deffacts name is any valid symbol. The facts in the deffacts statement are asserted using the CLIPS reset command. The reset command removes all facts from the fact list and then asserts the facts from existing deffacts statement. The syntax is (reset) It also create a new fact called initial-fact. Upon startup CLIPS automatically defines two constructs. (deftemplate initial-fact) (deffacts initial-fact (initial-fact) So if not define any deffacts statement, a reset will assert the fact initial-fact. The fact identifier of initial-fact is always f-0. The utility of initial-fact is to start the execution of a program.

28

Components of a Rule: An expert system consists of rules as well as facts. Rules can be type directly into CLIPS or loaded in from a file of rules created by an editor. Before rules created the deftemplate for the type of facts referred to by the rules must be defined. Rules can be entered by typing it after the CLIPS prompt.If the rule entered correctly, the CLIPS prompt will reappears; otherwise an error message will come. Comments can be including with rules but it should begin with a semicolon. The general format of the rule is (defrule <rule name>[<comment>] <pattern> ;LHS of the rule => <actions>); RHS of the rule A rule may have multiple patterns and actions. The entire rule must be surrounded by parentheses and each of the pattern and actions also must be surrounded by parentheses. The header of the rule consists of three parts. The rule must start with a defrule keyword, followed by the name of the rule. If the rule name already exist the new rule replace the old rule. The third part is an optional comment string. A comment is normally used to describe the purpose of the rule of any other information.

After the rule header are zero or more conditional elements (CEs).One is the pattern CE or simply pattern. Each pattern consists of one or more constraints intended to match the fields of a deftemplate fact. CLIPS attempted to match the pattern of the rule against the facts in the fact list. If all the pattern of the rule matches facts, the rule is activated and put on the agenda, the collection of activated rules. There may be zero or more rule in the agenda. The pattern of the rule follows an arrow indicating the THEN part of the IF. THEN rule.

The last part of rule actions will be executed when the rule fires. A program stops execution when there are no rules in agenda. When there are multiple rules on agenda CLIPS automatically determines which is the appropriate rule to fire. CLIPS orders the rules in agenda according to priority and execute the rule with highest priority. The priority of the rule is an integer attribute called salience. The list of rules on the agenda can be displayed with the agenda command. The syntax of the agenda command is CLIPS> (agenda)

29

Salience: CLIPS provide salience techniques for controlling the execution of the program. Salience allows the priority of rules to be explicitly specified. Normally the agenda acts like a stack. The most recent activation placed on the agenda is the first one to fire. Salience allows most important rules to be placed on the top of agenda regardless of when the rules were added. Lower salience rules pushed below the higher salience rules on the agenda. Salience is set using a numerical value ranging from the smallest value of -10,000 to the highest of 10,000.One of the use of salience is to force rules to fire in sequential fashion. Overuse of salience results poorly coded program. A well coded expert system needs not more than three or four salience values. Halt function: The halt function can be used on the RHS of the rule to stop the execution of rules on the agenda. It requires no arguments. When called control will return on the top level prompt. The halt function is particularly useful for halting execution when the user intends to restart execution later using the run command. BIND function: For storing value in temporary variable to avoid recalculation, the bind function can be used to bind the value of a variable to the value of an expression. The syntax is (bind <variable> <value>) The bind variable, <variable>, uses the syntax of a single field variable. The new value, <value> should be an expression that evaluates to either a single or a multi field value. In addition to creating new variables for use on the RHS of the rule, the bind function can also be used to rebind the value of a variable use in the LHS of the rule. Printout command: The RHS of the rule can use to print out information using the printout command. The syntax of printout command is (printout <logical name> <print-item>) Where <logical-name> indicates the output destination of printout command and <printitems> are zero or more items to be printed by this command. The letter t after the printout command indicates the destination of the output. This destination is also referred to as logical name. Normally the logical name t tells CLIPS to send the output to the standard output device of the computer, usually the terminal. So the default standard output device can be specified with the logical name t. The standard output device may

30

something else such as a modem or a printer. In that case other logical names can be used with the printout command to send the output to other destination other than screen. Eg:
(defrule smoking (declare (salience 80)) ?p <- (risk_factor smoking) => (printout t "Do you smoke? N=No Y=Yes" crlf) (bind ?smoke (read)) (while (and (neq ?smoke Y)(neq ?smoke y)(neq ?smoke N)(neq ?smoke n)(neq ?smoke Q)(neq ?smoke q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?smoke (read)) ) (if (or (eq ?smoke y)(eq ?smoke Y)(eq ?smoke N)(eq ?smoke n)) then (-----do required thing-----) ) (if (or (eq ?smoke y)(eq ?smoke Y)) then (-----do required thing-----))) (if (or (eq ?smoke Q)(eq ?smoke q)) then (halt)) (retract p) )

Refraction: Rules in CLIPS exhibit a property called refraction. It means CLIPS will not permit fire more than once for a specific set of facts. Without refraction expert system would always caught in trivial loops. That is as soon as the rule fired, it would keep on firing on that same fact over and over again. So refraction prevents rules from being constantly activated by old facts. A rule can be made to fire again by retracting the fact by using reset command and asserting it again. Suppose two rules are there in agenda for ready to execute. If run command issued the two rules would be executed and agenda would become empty. After enter agenda command no rules or activations would be there in the agenda.

A refresh command can be used to make the rule fire again. The refresh command places all activations that have already fired for a rule back on the agenda with the restrictions that the facts that triggered the activations are still present in the fact list. The syntax is (refresh <rule name>) Watch Command: Watch command is useful for debugging programs. The syntax is (watch <watch-item>) 31

Where watch is one of the symbols facts, rules, activations, statistics, compilations, focus or all. By default, when CLIPS is first started, compilations are watched and the remaining watch items are not watched. The word all can be used to enable all of the watch features.
CLIPS>(facts) f-0 (person (name George) (age 45) (gender M) (height 175) (weight 80)) For a total of 1 fact. CLIPS> (watch facts) CLIPS> (modify 0 (age 35)) <== f-0 (person (name George) (age 45) (gender M) (height 175) (weight 80)) ==> f-1 (person (name George) (age 35) (gender M) (height 175) (weight 80)) CLIPS>

The character sequences <== and ==> indicates that the fact is being retracted, the fact is being created.
CLIPS>(reset) CLIPS>(watch activations) CLIPS>(assert (risk_factor(smoking))) == >Activation 0 <fact 1> CLIPS>(agenda) 0 smoking : f-1 smoking: f-1

For a total of 1 activation. CLIPS> (retract 1) < ==Activation 0 CLIPS> (agenda) CLIPS> smoking: f-1

If rules are being watched, CLIPS will print a message FIRE whenever a rule is fired.
CLIPS> (reset) CLIPS> (watch rules)

32

CLIPS> (assert (risk_factor (smoking))) == > Activation 0 smoking : f-1 <fact-1> CLIPS> (run) FIRE 1 smoking: f-1 CLIPS> (agenda) CLIPS>

The effects of a watch command can be turned off by using corresponding unwatch command
(unwatch <watch-item>)

Loading Constructs from a file: A file of constructs made with a text editor can be loaded into CLIPS using the load command. The syntax is
(load <file name>)

Where <file name> is a string or symbol containing the name of file to be loaded. While loading the file the path name also should be specified. Normally the path is represented by backslash character. But CLIPS consider backslash as an escape character, two backslash are used to represent one backslash in a string. A file with name example.clp can be loaded as
(load c:\\user\\clips\\example.clp)

If no error occurs during loading the file, the load command will return the symbol TRUE otherwise return FALSE. Watching Compilations: When compilations are watched by default without using watch command, an informational message including the construct name is printed for each construct loaded by the load command. Eg:
CLIPS> (load thesis.clp) Defining defglobal: weight Defining defglobal: height Defining defrule: main_menu +j+j Defining defrule: personal_rule +j+j Defining defrule: smoking +j+j Defining defrule: alcoholic +j+j Defining defrule: diagnosisrule +j+j TRUE CLIPS>

The message indicates that the above deftemplates and defrules were loaded. The +j string at the end of the Defining defrule message is information from CLIPS about the internal structure of the compiled rules. If compilations are not being watched, then CLIPS prints a single character for each construct loaded: * for defrule, % for deftemplates and $ for deffacts.
CLIPS> (clear) CLIPS> (unwatch compilations) CLIPS> (load "duplicate.clp")

33

::::::::%$***************************************** TRUE CLIPS>

Saving Constructs to a File: The save command allows the set of constructs directly entered at the CLIPS prompt to be saved to a disk file. The syntax of the save command is
(save <file-name>) (save C:\duplicate.clp)

The save command will save all the constructs in CLIPS to the specified file. It is not possible to save specified files constructs to a file. But if an editor is used to create and modify the constructs, no need to use the save command. Commands for manipulating constructs: Displaying the list of members of a specified construct: (list-defrules): displays the current list of rules maintained by CLIPS. (list-deftemplates): displays current list of deftemplates (list-deffacts): displays the current list of deffacts
CLIPS> (reset) CLIPS> (list-deffacts) initial-fact For a total of 1 deffacts. CLIPS> (list-defrules) CLIPS> (list-deftemplates) initial-fact For a total of 1 deftemplate. CLIPS>

The ppdefrule (pretty print defrule), ppdeftemplate(pretty print deftemplate), ppdeffacts(pretty print deffacts) commands can be used to display the text representation of a defrule, deftemplate and deffacts respectively.
(ppdefrule <defrule name>) (ppdeftemplate <deftemplate name>) (ppdeffacts <deffacts name>) CLIPS> (ppdefrule smoking) (defrule MAIN::smoking (declare (salience 80)) ?p <- (risk_factor smoking) => (printout t "Do you smoke? N=No Y=Yes" crlf) (bind ?smoke (read)) (while (and (neq ?smoke Y)(neq ?smoke y)(neq ?smoke N)(neq ?smoke n)(neq ?smoke Q)(neq ?smoke q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf

34

"if you need to quit enter q...." crlf) (bind ?smoke (read)) ) (if (or (eq ?smoke y)(eq ?smoke Y)(eq ?smoke N)(eq ?smoke n)) then (-----do required thing-----) ) (if (or (eq ?smoke y)(eq ?smoke Y)) then (-----do required thing-----))) (if (or (eq ?smoke Q)(eq ?smoke q)) then (halt)) (retract p) )

The symbol MAIN:: preceeding each of the construct names indicate the module in which the constructs have been placed. (ppdefacts <initial-fact>) has no text representation since it is automatically created by CLIPS. Deleting a specified Construct member The undefrule, undeftemplate and undeffacts commands are used to delete a defrule, deftemplate and deffacts respectively. The syntaxes are (undefrule <defrule-name>) (undeftemplate <deftemplate-name>) (undeffacts <deffacts-name>) The initial-facts deffacts and initial-facts deftemplates can also be deleted using the above commands. If a reset command performed after that, the (initial-fact) would not be added to the fact list. If a symbol * is given as an argument to any of the construct deletion commands then all constructs of the appropriate type are deleted. (undefrule *) would delete all defrule constructs. Variables: CLIPS use variables to store values. Variables in CLIPs are written in the syntax of question mark followed by a symbolic field name. There should be no space between the question mark and symbolic field name. Variables are used on the LHS of the rule to contain slot values that can later be compared to other values on the LHS of the rule or accessed on the RHS of the rule. One common use of variable is to bind a variable on the LHS of the rule and then use that value on the RHS of the rule. . ?speed ?sensor ?value I/O functions: 35

Functions are entered at the CLIPS top level command loop or are used on the LHS or RHS of the rule. CLIPS provide several I/O functions. The open and close functions can be used to open and closing files. Opened files are associated with logical names. Logical names can be used in most functions that perform input and output to more than one type of physical devices. The printout and read function use logical names. The printout function can output to the terminal and files. The read function can input from the keyboard and files. The format function allows more control over the appearance of the output. The readline function can be used to read an entire line of data. Read function: This function is used to read information from the keyboard. The read function is used to input a single field at a time. To read more than one field as input it should enter in double quotes and treated as strings.
CLIPS>(read) South Africa South Africa CLIPS>

Open Function: CLIPS can read from and write to files. Before a file can be accessed for reading or writing, it must be opened using the open function.
(open<file-name> <file-id>[<file-access>])

<file-name> is a string representing the name of the file on the computer, <file-id> is the logical name CLIPS associates with the file. This is a global name by which CLIPS can access the file from any rule or the top level prompt. Mostly the logical name would be the same as file name. It is better to use another name to avoid confusion. <file-access> argument represent the access mode. It may be read access only (r),write access only(w), read and write access(r+), append access only(a). If file access not included as an argument the default value of r will be used. It return the symbol TRUE if a file successfully opened otherwise FALSE is returned. Close function: If the file is no need to access for a long time it should be closed.
(close [<file-ID>])

The optional argument <file-ID> is the logical name of the file to be closed. If <file-ID> no closed all open files will be closed. All open files will be closed when an exit command is issued. Reading and Writing to a file: For writing to a file, first the file opened with write access using open function. Then the values are written to the file using the <file-ID> or logical name as the first argument of the printout command, follows the values that need to write to 36

the file. Once the value has been written to the file, the file is closed using the close command. For reading that file first open the file using open function with read access then use read function with logical name or file-ID. The read function defaults to reading from the standard input device, t, if it is given no arguments. Format Function: It is used to format output from a CLIPS program. (format <logical-name><control-string><parameters>) The <logical-name> is the logical name where the output is sent. The control string consists of format flags, which indicate how the parameters to the format function should be printed and which contained within double quotes. Following the control string is a list of parameters. The return value of the format function is the formatted string. Format function is useful for displaying columns data. Format flags always begin with a % sign. readline function It is used to read an entire line of input. (readline [<logical-name>]) It will return the symbol EOF if the end of file has been reached if the logical name used by readline is associated with a file. Predicate Functions: Any function that return either the symbol TRUE or the symbol FALSE.It may be either predefined or user defined functions. Predefined functions are those functions already provided by CLIPS. User defined or external functions are functions other than predefined functions that are written in C or another language and linked with CLIPS. Open function is a predicate function. Utility Commands: The system command: It allows the execution of operating system commands from within CLIPS. The syntax is (system <expression>) The effects of system command may vary from one operating system to another. Not all operating systems provide the functionality for implementing the system command. The system command does not return a value. So it is not possible to directly return a value to CLIPS after executing an operating system command.

37

The Batch Command: The batch command allows commands and responses that would normally have to be entered at the top level prompt, to read directly from a file. The syntax of batch command is (batch <file-name>) In CLIPS the commands and responses that must be entered to run a CLIPS program is stored as a batch file with extension .bat. CLIPS>(batch batchfilename.bat) Then all commands and responses have been read from the batch file, and return the top level prompt. When run under operating system that support command line arguments for executables such as UNIX and DOS, CLIPS can automatically execute commands from a batch file on startup. The syntax for executing a batch file on startup is Clips f <file-name> Using the f option is equivalent to entering the command (batch <file-name>) once CLIPS has been started. Control Elements (CE): There are several control elements in CLIPS for controlling the flow of execution. 1) test CE: Test control elements along with predicate functions can be used on the LHS of the rule, to do a certain amount of expression evaluation on the left hand side of the rule.
(deftemplate personal-data (slot name) (slot age) (slot weight) (slot height) (multislot blood-pressure) ) (deffacts people (personal-data (name Andrew) (age 20) (weight 80) (height 188) (blood-pressure 130 80)) (personal-data (name Cyril) (age 63) (weight 70) (height 1678) (blood-pressure 180 90))) If want to print the name of persons, whose weight more than 100 use test CE. (defrule overweight (personal-data (name ?name) (weight ?weight)) (test (> ?weight 100)) => (printout t ?name " weighs " ?weight " kg - the fat sod." crlf) )

In this case, it will match facts where the value of the weight slot is greater than 100 kg. 2) and CE: 38

This CE used along with predicate functions on the LHS of the rule. (and(predicate 1)(predicate 2))
(defrule print-ages (and (personal-data (name ?name) (age ?age)) (personal-data (name ?name) (weight ?weight)) ) => (printout t ?name " weighs " ?weight " at " ?age " years old." crlf))

3) or CE: This CE used along with predicate functions on the LHS of the rule. (or(predicate 1)(predicate 2)) The or CE is used to express several rules as a single rule .If two rules satisfying same action, using or CE it can make as a single rule. The not CE allows pattern matching against the absence of a fact in the fact list. Eg: (defrule take-an-umbrella
(or (weather raining) (weather snowing) ) => (printout t "Take an umbrella" crlf) )

4) not CE: If need to activate rules based on the absence of a particular fact in the fact list use not CE. not(predicate 1) 4.2.5 GARBAGE COLLECTION Garbage collection is a process used by CLIPS to manage memory that most users do not need to understand to use CLIPS. In some cases, when users embed CLIPS within their applications, knowledge of the garbage collection process is necessary to understand when values returned by CLIPS to an embedding program can be safely accessed. As a CLIPS program executes, it allocates and deal locates numerous types of data structures. In many cases, some data structures cannot be immediately deallocated because either outstanding references to the data structure still exist or the need to deallocate the data structure is questionable. Data which has been marked for later deallocation is referred to as garbage. The process of deallocating this garbage is referred to as garbage collection. CLIPS only perform garbage collection when it can determine that it is safe to deallocate the data Structures marked for deallocation. 39

LITERATURE REVIEW

5. LITERATURE REVIEW

5.1.

REVIEWED PAPERS

1) ES DIABETES (An Expert system In Diabetes) This expert system is developed by Computer Science graduate students in Texas A&M University Corpus Christi. This is an ACM paper and the article is also published Consortium for Computing Sciences in Colleges, USA and the journal of computing sciences in colleges in 2001. ES Diabetes is the result of two research papers. The first phase was done by the graduate students of the same university in 1999.They did the literature review including software tools applied to diabetes. They presented a small prototype in CLIPS 6.0.The second phase has done by the same university graduate students in 2000. Description ESDIABETES is especially designed for type 2 diabetic patients. This system helps people to control blood glucose level. By using ES Diabetic people can enter their symptoms and blood sugar level at any time and get treatment suggestions of their blood sugar level. There is an interaction between ESDIABETES and Expert system user. ES DIABETICS will ask questions and user give answer. This procedure will continue until ESDIABETICS get enough information and give recommendation. The questions are put in different categories like personal information, diabetics symptoms experienced by the person or not, what type food they are consuming and how much quantity ,what is the blood sugar level and whether the person taking insulin shot or not, where it store ,how much quantity, who give shot etc. Once the system gets enough information it will give recommendation to maintain the blood glucose level within normal level. Limitation The domain chosen for this expert system is Diabetes type 2. So this expert system can use by only those people who know that they are type 2 diabetic. The system will ask the present symptoms ,blood glucose level, diet ,what medication currently following etc and according to the answers the system reach a conclusion and will give the treatment. Eg: According to the glucose level and diet today, you need to take 5 units of insulin. The system cant give treatment for diabetes type 1 and gestational diabetes. It is not diagnose the disease. In market already have diabetes monitoring instruments available eg: glucometer. They will help people 40

to monitor their blood glucose level. ES DIABETES helps to control the blood sugar level by giving some treatment suggestion. 2) Diabetes Expert System This expert system is developed by Jiang-Ming_yan and Chen Zhi-jian Electronic engineering department of Shandog University, Jinan, China in 1997.This is an IEEE article and is presented in IEEE international conference on intelligent processing system Beijing, China. Description This medical expert system is used for diagnosis, treatment and teaching of diabetes. It uses the inference mechanism of forward, backward, forward-backward and inaccurate method and it will judge the possibility of illness, whether light or severe and complications according to the patients symptoms and give some treatment and suggestions. It can also use for teaching practice. The system is made using turbo PROLOG (Programming Logic) and C language. Limitation PROLOG is not a specially designed language for expert system. It is a backward chaining artificial intelligence language, used for expert system applications. It is a logic based language. In PROLOG the knowledge is represented as logical statements and programs are expressed in terms of relations, and execution occurs by running queries over these relations. PROLOG is mainly used for symbolic manipulation especially for first order predicate calculus and database applications. 3) A proposed Expert system for Skin disease Diagnosis This expert system is developed by Samy .S. Abu Naser and Alaa N. Akkila faculty of engineering and information technology, Al-Azhar University, Gaza, Palestine. This paper is publisher by INSInetPublication In the journal of Applied Sciences Researches in 2008. This expert system is designed for the diagnosis of different types of skin diseases. There are many types of skin diseases and almost all symptoms of skin diseases are same. So the important thing to get the good and correct treatment is to right diagnose the skin disease. This expert system designed to help dermatologists to diagnose nine skin diseases. They are Psoriasis, Eczema, Ichthyosis, Acne, Meningitis, Measles, Scarlet fever, Warts, Insect Bites and Stings. It gives an overview of the nine skin diseases and outlines the causes also. In some cases it prescribes treatment also. For developing the expert system, use CLIPS as the programming language. 41

Description: It is a menu based system. In this expert system the nine skin diseases are divided into three main categories. Skin rashes without fever, skin rashes with fever, skin infections. The system will ask the user to enter the correct option. While diagnosing the system will give an overview about the disease, what are causes of the disease and prescribe some treatment and advice. It starts to ask some general information and finally end the diagnosis of the disease. The main source of the knowledge for making the expert system is dermatologists and some is specialized websites of skin diseases. The collected knowledge converted as CLIPS knowledge base syntax (facts, rules). This expert system consists of around 60 rules to cover the nine skin diseases. 4) Expert System for Endocrine Diagnosis and Treatment Using JESS This expert system is developed by faculty of engineering and Information Technology, AlAzhar University, Gaza, Palestine. This paper is published by Asian Network for Scientific Information in 2010 on the Journal of Artificial Intelligences 3(4): 239-251, ISSN 1994-5450. Description: This Expert system introduced the design and development of a system that can able to fully diagnose and treatment for Pancreas, Thyroid and parathyroid glands and disease. This system can help the physician to their work. This expert system not meant to replace the human physicians but using such a system may useful in cases like overcoming the problems of shortage in human physicians and accuracy and speed in processing facts. The endocrine system is one of the most important parts of the human body. It includes hypothalamus, pituitary gland, pineal gland, thyroid gland, parathyroid gland, heart, adrenal gland, kidney, stomach, pancreas, intestine, ovaries in female, testes in male etc. The glands in the endocrine system and the hormones they produce not only influence the organs in human body but also influence every cell and overall functions of the body. The endocrine system is in charge of the body processes that occur slowly such as cell growth.

The developed system does the following: Diagnosing diseases related to pancreas, thyroid and parathyroid glands and give possible treatments, helping newly graduated physicians in diagnose patients case and learn from it

42

and it can use for very urgent cases .So it can use in ambulances to serve urgent cases of fainting. It can use in emergency when the physicians are busy with other cases. This expert system use Java Expert system shell (JESS) to perform its functions, facts and procedures. It is a rule based engine for the Java language platform which is a superset of CLIPS programming language. It provides rule based programming suitable for automating an expert system and is often referred to as expert system shell. The system requires Java version 1.6.0 or 1.5.0 running on Windows XP or Windows Vista Home premium. 5) Artificial Intelligence Approach to Diabetes Diagnostics: This paper is published by international book series on the journal Information Science and Computing in 2009.The authors are Galina Setlak, Mariusz Dbrowski, Wioletta Szajnar, MonikaPirg-Mazur and Tomasz Koak. In this paper a concept of designing and building intelligent system in diabetes diagnostic is introduced. It explains three different categories of intelligent systems based on artificial intelligence. They are expert system, neural networks and hybrid system. Finally this paper explains that in medical field artificial intelligence or expert system is very important, that need experts knowledge. So author takes diabetes disease as a case study to develop an expert system in medical field. The methods used by the expert, classifying the input data system (symptoms) for four types of diabetes (classes) have been shown in that article. Like an expert, an expert system can diagnose the different types of diabetes. It may be Type 1, type 2, other classes of diabetes or pregnancy diabetes. For the diagnosis the one has to gather proper set of data. The source of data can be the following: Patients himself, patient records, primary physician, specialist, biochemical lab,, specialist tests. The system gathers data by the following tests: Subjective tests, objective tests, laboratory tests and additional tests. Subjective test: It means history taking. It include data such as name, surname, age, occupation, life style , patients family history like whether parents are diabetic or not ; if so what medication using, how long they got the disease etc. Objective test : It include height and body mass measurement and comparing the real mass, heart test, thyroid test, pressure checkup, neurology test, teeth and gum test, skin test etc. Laboratory tests: Blood glucose level in empty stomach and daily profile, HbA1C results, Lipid profile test in empty stomach for find out cholesterol and triglyceride level, urine test, 43

bacteriological

test,

peripheral

arteries

test,

electrocardiogram,

neurological

test,

ophthalmological test etc. Additional test: Collect details of some additional test like fundus test. After gaining all information of patient, symptoms, disease and basic tests the expert system draws conclusion. Diagnosing is done on the rule of moving on the decision tree. The system recognises four classes of diabetes. The final statement is the patient is having diabetes of the particular type and recommended remedy is proper diet and pharmacological treatment. So this paper says that if analyze the ways in detail, it is notice that the particular phases do not differ from the doctors way of proceedings. Always an expert system has a task to achieve the appropriate conclusion, behaving like an expert in that field .In this article the expert is a doctor, specifically a physician or endocrinologist.

44

METHODOLOGY

6. METHODOLOGY

6.1.

DESCRIPTION OF THE DEVELOPED SYSTEM

The proposed expert system, An Expert System for Diabetes Diagnosis (ESDD), is a rule based medical expert system for the diagnosis of diabetes using CLIPS as the programming language. Forward chaining inference mechanism is employed in ESDD. This is a menu based interactive system where systems communicate with user in common understandable language. The system consists of multiple options to Diagnosis, Complications and Diabetes Trainer. As the system uses plain English language to interact with user no special knowledge required for individual to use. In the Diagnosis option, based on the individuals answer the system concludes the level of diabetes impact in the person. In case of Complications the user will be able to understand the seriousness of diabetes in human life. The system is also provided with diabetes training option which can be used to develop diabetes awareness among the people. The system will give some details of each symptom to the user during the diagnosis process thus helps the user to learn by doing. Normally the doctors wont get time to explain the reasoning to each patient, but the expert system give the explanation about the cause of the disease. So the user will get knowledge about the symptoms so they can control the disease themselves. The diabetes symptoms are categorized into risk from individuals life style, risk from family history, classic symptoms, complicated symptoms and other symptoms. The symptoms are stored in facts list. Different rules exist for different symptoms. The system consists of 41 rules. It provides a simple, interactive, text oriented, command prompt, menu based interface. It stores all the rules as a batch file. So the series of rules can automatically read or run directly from a batch file as a result of a batch command. That is whenever the user click the batch file icon, the CLIPS file with rules will start automatically.

The proposed expert system is not a substitute for physician; expert system will provide a generic conclusion based on user input. The application will identify the diabetes risk in

45

individual but cannot identify diabetes is Type 1 or Type or Type3. The system wont be in a position to recommend treatment. 6.2. EXPERT SYSTEM DEVELOPMENT PROCESS

Figure 3: Hierarchy of expert system development process Background/Literature Review: The first step in developing an expert system is to study about the background details and concepts about expert systems and made literature review from journals, books, websites etc. There are already several expert systems developed in many fields including medical field. In case of diabetes, there are many expert systems available and they used different approaches and different tools. Some systems are specially designed for type 1 diabetes or type 2 diabetes. In that also there are different cases like, diagnosis, diet planning, telemedicine, treatment etc. Concepts: Second step is to do a well study about expert system and its internal parts, how it works, different concepts like rules, facts, inference methods etc. The expert system for diabetes diagnosis uses rules based approach and forward chaining inference method.

Problem Selection: Selecting an appropriate problem is very important in the development process. There are some general considerations should be made before start to develop an expert system. There should be a clear identification of the problem, from where will get the experts knowledge or how to do knowledge acquisition and who will be the users. All people know at least one person with diabetes. Diabetes is such a common disease or metabolic disorder that may affect anyone at any age because of a lot of risk factors, life style etc. This 46

paper selects the problem of diagnosing the disease diabetes by developing an expert system using the tool CLIPS version 6.3 and Windows/DOS environment Knowledge Acquisition: Knowledge elicitation was performed through Knowledge Acquisition: It is the process of transfer the problem solving expertise from knowledge source to computer code. Basic information about the diabetes diseases, risk factors, symptoms and treatment were collected from books, different web sites and diabetes journals. There are several techniques to do knowledge acquisition from expert person like direct interview, videotap, diagram, trees etc. The method used for this work is direct method. The knowledge acquisition for this paper consists of interview with two doctors. Fist, Doctor P.V. Abdulla, Rtd. District medical officer (DMO), currently working as chief medical officer of Life Care Hospital, Trikaripur, Kerala. He gave a lot of information about diabetes including symptoms, diagnosis, complications, treatment etc. Second, for getting the diabetes information about childrens, made a direct interview with Dr. Basawana Gowda, pediatrician of Apollo hospital, Electronic City, Bangalore. More over a lot of information are available from the different websites, some books, diabetes journals etc. Data Collection: In case of medical field data collection can be done from direct interview with patients, their past history, their physical examination records, laboratory test results etc. For this paper work the chief medical officer Doctor P V Abdulla gave an opportunity to meet patients directly from the lab and talked with them directly about their initial symptoms, current blood sugar level, and their physical problems etc. The patients interactions were very friendly. They were very open to tell what were their initial symptoms, what made them to consult a doctor ,what were their initial blood sugar level, currently how they are controlling blood sugar like medication, exercise , food they are consuming etc. Most of them think that one of the symptoms of diabetes like hair loss is common. But in case of diabetes, the hair loss is not a regular hair loss; they will lose their eyebrow, eye lashes etc because of high blood sugar. Some of the patients were type 1 diabetes and they are regularly taking insulin injection one or more than once daily. For collecting the data a template is made for each patient and collected 40 patients details. The format of template is given below.

47

PATIENT DETAILS Personal Details Name Age Gender Height Weight Find out BMI and check overweight or not For ladies birth size of babies born to them Do you Consume Alcohol? Do you Smoke? Do you chew tobacco? Occupation Family History Diabetic : Cholesterol : Hypertension : Classic Symptoms Frequent urination with large volume of urine (poly urea): Yes / No Excessive thirst (polydipsia) Extreme Hunger (polyphagia) Unusual weight loss Other Symptoms Increased fatigue Feeling very tired Feeling ill Hair loss or thinning of hair Nausea Vomiting Leg pain Sugar in urine Dry mouth Irritability Sleep disorder Gestational diabetes Impotence (in male) Lethargy Unexplained aches and pains Over eating and rapid weight gain Loss of consciousness Taking steroid medicine for Asthma : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No Father Mother Brother Father Mother Brother Father Mother Brother : : : Yes / No : Yes / No : Yes / No : : : : :

Date:

: Sedentary/Active

Sister Sister

Others Others

Sister

Others

48

Complication Symptoms Blurry vision Dry, itchy skin Bladder, Skin, or vaginal infection (in female) Swollen red gums and loosing teeth Delayed wound healing Bruises that wont go away Sores that wont heal Tingling or numbness in hands or legs A feeling of pins and needles in feet Burning pain in legs, feet, arms Fruity smell of breath and sweat High Cholesterol High Blood Pressure Lab Details Fasting Blood sugar(FBS) Post prandial Blood sugar (PPBS) Random Blood sugar (RBS) Blood pressure (BP) Cholesterol HbA1C : : : : : : : Yes / No : Yes / No : Yes / No : Yes/No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No : Yes / No

Table.2: Diabetic Personal Detail Tool Selection: The expert system developed using CLIPS language version 6.3 in Windows platform. CLIPS are a specially designed tool for expert systems. CLIPS expert system may be executed in three ways: interactively using a simple, text oriented, command prompt interface; interactively using a window/menu/mouse interface on certain machines, or as embedded expert system in which the user provides a main program and control execution of the expert system. In addition, a series of commands can be automatically read directly from a file when CLIPS is first started or as the result of the batch command. Knowledge representation: The collected knowledge has been converted into CLIPS knowledge base syntax. That is facts and rules. Currently the expert system consists of 41 rules. Each rule is a symptom. There is a brief description of the cause of each symptom. So the expert system can help the user to give knowledge about the symptom or the cause of the symptom Development process: This includes Analysis Design 49

Coding Testing Implementation

Analysis: In this system for diabetes diagnosis 41 different rules are used. These rules involve personal life style, family back ground, normal diabetes symptoms and other complications. Among these 31 rules are diabetic symptoms, 2 rules are personal habits like smoking, alcoholic 5 rules are persons details like BP, cholesterol, triglycerides, life style family diabetic history . The remaining 2 rules are for representing the main menu and personal information like gender, age, height, weight. The last rule is diagnosis rule. From the height and weight the system will calculate BMI index ( wt/(ht*ht)) and say whether the person is underweight, overweight or obese. It is decided that system will be using a score based approach to identify whether the individual is diabetic or not. Depending on the importance of the rules the weight of the score will be varying. The score levels to conclude the chance for different level of diabetes are decided after discussion with medical practitioner.The system can give reasoning for the symptoms like what is the cause of the symptoms. BMI index: BMI is a measure of body weight based on a persons weight and height and estimate whether individual is underweight, overweight or obese. A BMI of 18.5 to 25 indicate optimal weight; lower than 18.5 indicate underweight and above 25 indicate the person is overweight. A number above 30 suggest the person is obese. Obesity is one of the risk factor of diabetes. All should take care their body weight and maintain it as optimal weight always. Smoking: Smoking is one of the risk factor of diabetes. Smoking raises blood glucose levels and blood pressure. That is smoking decrease the bodys ability to use insulin and it can also change the way the body stores excess fat- increasing fat around the waist, which is linked to diabetes. The damage that tobacco chemicals do to blood vassals, muscles and organs may also increase the risk of diabetes. 25% of smokers affected with diabetes after 5 years compared to 14% of never smokers. The relative risk for developing diabetes is 2.1 times more than compared to non smokers. Alcoholic: Alcohol consuming is another risk factor of diabetics. Alcohol being high in calories increases blood sugar. In excess, it prevents the liver from releasing sugar in the blood, leading to hypoglycemia or very low blood sugar levels. Hypoglycemia caused by drinking is particularly serious and can even be fatal. Besides, alcohol also interferes with the working of diabetes medication and health. Moderate alcohol (about one drink a day for 50

women and two for men) has been shown to decrease the risk of diabetes compared to nondrinkers. Life style: The lack of daily physical exercise leads to obesity. It is a major factor of developing type 2 diabetes. Obesity caused insulin resistance. Blood Pressure: Diabetes and high blood pressure (hypertension) are serious disorders.

Complications from diabetes develop much more quickly if blood pressure is high. Many patients with diabetes also have high blood pressure. It has been estimated that high blood pressure is twice as likely to be present in a person with diabetes as compared to someone who does not have diabetes. It increases the chance of developing heart disease, a stroke and some other complications. Diabetes and high blood pressure are like twins. One of the diabetes prevention methods is controlling high blood pressure. High Cholesterol level: Diabetic patients have to be extremely vigilant about controlling

cholesterol Diabetes raise the amount of LDL cholesterol ("bad cholesterol") that tends to form plaques in arteries, and lower the number of HDL cholesterol particles (good cholesterol) that help to clear out dangerous plaques before they break off to cause a heart attack or stroke. High cholesterol can also be a predictor of diabetes; elevated cholesterol levels are often seen in people with insulin resistance, even before they have developed fullblown diabetes. High Triglyceride level: Diabetes also tends to cause higher levels of triglycerides. Triglycerides are a kind of fat. When you eat, the body uses the food it needs for immediate energy and stores the rest in the form of triglycerides. Triglycerides are stored in the fat cells, but they also circulate in the blood and can be measured in a blood test. When too many triglycerides are in your blood, they build up on the walls of your arteries in the form of sticky plaque, causing them to narrow and harden. A triglyceride level of 150 mg/dl or more is considered high. Family Diabetic history: Genetics most likely plays a role in all types of diabetes, since a family history is a major risk factor. Type 2 diabetes runs in families. In general, if the individual has type 2 diabetes, the risk of thechild getting diabetes is 1 in 7 if the individual diagnosed before age 50 and 1 in 13 if the individual diagnosed after age 50.Some scientists believe that a child's risk is greater when the parent with type 2 diabetes is the mother. If both you and your partner have type 2 diabetes, your child's risk is about 1 in 2. If you are a man with type 1 diabetes, the odds of your child getting diabetes are 1 in 17. If you are a woman with type 1 diabetes and your child was born before you were 25, your 51

child's risk is 1 in 25; if your child was born after you turned 25, your child's risk is 1 in 100.Your child's risk is doubled if you developed diabetes before age 11. If both you and your partner have type 1 diabetes, the risk is between 1 in 10 and 1 in 4. Gestational Diabetes: This appears during pregnancy in some women with no previous type-1 or type-2 diabetes and usually goes away after pregnancy. But after pregnancy 5 to 10 percentage of women with gestational diabetes are diagnosed with type 2 diabetes. Pregnant women have enough insulin, but the effect of insulin is partially blocked by other hormones produced in the placentas during pregnancy period. Excessive Thirsty: Excess thirsty happens because due to diabetes the body has excess glucose, which draws water from the body tissues. This causes to feel dehydrated often and tend to drink more water or other drinks. That is as the concentration of glucose increases in the blood, brain receives signal for diluting it and, in its counteraction we feel thirsty. Frequent Urination: Frequent urination often occurs with sugar diabetes, day and night. Increase in urine production is due to excess glucose present in body. Body gets rid of the extra sugar in the blood by excreting it through urine. This leads to dehydration because along with the sugar, a large amount of water is excreted out of the body. Diabetic patients have a tendency to drink lot of water due to dehydration that leads to more frequent urination throughout the day as well. Extreme Hunger: Because the glucose in the food you eat is not being used effectively the person may experience an increase in appetite as the body demands more. The hormone insulin is also responsible for stimulating hunger. In order to cope up with high sugar levels in blood, body produces insulin which leads to increased hunger. Sudden Unusual Weight Loss: The person may experience a sudden unexplained weight loss in spite of an increase in appetite, for the reason that the body cant utilize the food specifically the carbohydrate, into energy and fat, so it cant be stored and muscles lose already stored proteins, fat for bodys functions and cause weight loss. Feeling fatigue or drowsiness: The people will get the feeling of fatigue, drowsiness or not getting proper sleep because the glucose is not used to produce energy. Due to inefficiency of the cell to metabolize glucose, reserve fat of body is metabolized to gain energy. When fat is broken down in the body, it uses more energy as compared to glucose; hence body goes in negative calorie effect, which results in fatigue. Nausea and vomiting: They are the primary symptom of type 1 diabetes. Type 2 diabetes also get these symptom. In absence of insulin, body cells dont get the required glucose for 52

producing ATP (Adenosin Triphosphate) units which results into primary symptom in the form of nausea and vomiting. This may also a symptom of Diabetic ketoacidosis. Diabetic ketoacidosis is a serious condition in which uncontrolled hyperglycemia over time creates a buildup in the blood of acidic waste products called ketones. High levels of ketones are very harmful. This is particularly happens in people with type 1 diabetes who do not have good blood glucose control. Diabetic ketoacidosis is caused by infections, stress, trauma, missing medications like insulin or medical emergencies like stroke and heart attack. Feeling ill, tired or aging: Almost everyone suffering from this condition first has a prediabetes, meaning their blood glucose level are higher than the normal level but have not yet reached to the range of diabetes .It is due to decrease in energy production by the cells. Hair loss: Diabetes is a hormone related disorder that often leads to hair loss or thinning of the hair from whole body like eyebrow, eyelashes etc. Frequent loss of hair is often considered one of the early symptoms of diabetes, which gradually leads to thinning of hair. Weight gain: The desire for too much food is sometimes as a result of losing too much fluid or sugar. The body tries to compensate with cravings of sweets or other foods. Only few diabetic type 2 people will experience weight gain. Stomach pain: Persons with diabetes may develop abdominal pain, nausea, vomiting because of gastroparesis, a condition in which the stomach fails to empty properly and their blood sugars become abnormally high or low (hyperglycemia or hypoglycemia) because the sugar and insulin balance is disturbed. Gastroparesis may occur in people with type 1 diabetes or type 2 diabetes. In turn, gastroparesis contributes to poor blood glucose control. Sugar in Urine: An increase in the glucose levels in urine above normal. Diabetes is one of the possible causes of Sugar in urine. If a person has sugar in urine means, the patient has diabetes, or is at risk of diabetes, or has a family history of diabetes. Irritability: It is a sign of high blood sugar because of the inefficient glucose supply to the brain and other body organs, which make us feel tired and uneasy. Muscle cramps: Pain or recurring body aches is a predominant feature among diabetes patients. This is largely contributed by the rise in sugar or glucose levels in our body over a very long period of time. One of the major pitfalls of diabetes is the wear and tear of the nerves which leads to a condition we commonly refer to as pain. Genital infection: If the blood glucose is high, especially women will get urinary tract and genital infection because the increased blood glucose level supports bacterial growth.

53

Lethargy: Lethargy, a general low energy level and lack of response. Lethargy is a fairly imprecise description of the feeling or slowness, sluggishness, tiredness, or lack of energy. Lethargy is one of the symptoms of uncontrolled/poorly controlled diabetes. Untreated or not adequately treated, the diabetic's tissues are unable to use glucose amino acids and fatty acids properly. It normally resolves quickly after starting insulin therapy. Blurred Vision: Blurred vision occurs when the high levels of glucose in the blood causes water from the lens to go outward and deforming the lens, making the vision unfocused. Other retina damage symptoms: The diabetic patient may not have any signs of diabetes retina damage, or may have one or more signs because of high level of glucose in the blood like flashing light or blank spot, pain or pressure in one or both eyes. Dry itchy skin: If the blood glucose is high, the body loses fluid. With less fluid in your body, the skin can get dry. Dry skin can be itchy, causing you to scratch and make it sore. Nerve damage can decrease the amount you sweat. Sweating helps keep your skin soft and moist. Decreased sweating in your feet and legs can cause dry skin. Dry cracked skin: Dry skin can crack. Cracks allow germs to enter and cause infection. If your blood glucose is high, it feeds germs and makes infections worse. You may get dry skin on the legs, feet, elbows, and other places on the body. Athletes foot: Athletes foot is a fungus that causes itchiness, redness, and cracking of the skin. The cracks between the toes allow germs to get under the skin and cause infection. If your blood glucose is high, it feeds the germs and makes the infection worse. The infection can spread to the toenails and make them thick, yellow, and hard to cut. Sores not heal: High blood sugar resists the flourishing of WBC, (white blood cell) which is responsible for body immune system. When these cells do not function accordingly, wound healing is not at good pace. Secondly, long standing diabetes leads to thickening of blood vessels which affect proper circulation of blood in different body parts. Tingling or numbness in hands or feet: Tingling and numbness in hands or feet is a symptom of diabetic neuropathy. Neuropathy (or diffuse neuropathy) is a nerve disorder of which there are 2 types - peripheral-which affects the feet and hands-and autonomic-which affects the body's internal organs. Diabetic neuropathy is a nerve disorder caused by either type 1 or type 2 diabetes. Pins and needles in feet: One of the major pitfalls of diabetes is the wear and tear of the nerves which leads to a condition we commonly refer to as pain. The feeling of pins and needles in feet is another symptom of diabetic neuropathy. Diabetic who do not strictly 54

control their condition, may develop damage to the nerves around the body. The longer a person has diabetes, the greater the risk becomes of developing neuropathies. Burning pain in legs, arms and feet: Burning pain means occurrence of pain that feels like burning is a symptom of diabetic neuropathy. Neuropathy may affect up to 50% of people with diabetes. These may be minor at first, and therefore may remain unnoticed as the condition develops gradually. However, in some types of diabetic neuropathy, the onset of the pain will be sudden and sever. Dry mouth: Diabetes is a disease that can affect the whole body, including mouth. This is the effect of excessive urination. Dry mouth is often a symptom of undetected diabetes. Uncontrolled diabetes can decrease saliva flow, resulting in dry mouth. Dry mouth can further lead to soreness, ulcers, infections, and tooth decay. Uncontrolled diabetes impairs white blood cells, which are the body's main defense against bacterial infections that can occur in the mouth. Gum disease: Diabetic patients will get gum problems like red, swollen or bleed gums. Diabetes reduces the body's resistance to infections; the gums can become one of the tissues likely to be infected when plaque and tartar are not removed daily. Uncontrolled diabetes causes blood vessels to thicken, which slows the flow of nutrients to and waste products from body tissues, including the mouth. When this combination of events happens, the body's ability to fight infections is reduced. So uncontrolled diabetes may experience more frequent and more severe gum disease. Fast breathing and fruity smell of breath and sweat: A fruity odor to the breath occurs as the body attempts to get rid of excess acetone through the breathing. This is a sign of ketoacidosis, which may occur in diabetes. It is a potentially life-threatening condition. DKA happens in both type 1 and type 2 diabetes but most common with type 1 DKA results from an absolute shortage of insulin; in response the body switches to burn fats for energy. The constant break down of fat, releases fatty acids and ketone bodies. In high levels, ketones are poisonous; causing chemical imbalance (metabolic imbalance) called Diabetic Ketoacidosis. Frequent headache: Due to the high blood glucose level, people will get continuous headache frequently and it will last some 2 to 3 days. This type head ache may happen in children because of type 1 diabetes. Feel giddiness or faint: With high level of glucose in the blood and low energy level in the body cause the person to feel faint or fall in to unconscious.

55

Figure 3: Decision Flow diagram for Diabetes Diagnosis Expert System.

56

57

58

59

60

Design: The different symptoms used for this expert system and the score has given by the system are as follows.
Rule# 1

Rule Name Age above 45 BMI is above level 30(obesity) Smoking habit Alcoholic No Regular exercise + overweight High Blood Pressure High Cholesterol level High triglyceride level Family Diabetic history Gestational diabetes

Score 1 2 1 1 1 1 1 1 3 3

2 3 4 5 6 7 8 9 7

Classic symptoms 8 9 10 11 12 13 Excessive Thirsty Frequent urination Extreme hunger Sudden unusual weight loss Feeling Fatigue/drowsiness Nausea/Vomiting sensation with no cause 14 15 16 Blurred Vision Delayed healing of Sores/wound Fast breathing and Fruity smell of breath/sweat Other symptoms 17 18 19 20 21 22 Tiredness/Feeling ill Unusual Hair loss Over eating & rapid weight gain Stomach pain/abdominal pain Sugar in urine Feeling of irritability 61 2 1.5 1 2.5 1 1 5 5 5 5 5 5 5 5 5

23 24 25 26 27 28 29 30

Feeling of Muscle cramps Genital infection Lethargy Other retina damages Dry itchy skin Dry cracked skin Athletes Foot Tingling or Numbness in hands/legs

1 2 2 1 1 1 1 2.5

31 32 33 34 35

Pin/needles feet Burning pain in arm/hands/feet Dry mouth Gum diseases Two three days lasting Frequent headache in children

2.5 2.5 1 1 2

36

Feeling Dizziness/faint frequently in children

37

Abdominal pain in children

Table 3: Rules employed for ESDD

Each symptom is represented as rule in this CLIPS based system. To control the execution of the rule fact assert and retract method will be using. The initial rule to be executed is decided by salience of the rule. Define the required global variable Define definition template, personal_info, with slots personalinfo and factsseq Define definition facts, personal_detail and assert below facts in personal_info

(personal_info (personalinfo "What is your height in cm?")(factsseq personalfact4)) (personal_info (personalinfo "What is your weight in Kg?")(factsseq personalfact3)) (personal_info (personalinfo "What is your age?")(factsseq personalfact2)) (personal_info (personalinfo "What is your gender? (M/F) ")(factsseq personalfact1)))

The initial rule to be executed should be main_menu that displays below screen.

62

An Expert System For Diabetes Diagnosis MAIN MENU 1. 2. 3. 0. Diabetes Diagnosis Diabetes Complications Diabetes Information Exit

Enter your choice, press enter

Figure 5: Menu of an Expert System for Diabetes Diagnosis 1. Validate user choice 2. If selection is 1 then trigger personal_rule. The personal rule asks the user to provide age, weight and height and then calculate BMI of the user. o If the BMI is above prescribed value assign corresponding score value to the score variable. o Store the gender of the user and also whether user is young or adult in different global variables. These values are needed to control the appropriate rules during execution. 3. From the current rule retract the facts from the system if any exists 4. From the current rule assert the fact corresponding to the next rule to be triggered 5. Define the next rule o Check the facts corresponding to this rule is inserted from previous rule o If fact is present retrieve the factseq# or fact index o Interact with user and based on user input add new value to existing score 6. Repeat steps from 3 to 6 till all the required rules are processed
(defrule cholestrol_level (declare (salience 80)) ?p <- (risk_factor cholestrol_level) => (printout t "Do you have high cholestrol ? N=No Y=Yes" crlf) (bind ?cholestrol (read)) do the process .. do the process .. (retract ?p) (if (or (eq ?*gender* F)(eq ?*gender* f)) then (assert (risk_factor gestational_diabetes)) else (assert (classic_symptom excessive_thirsty))) ) ; (defrule gesational_diabetes (declare (salience 70)) ?p <- (risk_factor gestational_diabetes) => (if (or (eq ?*gender* F)(eq ?*gender* f)) then do the process .. do the process .. (retract ?p) (assert (classic_symptom excessive_thirsty)) )

63

7. Make sure the rules executed for males and females are controlled user gender variable. 8. Make sure the rules executed for youngsters and adults are controlled properly. 9. In case of female adult, one rule-gestational diabetes execute separately 10. Based on the total score earned determine the chance of diabetes in the user. The different cases are: 1. No symptom + score =0 2. No primary symptom + score between 1 & 2.5 3. No primary symptom + score between 2.5& 6 4. No primary symptom + score between 6 & 12 5. No primary symptom + score between 12& 18 6. No primary symptom + score between 18 & 24 => Not Diabetic =>Very slight chance =>Slight chance =>Moderate chance =>High chance =>Very high chance

7. No primary symptom + score between 24 & above => Diabetic 8. One primary symptom + score between 5 & 10 =>Moderate chance

9. One primary symptom + score between 10 & above =>High chance 10. Two primary symptom + score between 9 & 15 =>High chance

11. Two primary symptom + score between 15&above =>Very high chance 12. Three primary symptom + score between 15 & 20 =>Very high chance

13. Three primary symptom + score between 20 & above =>Diabetic 14. More than 3 primary symptom + score greater than 20 => Diabetic

System evaluation and Testing: In a preliminary evolution of the expert system, a few classical test cases were used to test the expert system and the result of the system was accurate when compared with the result of the Physicians; furthermore, some patients having diabetes diseases tried this expert system, in order to evaluate it and they were agreed the accuracy of the diagnosis of the diabetes diseases. Implementation: This tool can be implemented in some crowded places like hospitals, universities; collages etc. The environment requires are DOS/Windows environment and install CLIPS Win.exe version 6.3. So people can freely check their diabetes risk and also learn what are the different symptoms and their causes.

64

SUMMARY AND CONCLUSION

7. SUMMARY AND CONCLUSION The developed system is a medical expert system for diagnosing the metabolic disorder diabetes. The system is a generic tool for diabetes and can be used by all type of people because the symptoms of different types of diabetes are almost similar. It is a rule based system that supports forward chaining inference. Using this system user can enter the symptoms, the system will evaluate the symptoms and diagnose whether the user is a diabetic or not. If the user is a diabetic, system will find out how much severe and give suggestions for leading a healthy living. It provides a very fast and accurate diagnosis and if they have high chances of getting diabetes, it gives recommendation to meet a physician or endocrinologist. It acts as a diabetes trainer and gives an overall knowledge about the disease diabetes. Also it helps people to understand about the complications if they want. This expert system does not need intensive training to be used; it has simple and user friendly interface. It is developed using CLIPS language, version 6.3 and can use DOS/Windows environment. The system tested by using classical test cases and checked if the systems result in agreement with the physicians diagnoses. 7.1 FUTURE WORK This expert system can consider being the base of future work. It can be extended by other students. There are a lot of possibilities to extend this work. This expert system has a very good knowledge about diabetes. But the system cant prescribe treatment. The system can be extended by adding diabetes controlling exercise plans, diet plan etc. A fully fledged diabetes expert system can diagnose whether the patient is type 1 or type 2. Then it would be an excellent supplementary tool for diagnosing, treatment and for teaching. It can make accessible to more people by enhancing as web based application. This expert system tool can integrate with languages like Java using JESS, a rule based engine that are the superset of CLIPS langauage.

65

APPENDIX

APPENDIX (I)
PROGRAMMING OF EXPERT SYSTEM FOR DIABETES DIAGNOSIS
(defglobal ?*weight* = 0 ?*height* = 0 ?*bmi* = 0 ?*x* = 0 ?*age* = 0 ?*score* = 0 ?*gender* = a ?*primesym* = 0) ;************************************************************************************************************* (deftemplate personal_info (slot personalinfo)(slot factsseq)) ;************************************************************************************************************* (deffacts personal_detail (personal_info (personalinfo "What is your height in cm?")(factsseq personalfact4)) (personal_info (personalinfo "What is your weight in Kg?")(factsseq personalfact3)) (personal_info (personalinfo "What is your age?")(factsseq personalfact2)) (personal_info (personalinfo "What is your gender? (M/F) ")(factsseq personalfact1))) ;****************************Rule1************************************************************************** (defrule main_menu (declare (salience 100)) => (printout t crlf crlf crlf crlf) (printout t "|--------------------------------------------------------------------------------|" crlf "| |" crlf "| |" crlf "| An Expert System For Diabetes Diagnosis |" crlf "| |" crlf "| MAIN MENU |" crlf "| 1. Diabetes Diagnosis |" crlf "| 2. Diabetes Complications |" crlf "| 3. Diabetes Informations |" crlf "| 0. Exit |" crlf "| |" crlf "| Enter your choice, press enter |" crlf "| |" crlf "|--------------------------------------------------------------------------------|" crlf) (bind ?selection (read)) (while (and (neq ?selection 0)(neq ?selection 1)(neq ?selection 2)(neq ?selection 3))

66

(printout t "Entered choice is invalid, please enter correct choice" crlf) (bind ?selection (read)) ) (if (eq ?selection 0) then (exit)) ;*********************************************************************************************************************** **** (if(eq ?selection 2) then (printout t "|--------------------------------------------------------------------------------|" crlf "|1.Uncontrolled diabetes can harm the nerves in your body causing diabetic |" crlf "|neuropathy |" crlf "| |" crlf "|2.Heart disease, stroke, heart attack are all caused by blockage of blood |" crlf "|vessals causing lack of oxygen, in extreme case breakage of blood vessels may |" crlf "|happen. |" crlf "| |" crlf "|3.Diabetic retinopathy caused due to blood vessel damage in retina causing lack |" crlf "|of blood circulation thus lack of oxygen to nourish retina and in extreme cause |" crlf "|leakage of blood in retina. |" crlf "| |" crlf "|4.Diabetic Gastroparesis is disorder of stomach that takes too long to empty its|" crlf "|contents, it is caused by vagus nerve damage. |" crlf "| |" crlf "|5.Diabetes kidney disease are caused due to small blood vessel of kidney get |" crlf "|damaged due to long run of high blood glucose known as diabetes nephropathy. |" crlf "| |" crlf "|6.Erectile dysfunction or impotence is due to over all nerve damage, and also |" crlf "|may be nerves in penis. |" crlf "| |" crlf "|7.Urinary incontinence, over active bladder, bladder problems are all caused by |" crlf "|nerve damage due to prolonged high blood glucose. |" crlf "| |" crlf "|8.Urinary tract infection is also caused by nerve damage, but it is not directly|" crlf "|related with nerve cause. Due to Diabetic Gastroparesis the food emptying is |" crlf "|delayed, thus bacteria start growing and on it way it causes urinary tract |" crlf "|infection.Also due to long term diabetes immune system loss it capacity thus not|" crlf "|able to fight the infection. |" crlf "| |" crlf "|9.Diabetic ketoacidosis is a serious condition in which uncontrolled hyperglycem|" crlf "|ia overtime creates a buildup in the blood of acidic waste products called keton|" crlf "|es.High level of ketones are very harmful.This is particularly happens in people|" crlf "|with type 1 diabetes who do not have good blood glucose control.Diabetic |" crlf "|ketoacidosis is caused by infections, stress, trauma, missing medications like |" crlf "|insulin or medical emergencies like stroke and heart attack. |" crlf "| |" crlf

67

"|--------------------------------------------------------------------------------|" crlf) (exit) ) ;*********************************************************************************************************************** ***** (if(eq ?selection 3) then (printout t "|--------------------------------------------------------------------------------|" crlf "|Diabetes Mellitus is a clinical syndrome characterizes by hyperglycemia due to |" crlf "|absolute or relative deficiency of insulin. Lack of insulin whether absolute or |" crlf "|relative affects the metabolism of the body. It causes to increase the blood |" crlf "|sugar level. That is there is not enough insulin to reduce the percentage of |" crlf "|glucose to its normal level. |" crlf "| |" crlf "|All the people with diabetes have one thing common. They have too much sugar or |" crlf "|glucose in their blood. This is because a person who intake food is converted |" crlf "|into glucose and the body is unable to remove glucose from the blood and deliver|" crlf "|it to the cells as a source of energy in order to stay alive. A hormone called |" crlf "|Insulin, secreted by the pancreas helps to convert glucose to energy. When a |" crlf "|person has diabetes, the body either does not generate enough insulin or cannot |" crlf "|use its own insulin as it should. This will cause sugar to rise in the blood. |" crlf "| |" crlf "| |" crlf "|There are three types of Diabetes. |" crlf "|(1)Type-1diabetes (Juvenile Diabetes or Insulin dependent diabetes):- In Type I |" crlf "|diabetes, the immune system attacks insulin-producing beta cells in the pancreas|" crlf "|and destroys them. With little or no insulin, the cells are prevented from |" crlf "|taking up sugar from the blood. Patients with type 1 do not make enough insulin|" crlf "|and they are treated with injections of insulin. |" crlf "|(2)Type 2 diabetes:( Adult onset Diabetes or Insulin independent diabetes):|" crlf "|Patients with type 2 do make insulin, but for some reason, the cells in their |" crlf "|bodies are resistant to insulins action or they do not make enough insulin.90% |" crlf "|of all types of diabetes are type 2. It may involve the following three stages |" crlf "|in most patients. |" crlf "|3) Gestational diabetes: This appears during pregnancy in some women with no |" crlf "|previous type-1 or type-2 diabetes and usually goes away after pregnancy. But |" crlf "|after pregnancy 5 to 10 percentage of women with gestational diabetes are |" crlf "|diagnosed with type 2 diabetes within 10 years. Pregnant women have enough |" crlf "|insulin, but the effect of insulin is partially blocked by other hormones |" crlf "|produced in the placentas during pregnancy period. Around 13% of pregnant women |" crlf "|were diagnosed with this form of diabetes, including many who did not have any |" crlf "|risk factors. All pregnant women are tested for gestational diabetes between |" crlf "|their 24th and 28th week. |" crlf "| |" crlf "| |" crlf "|Insulin resistance: The first stage in type 2 diabetes is insulin resistance. |" crlf

68

"|Certain mechanisms prevent insulin from moving glucose (blood sugar) into the |" "|cells where it can be used. Thus lowering the rate in which glucose is utilized.|" "|Most patients with type 2 diabetes produce variable, even normal or high, amount|" "|of insulin. In the beginning, this amount is usually sufficient to overcome such|" "|resistance. |" "| |" "|Press "c" for Continue..........!!!!!!!!!!!!!!!!!!!!!!!!................. |" (bind ?x (read)) (if (or(eq ?x c)(eq ?x C)) then (printout t "|Prediabetes:Over time, the pancreas becomes unable to produce enough insulin to |" "|overcome resistance and in turn increasing the glucose in the blood leading to |" "|pre diabetes. It is the condition in which the blood sugar level is more than |" "|the normal level but not reach to the diabetic level. In type 2 diabetes, the |" "|initial effect of this stage is usually an abnormal rise in blood sugar right |" "|after a meal (called postprandial hyperglycemia). This effect is now believed to|" "|be particularly damaging to the body. |" "|Diabetes: Eventually, the cycle of elevated glucose further impairs and possibly|" "|destroys beta cells, thereby stopping insulin production completely and causing |" "|full-blown diabetes. This is made evident by fasting hyperglycemia, in which |" "|elevated glucose levels are present most of the time. |" "| |" "| |" "|The main causes of diabetes are|" "|Hereditary and genetics factors |" "|Infections caused by viruses |" "|Stress |" "|Obesity(A weight that is 20% more than ideal body weight) |" "|Increased cholesterol level (HDL (good) cholesterol less than 35 mg/dL or |" "|triglyceride level 250 mg/dL or higher) |" "|High carbohydrate diet |" "|Nutritional deficiency |" "|Excess intake of oil and sugar |" "|No physical exercise |" "|Overeating |" "|Tension and worries |" "|High blood pressure(140/90 mm/Hg or higher) |" "|Insulin deficiency |" "|Insulin resistance |" "|Age 45 or older |" "|African American, Hispanic/Latin American, American Indian and Alaska Native, |" "|Asian American, or Pacific Islander ethnicity |" "|Polycystic ovary syndrome(metabolic disorder that affects female reproductive |" "|system |" "|If you are on high levels of prednisone for asthma or allergies or other |" "|autoimmune diseases, you are very much at risk for diabetes. |"

crlf crlf crlf crlf crlf crlf crlf)

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf

69

"|Low birth weight. People who weighed less than 5.5 lb (2.5 kg) at birth are more|" crlf "|likely to develop type 2 diabetes later in life. |" crlf "| |" crlf "|Press "C" for continue...............!!!!!!!!!!!!!!!!..................... |" crlf)) (bind ?x (read)) (if (or(eq ?x c)(eq ?x C)) then (printout t "| "|The common symptoms are"|Classic Symptoms : "|Frequent urination with large volume of urine (poly urea) "|Excessive thirst (polydipsia) "|Extreme Hunger (polyphagia) "|Unusual,sudden,unexplained weight loss with no change in appetite "|Increased fatigue or Feeling very tired or Feeling ill "|Sudden vision changes or Blurry vision "|Nausea or Vomiting "|Stomach pain "|Other Symptoms : "|Hair loss or thinning of hair from whole body "|Sugar in urine "|Dry mouth "|Irritability "|Sleep disorder "|Dry or itchy skin "|Gestational diabetes "|Bladder, Skin, or vaginal infection (in female) "|Impotence (in male) "|Swollen red gums and loosing teeth "|Lethargy "|Over eating and rapid weight gain "|Taking steroid medicine for Asthma "|Loss of consciousness "|Complication Symptoms :

|" |" |" |" |"

crlf crlf crlf crlf crlf

|" crlf |" crlf |" crlf |" |" |" |" |" crlf crlf crlf crlf crlf

|" crlf |" crlf |" crlf |" crlf |" crlf |" crlf |" crlf |" crlf |" |" |" |" |" |" crlf crlf crlf crlf crlf crlf

70

"|Delayed wound healing "|Bruises that wont go away "|Sores that wont heal "|Tingling or numbness in hands or legs "|A feeling of pins and needles in feet "|Unexplained aches and pains "|Burning pain in legs, feet, arms

|" crlf |" crlf |" crlf |" crlf |" crlf |" crlf |" crlf crlf crlf crlf crlf))

"|Fruity smell of breath and sweat |" "| |" "|Press "C" for continue.............!!!!!!!!!!!!!!!!..................... |" "|--------------------------------------------------------------------------------|" (bind ?x (read)) (if (or(eq ?x c)(eq ?x C)) then (printout t "|Diabetic diagnosis tests are|" "| |" "|Fasting Plasma Glucose:The fasting plasma glucose (FPG) testis the standard test|" "|for diabetes. It is a simple blood test taken after 8 hours of fasting. Results |" "|indicate: |" "|1)FPG levels are considered normal up to 100 mg/dL (or 5.5 mmol/L).1 |" "|2)Levels between 100 and 125 mg/dL (5.5 to 7.0 mmol/L) are referred to as impai-|" "|ed fasting glucose or pre-diabetes. These levels are considered to be risk |" "|factors for type 2 diabetes and its complicaions. |" "|Diabetes is diagnosed when FPG levels are 126 mg/dL (7.0 mmol/L) or higher on |" "|two or more tests on different days. |" "| |" "|Postprandial blood glucose test (PPB): This test is followed by Fasting plasma |" "|glucose test. Take good amount of food after FPG wait 2 hours, and do the blood |" "|test again. Postprandial glucose level should be under 140 mg/dL. The value bet-|" "|een 140 and 199mg/dL indicate pre-diabetes.200 and above value may indicate |" "|diabetes. |" "| |" "|Random blood glucose test: A random blood glucose test can also be used to diag-|" "|nose diabetes. A blood glucose level of 200 mg/dl or higher indicates diabetes |" "| |" "|The Oral glucose tolerance test: This test is used for diagnosis of type 2.It is|" "|still commonly used for diagnosing gestational diabetes and in conditions of pre|" "|diabetes.With an oral glucose tolerance test, the person fasts overnight (at |" "|least eight but not more than 16 hours). Then first, the fasting plasma glucose |" "|is tested. After this test, the person receives 75 grams of glucose (100 grams |" "|for pregnant women).Blood samples are taken at specific intervals to measure the|"

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf

71

"|blood glucose over a period of three hours. In a person without diabetes, the |" "|glucose levels rise and then fall quickly. In someone with diabetes, glucose |" "|levels rise higher than normal and fail to come back down as fast. People with |" "|glucose levels between normal and diabetic have impaired glucose tolerance (IGT)|" "|.People with impaired glucose tolerance do not have diabetes, but are at high |" "|risk for progressing to diabetes. |" "| |" "|Press "C" for continue................!!!!!!!!!!!!!!!!................ |" (bind ?x (read)) (if (or(eq ?x c)(eq ?x C)) then (printout t "|Glucose tolerance tests may lead to one of the following diagnoses: |" "| |" "|Normal response: A person is said to have a normal response when the 2-hour |" "|glucose level is less than 140 mg/dl, and all values between 0 and 2 hours are |" "|less than 200 mg/dl. |" "|Impaired glucose tolerance: A person is said to have impaired glucose tolerance|" "|when the fasting plasma glucose is less than 126 mg/dl and the 2-hour glucose |" "|level is between 140 and 199 |" "|Diabetes: A person has diabetes when two diagnostic tests done on different |" "|days show that the blood glucose level is high. |" "|Gestational diabetes: A woman has gestational diabetes when she has any two of |" "|the following: a 100g OGTT, a fasting plasma glucose of more than 95 mg/dl, a 1-|" "|hour glucose level of more than 180 mg/dl, a 2-hour glucose level of more than |" "|155 mg/dl, or a 3-hour glucose level of more than 140 mg/dl. |" "| |" "|Hemoglobin A1C: In the body, sugar sticks with proteins. The red blood cells are|" "|a protein that circulates in the body live for about three months before they |" "|die off.When sugar sticks to these cells,it gives us an idea of how much sugaris|" "|around for the preceding three months.In most labs,the normal range is 4%-5.9 %.|" "|In poorly controlled diabetes,its 8.0% or above,and in well controlled patients |" "|it's less than 7.0% (optimal is <6.5%).it is used as a standard tool to deter -|" "|mine blood sugar control in patients known to have diabetes. |" "|--------------------------------------------------------------------------------|"

crlf crlf crlf crlf crlf crlf crlf crlf))

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf))

(exit) ) ************************************************************************************************************************ ***** (if (eq ?selection 1) then ( printout t "-----------------------------------------------------------------------------------" crlf "| |" crlf "| Thanks for selecting this tool for diabetes diagnosis. |" crlf "| |" crlf "| This tool helps the individual to diagnose whether he/she is diabetic or not. |" crlf "| |" crlf

72

"| This tool provides an interactive environment with the user,the system will |" crlf "| ask some questions to the user and user should give yes or no answer.If user |" crlf "| doesn't know the answer ,write answer no. |" crlf "| |" crlf "| Please note the tool is not a substitute of physician; it will provide only |" crlf "| a generic conclusion. |" crlf "| |" crlf "| Diabetes mellitus or Diabetes as generally called is a metabolic disorder of |" crlf "| human body with high blood sugar that results from lack of insulin secretion |" crlf "| or action or both. |" crlf "| |" crlf "| |" crlf "| There are three types of Diabetes|" crlf "| 1). Type 1: Body fails to produce the insulin |" crlf "| 2). Type 2: Body produces insulin but cells in body are resistant to insulin |" crlf "| action or not producing enough insulin. |" crlf "| 3). Type 3: Gestational diabetes.This appears in some woman during pregnancy |" crlf "| period. |" crlf "-----------------------------------------------------------------------------------" crlf) (assert (personal_rule)) ) ) ;************************Rule 2*********************************** (defrule personal_rule ;(declare (salience 90)) (personal_info (personalinfo ?personalinfo)(factsseq ?factsseq)) => (printout t ?personalinfo crlf) (bind ?response (read)) (if (eq ?factsseq personalfact1) then (while (and (neq ?response M)(neq ?response m)(neq ?response F)(neq ?response f)(neq ?response Q)(neq ?response q)) (printout t "Please enter your gender (M=male, F=woman) , or q to quit the system" crlf) (bind ?response (read)) ) (if (or(eq ?response q)(eq ?response Q)) then(halt) ) (if (or(eq ?response M)(eq ?response m)(eq ?response F)(eq ?response f)) then (bind ?*gender* ?response) (printout t "-----------------------------------------------------------------------------------" crlf "| |" crlf "| Comparatively diabetes complication for man is more than woman, risk for |" crlf

73

"| heart attack, strokes and impotence are more. |" "| |" "| |" "| In case of woman apart from normal complication diabetes may cause increased |" "| exposure to infections. |" "| |" "| Diagnosed and controlled, diabetes can be successfully managed to minimize its|" "| impact on health and well being. |" "| |" "| Amputation rates from diabetes-related problems are 1.4 to 2.7 times higher |" "| in men than women with diabetes. |" "| |" "|_________________________________________________________________________________|"

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)

) ) (if (eq ?factsseq personalfact2) then (bind ?x 'xyz') (while (eq ?x 'xyz') (if (numberp ?response) then(bind ?*age* ?response) (if (or (< ?*age* 1)(> ?*age* 120)) then (printout t "Entered age is invalid, please enter your age ? or q to quit the system" crlf) (bind ?response (read)) else (bind ?x '***') ) else(if (and (neq ?response q)(neq ?response Q)) then (printout t "Entered age is invalid, please enter your age ? or q to quit the system" crlf) (bind ?response (read)) else (bind ?x '***') ;(halt) ) ) ) (if (or(eq ?response Q)(eq ?response q)) then (halt) ) (if (or (> ?*age* 1)(< ?*age* 120)) then (printout t "-----------------------------------------------------------------------------------" crlf "| |" crlf "| The risk of getting type 2 diabetes increases with age. |" crlf "| |" crlf "| Type 1 usually occurs in children ,adults and older type 2 diabetes patients. |" crlf

74

"| It is more complicated than type 1. |" "| |" "| Type 2 usually occurs in adults over 30 years old, but can effect anyone, |" "| including children. |" "| |" "| All people with age 45 or above are under risk of diabetes. |" "| |" "|_________________________________________________________________________________|" ) (if (> ?*age* 45) then (bind ?*score* (+ ?*score* 1))) (if (< ?*age* 20) then (bind ?*gender* 'young'))

crlf crlf crlf crlf crlf crlf crlf crlf)

) (if (eq ?factsseq personalfact3) then (bind ?x 'xyz') (while (eq ?x 'xyz') (if (numberp ?response) then(bind ?*weight* ?response) (if (or (< ?*weight* 10)(> ?*weight* 120)) then (printout t "Entered weight is invalid, please enter your weight ? or q to quit the system" crlf) (bind ?response (read)) else (bind ?x '***') ) else(if (and (neq ?response q)(neq ?response Q)) then (printout t "Entered weight is invalid, please enter your weight ? or q to quit the system" crlf) (bind ?response (read)) else (bind ?x '***') (halt) ) ) ) ;(if (or (> ?*weight* 10)(< ?*weight* 120)) (printout t "-----------------------------------------------------------------------------------" "| |" "| People less than 2.5 kg at the birth are more likely to develop type 2 |" "| diabetes. If individual weight is 20% more than ideal body weight he/she |" "| is pro to diabetes. |" "|_________________________________________________________________________________|" ) (if (eq ?factsseq personalfact4) then (bind ?x 'xyz') crlf crlf crlf crlf crlf crlf)

75

(while

(eq ?x 'xyz') (if (numberp ?response) then(bind ?*height* (/ ?response 100)) (if (or (< ?*height* 1)(> ?*height* 2.4)) then (printout t "Entered height is invalid, please enter your height ? or q to quit the (bind ?response (read)) else (bind ?x '***') ) else(if (and (neq ?response q)(neq ?response Q)) then (printout t "Entered height is invalid, please enter your height ? or q to quit the

system" crlf)

system" crlf) (bind ?response (read)) else (bind ?x '***') (halt) ) ) ) (bind ?*bmi* (/ (/ ?*weight* ?*height*) ?*height*)) ( printout t " Your BMI (Body Mass Index) ratio is " ?*bmi* crlf) ( printout t "-----------------------------------------------------------------------------------" "| |" "| BMI is a measure of body weight based on a persons weight and height and |" "| estimate whether individual is underweight, overweight or obese |" "| |" "| A BMI of 18.5 to 25 indicate optimal weight, lower than 18.5 indicate |" "| underweight and above 25 indicate the person is overweight.A number above 30 |" "| suggest the person is obese. |" "| |" "| Obesity is one of the risk factor of diabetes.All should take care their body |" "| weight and maintain it as optimal weight always. |" "| |" "|_________________________________________________________________________________|" (if (> ?*bmi* 30) then (bind ?*score* (+ ?*score* 2))) (if (neq ?*gender* 'young') then (assert (risk_factor smoking))) (if (eq ?*gender* 'young') then (assert (risk_factor family_diabetic_history))) )) ;*************************Rule 3********************************** (defrule smoking ?p <- (risk_factor smoking) => (printout t "Do you smoke? N=No Y=Yes" crlf) (bind ?smoke (read)) (while (and (neq ?smoke Y)(neq ?smoke y)(neq ?smoke N)(neq ?smoke n)(neq ?smoke Q)(neq ?smoke q))

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)

76

(printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?smoke (read)) ) (if (or (eq ?smoke y)(eq ?smoke Y)(eq ?smoke N)(eq ?smoke n)) then (printout t "-----------------------------------------------------------------------------------" crlf "| |" crlf "| Smoking is one of the risk factor of diabetes.Smoking raises blood glucose |" crlf "| levels and blood pressure.That is smoking decrease the bodys ability to use |" crlf "| insulin and it can also change the way the body stores excess fat- increasing |" crlf "| fat around the waist, which is linked to diabetes.The damage that tobacco |" crlf "| chemicals do to blood vassals, muscles and organs may also increase the risk |" crlf "| of diabetes. |" crlf "| |" crlf "| 25% of smokers affected with diabetes after 5 years compared to 14% of never |" crlf "| smokers.The relative risk for developing diabetes is 2.1 times more than |" crlf "| compared to non smokers. |" crlf "| |" crlf "-----------------------------------------------------------------------------------" crlf) ) (if (or (eq ?smoke y)(eq ?smoke Y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?smoke Q)(eq ?smoke q)) then (halt) ) (retract *) (assert (risk_factor alcoholic)) (printout t ?*score* crlf) ) ;*************************Rule 4********************************** (defrule alcoholic ?p <- (risk_factor alcoholic) => (printout t "Do you take alcohol? N=No Y=Yes" crlf) (bind ?alcohol (read)) (while (and (neq ?alcohol Y)(neq ?alcohol y)(neq ?alcohol N)(neq ?alcohol n)(neq ?alcohol Q)(neq ?alcohol q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?alcohol (read)) ) (if (or (eq ?alcohol y)(eq ?alcohol Y)(eq ?alcohol N)(eq ?alcohol n)) then

77

(printout t "----------------------------------------------------------------------------------|" "| Alcohol consuming is another risk factor of diabetics. |" "| Alcohol being high in calories, increases blood sugar. In excess, it prevents |" "| the liver from releasing sugar in the blood, leading to hypoglycemia or very low|" "| blood sugar levels. Hypoglycemia caused by drinking is particularly serious and |" "| can even be fatal. Besides alcohol also interferes with the working of diabetes |" "| medication and health. |" "| Moderate alcohol (about one drink a day for women and two for men) has been |" "| shown to decrease the risk of diabetes compared to non-drinkers. |" "| |" "-----------------------------------------------------------------------------------"

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)

) (if (or (eq ?alcohol y)(eq ?alcohol Y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?alcohol Q)(eq ?alcohol q)) then (halt) ) (retract ?p) (assert (risk_factor lifestyle)) (printout t ?*score* crlf) ) ;*************************Rule 5********************************** (defrule lifestyle ?p <- (risk_factor lifestyle) => (printout t "Do you do regular exercise,minimum 4 days in a week?? N=No Y=Yes" crlf) (bind ?lifestyle (read)) (while (and (neq ?lifestyle Y)(neq ?lifestyle y)(neq ?lifestyle N)(neq ?lifestyle n)(neq ?lifestyle Q)(neq ?lifestyle q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?lifestyle (read)) ) (if (or (eq ?lifestyle y)(eq ?lifestyle Y)(eq ?lifestyle N)(eq ?lifestyle n)) then (printout t "|----------------------------------------------------------------------------------|"crlf "|The lack of daily physical exercise leads to obesity.It is a major factor of |"crlf "|developing type 2 diabetes.Obesity caused insulin resistance. |"crlf "|----------------------------------------------------------------------------------|"crlf) ) (if (> ?*bmi* 30) then (if (or (eq ?lifestyle Y)(eq ?lifestyle y)) then (bind ?*score* (+ ?*score* 1))) )

78

(if (or (eq ?lifestyle Q)(eq ?lifestyle q)) then (halt) ) (retract ?p) (assert (risk_factor blood_pressure)) (printout t ?*score* crlf) ) ;*************************Rule 6********************************** (defrule blood_pressure ?p <- (risk_factor blood_pressure) => (printout t "Do you have high BP? N=No Y=Yes" crlf) (bind ?bp (read)) (while (and (neq ?bp Y)(neq ?bp y)(neq ?bp N)(neq ?bp n)(neq ?bp Q)(neq ?bp q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?bp (read)) ) (if (or (eq ?bp y)(eq ?bp Y)(eq ?bp N)(eq ?bp n)) then (printout t"|-----------------------------------------------------------------------------------|"crlf "|Diabetes and high blood pressure (hypertension) are serious disorders.Complications|"crlf "|from diabetes develop much more quickly if blood pressure is high.Many patients |"crlf "|with diabetes also have high blood pressure. It has been estimated that high blood |"crlf "|pressure is twice as likely to be present in a person with diabetes as compared to |"crlf "|someone who does not have diabetes.It increase the chance of developing heart |"crlf "|disease, a stroke and some other complications. |"crlf "|Diabetes and high blood pressure are like twins.One of the diabetes prevention |"crlf "|method is controlling high blood pressure. |"crlf "|-----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?bp Y)(eq ?bp y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?bp Q)(eq ?bp q)) then (halt) ) (retract ?p)

(assert (risk_factor cholestrol_level)) (printout t ?*score* crlf) )


;*************************Rule 7********************************** (defrule cholestrol_level ?p <- (risk_factor cholestrol_level)

79

=> (printout t "Do you have high cholestrol ? N=No Y=Yes" crlf) (bind ?cholestrol (read)) (while (and (neq ?cholestrol Y)(neq ?cholestrol y)(neq ?cholestrol N)(neq ?cholestrol n)(neq ?cholestrol Q)(neq ?cholestrol q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?cholestrol (read)) ) (if (or (eq ?cholestrol y)(eq ?cholestrol Y)(eq ?cholestrol N)(eq ?cholestrol n)) then (printout t "|----------------------------------------------------------------------------------|"crlf "|Diabetic patients have to be extremely vigilant about controlling your cholesterol|"crlf "|Diabetes raise the amount of LDL cholesterol ("bad cholesterol") that tends to |"crlf "|form plaques in arteries, and lower the number of HDL cholesterol particles (good |"crlf "|cholesterol) that help to clear out dangerous plaques before they break off to |"crlf "|cause a heart attack or stroke. |"crlf "|High cholesterol can also be a predictor of diabetes; elevated cholesterol levels |"crlf "|are often seen in people with insulin resistance, even before they have developed |"crlf "|full-blown diabetes. |"crlf "| |"crlf "|----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?cholestrol Y)(eq ?cholestrol y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?cholestrol Q)(eq ?cholestrol q)) then (halt) ) (retract ?p) (assert (risk_factor high_triglyceride level)) (printout t ?*score* crlf) ) ;*************************Rule 8********************************** (defrule high_triglyceride_level ?p <- (risk_factor high_triglyceride level) => (printout t "Do you have high triglyceride level ? N=No Y=Yes" crlf) (bind ?tri (read)) (while (and (neq ?tri Y)(neq ?tri y)(neq ?tri N)(neq ?tri n)(neq ?tri Q)(neq ?tri q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?tri (read)) ) (if (or (eq ?tri y)(eq ?tri Y)(eq ?tri N)(eq ?tri n)) then (printout t "|----------------------------------------------------------------------------------|"crlf "|Diabetes also tends to cause higher levels of triglycerides.Triglycerides are a |"crlf "|kind of fat. When you eat, the body uses the food it needs for immediate energy |"crlf "|and stores the rest in the form of triglycerides. Triglycerides are stored in the |"crlf "|fat cells, but they also circulate in the blood and can be measured in a blood |"crlf

80

"|test. When too many triglycerides are in your blood, they build up on the walls of|"crlf "|your arteries in the form of sticky plaque, causing them to narrow and harden.A |"crlf "|triglyceride level of 150 mg/dl or more is considered high. |"crlf "|----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?tri Y)(eq ?tri y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?tri Q)(eq ?tri q)) then (halt) ) (retract ?p) (assert (risk_factor family_diabetic_history)) (printout t ?*score* crlf) ) ;*************************Rule 9********************************** (defrule family_diabetic_history ?p <- (risk_factor family_diabetic_history) => (printout t "Do you have a family history of diabetes like father,mother,brother,sister etc?"crlf "N=No Y=Yes" crlf) (bind ?diabetic_history (read)) (while (and (neq ?diabetic_history Y)(neq ?diabetic_history y)(neq ?diabetic_history N)(neq ?diabetic_history n)(neq ?diabetic_history Q)(neq ?diabetic_history q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?diabetic_history (read)) ) (if (or (eq ?diabetic_history y)(eq ?diabetic_history Y)(eq ?diabetic_history N)(eq ?diabetic_history n)) then (printout t "|----------------------------------------------------------------------------------|"crlf "|Genetics most likely plays a role in all types of diabetes, since a family history|"crlf "|is a major risk factor. |"crlf "| |"crlf "|Type 2 diabetes runs in families.In general, if you have type 2 diabetes, the risk|"crlf "|of your child getting diabetes is 1 in 7 if you were diagnosed before age 50 and 1|"crlf "|in 13 if you were diagnosed after age 50.Some scientists believe that a child's |"crlf "|risk is greater when the parent with type 2 diabetes is the mother. If both you |"crlf "|and your partner have type 2 diabetes, your child's risk is about 1 in 2. |"crlf "| |"crlf "|If you are a man with type 1 diabetes, the odds of your child getting diabetes are|"crlf "|1 in 17. If you are a woman with type 1 diabetes and your child was born before |"crlf "|you were 25, your child's risk is 1 in 25; if your child was born after you turned|"crlf "|25, your child's risk is 1 in 100.Your child's risk is doubled if you developed |"crlf "|diabetes before age 11. If both you and your partner have type 1 diabetes, the |"crlf "|risk is between 1 in 10 and 1 in 4. |"crlf "|----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?diabetic_history Y)(eq ?diabetic_history y)) then (bind ?*score* (+ ?*score* 3))) (if (or (eq ?diabetic_history Q)(eq ?diabetic_history q))

81

then (halt) ) (retract ?p) (if (eq ?*gender* 'young') then (assert (classic_symptom excessive_thirsty))) (if (or (eq ?*gender* F)(eq ?*gender* f)) then (assert (risk_factor gestational_diabetes)) else (assert (classic_symptom excessive_thirsty))) (printout t ?*score* crlf) ) ;*************************Rule 10********************************** (defrule gesational_diabetes ?p <- (risk_factor gestational_diabetes) => (if (or (eq ?*gender* F)(eq ?*gender* f)) then (printout t "Have you got gestational diabetes during pregnency or delevered a baby weighing more"crlf "than 4Kg ? N=No Y=Yes" crlf) (bind ?gd (read)) (while (and (neq ?gd Y)(neq ?gd y)(neq ?gd N)(neq ?gd n)(neq ?gd Q)(neq ?gd q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?gd (read)) ) (if (or (eq ?gd y)(eq ?gd Y)(eq ?gd N)(eq ?gd n)) then (printout t "|----------------------------------------------------------------------------------|"crlf "|This appears during pregnancy in some women with no previous type-1 or type-2 |"crlf "|diabetes and usually goes away after pregnancy. But after pregnancy 5 to 10 |"crlf "|percentage of women with gestational diabetes are diagnosed with type 2 diabetes. |"crlf "|Pregnant women have enough insulin, but the effect of insulin is partially blocked|"crlf "|by other hormones produced in the placentas during pregnancy period. |"crlf "|----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?gd Y)(eq ?gd y)) then (bind ?*score* (+ ?*score* 3))) (if (or (eq ?gd Q)(eq ?gd q)) then (halt) )) (retract ?p) (assert (classic_symptom excessive_thirsty)) (printout t ?*score* crlf) ) ;*************************Rule 11********************************** (defrule excessive_thirsty ?p <- (classic_symptom excessive_thirsty) =>

82

(printout t "Are you feeling excessive thirsty? ,N=No Y=Yes" crlf) (bind ?excessivethirsty (read)) (while (and (neq ?excessivethirsty Y)(neq ?excessivethirsty y)(neq ?excessivethirsty N)(neq ?excessivethirsty n)(neq ?excessivethirsty Q)(neq ?excessivethirsty q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?excessivethirsty (read)) ) (if (or (eq ?excessivethirsty y)(eq ?excessivethirsty Y)(eq ?excessivethirsty N)(eq ?excessivethirsty n)) then (printout t "|-----------------------------------------------------------------------------------|"crlf "|Excess thirsty happens because due to diabetes the body has excess glucose, which |"crlf "|draws water from the body tissues.This causes to feel dehydrated often and tend to |"crlf "|drink more water or other drinks.That is as the concentration of glucose increases |"crlf "|in the blood, brain receives signal for diluting it and, in its counteraction we |"crlf "|feel thirsty. |"crlf "|-----------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?excessivethirsty Y)(eq ?excessivethirsty y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?excessivethirsty Q)(eq ?excessivethirsty q)) then (halt) ) (retract ?p) (assert (classic_symptom frequent_urination)) (printout t ?*score* crlf) ) ;*************************Rule 12********************************** (defrule frequent_urination ?p <- (classic_symptom frequent_urination) => (printout t "Are you feeling frequent urination ?, N=No Y=Yes" crlf) (bind ?frequenturination (read)) (while (and (neq ?frequenturination Y)(neq ?frequenturination y)(neq ?frequenturination N)(neq ?frequenturination n)(neq ?frequenturination Q)(neq ?frequenturination q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?frequenturination (read)) ) (if (or (eq ?frequenturination y)(eq ?frequenturination Y)(eq ?frequenturination N)(eq ?frequenturination n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Frequent urination often occurs with sugar diabetes, day and night.Increase in urine |"crlf "|production is due to excess glucose present in body. Body gets rid of the extra sugar|"crlf "|in the blood by excreting it through urine. This leads to dehydration because along |"crlf "|with the sugar, a large amount of water is excreted out of the body. Diabetic |"crlf "|patients have a tendancy to drink lot of water due to dehydration, that leads to more|"crlf

83

"|frequent urination throughout the day as well. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?frequenturination Y)(eq ?frequenturination y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?frequenturination Q)(eq ?frequenturination q)) then (halt) ) (retract ?p) (assert (classic_symptom extreme_hunger)) (printout t ?*score* crlf) ) ;*************************Rule 13********************************** (defrule extreme_hunger ?p <- (classic_symptom extreme_hunger) => (printout t "Are you feeling extreme hungry especially after eating meals ? N=No Y=Yes" crlf) (bind ?extremehunger (read)) (while (and (neq ?extremehunger Y)(neq ?extremehunger y)(neq ?extremehunger N)(neq ?extremehunger n)(neq ?extremehunger Q)(neq ?extremehunger q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?extremehunger (read)) ) (if (or (eq ?extremehunger y)(eq ?extremehunger Y)(eq ?extremehunger N)(eq ?extremehunger n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Because the glucose in the food you eat is not being used effectively the person may |"crlf "|experience an in increase in apettite as the body demands more.The hormone insulin is|"crlf "|also responsible for stimulating hunger. In order to cope up with high sugar levels |"crlf "|in blood, body produces insulin which leads to increased hunger. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?extremehunger Y)(eq ?extremehunger y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?extremehunger Q)(eq ?extremehunger q)) then (halt)) (retract ?p) (assert (classic_symptom sudden_unusual_weight_loss)) (printout t ?*score* crlf) ) ;*************************Rule 14********************************** (defrule sudden_unusual_weight_loss ?p <- (classic_symptom sudden_unusual_weight_loss) => (printout t "Are you feeling sudden,unusual,unexpected weight loss with increase in appetite?" crlf " N=No Y=Yes "crlf) (bind ?weightloss (read))

84

(while (and (neq ?weightloss Y)(neq ?weightloss y)(neq ?weightloss N)(neq ?weightloss n)(neq ?weightloss Q)(neq ?weightloss q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?weightloss (read)) ) (if (or (eq ?weightloss y)(eq ?weightloss Y)(eq ?weightloss N)(eq ?weightloss n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|The person may experience a sudden unexplained weight loss inspite of an increase in |"crlf "|appetite, for the reason that the body can not utilize the food specifically the |"crlf "|carbohydrate, into energy and fat,so it can not be stored and muscles lose already |"crlf "|stored proteins,fat for bodys functions and cause weigh loss. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?weightloss Y)(eq ?weightloss y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?weightloss Q)(eq ?weightloss q)) then (halt) ) (retract ?p) (assert (classic_symptom fatigue)) (printout t ?*score* crlf) ) ;*************************Rule 15********************************** (defrule fatigue ?p <- (classic_symptom fatigue) => (printout t "Do you have a feeling fatigue or drowsiness or sleepiness? N=No Y=Yes" crlf) (bind ?fatigue (read)) (while (and (neq ?fatigue Y)(neq ?fatigue y)(neq ?fatigue N)(neq ?fatigue n)(neq ?fatigue Q)(neq ?fatigue q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?fatigue (read)) ) (if (or (eq ?fatigue y)(eq ?fatigue Y)(eq ?fatigue N)(eq ?fatigue n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|The people will get the feeling of fatigue ,drowsiness or not getting proper sleep |"crlf "|because the glucose is not used to produce energy. Due to inefficiency of the cell |"crlf "|to metabolize glucose, reserve fat of body is metabolized to gain energy. When fat |"crlf "|is broken down in the body, it uses more energy as compared to glucose, hence body |"crlf "|goes in negative calorie effect, which results in fatigue. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?fatigue Y)(eq ?fatigue y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1)))

85

(if (or (eq ?fatigue Q)(eq ?fatigue q)) then (halt) ) (retract ?p) (assert (classic_symptom nausea_vommittig)) (printout t ?*score* crlf) ) ;*************************Rule 16********************************** (defrule nausea_vommitting ?p <- (classic_symptom nausea_vommittig) => (printout t "Do you have a feeling nausea or vommitting? N=No Y=Yes" crlf) (bind ?vomit (read)) (while (and (neq ?vomit Y)(neq ?vomit y)(neq ?vomit N)(neq ?vomit n)(neq ?vomit Q)(neq ?vomit q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?vomit (read)) ) (if (or (eq ?vomit y)(eq ?vomit Y)(eq ?vomit N)(eq ?vomit n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Nausea and vommitting are the primary symptom of type 1 diabetes.Type 2 diabetes also|"crlf "|get these symptom.In absence of insulin, body cells dont get the required glucose |"crlf "|for producing ATP (Adenosin Triphosphate) units which results into primary symptom in|"crlf "|the form of nausea and vomiting. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?vomit Y)(eq ?vomit y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?vomit Q)(eq ?vomit q)) then (halt) ) (retract ?p) (if (eq ?*gender* 'young') then (assert (younger_symptom youngsrule1)) else (assert (other_symptom feeling_ill))) (printout t ?*score* crlf) ) ;*************************Rule 17********************************** (defrule feeling_ill ?p <- (other_symptom feeling_ill) => (printout t "Do you have a feeling of ill ,tired or feeling of aging? N=No Y=Yes" crlf) (bind ?ill(read)) (while (and (neq ?ill Y)(neq ?ill y)(neq ?ill N)(neq ?ill n)(neq ?ill Q)(neq ?ill q)) (printout t "You have entered wrong answer"crlf

86

"Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?ill (read)) ) (if (or (eq ?ill y)(eq ?ill Y)(eq ?ill N)(eq ?ill n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Almost everyone suffering from this condition first has a prediabetes, meaning |"crlf "|their blood glucose level are higher than the normal level but have not yet reached |"crlf "|to the range of diabetes.It is due to decrease in energy production by the cells. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?ill Y)(eq ?ill y)) then (bind ?*score* (+ ?*score* 2))) (if (or (eq ?ill Q)(eq ?ill q)) then (halt) ) (retract ?p) (assert (other_symptom hair_loss)) (printout t ?*score* crlf) ) ;*************************Rule 18********************************** (defrule hair_loss ?p <- (other_symptom hair_loss) => (printout t "Do you have a feeling of sudden hair loss or thinning of hair? N=No Y=Yes" crlf) (bind ?hair_loss(read)) (while (and (neq ?hair_loss Y)(neq ?hair_loss y)(neq ?hair_loss N)(neq ?hair_loss n)(neq ?hair_loss Q)(neq ?hair_loss q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?hair_loss (read)) ) (if (or (eq ?hair_loss y)(eq ?hair_loss Y)(eq ?hair_loss N)(eq ?hair_loss n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Diabetes is a hormone related disorder that often leads to hair loss or thinning of |"crlf "|the hair.Frequent loss of hair is often considered one of the early symptoms of |"crlf "|diabetes,which gradually leads to thinning of hair. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?hair_loss Y)(eq ?hair_loss y)) then (bind ?*score* (+ ?*score* 1.5))) (if (or (eq ?hair_loss Q)(eq ?hair_loss q)) then (halt)) (retract ?p) (assert (other_symptom weight_gain)) (printout t ?*score* crlf) ) ;*************************Rule 19********************************** (defrule weight_gain ?p <- (other_symptom weight_gain) => (printout t "Do you have a feeling of over eating and rapid weight gain? N=No Y=Yes" crlf) (bind ?weight_gain(read)) (while (and (neq ?weight_gain Y)(neq ?weight_gain y)(neq ?weight_gain N)(neq ?weight_gain n)(neq ?weight_gain Q)(neq ?weight_gain q))

87

(printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?weight_gain (read)) ) (if (or (eq ?weight_gain y)(eq ?weight_gain Y)(eq ?weight_gain N)(eq ?weight_gain n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|The desire for too much food is sometimes as a result of losing too much fluid or |"crlf "|sugar.The body tries to compensate with cravings of sweets or other foods. Only few |"crlf "|diabetic type 2 people will experience weight gain. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?weight_gain Y)(eq ?weight_gain y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?weight_gain Q)(eq ?weight_gain q)) then (halt) ) (retract ?p) (assert (other_symptom stomach_pain)) (printout t ?*score* crlf) ) ;*************************Rule 20********************************** (defrule stomach_pain ?p <- (other_symptom stomach_pain) => (printout t "Do you have a feeling of stomach/abdominal pain? N=No Y=Yes" crlf) (bind ?stomach_pain(read)) (while (and (neq ?stomach_pain Y)(neq ?stomach_pain y)(neq ?stomach_pain N)(neq ?stomach_pain n)(neq ?stomach_pain Q)(neq ?stomach_pain q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?stomach_pain (read)) ) (if (or (eq ?stomach_pain y)(eq ?stomach_pain Y)(eq ?stomach_pain N)(eq ?stomach_pain n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Persons with diabetes may develop abdominal pain,nausea,vomitting because of |"crlf "|gastroparesis, a condition in which the stomach fails to empty properly and their |"crlf "|blood sugars become abnormally high or low (hyperglycemia or hypoglycemia) because |"crlf "|the sugar and insulin balance is disturbed.Gastroparesis may occur in people with |"crlf "|type 1 diabetes or type 2 diabetes.In turn, gastroparesis contributes to poor blood |"crlf "|glucose control.This mayalso a symptom of Diabetic ketoacidosis.Diabetic ketoacidosis|"crlf "|is a serious condition in which uncontrolled hyperglycemia over time creates a build-|"crlf "|up in the blood of acidic waste products called ketones. High level of ketones are |"crlf "|very harmful. This is particularly happens in people with type 1 diabetes who do not |"crlf "|have good blood glucose control.Diabetic ketoacidosis is caused by infections,stress|"crlf "|,trauma, missing medications like insulin or medical emergencies like stroke and |"crlf "|heart attack. |"crlf "| |"crlf

88

"|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?stomach_pain Y)(eq ?stomach_pain y)) then (bind ?*score* (+ ?*score* 2.5))) (if (or (eq ?stomach_pain Q)(eq ?stomach_pain q)) then (halt) ) (retract ?p) (assert (other_symptom sugar_in_urine)) (printout t ?*score* crlf) ) ;*************************Rule 21********************************** (defrule sugar_in_urine ;(declare (salience 60)) ?p <- (other_symptom sugar_in_urine) => (printout t "Your urine contain sugar? N=No Y=Yes" crlf) (bind ?sugar_in_urine(read)) (while (and (neq ?sugar_in_urine Y)(neq ?sugar_in_urine y)(neq ?sugar_in_urine N)(neq ?sugar_in_urine n)(neq ?sugar_in_urine Q)(neq ?sugar_in_urine q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?sugar_in_urine (read)) ) (if (or (eq ?sugar_in_urine y)(eq ?sugar_in_urine Y)(eq ?sugar_in_urine N)(eq ?sugar_in_urine n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|An increase in the glucose levels in urine above normal.Diabetes is one of the |"crlf "|possible causes of Sugar in urine.If a person has sugar in urine means, the patient |"crlf "|has diabetes, or is at risk of diabetes, or has a family history of diabetes. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?sugar_in_urine Y)(eq ?sugar_in_urine y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?sugar_in_urine Q)(eq ?sugar_in_urine q)) then (halt) ) (retract ?p) (assert (other_symptom irritability)) (printout t ?*score* crlf) ) ;*************************Rule 22*********************************** (defrule irritability ?p <- (other_symptom irritability) => (printout t "Do you have a feeling of irritability? N=No Y=Yes" crlf) (bind ?irritability(read)) (while (and (neq ?irritability Y)(neq ?irritability y)(neq ?irritability N)(neq ?irritability n)(neq ?irritability Q)(neq ?irritability q)) (printout t "You have entered wrong answer"crlf

89

"Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?irritability (read)) ) (if (or (eq ?irritability y)(eq ?irritability Y)(eq ?irritability N)(eq ?irritability n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|It is a sign of high blood sugar because of the inefficient glucose supply to the |"crlf "|brain and other body organs, which makes us feel tired and uneasy. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?irritability Y)(eq ?irritability y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?irritability Q)(eq ?irritability q)) then (halt) ) (retract ?p) (assert (other_symptom muscle_cramps)) (printout t ?*score* crlf) ) ;*************************Rule 23*********************************** (defrule muscle_cramps ?p <- (other_symptom muscle_cramps) => (printout t "Do you have a feeling of body pain,mucsle cramps or aches? N=No Y=Yes" crlf) (bind ?pain(read)) (while (and (neq ?pain Y)(neq ?pain y)(neq ?pain N)(neq ?pain n)(neq ?pain Q)(neq ?pain q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?pain (read)) ) (if (or (eq ?pain y)(eq ?pain Y)(eq ?pain N)(eq ?pain n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Pain or recurring body aches is a predominant feature among diabetes patients.This is|"crlf "|largely contributed by the rise in sugar or glucose levels in our body over a very |"crlf "|long period of time. One of the major pitfalls of diabetes is the wear and tear of |"crlf "|the nerves which leads to a condition we commonly refer to as pain. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?pain Y)(eq ?pain y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?pain Q)(eq ?pain q)) then (halt) ) (retract ?p) (assert (other_symptom genital_infection)) (printout t ?*score* crlf) ) ;*************************Rule 24***********************************

90

(defrule genital_infection ?p <- (other_symptom genital_infection) => (if (or (eq ?*gender* F)(eq ?*gender* f)) then (printout t "Are you getting genital infection or thrush or intense itching oftenly? N=No Y=Yes" crlf) (bind ?infection(read)) (while (and (neq ?infection Y)(neq ?infection y)(neq ?infection N)(neq ?infection n)(neq ?infection Q)(neq ?infection q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?infection (read)) ) (if (or (eq ?infection y)(eq ?infection Y)(eq ?infection N)(eq ?infection n)) then (printout t"|-------------------------------------------------------------------------------------|"crlf "|If the blood glucose is high,especially women will get urinary tract and genital |"crlf "|infection because the increased blood glucose level supports bacterial growth. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?infection Y)(eq ?infection y)) then (bind ?*score* (+ ?*score* 2))) (if (or (eq ?infection Q)(eq ?infection q)) then (halt) )) (retract ?p) (assert (other_symptom lethargy)) (printout t ?*score* crlf) ) ;*************************Rule 25*********************************** (defrule lethargy ?p <- (other_symptom lethargy) => (printout t "Do you have a feeling of lethargy or low energy level? N=No Y=Yes" crlf) (bind ?lethargy(read)) (while (and (neq ?lethargy Y)(neq ?lethargy y)(neq ?lethargy N)(neq ?lethargy n)(neq ?lethargy Q)(neq ?lethargy q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?lethargy (read)) ) (if (or (eq ?lethargy y)(eq ?lethargy Y)(eq ?lethargy N)(eq ?lethargy n)) then (printout t"|-------------------------------------------------------------------------------------|"crlf "|Lethargy, a general low energy level and lack of response.Lethargy is a fairly |"crlf "|imprecise description of the feeling or slowness, sluggishness, tiredness, or lack of|"crlf "|energy. Lethargy is one of the symptoms of uncontrolled/poorly controlled diabetes. |"crlf "|Untreated or not adequately treated, the diabetic's tissues are unable to use glucose|"crlf "|amino acids and fatty acids properly. It normally resolves quickly after starting |"crlf "|insulin therapy. |"crlf "|-------------------------------------------------------------------------------------|"crlf) )

91

(if (or (eq ?lethargy Y)(eq ?lethargy y)) then (bind ?*score* (+ ?*score* 2))) (if (or (eq ?lethargy Q)(eq ?lethargy q)) then (halt) ) (retract ?p) (assert (retinopathy blurred vision)) (printout t ?*score* crlf) ) ;*************************Rule 26*********************************** (defrule blurred_vision ?p <- (retinopathy blurred vision) => (printout t "Do you have a feeling of sudden severe blurry or double vision? N=No Y=Yes" crlf) (bind ?vision(read)) (while (and (neq ?vision Y)(neq ?vision y)(neq ?vision N)(neq ?vision n)(neq ?vision Q)(neq ?vision q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?vision (read)) ) (if (or (eq ?vision y)(eq ?vision Y)(eq ?vision N)(eq ?vision n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Blurred vision occurs when the high levels of glucose in the blood causes water from |"crlf "|the lens to go outward and deforming the lens, making the vision unfocused. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?vision Y)(eq ?vision y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) ;) (if (or (eq ?vision Q)(eq ?vision q)) then (halt) ) (retract ?p) (assert (retinopathy other_retinadamage_symptoms)) (printout t ?*score* crlf) ) ;*************************Rule 27*********************************** (defrule other_retinadamage_symptoms ?p <- (retinopathy other_retinadamage_symptoms) => (printout t "Do you have a any sign of flashing light or blank spot,pain or pressure in one or both"crlf "eyes trouble seeing things out of the corner of your eyes? N=No Y=Yes" crlf) (bind ?vision(read)) (while (and (neq ?vision Y)(neq ?vision y)(neq ?vision N)(neq ?vision n)(neq ?vision Q)(neq ?vision q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf)

92

(bind ?vision (read)) ) (if (or (eq ?vision y)(eq ?vision Y)(eq ?vision N)(eq ?vision n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|The diabetic patient may not have any signs of diabetes retina damage, or you may |"crlf "|have one or more signs because of high level of glucose in the blood. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?vision Y)(eq ?vision y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?vision Q)(eq ?vision q)) then (halt) ) (retract ?p) (assert (skin_and_feet_problem dry_itchy_skin)) (printout t ?*score* crlf) ) ;*************************Rule 28*********************************** (defrule dry_itchy_skin ?p <- (skin_and_feet_problem dry_itchy_skin) => (printout t "Do you have a feeling of dry itchy skin? N=No Y=Yes" crlf) (bind ?dryskin(read)) (while (and (neq ?dryskin Y)(neq ?dryskin y)(neq ?dryskin N)(neq ?dryskin n)(neq ?dryskin Q)(neq ?dryskin q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?dryskin (read)) ) (if (or (eq ?dryskin y)(eq ?dryskin Y)(eq ?dryskin N)(eq ?dryskin n)) then (printout t"|-------------------------------------------------------------------------------------|"crlf "|If the blood glucose is high, the body loses fluid. With less fluid in your body,the |"crlf "|skin can get dry. Dry skin can be itchy, causing you to scratch and make it sore. |"crlf "|Nerve damage can decrease the amount you sweat. Sweating helps keep your skin soft |"crlf "|and moist. Decreased sweating in your feet and legs can cause dry skin. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?dryskin Y)(eq ?dryskin y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?dryskin Q)(eq ?dryskin q)) then (halt) ) (retract ?p) (assert (skin_and_feet_problem dry_cracked_skin)) (printout t ?*score* crlf) ) ;*************************Rule 29*********************************** (defrule dry_cracked_skin

93

?p <- (skin_and_feet_problem dry_cracked_skin) => (printout t "Do you have a problem of dry cracked skin? N=No Y=Yes" crlf) (bind ?crack(read)) (while (and (neq ?crack Y)(neq ?crack y)(neq ?crack N)(neq ?crack n)(neq ?crack Q)(neq ?crack q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?crack (read)) ) (if (or (eq ?crack y)(eq ?crack Y)(eq ?crack N)(eq ?crack n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Dry skin can crack. Cracks allow germs to enter and cause infection. If your blood |"crlf "|glucose is high, it feeds germs and makes infections worse. You may get dry skin on |"crlf "|the legs, feet, elbows, and other places on the body. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?crack Y)(eq ?crack y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?crack Q)(eq ?crack q)) then (halt)) (retract ?p) (assert (skin_and_feet_problem athletes_foot)) (printout t ?*score* crlf) ) ;*************************Rule 30*********************************** (defrule athletes_foot ?p <- (skin_and_feet_problem athletes_foot) => (printout t "Do you have the problem of athlete's foot? N=No Y=Yes" crlf) (bind ?ath (read)) (while (and (neq ?ath Y)(neq ?ath y)(neq ?ath N)(neq ?ath n)(neq ?ath Q)(neq ?ath q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?ath (read)) ) (if (or (eq ?ath y)(eq ?ath Y)(eq ?ath N)(eq ?ath n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Athletes foot is a fungus that causes itchiness, redness, and cracking of the skin. |"crlf "|The cracks between the toes allow germs to get under the skin and cause infection. |"crlf "|If your blood glucose is high, it feedsthe germs and makes the infection worse. The |"crlf "|infection can spread to the toenails and make them thick, yellow, and hard to cut. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?ath Y)(eq ?ath y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?ath Q)(eq ?ath q)) then (halt)) (retract ?p) (assert (neuropathy sores_not_heal)) (printout t ?*score* crlf) )

94

;*************************Rule 31*********************************** (defrule sores_not_heal ?p <- (neuropathy sores_not_heal) => (printout t "Do you have a feeling of sores,wounds or bruises that donot heal or dont go away" crlf "fastly? N=No Y=Yes"crlf) (bind ?sores(read)) (while (and (neq ?sores Y)(neq ?sores y)(neq ?sores N)(neq ?sores n)(neq ?sores Q)(neq ?sores q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?sores (read)) ) (if (or (eq ?sores y)(eq ?sores Y)(eq ?sores N)(eq ?sores n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|High blood sugar resists the flourishing of WBC, (white blood cell) which are |"crlf "|responsible for body immune system. When these cells do not function accordingly, |"crlf "|wound healing is not at good pace. Secondly, long standing diabetes leads to |"crlf "|thickening of blood vessels which affect proper circulation of blood in different |"crlf "|body parts. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?sores Y)(eq ?sores y)) then (bind ?*score* (+ ?*score* 5)) (bind ?*primesym* (+ ?*primesym* 1))) (if (or (eq ?sores Q)(eq ?sores q)) then (halt) ) (retract ?p) (assert (neuropathy tingling_numbness)) (printout t ?*score* crlf) ) ;*************************Rule 32*********************************** (defrule tingling_numbness ?p <- (neuropathy tingling_numbness) => (printout t "Do you have a feeling of tingling or numbness in hands or feet? N=No Y=Yes" crlf) (bind ?numb(read)) (while (and (neq ?numb Y)(neq ?numb y)(neq ?numb N)(neq ?numb n)(neq ?numb Q)(neq ?numb q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?numb (read)) ) (if (or (eq ?numb y)(eq ?numb Y)(eq ?numb N)(eq ?numb n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Tingling and numbness in hands or feet is a symptom of diabetic neuropathy.Neuropathy|"crlf "|(or diffuse neuropathy) is a a nerve disorder of which there are 2 types - peripheral|"crlf

95

"|-which affects the feet and hands-and autonomic-which affects the body's internal |"crlf "|organs. Diabetic neuropathy is a nerve disorder caused by either type 1 or type 2 |"crlf "|diabetes. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?numb Y)(eq ?numb y)) then (bind ?*score* (+ ?*score* 2.5))) (if (or (eq ?numb Q)(eq ?numb q)) then (halt) ) (retract ?p) (assert (neuropathy pins_needeles_feet)) (printout t ?*score* crlf) ) ;*************************Rule 33*********************************** (defrule pins_needles_feet ?p <- (neuropathy pins_needeles_feet) => (printout t "Do you have a feeling of pins and needles in feet? N=No Y=Yes" crlf) (bind ?pin(read)) (while (and (neq ?pin Y)(neq ?pin y)(neq ?pin N)(neq ?pin n)(neq ?pin Q)(neq ?pin q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?pin (read)) ) (if (or (eq ?pin y)(eq ?pin Y)(eq ?pin N)(eq ?pin n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|One of the major pitfalls of diabetes is the wear and tear of the nerves which leads |"crlf "|to a condition we commonly refer to as pain. |"crlf "|The feeling of pins and needles in feet is anothor symptom of diabetic neuropathy. |"crlf "|diabetics who do not strictly control their condition, may develop damage to the |"crlf "|nerves around the body.The longer a person has diabetes, the greater the risk becomes|"crlf "|of developing neuropathies. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?pin Y)(eq ?pin y)) then (bind ?*score* (+ ?*score* 2.5))) (if (or (eq ?pin Q)(eq ?pin q)) then (halt) ) (retract ?p) (assert (neuropathy burning_pain)) (printout t ?*score* crlf) ) ;*************************Rule 34*********************************** (defrule burning_pain ?p <- (neuropathy burning_pain)

96

=> (printout t "Do you have a feeling of burning pain in legs,arms,feet? N=No Y=Yes" crlf) (bind ?burn(read)) (while (and (neq ?burn Y)(neq ?burn y)(neq ?burn N)(neq ?burn n)(neq ?burn Q)(neq ?burn q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?burn (read)) ) (if (or (eq ?burn y)(eq ?burn Y)(eq ?burn N)(eq ?burn n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Burning pain means occurrence of pain that feels like burning is a symptom of |"crlf "|diabetic neuropathy.Neuropathy may affect up to 50% of people with diabetes.These may|"crlf "|be minor at first, and therefore may remain unnoticed as the condition develops |"crlf "|gradually. However, in some types of diabetic neuropathy, the onset of the pain will |"crlf "|be sudden and sever |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?burn Y)(eq ?burn y)) then (bind ?*score* (+ ?*score* 2.5))) (if (or (eq ?burn Q)(eq ?burn q)) then (halt)) (retract ?p) (assert (oral_problem dry_mouth)) (printout t ?*score* crlf) ) ;*************************Rule 35*********************************** (defrule dry_mouth ?p <- (oral_problem dry_mouth) => (printout t "Do you have a feeling of dry mouth or dry troat? N=No Y=Yes" crlf) (bind ?drymouth(read)) (while (and (neq ?drymouth Y)(neq ?drymouth y)(neq ?drymouth N)(neq ?drymouth n)(neq ?drymouth Q)(neq ?drymouth q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?drymouth (read)) ) (if (or (eq ?drymouth y)(eq ?drymouth Y)(eq ?drymouth N)(eq ?drymouth n)) then (printout t"|-------------------------------------------------------------------------------------|"crlf "|Diabetes is a disease that can affect the whole body, including mouth.This is the |"crlf "|effect of excessive urination. |"crlf "|Dry mouth is often a symptom of undetected diabetes.Uncontrolled diabetes can |"crlf "|decrease saliva flow, resulting in dry mouth. Dry mouth can further lead to soreness,|"crlf "|ulcers, infections, and tooth decay.Uncontrolled diabetes impairs white blood cells, |"crlf "|which are the body's main defense against bacterial infections that can occur in the |"crlf "|mouth. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?drymouth Y)(eq ?drymouth y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?drymouth Q)(eq ?drymouth q)) then (halt))

97

(retract ?p) (assert (oral_problem gum_disease)) (printout t ?*score* crlf) ) ;*************************Rule 36*********************************** (defrule gum_disease ?p <- (oral_problem gum_disease) => (printout t "Have you got any gum disease like red and swollen gums or gums that tend to bleed easily,"crlf "gums separating from the teeth,loose teeth etc? N=No Y=Yes" crlf) (bind ?gum(read)) (while (and (neq ?gum Y)(neq ?gum y)(neq ?gum N)(neq ?gum n)(neq ?gum Q)(neq ?gum q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?gum (read)) ) (if (or (eq ?gum y)(eq ?gum Y)(eq ?gum N)(eq ?gum n)) then (printout t "|---------------------------------------------------------------------------------------|"crlf "|Diabetes reduces the body's resistance to infection, the gums can become one of the |"crlf "|tissues likely to be infected when plaque and tartar are not removed daily.Uncontrolled|"crlf "|diabetes causes blood vessels to thicken,which slows the flow of nutrients to and waste|"crlf "|products from body tissues, including the mouth. When this combination of events |"crlf "|happens, the body's ability to fight infections is reduced.So uncontrolled diabetes |"crlf "|may experience more frequent and more severe gum disease. |"crlf "|---------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?gum Y)(eq ?gum y)) then (bind ?*score* (+ ?*score* 1))) (if (or (eq ?gum Q)(eq ?gum q)) then (halt)) (retract ?p) (assert (nephropathy fruity_smell)) (printout t ?*score* crlf) ) ;*************************Rule 37*********************************** (defrule fruity_smell ?p <- (nephropathy fruity_smell) => (printout t "Do you have a feeling of fruity smell of breath and sweat with fast breathing? N=No Y=Yes" crlf) (bind ?smell(read)) (while (and (neq ?smell Y)(neq ?smell y)(neq ?smell N)(neq ?smell n)(neq ?smell Q)(neq ?smell q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?smell (read)) ) (if (or (eq ?smell y)(eq ?smell Y)(eq ?smell N)(eq ?smell n)) then (printout t "|---------------------------------------------------------------------------------------|"crlf "|A fruity odor to the breath occurs as the body attempts to get rid of excess acetone |"crlf "|through the breathing. This is a sign of ketoacidosis, which may occur in diabetes. It |"crlf

98

"|is a potentially life-threatening condition. DKA happens in both type 1 and type 2 |"crlf "|diabetes but most common with type 1. |"crlf "|DKA results from an absolute shortage of insulin; in response the body switches to burn|"crlf "|fats for energy.The constant break down of fat, releases fatty acids and ketone bodies.|"crlf "|In high levels, ketones are poisonous,causing chemical imbalance (metabolic imbalance) |"crlf "|called Diabetic Ketoacidosis. |"crlf "| |"crlf "|---------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?smell Y)(eq ?smell y)) then (bind ?*score* (+ ?*score* 5))) (if (or (eq ?smell Q)(eq ?smell q)) then (halt)) (retract ?p) (assert (resultrule diagnosisrule)) (printout t ?*score* crlf) ) ;*************************Rule 38*********************************** (defrule youngsrule1 ?p <- (younger_symptom youngsrule1) => (if (eq ?*gender* 'young') then (printout t "Do you have a feeling of abdominal pain? N=No Y=Yes" crlf) (bind ?stomach_pain(read)) (while (and (neq ?stomach_pain Y)(neq ?stomach_pain y)(neq ?stomach_pain N)(neq ?stomach_pain n)(neq ?stomach_pain Q)(neq ?stomach_pain q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?stomach_pain (read)) ) (if (or (eq ?stomach_pain y)(eq ?stomach_pain Y)(eq ?stomach_pain N)(eq ?stomach_pain n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Persons with diabetes may develop abdominal pain,nausea,vomitting because of |"crlf "|gastroparesis, a condition in which the stomach fails to empty properly and their |"crlf "|blood sugars become abnormally high or low (hyperglycemia or hypoglycemia) because |"crlf "|the sugar and insulin balance is disturbed.Gastroparesis may occur in people with |"crlf "|type 1 diabetes or type 2 diabetes.In turn, gastroparesis contributes to poor blood |"crlf "|glucose control. |"crlf "|Abdominal pain mostly occurs in children those who have type 1 diabetes. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?stomach_pain Y)(eq ?stomach_pain y)) then (bind ?*score* (+ ?*score* 4))) (if (or (eq ?stomach_pain Q)(eq ?stomach_pain q)) then (halt) ) (retract ?p) (assert (younger_symptom youngsrule2))) (printout t ?*score* crlf) ) ;*************************Rule 39***********************************

99

(defrule youngsrule2 ?p <- (younger_symptom youngsrule2) => (if (eq ?*gender* 'young') then (printout t "Do you feel regular headache ? N=No Y=Yes" crlf) (bind ?headache (read)) (while (and (neq ?headache Y)(neq ?headache y)(neq ?headache N)(neq ?headache n)(neq ?headache Q)(neq ?headache q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?headache (read)) ) (if (or (eq ?headache y)(eq ?headache Y)(eq ?headache N)(eq ?headache n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|Due to the high blood glucose level, people will get continuous headache frequently |"crlf "|and it will last some 2 to 3 days or more.This type head ache may happen in children |"crlf "|becauseof type 1 diabetes. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?headache Y)(eq ?headache y)) then (bind ?*score* (+ ?*score* 2))) (if (or (eq ?headache Q)(eq ?headache q)) then (halt) ) (retract ?p) (assert (younger_symptom youngsrule3))) (printout t ?*score* crlf) ) ;*************************Rule 40*********************************** (defrule youngsrule3 ?p <- (younger_symptom youngsrule3) => (if (eq ?*gender* 'young') then (printout t "Do you feel dizziness or faint or fall into unconscious ? N=No Y=Yes" crlf) (bind ?uncon (read)) (while (and (neq ?uncon Y)(neq ?uncon y)(neq ?uncon N)(neq ?uncon n)(neq ?uncon Q)(neq ?uncon q)) (printout t "You have entered wrong answer"crlf "Please enter yes or no (y/n)..." crlf "if you need to quit enter q...." crlf) (bind ?uncon (read)) ) (if (or (eq ?uncon y)(eq ?uncon Y)(eq ?uncon N)(eq ?uncon n)) then (printout t "|-------------------------------------------------------------------------------------|"crlf "|With high level of glucose in the blood and low energy level in the body cause the |"crlf "|person to fall in to unconcious. |"crlf "|-------------------------------------------------------------------------------------|"crlf) ) (if (or (eq ?uncon Y)(eq ?uncon y)) then (bind ?*score* (+ ?*score* 2))) (if (or (eq ?uncon Q)(eq ?uncon q))

100

then (halt) ) (retract ?p) (assert (resultrule diagnosisrule))) (printout t ?*score* crlf) ) ;*************************Rule 41*********************************** (defrule diagnosisrule ?p <- (resultrule diagnosisrule) => (printout t ?*score* crlf) (if (eq ?*score* 0) then (printout t " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" " ******************** *************************" " ******************** It appears that you are not Diabetic *************************" " ******************** *************************" " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" (if (and (eq ?*primesym* 0)(< ?*score* 2.5)(>= ?*score* 1)) then (printout t " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" " ******************** *************************" " ********************It appears that you have a very slight *************************" " ******************** *************************" " ******************** chances of getting Diabetes *************************" " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" (if (and (eq ?*primesym* 0)(>= ?*score* 2.5)(< ?*score* 6)) then (printout t " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" " ************** ******************" " ************** It appears that you have slight chances of diabetes******************" " ************** ******************" " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" (if (and (eq ?*primesym* 0)(>= ?*score* 6)(< ?*score* 12)) then (printout t " ************************************************************************************" " ************************************************************************************" " ************************************************************************************" " ************ *****************" " ************ It appears that you have moderate chances of diabetes *****************" " ************ *****************" " ************ Please consult a physician *****************"

crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf

101

" " " (if (and (eq ?*primesym* (printout t " " " " " " " " " " (if (and (eq ?*primesym* (printout t " " " " " " " " " " (if (and (eq ?*primesym* (printout t " " " " " " " " " (if (and (eq ?*primesym* (printout t " " " " " " " " " " (if (and (eq ?*primesym* (printout t " " " "

************************************************************************************" ************************************************************************************" ************************************************************************************" 0)(>= ?*score* 12)(< ?*score* 18)) then ************************************************************************************" ************************************************************************************" ************************************************************************************" ************** ******************" ************** It appears that you have high chances of diabetes ******************" ************** ******************" ************** Please consult a physician ******************" ************************************************************************************" ************************************************************************************" ************************************************************************************" 0)(>= ?*score* 18)(< ?*score* 24)) then ************************************************************************************" ************************************************************************************" *********************************************** ************************************" ************** ***********************" ************** It appears that you have very high chance of ***********************" ************** ***********************" ************** Diabetes, Please consult a physician ***********************" ************************************************************************************" ************************************************************************************" ************************************************************************************" 0)(>= ?*score* 24)) then ************************************************************************************" ************************************************************************************" ************************************************************************************" ************** It appears that you are diabetic ***********************" ************** ***********************" ************** Please consult a physician ***********************" ************************************************************************************" ************************************************************************************" ************************************************************************************" 1)(>= ?*score* 5)(< ?*score* 14)) then ************************************************************************************" ************************************************************************************" ************************************************************************************" ************ *****************" ************ It appears that you have moderate chances of diabetes *****************" ************ *****************" ************ Please consult a physician *****************" ************************************************************************************" ************************************************************************************" ************************************************************************************" 1)(>= ?*score* 5)(>= ?*score* 14)) then ************************************************************************************" ************************************************************************************" ************************************************************************************" ***************** *************"

crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf)) crlf crlf crlf crlf

102

" ***************** It appears that you have high chances of Diabetes *************" crlf " ***************** *************" crlf " ***************** Please consult a physician *************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf)) (if (and (eq ?*primesym* 2)(>= ?*score* 10)(< ?*score* 19)) then (printout t " ************************************************************************************" crlf " ************************************* ***********************************************" crlf " ************************************************************************************" crlf " ***************** *************" crlf " ***************** It appears that you have high chances of Diabetes *************" crlf " ***************** *************" crlf " ***************** Please consult a physician *************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf)) (if (and (eq ?*primesym* 2)(>= ?*score* 10)(>= ?*score* 19)) then (printout t " ************************************************************************************" crlf " ************************************* ***********************************************" crlf " ************************************************************************************" crlf " ***************** *************" crlf " *****************It appears that you have very high chances of Diabetes*************" crlf " ***************** *************" crlf " ***************** Please consult a physician *************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf)) (if (and (eq ?*primesym* 3)(>= ?*score* 15)(< ?*score* 24)) then (printout t " ************************************************************************************" crlf " ************************************* ***********************************************" crlf " ************************************************************************************" crlf " ***************** *************" crlf " *****************It appears that you have very high chances of Diabetes*************" crlf " ***************** *************" crlf " ***************** Please consult a physician *************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf)) (if (and (eq ?*primesym* 3)(>= ?*score* 15)(>= ?*score* 24)) then (printout t " ************************************************************************************" crlf " ************************************* **********************************************" crlf " ************************************************************************************" crlf " ***************** *************" crlf " ***************** It appears that you are Diabetic *************" crlf " ***************** *************" crlf " ***************** Please consult a physician *************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf " ************************************************************************************" crlf)) (if (and (> ?*primesym* 3)(>= ?*score* 20)) then

103

(printout t " " " " " " " " " " (retract ?p) (halt) )

************************************************************************************" ************************************************************************************" ************************************************************************************" ************************ ********************" ************************ It appears that you are diabetic ********************" ************************ ********************" ************************ Please consult a physician ********************" ************************************************************************************" ************************************************************************************" ************************************************************************************"

crlf crlf crlf crlf crlf crlf crlf crlf crlf crlf))

104

LITERATURE CITED
1. Texas University-ESDIABETES(An Expert system In diabetes)- Consortium for Computing Sciences in Colleges ,Proceedings of the twelth annual CCSC South Central conference on The journal of computing in small colleges April 2001, Journal of Computing Sciences in Colleges(JCSC) March 2001. 2. Jiang Ming-yan, Chen Zhi-jian-Diabetes Expert System-IEEE International Conference on Intelligent Processing System, 1997. 3. S. Abu Naser, Alaa N. Akkila, A Proposed Expert System for Skin Diseases Diagnosis, INSInet Publication ,Journal of Applied Sciences Research, 4(12): 1682-1693, 2008. 4. Abu-Naser, S.S., H. El-Hissi, M. Abu-Rass and N. El-Khozondar, Al-Azhar University, Gaza, Palestine ,An Expert System for Endocrine Diagnosis and Treatment Using JESS, SCIENCE ALERT an open access publisher,Journal of Artificial Intelligences 3(4): 239-251, 2010 5. Galina Setlak, Mariusz Dbrowski, Wioletta Szajnar,Monika Pirg-Mazur, Tomasz KoakArtificial Intelligence Approach to Diabetes Diagnostics- International Book Series "Information Science and Computing" 209, 2009 6. Ovidiu Noran, Griffith University School of Computing and information technology Australia, Case Study: A course advisor expert system, Advances in Artificial Intelligences, Springer Link 2003 7. Ajith Abraham, Oklahoma state university, USA, Rule bases expert systems, Soft computing.net, 2005 8. Robert S Engelmore & Edward Feigenbaum,Expert systems and artificial Intelligence,WTEC Hyper-Librarian,May 1993 9. G Neumann , Programming Languages in Artificial Intelligence , German Research Center for Artificial Intelligence (LTLab, DFKI) 10. Daisuke Takahashi, Yang Xiao, Fei Hu, andMichael Lewis, Review Article-A Survey of Insulin-Dependent DiabetesPart I: Therapies and Devices, Hindawi Publishing Corporation International Journal of Telemedicine and Applications, 2008

105

11. Daisuke Takahashi, Yang Xiao, Fei Hu, andMichael Lewis, Review Article-A Survey of Insulin-Dependent Diabetes Part II: ControlMethods, Hindawi Publishing Corporation International Journal of Telemedicine and Applications, 2008 12. Joseph Giarratano, Gary Reilly -Expert Systems Principles and Programming 13. Joseph C. Giarratano ,CLIPS Basic Programming Guide, ,2007 14. Joseph C. Giarratano, CLIPS Users Guide, 2007 15. Joseph C. Giarratano, CLIPS Advanced Programming Guide, 2008 16. Joseph C. Giarratano, CLIPS Interfaces Guide, 2007 17. American Diabetes Association Complete Guide to Diabetes 3rd Edition 18. www.healthsinfo.com 19. www.diabetes.webmd.com/tc/type-2-diabet 20. www.medicinenet.com/diabetes_mellitus/article.htm 21. http://care.diabetesjournals.org/content/33/Supplement_1/S89.full 22. www.diabetessymptomsonline.comwww.diabetesinformationhub.com 23. www.healthcentral.com

106

ACKNOWLEDGEMENT
I express my sincere thanks to Dr. P V Abdulla, Rtd DMO, working as the chief medical officer of Life Care Hospital, Trikarpur, Kerala and Dr. Basavana Gowda, Pediatrician, Apollo Clinic, Electronic City, Bangalore for providing domain knowledge, Dr. Sooraj (physiotherapist), laboratory staff and patients for providing help in collecting data from Life Care Hospital, Trikarpur. I express my sincere gratitude to my guide Asst. Professor Mrs. Rohini for her valuable guidance and immense help to complete the thesis. I am very grateful to our course coordinator Prof. K. Balachandran for providing the environment to complete the thesis successfully. I would like to thank our Vice chancellor, Pro-vice chancellor, and Dean of Sciences of Christ University. Also I am deeply indebted to our Head of the Department and faculty members of Computer Science department of Christ University, Bangalore for providing technical support to achieve this work. Finally, I take this opportunity to extend my deep appreciation to my family and classmates, for all that they meant to me during the crucial times of the completion of my work.

107

Potrebbero piacerti anche