1 Introduction

The Intensive Care Unit (ICU) is considered a high-risk care setting where medical carelessness or errors can cause deaths or complications to patients’ health [1]. In pandemic times, such as that of the coronavirus disease (COVID-19), the ICU’s importance in the treatment of critically ill patients became even more evident. Since patients need special care varying from basic requirements to the need for equipment for patient monitoring and life support, such as respirators and mechanical ventilators [2, 3]. Artificial Intelligence (AI) applications currently are used in the management of such complex tasks. AI can assist in the monitoring and treatment of patients with chronic diseases and in critical conditions hospitalized in the ICU, where these cases occur more frequently [4].

The ICU patient monitoring must rigorously take place. The FAST HUG - Feeding, Analgesia, Sedation, Thromboembolic prevention, Head of the bed elevated, stress Ulcer prophylaxis, and Glucose control - is a simple and significant mnemonic to highlight seven of the main aspects that must be monitored by health professionals for each patient in the ICU to minimize possible problems [1].

Focusing in the FAST HUG, glycemic control has the function of checking the patient’s glucose level in the blood, keeping as long as possible in the target range [1]. Regardless of which is the ideal target range, it is vital to keep it monitored. Effective glycemic control in the ICU environment has the potential to decrease mortality rates and the patient’s length of stay in the ICU, optimizing hospital resources [5]. The overload of health professionals in pandemic times is crucial, and factors such as this point out that automated systems to monitor and assist patients’ treatment can bring benefits. Thus, the FAST HUG, or at least some of its items, can be improved with process automation combined with AI techniques.

In the literature review, AI-based works for glycemic control of ICU patients are presented [5,6,7], as well as the application of Multi-Agent System (MAS) for patients glycemic control [8], and MAS in the ICU context [9, 10]. However, none of the works applies MAS for patients’ glycemic control admitted to the ICU. Some work points to prediction models as good solutions for glycemic control [11,12,13].

Considering the cited scenario, the objective of this work is to present a system to track and monitor the glycemic control of critical patients in the ICU through a MAS approach. In a previous work [14], the MAS development process was presented without implementation results. More specifically, the following hypothesis has to be proven: a MAS can suggest patients’ treatment recommendations using prediction models and a knowledge base with inference rules similar to specialist intensive care physicians.

The rest of the manuscript is organized as follows. In Sect. 2 some works found in the literature are presented. In Sect. 3, the materials and methods are presented. In Sect. 4 the experiments were carried out with results. Finally, in Sect. 5 the final considerations and possible future work are indicated.

2 Literature Review

The literature review used the Portal de Periódicos Capes, seeking articles in English published from 2015 to 2021, with the following combined keywords: artificial intelligence, multiagent systems, intensive care unit, glucose control.

The works of DeJournett et al. [6, 7] present an autonomous glucose control system (artificial pancreas) to reduce problems resulting from the glycemia of patients in the ICU. In the first work [6], the authors perform an insulin test with simulated patients, using an AI-based glucose controller. As an AI technique, they used rule-based reasoning (RBR). In the second work [7], the same system was used, but the objective was to evaluate the system’s safety and performance by applying simulated tests with swine in a clinical setting.

In Jemal et al. [10], a model was proposed, and a specialized decision support system was implemented and validated to detect the degree of risk of patients in the ICU. A MAS was used as the main technology combined with a knowledge base and Intuitionistic Logic Fuzzy (IFS). In Malak et al. [9] an architecture based on agents with decision support and in real-time for the management of high-risk newborns admitted to the ICU-N was presented. Both studies showed that MAS is a good solution to be used in healthcare systems.

When it comes to glycemic control, studies such as those presented in Vehi et al. [11], Bertachi et al. [12], and Kim et al. [13] point to prediction models as interesting solutions, where the prevention of hypo or hyperglycemic events tends to be more efficient than the correction of these episodes. The solutions presented in these works include (1) prediction and prevention of hypoglycemic events in diabetics [11]; (2) a prediction model for episodes of nocturnal hypoglycemia in diabetics [12]; and (3) a glucose prediction model for hospitalized type 2 diabetic patients [13].

Table 1 summarizes the qualitative aspects of the related work, limited to the application context (glycemic control, ICU patients) and technologies used (agent-based, prediction model). Note that no work presents a solution with MAS to manage glycemic control with predictions in the ICU setting.

Table 1. Related work overview.

3 Materials and Methods

The methodological process used was based on previous work [14] and consists basically of four steps as presented in Fig. 1 and described in the sequence.

3.1 Problem Definition

