xCARE: A Development Platform for Supporting Smart and Pervasive Healthcare

We are assisting to an important change in the healthcare domain where healthy citizens and patients are more and more in the center and become active partners in the entire process. In this scenario, smart and pervasive solutions assume a relevant role for remotely assisting citizens and patients together with their carers and supporting the overall team of professionals. From a software-engineering perspective, to follow and/or anticipate changes in requirements, modular solutions must be investigated and developed. Moreover, issues like personalization, adaptation, and scalability must be considered from the very beginning. In this chapter, we present xCARE, a microservices-based platform explicitly implemented to support the development of smart and pervasive healthcare systems. To show the potentiality and adaptability of xCARE, three relevant applications are presented: (i) a selfmanagement system to support chronic complex patients; (ii) a patient management system that allows the team of professionals to assist patients before a major surgery together with a self-management system for the patients themselves; and (iii) an automatic self-management system for healthy citizens that want to follow healthier habits and that supports behavioral change.


Introduction
In the near future, healthcare has to rapidly move from a professional-centric system to distributed networked healthcare systems in which citizens become active partners in the entire healthcare process [1]. According to [2], there is the need to move from managing illness to managing wellness. In this new scenario, smart and pervasive healthcare plays an important role [3,4].
Smart and pervasive healthcare refers to several different application fields: self-management of patients, health-status monitoring and follow-up, communication between patients and healthcare professionals, daily-life activities monitoring of citizens, as well as support for behavioral change for citizens of any age. The common perspective is assisting citizens remotely by relying on a set of sensors and/ or devices (e.g., wearable and medical) suitably integrated together. In doing so, healthcare field. xCARE can be easily customized and adapted to develop system for: patients' self-management; health-status monitoring and follow-up; allowing communication between patients and healthcare professionals; monitoring dailylife activities; integrating wearable-and medical-devices and gathering data from them; as well as giving recommendations and nudges to patients, citizens, and healthcare professionals to support behavioral change.
The microservice approach has been adopted since microservices enable software to be divided into modules, making it easier to change and to adapt it. Figure 1 sketches the overall platform. It is composed of a set of microservices each of them in charge of performing a simple task. Complex tasks are achieved by the collaboration, interaction, and coordination of one or more simple microservice. In the Figure, connections between microservices are shown to point out those that cooperate together to reach complex goals. When changes are needed in a microservice, they do not affect the rest of the system. Moreover, when a new functionality is required, a new microservice (or a set of them) is defined and simply added to the system. In doing so, the proposed solution is robust to changes and improvements.
Each microservice is completely independent of the actual system that will use it. In this way, a set of microservices has been implemented and it is already available (e.g., for monitoring physical activities, for taking measurements from medical devices, for following up drug prescriptions). If the actual system needs one or more of the already-implemented microservices, it/they will be used "as is" as bricks to build the system. On the contrary, if the actual system needs to rely on a new functionality for which there is not a corresponding microservice, the new microservice will be defined from scratch in a very generic way to be used in the system and to leave it available in the generic xCARE platform for the development of further systems.
In order to locate the microservices, Netflix-Eureka service discovery is adopted 5 . Eureka is a REST based microservice for locating microservices with the purpose of load balancing and failover of middle-tier servers (the Eureka Server). Eureka also comes with a client component (the Eureka Client), which makes interactions with the microservice much easier. The client also has a built-in load balancer that does basic round-robin load balancing.
As a front door for all requests from the front-end and the microservices, we rely on Netflix Zuul 6 . Zuul is the front door for all requests from devices and websites to the backend of the Netflix streaming application. It is built to enable dynamic routing, monitoring, resiliency and security. It uses a range of different types of filters that enables to quickly and nimbly apply functionality to the edge microservice. These filters help performing the following functions: authentication and security, identifying authentication requirements for each resource and rejecting requests that do not satisfy them; insights and monitoring, tracking meaningful data and statistics at the edge in order to give an accurate view of production; dynamic routing, dynamically routing requests to different backend clusters as needed; stress testing, gradually increasing the traffic to a cluster in order to gauge performance; load shedding, allocating capacity for each type of request and dropping requests that go over the limit; and static response handling, building some responses directly at the edge instead of forwarding them to an internal cluster.
Management of roles, rights, authentication control, and login is implemented by relying on Spring Cloud Security 7 . It offers a set of primitives for building secure applications and services with minimum fuss; as well as a declarative model which can be heavily configured externally (or centrally) and lend itself to the implementation of large systems of co-operating, remote components, usually with a central identity management service.
The front-end fully depends on the actual final system and the corresponding user-requirements and application. Different kinds of front-end can be developed: mobile apps, especially for patients, carers, or citizens who want to self-manage their status or activities; web apps, mostly for professionals that need to follow-up patients during an intervention; or desktop solutions to closed-system that need to directly interact to other systems, as for instance hospital information systems.

