## 3 Methods
### Architecture and Design of the System
#### 3.1.3 Rule-Based System  
Every rule of the system characterises a disease by relating analysis outcomes with a disease, taking into account deviations in parameters' values which fall outside the reference interval. In this way, each rule receives a score by means of heuristics applied. This allows the system to sort the list of likely diseases, which would be displayed to a clinician. Our system has 357 rules with 51 parameters from blood tests and urinalysis covering aspects such as hematology, liver function, hormones, immunology, lipid profile and clinical biochemistry. Our approach uses a set of If-Then rules which do not require following any fixed order (Figure 3). In that setting, multiple rules could be triggered. Heuristics applied in order to prioritize most likely diagnoses are further discussed in next point. We present three rules to illustrate our rule-based system:  
1. IF Fibrinogen \(>\) 1.8 AND Leukocytes \(<\) 4.4 AND Monocytes \(>\) 12 AND Neutrophils \(>\) 1.32 AND Total protein \(>\) 83 THEN Malaria
2. IF Glucose \(<\) 70 Low-density lipoprotein \(>\) 130 AND Potassium \(<\) 3.5 THEN Anorexia
3. IF Bilirubin \(>\) 1.2 AND Aspartate transaminase \(>\) 40 AND Alanine Transaminase \(>\) 40 THEN Autoimmune Hepatitis  
Reference intervals should preferably be taken from laboratory which performs tests, regarding the fact that these intervals can be altered by the methods and techniques used to retrieve parameter values. Rules are included in a spreadsheet containing laboratory parameters and diseases. Add or update existing knowledge of our expert system is easy, in that it is only necessary to change values in this spreadsheet without any need for computer programming skills. Rules contained in the spreadsheet are then transformed into a rule set in XML format regarding constraints of JRuleEngine library. This transformation is performed by means of a script developed with R programming language, which facilitates access and retrieval of table-type structures. This set of rules in XML format could be easily integrated in other systems also using JRuleEngine library. We have extracted rules of our expert system taking [PERSON] and Pincus reference books [28] and the help of an expert in the field. The extraction of knowledge has followed a systematic approach. For each disease included in the rule set, we have obtained parameter deviation which characterises that disease and have taken particular parameter reference intervals associated with that disease. These reference intervals have been taken mostly from the previously mentioned reference book but also from the valoresnormales.com website. This website provides reference values supported by specialized bibliography. The whole process of elicitation is represented in Figure 4.  
Figure 3: Structure of a rule. Specifically, rules have been obtained for nine areas: hematology, clinical biochemistry, lipid profile, liver function, ions, hormones, cardiac function, immunology and urine. The detailed process of elicitation is explained below. The reference book's chapters related with laboratory tests interpretation are structured as follows: The diseases are grouped in different areas (for example, hematology or liver function). In each of these areas, diseases are characterised by means of a theoretical explanation and the parameters' values deviations, which suggest that diagnosis. The kind of deviation for each parameter is also referenced if the abnormal value is higher or lower than reference values. In addition, it is possible to have a different set of rules for different age groups, ethnicities or genders. This can lead the system to a better performance, due to variations in certain parameter threshold values in different groups. This way to present the knowledge allowed us, for each disease, to (i) obtain a list of parameters deviations which characterise the disease; (ii) set an upper or lower threshold for each parameter's deviation; and (iii) set the exact value for these thresholds.