The problem definition is based on the literature review (Sect. 2). The theoretical foundation includes FAST HUG, glycemic control, and MAS concepts.

Fig. 1.
figure 1

Methodological workflow.

FAST HUG in ICU Management. According to the National Health Surveillance Agency (Anvisa) [15], ICU is considered a complex unit to be managed in a hospital being the place where critical condition patients deserving greater care are concentrated. Such patients are very difficult to manage safely and effectively due to their complex, nonlinear, and highly variable physiology. Therefore, improving patients care and treatment are the main current challenges for ICU settings, where personalization and automation of care offer opportunities to cause significant impacts [16]. Mnemonics are commonly used in medical procedures as cognitive aids to guide doctors around the world. Thus, Vincent [1] suggested the simple mnemonic FAST HUG that contains seven essential aspects to be verified during the care of critical patients in an ICU during medical rounds. Such checks should take place at least once a day and ideally, whenever any of the professionals assist the patient.

Glycemic Control. The glycemic control concerns the amount of glucose (sugar) that the patient has in the blood. Both, high glucose level (hyperglycemia), and low blood glucose level (hypoglycemia) are frequent problems in ICU patients causing damage to health [17]. One of the studies in Vincent’s [1] highlights the importance of glycemic control in the ICU. The author demonstrates that maintaining blood glucose levels at approximately 140mg/dL results in a 29.3% decrease in-hospital mortality rates, and a 10.8% reduction in the ICU stay.

Hyperglycemia is prevalent in ICU being a good example that the strict glycemic control of these patients can have a great impact. Such an episode occurs due to the non-suppressed production of glucose by the body, medications, suppression of the body’s insulin secretion, among others. All these factors effectively damage the body’s normal feedback control mechanisms resulting in less insulin-mediated glucose uptake. Therefore, some type of supplementary glycemic control is necessary, possibly in a closed circuit and highly personalized in intensive care [16].

Table 2 was prepared in conjunction with a specialist doctor and presents, in addition to the values, what must be done for each glycemic episode. It synthesizes the information necessary to identify the glycemic episode, using a code (in the system implementation) and blood glucose values. It also presents treatment suggestions (applying glucose or insulin with the respective dosage), in addition to monitoring (how long it will be necessary to collect and measure blood glucose). This table is an adaptation of the previous work [14].

Table 2. Scale of glycemic values related to treatment and monitoring.

MAS Aspects. A MAS is composed of two or more intelligent agents capable of perceiving events in the environment through sensors, reasoning, and acting in the environment through actuators [18]. According to [8], a MAS has an intelligent distributed approach suitable for modular, changeable, and complex applications, with characteristics such as autonomy, integration, reactivity, and flexibility, becoming an interesting solution for modeling large-scale health systems.

Regarding the agents’ reasoning, different AI techniques can be used including the combination of them. In this work, agents should make predictions according to the patient’s blood glucose and data. Also, to make treatment and monitoring suggestions for the patients. Regarding predictions, predictive models can be highlighted, which can assist in decision-making [11,12,13]. In the case of monitoring and suggesting treatments, a good solution would be to represent the knowledge of medical specialists through RBR [6].

  • Predictive model: A regression model is based on the correlation between two (Simple Linear Regression - SLR) or more variables (Multiple Linear Regression - MLR), where one depends on another or others [19]. The use of regression models obtained satisfactory results in previous works of [20, 21] in the health area, more specifically, the prediction of new cases of COVID-19 and prediction of glucose levels in critically ill patients, respectively.

    An MLR is expressed by the Eq. 1, where y is the dependent variable or the value to be predicted. The \(\beta _0\) is the constant that represents the intercept of the line on the y axis, and the independent variables \(\beta _1 x_i +\beta _2 x_2 +...+\beta _kx_k\) represent the slope of the line. The x is the independent variable or predictor variable, this has the power to influence the variable to be found, and \(\varepsilon \) the variable that represents the residual factors of the measurement errors [20].

    $$\begin{aligned} y = \beta _0 + \beta _1 x_i + \beta _2 x_2 + ... +\beta _k x_k + \varepsilon \end{aligned}$$
    (1)
  • RBR: Dejournett [6] associates systems based on rules or knowledge with AI controllers that seek to capture the human thought process, creating rules that mimic the exact reason used by human beings. Such a system is created when a domain expert joins a knowledge engineer and explains his lines of reasoning to perform certain functions when trying to control the system in question. The engineer in turn transforms the lines of reasoning into a series of if-then rules that mimic the thinking of experts in the field.