xCARE in action
Among the different implementations we have implemented and we are currently implementing by using xCARE as baseline, in the following, we present how xCARE has been used for providing self-management to complex chronic patients in the CONNECARE project and for supporting behavioral change through a recommender system in the CarpeDiem project.

Self-management of complex chronic patients
The project CONNECARE (Personalized Connected Care for Complex Chronic Patients) is a H2020 Research and Innovation Project, started on April 2016 and finished on December 2019. CONNECARE is a technologically-oriented initiative aiming at exploring digital tools to support two key requirements of integratedcare services for chronic patients, namely: (i) Smart adaptive case management of patients with multimorbid conditions; and, (ii) Collaborative work among the various stakeholders, including patients and their families across health and social care tiers, involved in the services. The CONNECARE approach uses an observational study design, focused on implementing the CONNECARE organizational model and technology in a real life clinical setting, with an intervention group and matched control group and four implementation sites: Barcelona and Lleida in Spain, Ashdod in Israel, and Groningen in The Netherlands.  The CONNECARE system has been deployed in two situations: 1) Communitybased prevention of unplanned hospital-related events in chronic complex patients with high risk for hospitalization; and 2) Preventive patient-centered intervention in complex chronic patients undergoing elective major surgical procedures. While the objectives and desired outcomes are the same in all sites, the organizational model for integrated-care and the supporting digital tools have been adapted to the specific needs of each site.
The CONNECARE system, depicted in Figure 2, is composed of a Self-Management System (SMS), installed on patients' smartphones (or tablets), and the Smart Adaptive Case Management system (SACM), accessible via Web. The SMS allows monitoring patients and providing engagement, rewards, and warnings [8]. The SACM has extended functionalities for case management to define a case according to an organizational model based on a 5-dimension score strategy: Case Identification, Case Evaluation, Workplan definition, Workplan execution, and Discharge [9]. Additionally, the SACM includes an advanced Clinical Decision Support System focused on helping clinicians in risk assessment and stratification and a visual support tool for locating the patients and organizing their visits [10]. The SMS and SACM interact each other through the CONNECARE Enterprise Service Bus which connects both subsystems and orchestrates their communication. All professionals, including health professionals from both primary care and hospitals and social workers, interact with each other using a direct communication tool to coordinate the patient's care plan and its execution, assuring continuity of care between hospital, primary-, and social-care. Patients continuously check their status and execute their assigned tasks through the SMS. Hospital staff, primary care professionals, and social workers may also help and accompany the patients using the messaging. CONNECARE provides also an integration framework to link its services to specific Electronic Health Records and regional Personal Health Folders.
The CONNECARE SMS has been built upon the xCARE platform. Figure 3 sketches the adaption that has been done. In total, 12 microservices have been defined and developed, 7 of them specifically to perform patient's monitoring (5 for basic-and 2 for advanced-monitoring) and 5 are for giving support and providing further functionalities: ○ Sleeping, to monitor sleeping data (sleep time per night, minutes that the user has been awake during the night sleep, and sleep time during the day) through the wristbands used for monitoring the physical activity.
○ Questionnaires, to assign one or more questionnaires to a patient; settingup of the questionnaire(s) to be answered, together with the frequency that questionnaires will be requested to the patient's under the medical surveillance provisions; sending back questionnaire answers to the clinician; and checking the list of prescribed questionnaires and their answers.
○ Simple tasks, to monitor the performance of specific tasks during the day (e.g., dancing, cooking, reading). Moreover, depending on the disease and the kind of patient (e.g., in case of elderly people) the professional may ask to perform healthy activities such as drinking or eating a fruit. Through the self-management system, the patient can accept or reject the request and check when the activity has been performed. them via Bluetooth or WI-FI. In case of traditional medical devices were preferred, also the manual input from the patients was allowed.
○ Drug prescription, to remind to take a medication and to monitor the intake. Professionals prescribe all the drugs to be taken and the patient will receive a reminder any time s/he has to take one. In case of low adherence, a message is sent to both the patient and the professional.
• System ○ Advice, to allow professionals to select pieces of advice and training material in the form of text, images, or videos that patient is asked to see. The patient may create her/his own list of bookmarks to have a direct access to relevant information any time is needed. Four categories of advice have been defined: automatic advice (generated by the system according to the collected data), personalized advice (written by the professional for a specific patient), educational material (specific of a given case study in a specific site and common to all the patients of the corresponding case and site), and health educational videos (specific for a given site and common to all the patients to that site).
○ Messaging, to offer a bidirectional communication that allows patients to interact with members of the medical staff in charge of the case, a given clinician, or even with other patients or communities of patients. Similarly to the well-known Whatsapp app, patients may send/receive text, images, videos, links, and documents.
○ Notifications, it receives the notifications generated by any of the other microservices whose recipient is the patient (e.g., a new prescription has been generated). Complex notifications coming from interaction with the patient's monitoring microservices may also be sent.
○ Alerts, as soon as a patient's monitoring microservice finds an anomaly, it interacts with this microservice and a suitable alert message is sent to both the patient (to be aware of the issue) and the clinical staff (to be informed and act accordingly). Anomalies are triggered any time the data gathered from the patient (e.g., through the medical devices or a questionnaire) exceeds a given threshold defined at prescription time (e.g., a critical heart rate value).
○ Third party, to integrate third party elements, such as wearable and medical devices. This microservice has two main functionalities: managing the connections to external providers and standardizing the data model.
A total of 301 patients have been involved. Satisfaction of patients and carers with the SMS has been evaluated by relying on the Likert Scales/Net-Promoter-Score [12] and the System-Usability-Scale 11 . Overall, the satisfaction was high, despite a significant number of challenges encountered along the way. Satisfaction was clearly linked to the perception that the SMS was part of an overall integratedcare process and the relationship between professionals and patients. Finally, the User eXperience analysis performed in Lleida (Spain) shows that, in order to improve satisfaction and engagement, patients need to perceive the app as relevant and that it gives them a clear and simple added value [13].
The CONNECARE SMS is an app available in both Apple App Store and Google Play markets 12 . Figure 4 shows some screenshots of the CONNECARE SMS: (a) the feedback on physical activity in terms of number of steps, (b) the administration of the EQ-5D-5 L questionnaire, (c) the follow-up of the drug prescription of Ipratropium, and (d) the communications with the team of professionals showing the list of actions the patient may do.

