← Back to list

Rule based expert systems for medical diagnosis

Medical diagnosis systems (MDS) are intelligent systems that can assist medical experts and patients in identifying various health issues…

Eve Pardi · 2024-09-08 09:54 · 2 claps · 4.8 min read
#rule-based #expert-systems #intelligent-systems #artificial-intelligence #medical-diagnosis
Open on Medium ↗
Wiki topics: AI · AI · General CLI · Clinical Medicine

Rule based expert systems for medical diagnosis

Medical diagnosis systems (MDS) are intelligent systems that can assist medical experts and patients in identifying various health issues, such as heart disease (Ephzibah, 2012), or malaria (Awotunde, Matiluko and Fatai, 2014).

This article presents a rule-based expert system for diagnosis and management of a new virus disease that was detected first in Virusland. Rule-based expert systems are a type of intelligent systems or artificial intelligence that uses a set of “if-then” rules to derive conclusions or make decisions. These systems mimic the decision-making, reasoning, learning, and understanding abilities of human experts in a specific domain.

Components of rule-based expert systems

Components of rule-based expert systems

Rule-based expert systems consist of three main components:

  • Knowledge-base: declarative intelligence, relies on internal knowledge to utilise reasoning methods to derive appropriate new knowledge. Knowledge is represented as “if-then” rules.
  • Inference engine: derives new axioms, applies the rules to the known facts to deduce the new information or make decisions. The procedural knowledge is enhanced with knowledge engineering by developers and experts.
  • User interface: the users interact with the system, input data and receive conclusions, recommendations, and possibly an explanation of how the system made a specific decision.

The solution is developed using Prolog, which is a logic programming language that excels in applications involving artificial intelligence, theorem proving, and natural language processing. Unlike many other programming languages, it is declarative, meaning it expresses logic in terms of relations, defined by facts and rules. SWI-Prolog is a popular and comprehensive implementation of Prolog, widely used in both academic and commercial settings.

The system takes the patients’ personal and medical data, such as name, age, pre-existing health issues, and symptoms, then outputs the risk of infection, the need for medical assessment, and the duration of infectiousness. The objective is to inform patients about their need for urgent medical care and the duration of isolation required to prevent transmission. To achieve this, the application considers the symptom severity, the age and comorbidities of the patient, and the gender-specific risk factors for developing severe symptoms.

All code discussed in the article is available on my GitHub: rbes-medical/medic-diagnosis.pl at main · ExOblivione/rbes-medical (github.com)

Development environment

Microsoft Azure Data Science Virtual Machine

  • Windows (Windows Server 2022 Datacenter)
  • Standard B2s (2 vcpus, 4 GiB memory)

Visual Studio Code (VSCode)

  • SWI Prolog is configured for VSCode (Arthwang, no date)
  • Prolog and VSC-Prolog extensions installed

Data collection

First, the service obtains the patient data by prompting the user to answer questions. The application then stores the collected data in two dynamic predicates: patient and development.

Collection, storage, and retrieval of patient data

Collection, storage, and retrieval of patient data

Rules

The following rules are used to determine the risk of severe symptom development, which is then used for decision-making:

  • Patients older than 70 years and have comorbidities are at a higher risk of developing severe symptoms.
  • Male patients are more likely to develop severe symptoms than female patients.

Rules to define risk of development of severe symptoms

Rules to define risk of development of severe symptoms

Another rule evaluates the risk of infection, transmission, and severity of the virus. It assigns a risk value to each symptom based on the symptom facts and the patient’s risk factor calculated earlier, then selects the maximum value which is used to define the risk level of infection and its severity.

Rule for defining the risk of infection

Rule for defining the risk of infection

The following rule states that if any of the symptoms are classified as severe, the patient requires urgent medical care. In this case, the system notifies the user to seek professional help as soon as possible.

Rule for defining whether the patient needs medical attention

Rule for defining whether the patient needs medical attention

Another rule considers the presence of dry cough or runny nose as indicators of high infectiousness since the virus is mainly spread through respiratory droplets. It also increases the risk of transmission if the patient has a medium or high risk of infection.

Define whether the patient is infectious

Define whether the patient is infectious

The virus has an incubation period of one to fourteen days, but the patient may be infectious before the onset of symptoms, up to two days prior. The system calculates a fifteen day period from the date of the first recognizable symptom and advises users to isolate from others, as infected patients can be contagious during this period.

All code discussed above is available on my GitHub: rbes-medical/medic-diagnosis.pl at main · ExOblivione/rbes-medical (github.com)

Testing

Test 1: Diana, 94/F

Diana has a high risk of developing severe symptoms, because she is 93 and has pre-existing health issues. The infection risk level is only two, but as she is coughing, she might be infectious.

Test 1

Test 1

Test 2: Drew, 62/M

Drew is not 70 yet and doesn’t have any pre-existing health conditions. However, he is a man, which elevates the risk of developing severe symptoms.

Test 2

Test 2

Conclusion

The article presented a rule-based expert system for diagnosing a new virus and providing advice to patients on managing the symptoms. The system has limitations such as it does not handle the uncertainty about the incubation period of the virus. These factors could have a significant impact on the risk assessment of the disease. One improvement would be to use Bayesian reasoning to incorporate prior knowledge and update the probabilities of infection and transmission based on new evidence (Good, Hernandez and Smith, 2020).

All code discussed in the article is available on my GitHub: rbes-medical/medic-diagnosis.pl at main · ExOblivione/rbes-medical (github.com)

References:

Arthwang (no date) Executable path for linter · Issue #4 · arthwang/vsc-prolog. https://github.com/arthwang/vsc-prolog/issues/4.

Awotunde, J.B., Matiluko, O.E. and Fatai, O.W. (2014) Medical Diagnosis System Using Fuzzy, African Journal of Computing & ICT African Journal of Computing & ICT Reference Format. Available at: www.ajocict.net.

Ephzibah, E.P. (2012) ‘Framing Fuzzy Rules using Support Sets for Effective Heart Disease Diagnosis’, International Journal of Fuzzy Logic Systems, 2(1), pp. 11–16. Available at: https://doi.org/10.5121/ijfls.2012.2102.

Good, C.B., Hernandez, I. and Smith, K. (2020) ‘Interpreting COVID-19 Test Results: a Bayesian Approach’, Journal of General Internal Medicine. Springer, pp. 2490–2491. Available at: https://doi.org/10.1007/s11606-020-05918-8.

Negnevitsky, M. (2013). Artificial Intelligence : a guide to intelligent systems (3rd ed.). Pearson Education Custom Content.


메타데이터
post_id
6f77eae4894d
slug
rule-based-expert-systems-for-medical-diagnosis-6f77eae4894d
url
https://medium.com/@evepardi/rule-based-expert-systems-for-medical-diagnosis-6f77eae4894d
canonical_url
https://medium.com/@evepardi/rule-based-expert-systems-for-medical-diagnosis-6f77eae4894d
author_url
https://medium.com/@evepardi
status
ok
fetched_at
2026-06-20 20:29:01