Assuming the situation where a patient is in the ICU and the blood glucose collected value is 60mg/dL, the rule compatible with this case would be:

$$\text {IF glycemia = hypoM THEN ``Glucose: 2 amp--50}\%\text { IV''}$$

3.2 Project Design

This step includes the agents’ identification with their respective objectives and the construction of diagrams that will assist in the implementation step.

Agents Pre-project. A MAS project includes the identification of the perceptions, actions, objectives, performance, and environment of each agent in the system. The pre-project includes these definitions through the acronym PEAS (Performance, Environment, Actuators, Sensors). The MAS pre-project serves to identify in which environment the agent will act and its respective characteristics. Based on the objectives of each agent, it is also possible to describe what are the mechanisms by which they will perceive the information and how they will act in response to such stimuli [18].

Tropos Modeling. The MAS modeling can use Tropos software development methodology for agent-oriented software systems. Tropos is based on the i* framework (ISTAR - Intentional STrategic Actor Relationships modeling), modeling the functionality of an application based on objectives using diagrams [22]. Although there are other methodologies for agent modeling, the Tropos was chosen since it encompasses all five phases of software development supporting the analysis of initial requirements to implementation with the diagrams: initial requirements, final requirements, architectural design, detailed design, and implementation. The five Tropos diagrams of MAS4CG can be found in [14].

Figure 2 presents the diagram of the late requirements of the proposed system. Red circles represent MAS external Actors (e.g., people, systems), Yellow circles with a top straight line illustrate MAS Agents. The green rounded rectangles represent the agent Goals that can be understood as the system requirements. The purple rectangles represent Resources, a physical or informational entity needed by the actor or agent to perform a task. The MAS agents are Patient Analyzing Agent (PAA), Proposed Treatment Agent (PTA), and Adjustment Monitoring Agent (AMA) with functionalities detailed Fig. 3.

Other diagrams, such as the architecture and UML (Unified Modeling Language), can be developed to complement the understanding of the proposed solution representing details aimed at implementing the solution. In the implementation stage, details of how all technologies, systems, and agents were implemented are presented.

Fig. 2.
figure 2

Tropos late requirements diagram.

Architecture. Figure 3 presents the MAS4GC architecture. The PAA’s main objective is to collect the patient’s data and respective glycemia, whenever new data is inserted or updated in the Glycon Database. Glycon is a web system used as an interface by healthcare professionals, both for entering information about the patient and their blood glucose, and for displaying the recommendations made by agents. This agent should analyze such data and make a report assessing the patient’s situation in comparison with previous data. This will allow the agent to calculate and make predictions of how the patient’s next blood glucose will be. This report will be sent to the PTA and AMA agents, who in turn will analyze it and propose a treatment (what should be applied, glucose or insulin, and how much) or adjust the blood glucose monitoring (indicate the appropriate frequency of blood collection). It will be possible to send an alert containing the recommendation to health professionals through the Glycon interface.

Fig. 3.
figure 3

MAS4GC architecture.

3.3 MAS4GC Implementation

In this work, we present a MAS developed using objective-oriented agent modeling for glycemic control of patients admitted to the ICU. The three agents PAA, PTA, and AMA interact with each other and with a Web system called Glycon, used as an interface for collecting and presenting patient data, including blood glucose levels. The MAS4GC consists of three integrated systems, one of which is an interface that serves for the entry and visualization of data through health professionals. The other is the MAS itself, where, through a framework, the three agents were implemented. Finally, the agents’ reasoning was built in the form of a rule base, also with the help of a framework. All source code, diagrams, dataset and frameworks used are available in the repository: https://github.com/tiagosegato/mas4gc.

Fig. 4.
figure 4

Glycon interface

Interface. The interface system called Glycemic Control On-line (Glycon) [14] is a web system whose main objective is to receive patient data and blood glucose. Health professionals can maintain this data by inserting, updating, and listing. However, the two most important tasks of the system are to record blood glucose levels and the possible applications of glucose or insulin that the patient may have received. Such information is listed and presented using graphics in a kind of patient’s dashboard and alerts regarding monitoring (time of next blood collect) and treatment (glucose, keep watching, regular insulin) suggestions are displayed on the interface’s initial screen, serving as treatment suggestions to health professionals, as shown in Fig. 4. Glycon was developed in Javascript, more specifically through the frameworks React.js (front-end) and Node.js (back-end). Its database uses the MongoDB available through the Atlas web tool. It is currently hosted on the Heroku Cloud Application PlatformFootnote 1.