Patient empowerment for major surgery preparation at home
The project PAPRIKA (patient empowerment for major surgery preparation at home) is an EIT Health Innovation Project, started in January 2019 and that will finish on January 2022. PAPRIKA establishes a technologically enabled and personalized program to prepare patients for elective surgery and to provide follow-up, as a way to improve the outcomes of the operation. The program develops close collaboration with the medical environment that empowers patients to co-create their own care. PAPRIKA will roll out its services fully in Spain, Germany, France, and Poland.
The project integrates short-term preoperative interventions, averaging about four weeks and including endurance training, promotion of physical activity and nutritional and psychological support. Interventions are planned both in the community and at the hospital, reducing unnecessary interactions between patients and tertiary care. The project incorporates two digital solutions (see Figure 5): a case management system for professionals, integrated with the electronic health record (EHR); and a self-management system for patients, integrated with the regional health folder. Both digital solutions have been built upon xCARE. Figure 6 shows how xCARE has been adapted for the PAPRIKA aims. The following functionalities, powered by the xCARE microservice architecture, are currently available: • Prescription, to allow professionals to prescribe any kind of tasks to the patients: physical activity, medical check-up, mindfulness and nutrition tasks, drug intake, and questionnaire filling. 12 Apple store: https://apps.apple.com/es/app/connecare-h2020/id1364574255?l=en and Google Play: https://play.google.com/store/apps/details?id=connecare.mobile&hl=en  • Simple tasks, to monitor the performance of specific tasks during the day related to nutrition habits (e.g., eat a fruit) or mindfulness activities (e.g., watch a given video).  • Questionnaires, to assign one or more questionnaires to a patient, as for instance "how do you feel today?". The microservice then sends back the answers to the clinician.
• Third party, same behavior of CONNECARE.
• Advice, to send text, images, or videos containing suggestions or educational material to the patients. The pieces of advice are set-up an priori by the professionals and the patient may access them any time s/he needs.
• Messages, to offer a bidirectional communication that allows patients to interact with members of the medical staff in charge of the case, a given clinician, or even with other patients or communities of patients. Videocalls are also supported by this microservice.
• Notifications, to notify patients and professionals in case a microservice generates a notification or an alert (e.g., a prescription has been done, a new measurement has been taken, a questionnaire has been answered).
The pilot of PAPRIKA is currently running in the 4 sites (Spain, Germany, France, and Poland). The case management system for professionals is available in each hospital thanks to its integration with the EHRs, while the self-management system is an app available in both Apple App Store and Google Play markets 15 . Figure 7 shows some screenshots of the case management system for the professionals: (a) the list of prescriptions of a patient; and of the self-management system for the patients (b) the main screen with the list of tasks to be performed, (c) the performed physical activity, and (d) the communications with the team of professionals in charge.

