├── Disease symptoms ├── Alzheimers.txt ├── Arthritis.txt ├── Asthma.txt ├── Diabetes.txt ├── Epilepsy.txt ├── Glaucoma.txt ├── Hypothermia.txt ├── Jaundice.txt ├── Sinusitis.txt ├── Heart Disease.txt ├── Heat Stroke.txt ├── Hyperthyroidism.txt └── Tuberculosis.txt ├── diseases.txt ├── Disease treatments ├── Alzheimers.txt ├── Heart Disease.txt ├── Jaundice.txt ├── Epilepsy.txt ├── Asthma.txt ├── Sinusitis.txt ├── Hypothermia.txt ├── Glaucoma.txt ├── Tuberculosis.txt ├── Hyperthyroidism.txt ├── Diabetes.txt ├── Arthritis.txt └── Heat Stroke.txt ├── Disease descriptions ├── Epilepsy.txt ├── Alzheimers.txt ├── Asthma.txt ├── Diabetes.txt ├── Glaucoma.txt ├── Heat Stroke.txt ├── Sinusitis.txt ├── Jaundice.txt ├── Hypothermia.txt ├── Hyperthyroidism.txt ├── Arthritis.txt ├── Heart Disease.txt └── Tuberculosis.txt ├── README.md └── medical_expert_system.py /Disease symptoms/Alzheimers.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | no 6 | no 7 | no 8 | yes 9 | no 10 | no 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Arthritis.txt: -------------------------------------------------------------------------------- 1 | no 2 | yes 3 | no 4 | no 5 | no 6 | no 7 | yes 8 | no 9 | no 10 | no 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Asthma.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | yes 4 | yes 5 | no 6 | no 7 | no 8 | yes 9 | no 10 | no 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Diabetes.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | no 6 | no 7 | yes 8 | no 9 | no 10 | no 11 | no 12 | yes 13 | yes -------------------------------------------------------------------------------- /Disease symptoms/Epilepsy.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | no 6 | no 7 | yes 8 | no 9 | no 10 | no 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Glaucoma.txt: -------------------------------------------------------------------------------- 1 | yes 2 | no 3 | no 4 | no 5 | no 6 | no 7 | no 8 | no 9 | no 10 | no 11 | no 12 | yes 13 | yes -------------------------------------------------------------------------------- /Disease symptoms/Hypothermia.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | yes 6 | no 7 | no 8 | no 9 | yes 10 | no 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Jaundice.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | no 6 | no 7 | yes 8 | no 9 | no 10 | yes 11 | no 12 | yes 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Sinusitis.txt: -------------------------------------------------------------------------------- 1 | yes 2 | no 3 | no 4 | yes 5 | no 6 | yes 7 | no 8 | no 9 | no 10 | yes 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Heart Disease.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | yes 4 | no 5 | no 6 | no 7 | no 8 | no 9 | no 10 | no 11 | no 12 | yes 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Heat Stroke.txt: -------------------------------------------------------------------------------- 1 | yes 2 | no 3 | no 4 | no 5 | no 6 | no 7 | no 8 | no 9 | no 10 | yes 11 | no 12 | yes 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Hyperthyroidism.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | no 4 | no 5 | no 6 | no 7 | yes 8 | no 9 | no 10 | no 11 | no 12 | yes 13 | no -------------------------------------------------------------------------------- /Disease symptoms/Tuberculosis.txt: -------------------------------------------------------------------------------- 1 | no 2 | no 3 | yes 4 | yes 5 | no 6 | no 7 | no 8 | no 9 | no 10 | yes 11 | no 12 | no 13 | no -------------------------------------------------------------------------------- /diseases.txt: -------------------------------------------------------------------------------- 1 | Jaundice 2 | Alzheimers 3 | Arthritis 4 | Tuberculosis 5 | Asthma 6 | Sinusitis 7 | Epilepsy 8 | Heart Disease 9 | Diabetes 10 | Glaucoma 11 | Hyperthyroidism 12 | Heat Stroke 13 | Hypothermia -------------------------------------------------------------------------------- /Disease treatments/Alzheimers.txt: -------------------------------------------------------------------------------- 1 | No treatments stop or reverse its progression, though some may temporarily improve symptoms but medication and management strategies may temporarily improve symptoms. 2 | 3 | Medication: 4 | 5 | Cognition-enhancing medication 6 | Improves mental function, lowers blood pressure and may balance mood. -------------------------------------------------------------------------------- /Disease descriptions/Epilepsy.txt: -------------------------------------------------------------------------------- 1 | Epilepsy is a central nervous system (neurological) disorder in which brain activity becomes abnormal, causing seizures or periods of unusual behavior, sensations, and sometimes loss of awareness. 2 | 3 | Anyone can develop epilepsy. Epilepsy affects both males and females of all races, ethnic backgrounds and ages. 4 | 5 | Seizure symptoms can vary widely. Some people with epilepsy simply stare blankly for a few seconds during a seizure, while others repeatedly twitch their arms or legs. 6 | 7 | Having a single seizure doesn't mean you have epilepsy. At least two unprovoked seizures are generally required for an epilepsy diagnosis. -------------------------------------------------------------------------------- /Disease treatments/Heart Disease.txt: -------------------------------------------------------------------------------- 1 | Prevention: 2 | 3 | Certain types of heart disease, such as heart defects, can't be prevented. However, you can help prevent many other types of heart disease by making the same lifestyle changes that can improve your heart disease, such as: 4 | 5 | Quit smoking 6 | Control other health conditions, such as high blood pressure, high cholesterol and diabetes 7 | Exercise at least 30 minutes a day on most days of the week 8 | Eat a diet that's low in salt and saturated fat 9 | Maintain a healthy weight 10 | Reduce and manage stress 11 | Practice good hygiene 12 | 13 | Medications: 14 | 15 | ACE Inhibitors 16 | Antiarrhythmics 17 | Beta-Blocker Therapy 18 | Digoxin 19 | Diuretics -------------------------------------------------------------------------------- /Disease descriptions/Alzheimers.txt: -------------------------------------------------------------------------------- 1 | Alzheimer's disease (AD), also referred to simply as Alzheimer's, is a chronic neurodegenerative disease that usually starts slowly and worsens over time. 2 | 3 | As a person's condition declines, they often withdraw from family and society. Gradually, bodily functions are lost, ultimately leading to death. Although the speed of progression can vary, the average life expectancy following diagnosis is three to nine years. 4 | 5 | The cause of Alzheimer's disease is poorly understood. About 70% of the risk is believed to be genetic with many genes usually involved. 6 | 7 | A probable diagnosis is based on the history of the illness and cognitive testing with medical imaging and blood tests to rule out other possible causes -------------------------------------------------------------------------------- /Disease treatments/Jaundice.txt: -------------------------------------------------------------------------------- 1 | Jaundice is treated by managing the underlying cause. 2 | 3 | Medication: 4 | 5 | Medication or supplements can help jaundice depending on the cause. 6 | Treatment will depend on the underlying cause. 7 | 8 | Jaundice treatment targets the cause rather than the jaundice symptoms. 9 | 10 | The following treatments are used: 11 | 12 | Anemia-induced jaundice may be treated by boosting the amount of iron in the blood by either taking iron supplements or eating more iron-rich foods. 13 | Hepatitis-induced jaundice requires antiviral or steroid medications. 14 | Doctors can treat obstruction-induced jaundice by surgically removing the obstruction. 15 | 16 | If the jaundice has been caused by use of a medication, treatment for involves changing to an alternative medication. -------------------------------------------------------------------------------- /Disease descriptions/Asthma.txt: -------------------------------------------------------------------------------- 1 | Asthma is a common long-term inflammatory disease of the airways of the lungs. 2 | It is characterized by variable and recurring symptoms, reversible airflow obstruction, and bronchospasm. 3 | 4 | Asthma is thought to be caused by a combination of genetic and environmental factors. 5 | Environmental factors include exposure to air pollution and allergens. 6 | 7 | Other potential triggers include medications such as aspirin and beta blockers. 8 | 9 | Diagnosis: 10 | Diagnosis is usually based on the pattern of symptoms, response to therapy over time, and spirometry. 11 | 12 | Asthma is classified according to the frequency of symptoms, forced expiratory volume in one second (FEV1), and peak expiratory flow rate. 13 | 14 | It may also be classified as atopic or non-atopic, where atopy refers to a predisposition toward developing a type 1 hypersensitivity reaction. -------------------------------------------------------------------------------- /Disease treatments/Epilepsy.txt: -------------------------------------------------------------------------------- 1 | Treatment with medications or sometimes surgery can control seizures for the majority of people with epilepsy. 2 | 3 | Some people require lifelong treatment to control seizures, but for others, the seizures eventually go away. Some children with epilepsy may outgrow the condition with age. 4 | 5 | Medication: 6 | 7 | Epilepsy medications, sometimes called anti-seizure or anticonvulsant medications, change the way your brain cells work and send messages to each other. 8 | 9 | The kind of medication depends on: 10 | 11 | The type of seizures 12 | Frequency of seizures 13 | Age 14 | Sex 15 | Other medical conditions 16 | 17 | General Medications are: 18 | 19 | Carbamazepine (Tegretol or Carbatrol) 20 | Divalproex (depakote, Depakote ER) 21 | Diazepam (Valium and similar tranquilizers) 22 | Ethosuximide (Zarontin) 23 | Phenytoin (Dilantin or Phenytek) 24 | Phenobarbital 25 | Primidone (Mysoline) 26 | Valproic acid (Depakene) -------------------------------------------------------------------------------- /Disease descriptions/Diabetes.txt: -------------------------------------------------------------------------------- 1 | Diabetes, describes a group of metabolic diseases in which the person has high blood glucose (blood sugar), either because insulin production is inadequate, or because the body's cells do not respond properly to insulin, or both. 2 | 3 | Diabetes is a long-term condition that causes high blood sugar levels. 4 | There are two types of diabetes: 5 | 6 | 1.Type 1 diabetes and 2. Type 2 diabetes 7 | 8 | In Type 1 Diabetes, the body does not produce insulin. Approximately 10% of all diabetes cases are type 1. 9 | 10 | In Type 2 Diabetes, the body does not produce enough insulin for proper function. Approximately 90% of all cases of diabetes worldwide are of this type. 11 | 12 | People usually develop type 1 diabetes before their 40th year, often in early adulthood or teenage years. 13 | 14 | Diagnosis Tests: 15 | 16 | Glycated hemoglobin (A1C) test 17 | Random blood sugar test 18 | Fasting blood sugar test 19 | Oral glucose tolerance test 20 | 21 | 22 | -------------------------------------------------------------------------------- /Disease treatments/Asthma.txt: -------------------------------------------------------------------------------- 1 | There is no cure for asthma. 2 | 3 | Symptoms can be prevented by avoiding triggers, such as allergens and irritants, and by the use of inhaled corticosteroids. 4 | 5 | Anti-inflammatory drugs, particularly inhaled steroids, are the most important treatment for most people with asthma. 6 | 7 | Bronchodilators relieve the symptoms of asthma by relaxing the muscles that can tighten around the airways. This helps to open up the airways. 8 | 9 | Short-acting bronchodilator inhalers are often referred to as rescue inhalers and are used to quickly relieve the cough, wheeze, chest tightness, and shortness of breath caused by asthma 10 | 11 | Long-acting beta agonists (LABA) or antileukotriene agents may be used in addition to inhaled corticosteroids if asthma symptoms remain uncontrolled. 12 | 13 | Treatment of rapidly worsening symptoms is usually with an inhaled short-acting beta-2 agonist such as salbutamol and corticosteroids taken by mouth. In very severe cases, intravenous corticosteroids, magnesium sulfate, and hospitalization may be required. -------------------------------------------------------------------------------- /Disease treatments/Sinusitis.txt: -------------------------------------------------------------------------------- 1 | Prevention: 2 | 3 | Take these steps to help reduce your risk of getting acute sinusitis: 4 | 5 | Avoid upper respiratory infections. Minimize contact with people who have colds. Wash your hands frequently with soap and water, especially before your meals. 6 | 7 | Manage your allergies. 8 | 9 | Avoid cigarette smoke and polluted air. Tobacco smoke and other pollutants can irritate and inflame your lungs and nasal passages. 10 | 11 | Use a humidifier. If the air in your home is dry, such as it is if you have forced-air heat, adding moisture to the air may help prevent sinusitis. Be sure the humidifier stays clean and free of mold with regular, thorough cleaning. 12 | 13 | Treatment: 14 | 15 | Using a nasal decongestant spray, such as oxymetazoline, can help relieve sinus infection symptoms short-term. 16 | 17 | Other over-the-counter medicines that contain antihistamines and decongestants can help with sinus infections, particularly if you also suffer from allergies. 18 | 19 | Medications: 20 | 21 | Sudafed 22 | Zyrtec 23 | Allegra 24 | Claritin 25 | 26 | -------------------------------------------------------------------------------- /Disease treatments/Hypothermia.txt: -------------------------------------------------------------------------------- 1 | Depending on the severity of hypothermia, emergency medical care for hypothermia may include one of the following interventions to raise the body temperature: 2 | 3 | Passive rewarming: For someone with mild hypothermia, it is enough to cover them with heated blankets and offer warm fluids to drink. 4 | 5 | Blood rewarming : Blood may be drawn, warmed and recirculated in the body. A common method of warming blood is the use of a hemodialysis machine, which is normally used to filter blood in people with poor kidney function. Heart bypass machines also may need to be used. 6 | 7 | Warm intravenous fluids: A warmed intravenous solution of salt water may be put into a vein to help warm the blood. 8 | 9 | Airway rewarming: The use of humidified oxygen administered with a mask or nasal tube can warm the airways and help raise the temperature of the body. 10 | 11 | Irrigation: A warm saltwater solution may be used to warm certain areas of the body, such as the area around the lungs (pleura) or the abdominal cavity (peritoneal cavity). The warm liquid is introduced into the affected area with catheters. 12 | 13 | -------------------------------------------------------------------------------- /Disease treatments/Glaucoma.txt: -------------------------------------------------------------------------------- 1 | Vision loss due to glaucoma can't be recovered. 2 | 3 | Prevention: 4 | Get regular eye exams that include measurements of your eye pressure. 5 | If glaucoma is recognized early, vision loss can be slowed or prevented. life. 6 | 7 | Treatments for Glaucoma include: 8 | 9 | Medicines: 10 | 11 | Medicines, in the form of eyedrops or pills, are the most common early treatment for glaucoma. 12 | 13 | Taken regularly, these eyedrops lower eye pressure. Some medicines cause the eye to make less fluid. Others lower pressure by helping fluid drain from the eye. 14 | 15 | Laser trabeculoplasty: 16 | 17 | Laser trabeculoplasty helps fluid drain out of the eye. Your doctor may suggest this step at any time. In many cases, medicines still need to be taken after the procedure. 18 | 19 | If glaucoma is present in both eyes, usually only one eye will be treated at a time. Laser treatments for each eye will be scheduled several days to several weeks apart. 20 | 21 | Conventional surgery: 22 | Conventional surgery makes a new opening for the fluid to leave the eye. Conventional surgery often is done after medicines and laser surgery have failed to control pressure -------------------------------------------------------------------------------- /Disease treatments/Tuberculosis.txt: -------------------------------------------------------------------------------- 1 | Medications are the cornerstone of tuberculosis treatment. 2 | 3 | Medications are the cornerstone of tuberculosis treatment. But treating TB takes much longer than treating other types of bacterial infections. 4 | 5 | With tuberculosis, you must take antibiotics for at least six to nine months. The exact drugs and length of treatment depend on your age, overall health, possible drug resistance, the form of TB (latent or active) and the infection's location in the body. 6 | 7 | Four months instead of nine — with combined medication may be effective in keeping latent TB from becoming active TB. With the shorter course of treatment, people are more likely to take all their medication, and the risk of side effects is lessened. 8 | 9 | The most common medications used to treat tuberculosis include: 10 | Isoniazid 11 | Rifampin (Rifadin, Rimactane) 12 | Ethambutol (Myambutol) 13 | Pyrazinamide 14 | 15 | If you have drug-resistant TB, a combination of antibiotics called fluoroquinolones and injectable medications, such as amikacin, kanamycin or capreomycin, are generally used for 20 to 30 months. Some types of TB are developing resistance to these medications as well. -------------------------------------------------------------------------------- /Disease treatments/Hyperthyroidism.txt: -------------------------------------------------------------------------------- 1 | Treatment 2 | 3 | Several treatments for hyperthyroidism exist. The best approach depends on age, physical condition, the underlying cause of the hyperthyroidism, personal preference and the severity of disorder: 4 | 5 | Radioactive iodine. Taken by mouth, radioactive iodine is absorbed by thyroid gland, where it causes the gland to shrink and symptoms to subside, usually within three to six months. Because this treatment causes thyroid activity to slow considerably, causing the thyroid gland to be underactive (hypothyroidism), you may eventually need to take medication every day to replace thyroxine. 6 | 7 | Anti-thyroid medications. These medications gradually reduce symptoms of hyperthyroidism by preventing thyroid gland from producing excess amounts of hormones. They include propylthiouracil and methimazole (Tapazole). Both drugs can cause serious liver damage, sometimes leading to death. 8 | 9 | Beta blockers. These drugs are commonly used to treat high blood pressure. They won't reduce thyroid levels, but they can reduce a rapid heart rate and help prevent palpitations. 10 | 11 | Surgery (thyroidectomy). If patients can't tolerate anti-thyroid drugs and don't want to or can't have radioactive iodine therapy, they may be a candidate for thyroid surgery. 12 | -------------------------------------------------------------------------------- /Disease descriptions/Glaucoma.txt: -------------------------------------------------------------------------------- 1 | Glaucoma is a group of eye conditions that damage the optic nerve, which is vital to good vision. This damage is often caused by an abnormally high pressure in the eye. 2 | 3 | It can occur at any age but is more common in older adults. 4 | 5 | Glaucoma is the result of damage to the optic nerve. As this nerve gradually deteriorates, blind spots develop in your visual field. 6 | 7 | This nerve damage is usually related to increased pressure in the eye. 8 | 9 | Elevated eye pressure is due to a buildup of a fluid (aqueous humor) that flows throughout your eye. 10 | 11 | This fluid normally drains into the front of the eye (anterior chamber) through tissue (trabecular meshwork) at the angle where the iris and cornea meet. 12 | 13 | When fluid is overproduced or the drainage system doesn't work properly, the fluid can't flow out at its normal rate and pressure builds up. 14 | 15 | Types of glaucoma are: 16 | 17 | Open-angle glaucoma 18 | Angle-closure glaucoma 19 | Normal-tension glaucoma 20 | Pigmentary glaucoma 21 | 22 | Dignosis: 23 | 24 | The following are checked for diagnosing Glaucoma: 25 | 26 | Pressure in eyes 27 | Drainage angle of eyes 28 | Examination of optic nerve for damage 29 | Testing of peripheral side vision 30 | Measurement of optic nerve 31 | thickness of cornea -------------------------------------------------------------------------------- /Disease treatments/Diabetes.txt: -------------------------------------------------------------------------------- 1 | Patients with type 1 diabetes will need to take insulin injections for the rest of their life. They must also ensure proper blood-glucose levels by carrying out regular blood tests and following a special diet. 2 | 3 | Type 2 patients need to eat healthily, be physically active, and test their blood glucose. They may also need to take oral medication, and/or insulin to control blood glucose levels. 4 | 5 | Treatment for type 1 diabetes includes: 6 | 7 | Taking insulin 8 | Carbohydrate, fat and protein counting 9 | Frequent blood sugar monitoring 10 | Eating healthy foods 11 | Exercising regularly and maintaining a healthy weight 12 | 13 | Types of insulin are many and include: 14 | 15 | Short-acting (regular) insulin 16 | Rapid-acting insulin 17 | Intermediate-acting (NPH) insulin 18 | Long-acting insulin 19 | 20 | Other Medications: 21 | 22 | High blood pressure medications 23 | Aspirin 24 | Cholesterol-lowering drugs 25 | 26 | Treatment for type 2 diabetes includes: 27 | 28 | Healthy eating 29 | Regular exercise 30 | Possibly, diabetes medication or insulin therapy 31 | Blood sugar monitoring 32 | 33 | Examples of possible treatments for type 2 diabetes include: 34 | 35 | Metformin (Glucophage, Glumetza, others) 36 | Sulfonylureas 37 | Meglitinides 38 | Thiazolidinediones 39 | Insulin therapy -------------------------------------------------------------------------------- /Disease descriptions/Heat Stroke.txt: -------------------------------------------------------------------------------- 1 | Heatstroke generally occurs when an individual has been too hot for too long, whether working, exercising, or simply sitting in a hot environment. 2 | 3 | Also known as sunstroke, heatstroke is a serious condition and must be considered an emergency. 4 | 5 | If the body temperature rises above 40° Celsius, and the body loses the ability to cool down, it is considered to be heatstroke. 6 | 7 | If left untreated, damage to internal organs can occur. The longer it is left, the more serious heatstroke can become. In some cases, heatstroke can be fatal. 8 | 9 | Heatstroke can be brought on by physical exertion in hot conditions, or simply by being in a hot environment 10 | 11 | Treating heatstroke centers around bringing body temperature down. 12 | 13 | Heatstroke can occur as a result of: 14 | 15 | Exposure to a hot environment. 16 | 17 | In a type of heatstroke, called nonexertional (classic) heatstroke, being in a hot environment leads to a rise in core body temperature. This type of heatstroke typically occurs after exposure to hot, humid weather, especially for prolonged periods. 18 | 19 | It occurs most often in older adults and in people with chronic illness. 20 | 21 | Strenuous activity. Exertional heatstroke is caused by an increase in core body temperature brought on by intense physical activity in hot weather. 22 | 23 | Anyone exercising or working in hot weather can get exertional heatstroke, but it's most likely to occur if you're not used to high temperatures. -------------------------------------------------------------------------------- /Disease descriptions/Sinusitis.txt: -------------------------------------------------------------------------------- 1 | Acute sinusitis (acute rhinosinusitis) causes the cavities around your nasal passages (sinuses) to become inflamed and swollen. This interferes with drainage and causes mucus to build up. 2 | 3 | With acute sinusitis, it might be difficult to breathe through your nose. The area around your eyes and face might feel swollen, and you might have throbbing facial pain or a headache. 4 | 5 | Acute sinusitis is mostly caused by the common cold. Unless a bacterial infection develops, most cases resolve within a week to 10 days. 6 | 7 | In most cases, home remedies are all that's needed to treat acute sinusitis. However, persistent sinusitis can lead to serious infections and other complications. Sinusitis that lasts more than 12 weeks despite medical treatment is called chronic sinusitis. 8 | 9 | Acute sinusitis is most often caused by the common cold, which is a viral infection. In some cases, a bacterial infection develops. 10 | 11 | You may be at increased risk of getting sinusitis if you have: 12 | 13 | Hay fever or another allergic condition that affects your sinuses 14 | A nasal passage abnormality, such as a deviated nasal septum, nasal polyps or tumors 15 | A medical condition such as cystic fibrosis or an immune system disorder such as HIV/AIDS 16 | 17 | Diagnosis: 18 | 19 | Redness and swelling of the nasal passages 20 | 21 | Purulent (pus like) drainage from the nasal passages (the symptom most likely to clinically diagnose a sinus infection) 22 | 23 | Tenderness to percussion (tapping) over the cheeks or forehead region of the sinuses 24 | 25 | Swelling about the eyes and cheeks. -------------------------------------------------------------------------------- /Disease descriptions/Jaundice.txt: -------------------------------------------------------------------------------- 1 | Jaundice is a term used to describe a yellowish tinge to the skin and the whites of the eye. Body fluids may also be yellow. 2 | 3 | The color of the skin and whites of the eyes will vary depending on levels of bilirubin. Bilirubin is a waste material found in the blood. 4 | 5 | Moderate levels lead to a yellow color, while very high levels will appear brown. 6 | An inflamed liver or obstructed bile duct can lead to jaundice, as well as other underlying conditions. 7 | 8 | Underlying conditions that may cause jaundice include: 9 | 10 | Acute inflammation of the liver: This may impair the ability of the liver to conjugate and secrete bilirubin, resulting in a buildup. 11 | 12 | Inflammation of the bile duct: This can prevent the secretion of bile and removal of bilirubin, causing jaundice. 13 | 14 | Obstruction of the bile duct: This prevents the liver from disposing of bilirubin. 15 | Hemolytic anemia: The production of bilirubin increases when large quantities of red blood cells are broken down. 16 | 17 | Gilbert's syndrome: This is an inherited condition that impairs the ability of enzymes to process the excretion of bile. 18 | 19 | Cholestasis: This interrupts the flow of bile from the liver. The bile containing conjugated bilirubin remains in the liver instead of being excreted. 20 | 21 | Diagnosis: 22 | 23 | The yellowing of skin and eyes are likely to be the main clues a doctor will use before confirming a jaundice diagnosis. 24 | 25 | A physical examination will be carried out to look for signs of swelling of the liver and legs, ankles or feet, which might indicate cirrhosis of the liver. -------------------------------------------------------------------------------- /Disease descriptions/Hypothermia.txt: -------------------------------------------------------------------------------- 1 | Hypothermia is a medical emergency that occurs when your body loses heat faster than it can produce heat, causing a dangerously low body temperature. Normal body temperature is around 98.6 F (37 C). Hypothermia (hi-poe-THUR-me-uh) occurs as your body temperature falls below 95 F (35 C). 2 | 3 | When your body temperature drops, your heart, nervous system and other organs can't work normally. Left untreated, hypothermia can eventually lead to complete failure of your heart and respiratory system and eventually to death. 4 | 5 | Hypothermia is often caused by exposure to cold weather or immersion in cold water. Primary treatments for hypothermia are methods to warm the body back to a normal temperature. 6 | 7 | Hypothermia has two main types of causes. It classically occurs from exposure to extreme cold. 8 | 9 | It may also occur from any condition that decreases heat production or increases heat loss. 10 | Commonly this includes alcohol intoxication but may also include low blood sugar, anorexia, and advanced age. 11 | 12 | Body temperature is usually maintained near a constant level of 36.5–37.5 °C (97.7–99.5 °F) through thermoregulation. 13 | 14 | Efforts to increase body temperature involve shivering, increased voluntary activity, and putting on warmer clothing. 15 | 16 | Diagnosis: 17 | 18 | The diagnosis of hypothermia is usually apparent based on a person's physical signs and the conditions in which the person with hypothermia became ill or was found. Blood tests also can help confirm hypothermia and its severity. 19 | 20 | A diagnosis may not be readily apparent, however, if the symptoms are mild, as when an older person who is indoors has symptoms of confusion, lack of coordination and speech problems. -------------------------------------------------------------------------------- /Disease descriptions/Hyperthyroidism.txt: -------------------------------------------------------------------------------- 1 | Hyperthyroidism is a condition of the thyroid. The thyroid is a small, butterfly-shaped gland located at the front of your neck. It produces tetraiodothyronine (T4) and triiodothyronine (T3), which are two primary hormones that control how your cells use energy. Your thyroid gland regulates your metabolism through the release of these hormones. 2 | 3 | Hyperthyroidism occurs when the thyroid makes too much T4, T3, or both. Diagnosis of overactive thyroid and treatment of the underlying cause can relieve symptoms and prevent complications. 4 | 5 | A variety of conditions can cause hyperthyroidism. Graves' disease, an autoimmune disorder, is the most common cause of hyperthyroidism. It causes antibodies to stimulate the thyroid to secrete too much hormone. Graves’ disease occurs more often in women than in men. It tends to run in families, which suggests a genetic link. You should tell your doctor if your relatives have had the condition. 6 | 7 | Other causes of hyperthyroidism include: 8 | 9 | Excess iodine, a key ingredient in T4 and T3 10 | 11 | Thyroiditis, or inflammation of the thyroid, which causes T4 and T3 to leak out of the gland 12 | 13 | Tumors of the ovaries or testes 14 | 15 | Benign tumors of the thyroid or pituitary gland 16 | 17 | Large amounts of tetraiodothyronine taken through dietary supplements or medication 18 | 19 | Diagnosis: 20 | 21 | Cholesterol test 22 | T4, free T4, T3 tests 23 | Thyroid stimulating hormone level test 24 | Triglyceride test 25 | Thyroid scan and uptake 26 | Ultrasound 27 | CT or MRI scans 28 | Radio Iodine Uptake test 29 | 30 | Physical Exam 31 | Blood Tests 32 | Checking for weight loss 33 | Checking for protruding eyes 34 | Checking for enlarged thyroid gland 35 | -------------------------------------------------------------------------------- /Disease descriptions/Arthritis.txt: -------------------------------------------------------------------------------- 1 | Arthritis is Inflammation of one or more joints, causing pain and stiffness that can worsen with age. 2 | 3 | Arthritis is very common but is not well understood. 4 | 5 | Different types of arthritis exist, each with different causes including wear and tear, infections and underlying diseases. 6 | 7 | There are over 100 types of arthritis. The most common forms are osteoarthritis (degenerative joint disease) and rheumatoid arthritis. 8 | 9 | Osteoarthritis is the most common type of arthritis. When the cartilage – the slick, cushioning surface on the ends of bones – wears away, bone rubs against bone, causing pain, swelling and stiffness. Over time, joints can lose strength and pain may become chronic. Risk factors include excess weight, family history, age and previous injury (an anterior cruciate ligament, or ACL, tear, for example). 10 | 11 | Rheumatoid arthritis is a chronic inflammatory disorder that can affect more than just your joints. In some people, the condition also can damage a wide variety of body systems, including the skin, eyes, lungs, heart and blood vessels. 12 | 13 | An autoimmune disorder, rheumatoid arthritis occurs when your immune system mistakenly attacks your own body's tissues. 14 | 15 | Unlike the wear-and-tear damage of osteoarthritis, rheumatoid arthritis affects the lining of your joints, causing a painful swelling that can eventually result in bone erosion and joint deformity. 16 | 17 | The inflammation associated with rheumatoid arthritis is what can damage other parts of the body as well. While new types of medications have improved treatment options dramatically, severe rheumatoid arthritis can still cause physical disabilities. 18 | 19 | Diagnosis: 20 | X-rays 21 | Blood Tests 22 | MRI 23 | CT Scans -------------------------------------------------------------------------------- /Disease treatments/Arthritis.txt: -------------------------------------------------------------------------------- 1 | Arthritis treatment focuses on relieving symptoms and improving joint function. You may need to try several different treatments, or combinations of treatments, before you determine what works best for you. 2 | 3 | Medications 4 | The medications used to treat arthritis vary depending on the type of arthritis. Commonly used arthritis medications include: 5 | 6 | Analgesics. These medications help reduce pain, but have no effect on inflammation. 7 | 8 | Nonsteroidal anti-inflammatory drugs (NSAIDs). NSAIDs reduce both pain and inflammation. Over-the-counter NSAIDs include ibuprofen and naproxen sodium. Oral NSAIDs can cause stomach irritation, and some may increase your risk of heart attack or stroke. 9 | 10 | Disease-modifying antirheumatic drugs (DMARDs). Often used to treat rheumatoid arthritis, DMARDs slow or stop your immune system from attacking your joints. 11 | 12 | Therapy 13 | Physical therapy can be helpful for some types of arthritis. Exercises can improve range of motion and strengthen the muscles surrounding joints. In some cases, splints or braces may be warranted. 14 | 15 | Surgery 16 | 17 | If conservative measures don't help, your doctor may suggest surgery, such as: 18 | 19 | Joint repair. In some instances, joint surfaces can be smoothed or realigned to reduce pain and improve function. These types of procedures can often be performed arthroscopically — through small incisions over the joint. 20 | 21 | Joint replacement. This procedure removes your damaged joint and replaces it with an artificial one. Joints most commonly replaced are hips and knees. 22 | 23 | Joint fusion. This procedure is more often used for smaller joints, such as those in the wrist, ankle and fingers. It removes the ends of the two bones in the joint and then locks those ends together until they heal into one rigid unit. -------------------------------------------------------------------------------- /Disease descriptions/Heart Disease.txt: -------------------------------------------------------------------------------- 1 | Heart disease describes a range of conditions that affect your heart. Diseases under the heart disease umbrella include blood vessel diseases, such as coronary artery disease; heart rhythm problems (arrhythmias); and heart defects you're born with (congenital heart defects), among others. 2 | 3 | The term "heart disease" is often used interchangeably with the term "cardiovascular disease." Cardiovascular disease generally refers to conditions that involve narrowed or blocked blood vessels that can lead to a heart attack, chest pain (angina) or stroke. Other heart conditions, such as those that affect your heart's muscle, valves or rhythm, also are considered forms of heart disease. 4 | 5 | Many forms of heart disease can be prevented or treated with healthy lifestyle choices. 6 | 7 | Cardiovascular disease symptoms may be different for men and women. 8 | 9 | Causes: 10 | 11 | While cardiovascular disease can refer to different heart or blood vessel problems, the term is often used to mean damage to your heart or blood vessels by atherosclerosis, a buildup of fatty plaques in your arteries. 12 | 13 | Plaque buildup thickens and stiffens artery walls, which can inhibit blood flow through your arteries to your organs and tissues. 14 | 15 | Atherosclerosis is also the most common cause of cardiovascular disease. It can be caused by correctable problems, such as an unhealthy diet, lack of exercise, being overweight and smoking 16 | 17 | Common causes of abnormal heart rhythms (arrhythmias) or conditions that can lead to arrhythmias include: 18 | 19 | Heart defects since birth 20 | Coronary artery disease 21 | High blood pressure 22 | Diabetes 23 | Smoking 24 | Excessive use of alcohol or caffeine 25 | Drug abuse 26 | Stress 27 | Some over-the-counter medications, prescription medications, dietary supplements and herbal remedies 28 | Valvular heart disease -------------------------------------------------------------------------------- /Disease treatments/Heat Stroke.txt: -------------------------------------------------------------------------------- 1 | Prevention: 2 | 3 | Heatstroke is predictable and preventable. 4 | 5 | Wearing excess clothing or clothing that fits tightly won't allow your body to cool properly. 6 | 7 | Protect against sunburn. Sunburn affects the body's ability to cool itself, so protect yourself outdoors with a wide-brimmed hat and sunglasses and use a broad-spectrum sunscreen with an SPF of at least 15. 8 | 9 | Drink plenty of fluids. Staying hydrated will help your body sweat and maintain a normal body temperature.. 10 | 11 | Treatments: 12 | 13 | The underlying cause must be removed. Mild hyperthemia caused by exertion on a hot day may be adequately treated through self-care measures, such as increased water consumption and resting in a cool place. 14 | 15 | Heat stroke that results from drug exposure requires prompt cessation of that drug, and occasionally the use of other drugs as counter measures. Antipyretics (e.g., acetaminophen, aspirin, other nonsteroidal anti-inflammatory drugs) have no role in the treatment of heatstroke because antipyretics interrupt the change in the hypothalamic set point caused by pyrogens; they are not expected to work on a healthy hypothalamus that has been overloaded, as in the case of heatstroke. 16 | 17 | In this situation, antipyretics actually may be harmful in patients who develop hepatic, hematologic, and renal complications because they may aggravate bleeding tendencies. 18 | 19 | When body temperature is significantly elevated, mechanical cooling methods are used to remove heat and to restore the body's ability to regulate its own temperatures. 20 | 21 | Passive cooling techniques, such as resting in a cool, shady area and removing clothing can be applied immediately. Active cooling methods, such as sponging the head, neck, and trunk with cool water, remove heat from the body and thereby speed the body's return to normal temperatures. Drinking water and turning a fan or dehumidifying air conditioning unit on the affected person may improve the effectiveness of the body's evaporative cooling mechanisms (sweating). -------------------------------------------------------------------------------- /Disease descriptions/Tuberculosis.txt: -------------------------------------------------------------------------------- 1 | Tuberculosis (TB) is a potentially serious infectious disease that mainly affects your lungs. The bacteria that cause tuberculosis are spread from one person to another through tiny droplets released into the air via coughs and sneezes. 2 | 3 | Many strains of tuberculosis resist the drugs most used to treat the disease. People with active tuberculosis must take several types of medications for many months to eradicate the infection and prevent development of antibiotic resistance. 4 | 5 | Although your body may harbor the bacteria that cause tuberculosis, your immune system usually can prevent you from becoming sick. For this reason, doctors make a distinction between: 6 | 7 | Latent TB. In this condition, you have a TB infection, but the bacteria remain in your body in an inactive state and cause no symptoms. Latent TB, also called inactive TB or TB infection, isn't contagious. It can turn into active TB, so treatment is important for the person with latent TB and to help control the spread of TB. An estimated 2 billion people have latent TB. 8 | 9 | Active TB. This condition makes you sick and can spread to others. It can occur in the first few weeks after infection with the TB bacteria, or it might occur years later. 10 | 11 | Although tuberculosis is contagious, it's not easy to catch. You're much more likely to get tuberculosis from someone you live with or work with than from a stranger. Most people with active TB who've had appropriate drug treatment for at least two weeks are no longer contagious. 12 | 13 | The most commonly used diagnostic tool for tuberculosis is a simple skin test, though blood tests are becoming more commonplace. A small amount of a substance called PPD tuberculin is injected just below the skin of your inside forearm. You should feel only a slight needle prick. 14 | 15 | Within 48 to 72 hours, a health care professional will check your arm for swelling at the injection site. A hard, raised red bump means you're likely to have TB infection. The size of the bump determines whether the test results are significant. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Medical-Expert-System-Knowledge-Base 2 | An expert system using knowledge graphs 3 | that aims to provide the patients with medical advice and basic 4 | knowledge on various diseases 5 | 6 | ## Brief Description 7 | Using expert system shells for the development of **Expert systems**. These shells are empty Expert System knowledge bases, which have the structure and interface already written for us; all we need to do is to add the knowledge into the KB. Instead of writing an Expert System from scratch, for this problem we will be using a small Expert System shell to design and implement an expert system. We used **PyKnow Framework** for building the concerned expert system. 8 | 9 | ## Idea 10 | Many rural areas in India have extremely limited access to medical advice. People travel long distances to clinics, or medical facilities and there is a shortage of medical experts in most of these facilities. This results in slow service, and patients end up waiting long hours without receiving any attention. Hence, medical expert systems can play a significant role in such cases where medical experts are not readily available. A Diagnosis Expert System can help a great deal in identifying those diseases and describing methods of treatment to be carried out. 11 | 12 | Design a knowledge-base expert system that aims to provide the patients with medical advice and basic knowledge on various diseases. It should consider various symptoms and signs like chest pain, cough, fainting, fatigue, headache, back pain, sunken eyes, low body temperature, restlessness, sore throat, fever etc. along with its severity status and provide the patients with medical advice. 13 | 14 | ## Installation 15 | - Clone this repository in your preferred directory 16 | > git clone `https://github.com/Moozzaart23/Medical-Expert-System.git` 17 | 18 | - Run the main file. 19 | > python medical_expert_system.py 20 | 21 | - Answer the questions in the prompt with best to your knowledge. 22 | 23 | ## Files 24 | The important files in this repository are: 25 | | File Name |Description | 26 | |---------------------------------------|------------------------| 27 | |medical_expert_system |Main file containing the source code. 28 | |Disease descriptions | The folder containing the description of the diseases. 29 | |Disease symptoms | The folder containing the symptoms of the diseases. 30 | |Disease treeatment | The folder containing the treatments of the diseases. 31 | |diseases |A text file containing the names of the diseases used in this system. 32 | 33 | ### Disclaimer 34 | This is just for demonstration purposes. The symptoms and diseases are likely to match. It is an attempt to showcase how powerful these basic systems can get. Please do not use for any medical advice. 35 | 36 | ## Team Members 37 | - Anish Dey 38 | - Sanjiv Shenoy 39 | - Srestha Srivastava 40 | -------------------------------------------------------------------------------- /medical_expert_system.py: -------------------------------------------------------------------------------- 1 | from experta import * 2 | 3 | diseases_list = [] 4 | diseases_symptoms = [] 5 | symptom_map = {} 6 | d_desc_map = {} 7 | d_treatment_map = {} 8 | 9 | def preprocess(): 10 | global diseases_list,diseases_symptoms,symptom_map,d_desc_map,d_treatment_map 11 | diseases = open("diseases.txt") 12 | diseases_t = diseases.read() 13 | diseases_list = diseases_t.split("\n") 14 | diseases.close() 15 | for disease in diseases_list: 16 | disease_s_file = open("Disease symptoms/" + disease + ".txt") 17 | disease_s_data = disease_s_file.read() 18 | s_list = disease_s_data.split("\n") 19 | diseases_symptoms.append(s_list) 20 | symptom_map[str(s_list)] = disease 21 | disease_s_file.close() 22 | disease_s_file = open("Disease descriptions/" + disease + ".txt") 23 | disease_s_data = disease_s_file.read() 24 | d_desc_map[disease] = disease_s_data 25 | disease_s_file.close() 26 | disease_s_file = open("Disease treatments/" + disease + ".txt") 27 | disease_s_data = disease_s_file.read() 28 | d_treatment_map[disease] = disease_s_data 29 | disease_s_file.close() 30 | 31 | 32 | def identify_disease(*arguments): 33 | symptom_list = [] 34 | for symptom in arguments: 35 | symptom_list.append(symptom) 36 | # Handle key error 37 | return symptom_map[str(symptom_list)] 38 | 39 | def get_details(disease): 40 | return d_desc_map[disease] 41 | 42 | def get_treatments(disease): 43 | return d_treatment_map[disease] 44 | 45 | def if_not_matched(disease): 46 | print("") 47 | id_disease = disease 48 | disease_details = get_details(id_disease) 49 | treatments = get_treatments(id_disease) 50 | print("") 51 | print("The most probable disease that you have is %s\n" %(id_disease)) 52 | print("A short description of the disease is given below :\n") 53 | print(disease_details+"\n") 54 | print("The common medications and procedures suggested by other real doctors are: \n") 55 | print(treatments+"\n") 56 | 57 | # @my_decorator is just a way of saying just_some_function = my_decorator(just_some_function) 58 | #def identify_disease(headache, back_pain, chest_pain, cough, fainting, sore_throat, fatigue, restlessness,low_body_temp ,fever,sunken_eyes): 59 | class Greetings(KnowledgeEngine): 60 | @DefFacts() 61 | def _initial_action(self): 62 | print("") 63 | print("Hi! I am Dr.Yar, I am here to help you make your health better.") 64 | print("For that you'll have to answer a few questions about your conditions") 65 | print("Do you feel any of the following symptoms:") 66 | print("") 67 | yield Fact(action="find_disease") 68 | 69 | 70 | @Rule(Fact(action='find_disease'), NOT(Fact(headache=W())),salience = 1) 71 | def symptom_0(self): 72 | self.declare(Fact(headache=input("headache: "))) 73 | 74 | @Rule(Fact(action='find_disease'), NOT(Fact(back_pain=W())),salience = 1) 75 | def symptom_1(self): 76 | self.declare(Fact(back_pain=input("back pain: "))) 77 | 78 | @Rule(Fact(action='find_disease'), NOT(Fact(chest_pain=W())),salience = 1) 79 | def symptom_2(self): 80 | self.declare(Fact(chest_pain=input("chest pain: "))) 81 | 82 | @Rule(Fact(action='find_disease'), NOT(Fact(cough=W())),salience = 1) 83 | def symptom_3(self): 84 | self.declare(Fact(cough=input("cough: "))) 85 | 86 | @Rule(Fact(action='find_disease'), NOT(Fact(fainting=W())),salience = 1) 87 | def symptom_4(self): 88 | self.declare(Fact(fainting=input("fainting: "))) 89 | 90 | @Rule(Fact(action='find_disease'), NOT(Fact(fatigue=W())),salience = 1) 91 | def symptom_5(self): 92 | self.declare(Fact(fatigue=input("fatigue: "))) 93 | 94 | @Rule(Fact(action='find_disease'), NOT(Fact(sunken_eyes=W())),salience = 1) 95 | def symptom_6(self): 96 | self.declare(Fact(sunken_eyes=input("sunken eyes: "))) 97 | 98 | @Rule(Fact(action='find_disease'), NOT(Fact(low_body_temp=W())),salience = 1) 99 | def symptom_7(self): 100 | self.declare(Fact(low_body_temp=input("low body temperature: "))) 101 | 102 | @Rule(Fact(action='find_disease'), NOT(Fact(restlessness=W())),salience = 1) 103 | def symptom_8(self): 104 | self.declare(Fact(restlessness=input("restlessness: "))) 105 | 106 | @Rule(Fact(action='find_disease'), NOT(Fact(sore_throat=W())),salience = 1) 107 | def symptom_9(self): 108 | self.declare(Fact(sore_throat=input("sore throat: "))) 109 | 110 | @Rule(Fact(action='find_disease'), NOT(Fact(fever=W())),salience = 1) 111 | def symptom_10(self): 112 | self.declare(Fact(fever=input("fever: "))) 113 | 114 | @Rule(Fact(action='find_disease'), NOT(Fact(nausea=W())),salience = 1) 115 | def symptom_11(self): 116 | self.declare(Fact(nausea=input("Nausea: "))) 117 | 118 | @Rule(Fact(action='find_disease'), NOT(Fact(blurred_vision=W())),salience = 1) 119 | def symptom_12(self): 120 | self.declare(Fact(blurred_vision=input("blurred_vision: "))) 121 | 122 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="yes"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="yes"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="no")) 123 | def disease_0(self): 124 | self.declare(Fact(disease="Jaundice")) 125 | 126 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="yes"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 127 | def disease_1(self): 128 | self.declare(Fact(disease="Alzheimers")) 129 | 130 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="yes"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="yes"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 131 | def disease_2(self): 132 | self.declare(Fact(disease="Arthritis")) 133 | 134 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="yes"),Fact(cough="yes"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="yes"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 135 | def disease_3(self): 136 | self.declare(Fact(disease="Tuberculosis")) 137 | 138 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="yes"),Fact(cough="yes"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="yes"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 139 | def disease_4(self): 140 | self.declare(Fact(disease="Asthma")) 141 | 142 | @Rule(Fact(action='find_disease'),Fact(headache="yes"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="yes"),Fact(fainting="no"),Fact(sore_throat="yes"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="yes"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 143 | def disease_5(self): 144 | self.declare(Fact(disease="Sinusitis")) 145 | 146 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="yes"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 147 | def disease_6(self): 148 | self.declare(Fact(disease="Epilepsy")) 149 | 150 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="yes"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="no")) 151 | def disease_7(self): 152 | self.declare(Fact(disease="Heart Disease")) 153 | 154 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="yes"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="yes")) 155 | def disease_8(self): 156 | self.declare(Fact(disease="Diabetes")) 157 | 158 | @Rule(Fact(action='find_disease'),Fact(headache="yes"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="yes")) 159 | def disease_9(self): 160 | self.declare(Fact(disease="Glaucoma")) 161 | 162 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="yes"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="no")) 163 | def disease_10(self): 164 | self.declare(Fact(disease="Hyperthyroidism")) 165 | 166 | @Rule(Fact(action='find_disease'),Fact(headache="yes"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="no"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="no"),Fact(fever="yes"),Fact(sunken_eyes="no"),Fact(nausea="yes"),Fact(blurred_vision="no")) 167 | def disease_11(self): 168 | self.declare(Fact(disease="Heat Stroke")) 169 | 170 | @Rule(Fact(action='find_disease'),Fact(headache="no"),Fact(back_pain="no"),Fact(chest_pain="no"),Fact(cough="no"),Fact(fainting="yes"),Fact(sore_throat="no"),Fact(fatigue="no"),Fact(restlessness="no"),Fact(low_body_temp="yes"),Fact(fever="no"),Fact(sunken_eyes="no"),Fact(nausea="no"),Fact(blurred_vision="no")) 171 | def disease_12(self): 172 | self.declare(Fact(disease="Hypothermia")) 173 | 174 | @Rule(Fact(action='find_disease'),Fact(disease=MATCH.disease),salience = -998) 175 | def disease(self, disease): 176 | print("") 177 | id_disease = disease 178 | disease_details = get_details(id_disease) 179 | treatments = get_treatments(id_disease) 180 | print("") 181 | print("The most probable disease that you have is %s\n" %(id_disease)) 182 | print("A short description of the disease is given below :\n") 183 | print(disease_details+"\n") 184 | print("The common medications and procedures suggested by other real doctors are: \n") 185 | print(treatments+"\n") 186 | 187 | @Rule(Fact(action='find_disease'), 188 | Fact(headache=MATCH.headache), 189 | Fact(back_pain=MATCH.back_pain), 190 | Fact(chest_pain=MATCH.chest_pain), 191 | Fact(cough=MATCH.cough), 192 | Fact(fainting=MATCH.fainting), 193 | Fact(sore_throat=MATCH.sore_throat), 194 | Fact(fatigue=MATCH.fatigue), 195 | Fact(low_body_temp=MATCH.low_body_temp), 196 | Fact(restlessness=MATCH.restlessness), 197 | Fact(fever=MATCH.fever), 198 | Fact(sunken_eyes=MATCH.sunken_eyes), 199 | Fact(nausea=MATCH.nausea), 200 | Fact(blurred_vision=MATCH.blurred_vision),NOT(Fact(disease=MATCH.disease)),salience = -999) 201 | 202 | def not_matched(self,headache, back_pain, chest_pain, cough, fainting, sore_throat, fatigue, restlessness,low_body_temp ,fever ,sunken_eyes ,nausea ,blurred_vision): 203 | print("\nDid not find any disease that matches your exact symptoms") 204 | lis = [headache, back_pain, chest_pain, cough, fainting, sore_throat, fatigue, restlessness,low_body_temp ,fever ,sunken_eyes ,nausea ,blurred_vision] 205 | max_count = 0 206 | max_disease = "" 207 | for key,val in symptom_map.items(): 208 | count = 0 209 | temp_list = eval(key) 210 | for j in range(0,len(lis)): 211 | if(temp_list[j] == lis[j] and lis[j] == "yes"): 212 | count = count + 1 213 | if count > max_count: 214 | max_count = count 215 | max_disease = val 216 | if_not_matched(max_disease) 217 | 218 | 219 | if __name__ == "__main__": 220 | preprocess() 221 | engine = Greetings() 222 | while(1): 223 | engine.reset() # Prepare the engine for the execution. 224 | engine.run() # Run it! 225 | print("Would you like to diagnose some other symptoms?") 226 | if input() == "no": 227 | exit() 228 | #print(engine.facts) 229 | --------------------------------------------------------------------------------