MAS Framework. The MAS implementation used the Python Agent DEvelopment framework (PADE) that allows the development, execution, and management of MAS in distributed computing environments [23]. PADE was selected in this work since it is free software that provides resources as a module for protocols implementation as defined by FIPA to allow the exchange of messages and collaboration between agents. Listing 1 displays the PTAgent class, where the PTA agent creates and sends a data request to the PAA agent.

After that, the PAA will prepare the evaluation report that brings, in addition to patient and blood glucose data, a forecast of the patient’s next blood glucose after 4 h. The prediction was calculated using an MLR and LinearRegression(). The functions Fit(xy) and predict() from the Python library scikit-learn were used [24].

figure q

Agents’ RBR. After the PAA agent generates the assessment report containing the patients’ situation, it sends the report to the PTA and AMA agents, who in turn consult the knowledge base coded using Experta. Experta is a Python library that can be used in the development of rule-based systems. A system developed with Experta can pair a set of facts with a set of rules for those facts and perform some actions based on the rules of correspondence [25]. With Experta the specialist’s knowledge was transcribed in a knowledge base to be used by the MAS4GC agents. At the moment, the rule base has 48 initial rules that indicate both treatment recommendations and blood glucose collections’ frequency. The rules were defined based on the knowledge of an intensive care specialist. In addition, new rules may be manually introduced in the rule base as tests take place in conjunction with specialists.

Listing 2 presents a rule where a hypoS (Severe Hypoglycemia in Table 2) situation is received and indicates that the treatment should be “Glucose: 4 amp–50% IV”. Afterward, this information is inserted in the database shared with Glycon and it will appear on the screen of that interface.

figure r

The Experta syntax does not use \(if-then\) for condition and action as other RBR tools. The condition applies to the @Rule expression and the result of the action is presented in a specific function in def.

4 Experiments and Results

To evaluate the results of MAS4GC, two experiments were carried out. The first aimed to identify the regression model to be used to predict patient events, as well as its accuracy, and the second to compare MAS treatment suggestions with human physicians.

4.1 Experiment 1

This experiment aims to identify which type of regression is the most appropriate one (SLR or MLR) to predict a patient’s next glycemic event, as well as to gauge whether such a model presents satisfactory results. The experiment systematization is illustrated in Fig. 5 and described in the sequence.

Fig. 5.
figure 5

Experiment 1 and 2 pipeline.

  1. 1.

    Dataset used - A dataset was created by an intensive care physician based on his experience to simulate synthetic data from 50 patients. Each patient has 30 blood glucose collections according to the initial collection plan defined by the physician, assuming patients are not in treatment. The information present in the dataset include patient, gender, age, height, weight, BMIFootnote 2, diabetes, time, time of day, food, and blood glucose.

  2. 2.

    Data preparation - Some of the values available in the dataset are categorical and have undergone adjustments. From the patient, a sequential numeric code started at 1 was used, for sex 0 was defined for female and 1 for male. The values 0, 1, and 2 were used to represent those who do not have diabetes, had this information ignored, or have diabetes, respectively. The time field received a scale of values according to the difference in hours in which the collections took place and the time of day field received only the value that represents the hours (discarded minutes, seconds). The rest of the values are numeric and have been maintained, except in the case of numbers with decimal places that have been approximated for their correspondents in integer.

  3. 3.

    Definition of the models used - Simple and multivariate linear regressions were used (SLR and MLR).

  4. 4.

    Dataset partitioning - In the SLR and MLR, the regressions were subjected to cross-validation, whose dataset was divided into 10 groups of 5 patients each, where the accuracy will be measured 10 times between the training and test sets.

  5. 5.

    Selection of variables - In the case of SLR, only the time variables will be used, as the independent variable and blood glucose with the dependent one. In MLR, glycemia is also the dependent variable, as this is the value that is intended to be predicted and all other variables were used as an independent. After some significance tests, the p-value was analyzed and only the variables patient, sex, BMI, diabetes, time, time of day, food (how many hours did the patient receive food), and the last blood glucose were selected for use.

  6. 6.

    Choice of validation metric - The K-fold method was applied by creating 10 subgroups from the current base. The results will be analyzed using the following measures: coefficient \(R^2\), Mean Absolute Error (MAE), Mean Absolute Percent Error (MAPE), and Root Mean Square Error (RMSE).

  7. 7.

    Experiment execution - The whole process was performed at first using the SLR and then using the MLR. It was started by calculating the linear regression and then the predictions were calculated.

  8. 8.

    Results analysis - With the regressions and predictions performed, the results were analyzed with accuracy (coefficient \(R^2\)), and error metrics (MAE, MAPE, RMSE). As shown in Fig. 6, the MLR presents the accuracy of correct answers 90% of the times that recommend the treatment to the health professional, against 13% of the SLR. The MLR presents errors inferior compared to SLR. Thus, the MLR is more adequate in the applied context in accordance with the specialist opinion.