Collaborative and adaptive recommendations for personalized diet management
The project CarpeDiem (Collaborative and Adaptive Recommender for PErsonalized DIEt Management) is aimed at providing intelligent and automatic support to people who want to follow a diet to stay fit, lose or gain weight. The concept of "diet" in CarpeDiem is considered in an integral way, taking into account nutrition, physical-and sleeping-activity. CarpeDiem users are elderly people who need to follow a strict diet, athletes who want to control their weight and stay healthy or simply, people who want to follow a healthy diet.
CarpeDiem is an IoT-based intelligent self-management system aimed at monitoring physical-and sleeping-activity, nutrition, as well as environmental data and lifestyle habits, with the final goal of providing personalized recommendations and nudges to foster behavior change towards healthier behaviors [14]. The selfmanagement system is bulit upon xCARE where intelligent techniques have been implemented for personalization and automatic monitoring, and a front-end is given in the form of an app to be installed in the citizen's smartphone.
As depicted in Figure 8, the IoT-based self-management system works with a set of data coming from different sources. CarpeDiem users wear an off-the-shelf activity tracker 24/7 to monitor physical-and sleep-activity as well as the energy expenditure in terms of calories. CarpeDiem users are also asked to monitor their weight once a week in order to take under control the Body Mass Index (BMI) and to avoid reaching overweight and, thus, obesity. The CarpeDiem system integrates the LogMeal API [15], capable of recognizing meals through pictures taken from the smartphone camera. The pictures taken by using the CarpeDiem system are automatically sent to LogMeal that analyzes them and gives as output a list of meals. The citizen selects the right one and CarpeDiem automatically indicates the corresponding food group and calculates the number of calories and key nutrients of a dish portion, basing such calculation on the recipes also available through LogMeal. Moreover, questionnaires are used to directly ask the users regarding some lifestyle habits. Finally, to be aware of the seasonality, the daylight hours, and further environmental data, we rely to the Dark Sky API 16 , whereas to monitor the air quality (currently, only in Catalonia) Dades Obertes by Generalitat de Catalunya is used 17 . Figure 9 shows how xCARE has been adapted to implement the CarpeDiem IoTbased self-management system; 10 microservices have been implemented: • Monitoring ○ Physical Activity, to monitor the walking activity by relying on an activity tracker.
○ Sleeping, through the activity tracker it automatically recognizes when the patient is sleeping or awake.
○ Nutrition, to monitor food intake by relying on the LogMeal app.
○ Weight, to monitor the increase/decrease of the weight by relying on a smart scale that automatically sends the data.
○ Questionnaires, to collect answers from the selected questionnaires: SATED [16], about the satisfaction of the citizen regarding her/his sleep; Smoke, on the number of cigarettes smoked on average during the week; Use of light-emitting screens, concerning the number of minutes spent on average using the smartphone or a tablet just before going to sleep; and Caffeine, to check the number of coffees, teas, and energy drinks the user drunk during the 7 hours before going to sleep, the day before. 16  ○ S_RecSys, analyzing the sleep habits gathering the information from the Sleeping, Questionnaires, and We ight microservices, it sends nudges and recommendations to follow better habits.
○ N_RecSys, generating the profile of the user, this service sends suggestions to change habits, as well as general recommendations on healthy foods.