Fig. 6.
figure 6

The Experiment 1 result analysis with the \(R^2\) coefficiente, and MAE, MAPE, RMSE error metrics per prediction of next action.

Experiment 1 was useful to assess the accuracy of blood glucose predictions made by the PAA and consequently enable health professionals to provide preventive treatment for patients. In Experiment 2, the idea is to verify whether the treatment and monitoring recommendations made by the PTA and AMA are similar to real physicians.

4.2 Experiment 2

The objective of Experiment 2 is to compare the treatment and monitoring recommendations made by the MAS4GC with real health professionals. Six health professionals contributed to the experiment. Five professionals were from different specialties, such as endocrinology, neurology, urology, gastroenterology, and physiotherapy. In addition, an IUC intensivist contributed with his knowledge in treating ICU patients. The experiment systematization contains the same eight steps as in Experiment 1. Steps 1, 2, and 5, that is, dataset, data preparation, and selection of variables are the same. The other steps will be presented in the sequence:

  • Definition of the models used - the agents’ knowledge used to make the recommendations were RBR, while human health professionals used their knowledge based on their studies and experience.

  • Dataset partitioning - the \(29^th\) collection from each of the 50 patients were used, both by the intensive care physician, who analyzed the 50 cases and by health professionals from different areas, where each of the five professionals analyzed 10 cases each.

  • Choice of validation metric - the MAS responses compared to the health professionals and the specialist ones.

  • Experiment execution - five spreadsheets were created containing an explanation of the experiment and the 10 cases. It is understood by case the patient’s data that include blood glucose among other information, described in the Selection of variables step. For each case, the healthcare professional was asked to inform: (1) one treatment based on Table 2; and (2) how many hours the next collection should be based on Table 2. The ICU specialist received a similar spreadsheet but containing all the 50 cases.

  • Results analysis - after the health professionals filled out the worksheets, the data were tabulated containing the recommendations of the MAS, the health professionals’ recommendations, and the ICU specialist for treatment and monitoring recommendations. First, the MAS treatment recommendations were matched to the exact health professionals’ recommendations. The results coincided with 80% of the cases. Comparing the MAS recommendations with those of the specialist physician, the combinations were 84%. Regarding monitoring, the health professionals’ recommendations coincided with MAS in 48% of times. Concerning the MAS’ recommendations with the specialist, the combinations were 78%. The results are presented in Table 3.

Table 3. Comparison of treatment and monitoring recommendations.

According to the ICU specialist physician, an acceptable hit rate would be close to 80% of the cases. Experiment 2 shows that the MAS recommendations were satisfactory in most cases, except for the health professionals’ monitoring recommendation. Considering Table 2, the divergence of the MAS and health professionals’ monitoring recommendations was because some professionals use their frequency parameters to measure blood glucose based on their ICU knowledge or hospital rules (e.g., hourly collections or continuous monitoring standards). The ICU specialist confirmed this observation.

Although the presented results are promising, other experiments should better investigate the parameters used by the software agents’ decisions, performance, and usability aspects of the MAS4CG.

5 Conclusion

This work presents a system based on agents capable of performing glycemic control in ICU patients. For this, predictive models and a knowledge base with inference rules were used to compose the agents’ intellectual capacity. According to the literature, such methods are highlighted as viable solutions in healthcare applications including glycemic control. However, it was not found the combination of these techniques with MAS to solve the problem in question.

Two experiments were conducted to validate MAS4CG. Experiment 1 shows that the prediction model has a 90% accuracy rate of blood glucose for the next 4 h, allowing health professionals to anticipate and perform preventive treatment on their patients. In Experiment 2, the MAS treatment recommendations coincided in 84% of the cases with those of the specialist and 78% about the recommendations for monitoring (collection of blood glucose) of the patients, proving to be a viable solution.

As future work, the rule base might improve the agents’ capacity about the recommendation, mainly in terms of glycemic monitoring of patients in different contexts, such as in continuous monitoring environments. The qualitative analysis on the discrepancy in time predicted for next collection is interesting and can be quantified using diagnostic test validation. Considering the results as a whole, the MAS4GC had a good capacity for predictions and recommendations. The promissing results indicate that the system can be tested in a real clinical environment.