• System
○ Third party, it implements the connections and calls the selected external APIs (i.e., activity trackers 18 , smart scales 19 , LogMeal, and open-data sources). This microservice works as an abstraction level. It only has to ask the third party connector for the information and wait for the data without worrying about the communication process and the different data model used.
○ Notifications, it sends to the front-end the notifications generated by any of the microservices. 18 In the current version, we use activity trackers from Fitbit (https://www.fitbit.com/) and Withings(https://www.withings.com/) for monitoring steps, sleeping habits, and energy expenditure; 19 In the current version, we use smart scales from Withings, for monitoring the weight and the BMI The CarpeDiem IoT-based self-management system is an app available in the Google Play (early access) for Android smartphones 20 . On July 2020, a pilot started with 14 healthy volunteers recruited in Eurecat ( 35.64 8.58 ± years old; 5 females; and 22.96 2.67 ± BMI). The pilot, which will end at the end of the year, has a threefold objective: (1) collecting feedback to improve the app and/or correct bugs; (2) testing the usability and evaluating the user experience; and (3) gathering new data to improve the 3 recommender systems and start implementing the holistic one. Results of the pilot will be calculated in terms of usability once the pilot ends. Figure 10 shows some screenshots of the Carpe Diem system: (a) the home page where the user has an overview of her/his status and may answer to the questionnaires; (b) a list of received notifications, each pillar represented by a different icon; (c) the setting page that shows, besides other information, that the app is linked to Fitbit; (d) the physical activity page with the summary of the steps per day and a green star indicating when the goal was achieved; (e) the sleeping page 20 https://play.google.com/store/apps/details?id=com.eurecat.carpediem  with the summary of the current week showing the sleeping hours and the efficiency as calculated by Fitbit; and (f) an example of recognized food (meatballs).

Discussion
As described in Section 2 and then pointed out by presenting three relevant adaptations of xCARE in Section 3, the proposed platform can be easily customized and adapted to develop smart and pervasive healthcare systems. Our lessons learnt coming from the development and adoption of this generic architecture is that from a software engineering perspective the tasks to be done to develop a healthcare system are almost always the same as the functionalities to be provided. On the contrary, what changes from an application to another is related to personalization, usability, and intelligent support. This conclusion clearly supports the definition of a generic development platform, such as xCARE.
Thinking on the xCARE microservices as LEGO pieces, any new application can be built by composing them according to the requirements. Continuing with such metaphor, what differentiate each application is which pieces are used, how they are combined, their color, and the final aspect as a whole. Accordingly, first, a co-design approach should be performed involving the final users (at any level), domain experts (i.e., healthcare professionals), technicians, and user experience experts. In doing so, the specific front-end for that application will be designed and the usability issues will be taken into account at the very beginning. Once all the needs have been collected, the xCARE software engineer gathers the requirements, selects the microservices already available, defines those that are not, and designs the overall architecture. In parallel, the IoT programmers develop the interface for the connection with the required devices (if not already available) and the artificial-intelligent team defines the models for providing personalized and intelligent support to the final users.
It is worth noting that the adoption of this kind of solution is very effective for rapid prototyping, because the final users can have a first version available in very few time. Thanks to its modularity, the corresponding application is robust to changes in requirements, thus supporting application development in which different actors are involved. Finally, it can be scaled-up easily by simply adding new microservices/ functionalities or by delegating tasks and functions to additional microservices.

Conclusions
This chapter presented the xCARE development platform suitably defined for smart and pervasive healthcare systems. The platform is currently adopted in several solutions adopted at the European level. To give a view of the potentiality of xCARE, three relevant projects in which the platform has been used have been presented.
As for the future work, we plan to improve the platform with more microservices, to enhance the intelligent support with further models based on artificial intelligence and to apply xCARE approach and technology to further healthcare domains and use cases.