Sensor Networks and Personal Health Data Management: Software Engineering Challenges

. The advances of 5G, sensors, and information technologies enabled proliferation of smart pervasive sensor networks. 5G mobile networks provide low-power, high-availability, high density, and high-throughput data capturing by sensor networks and continuous streaming of multiple measured variables. Rapid progress in sensors that can measure vital signs, advances in the management of medical knowledge, and improvement of algorithms for decision support, are fueling a technological disruption to health monitoring. The increase in size and complexity of wireless sensor networks and expansion into multiple areas of health monitoring creates challenges for system design and software engineering practices. In this paper, we highlight some of the key software engineering and data-processing issues, along with addressing emerging ethical issues of data management. The challenges associated with ensuring high dependability of sensor network systems can be addressed by metamorphic testing. The proposed conceptual solution combines data streaming, filtering, cross-calibration, use of medical knowledge for system operation and data interpretation, and IoT-based calibration using certified linked diagnostic devices. Integration of blockchain technologies and artificial intelligence offers a solution to the increasing needs for higher accuracy of measurements of vital signs, high-quality decision-making, and dependability, including key medical and ethical requirements of safety and security of the data.


Introduction
Wireless sensor networks (WSNs) are spatially distributed sensor systems that concurrently measure targeted variables. The WSNs monitor variables, record and communicate the data for immediate processing or for processing and storage. Distributed WSNs monitor air quality in a defined broader location such as building, airport, or other geographic areas. Localized WSNs are more limited and may include personal health monitoring systems or in-vehicle sensor systems [1]. The main problems restricting WSNs deployment are hardware constraints and limited energy Table 1. 5G mobile network capabilities [3]. 5G supports multi-sensor body area networks with and their real-time connectivity with multiple devices, while 4G networks require data storing and subsequent synchronization and transmission of the data between devices. Increases in volume, speed, and coverage of data communication require new hardware, system design, and software solutions. The challenges include needs to improve sensor accuracy, synchronization, miniaturization, and reliability of sensors, much higher energy efficiency, robustness of sensors, and improved connectivity and performance of the Internet of Things (IoT) devices. New software solutions are needed for filtering, compression, and real-time decision-making. The increased complexity of WSN systems as well as increased dependence on these systems for monitoring, control, optimization, and decision-making requires software engineering (SE) solutions. The safety, security, governance, privacy, and right to access and use the data are among the societal and ethical issues that need to be considered. 5G connectivity enables rapid expansion of WSNs, both in physical scope and complexity. A 5G mobile phone can support not less than 40 wide area network (WAN) bands as well as multiple radio frequencies for wireless local area networks (WLANs) [4]. Different types of LANs have been defined by size, such as personal (PAN), home (HAN), and storage (SAN) area networks, as well as larger ones, such as campus area (CAN) or metropolitan area (MAN) area networks. Some network types, according to their physical scope are listed in Table 2. Connectivity and communication between devices, objects, systems, and living beings provide data for monitoring health. Data are collected by embedded sensors, devices or instruments, and transferred by communication devices to analytical devices for processing. Analytical devices process, exchange and store the data. Decision support algorithms, as part of data processing, provide for appropriate actions or responses to certain situations. These actions or responses involve sensing of the environment and bodily functions and alerting or prompting people to respond to various situations and conditions or triggering automated responses. Devices and systems that involve sensors, data communication, and real-time responses are known as smart technologies. Such systems include smartphones, clocks, cameras, or appliances. More complex smart systems include smart cars, homes, buildings, hospitals or broader geographic areas, such as smart cities [13,14]. The convergence of hardware (sensor systems, embedded electronics, information and communications technology (ICT)) and software (real-time data analytics, machine learning, and artificial intelligence methods for decision-making) advances enabled the emergence of the Internet of Things (IoT). IoT is a network of devices and systems, such as vehicles, home appliances, or health monitoring systems. They interact, exchange data, respond, and make decisions about the system operation in response to changes or respond to changes in variables [15].

5G Capabilities
Sensor systems and IoT produce amounts of data that are growing exponentially [16]. The size and complexity of these data are so large that traditional methods for capturing, processing, transferring, analyzing and storing are not adequate. These data are termed Big Datathey have high volume and are generated and processed at high speed, making them not suitable for storage into relational databases [17]. Big Data properties are popularly described by Vs: volume, velocity, variety, variability, veracity, visualization, and value [18]. Traditional data analytics mainly employs statistics, while Big Data analytics employs a broader set of methods including machine learning (ML), mathematical modeling, and other artificial intelligence (AI) techniques [19]. Big Data accumulation, fueled by sensor networks and IoT devices, produces bottlenecks. This creates a need for a) real-time pre-processing of Big Data to reduce them to a workable size; b) synchronization of multiple data streams, extraction of critical information, and context awareness; c) new algorithms for real-time responses; and d) management of knowledge and its real-time deployment [20].
The WSNs field is growing rapidly leaving, some fundamental questions yet unanswered, while guidelines and standards are weak. In this work, we deliberate some of the key questions and provide guidelines for some Software Engineering (SE) aspects for practical applications of WSNs for personal health monitoring. We have analyzed data types generated by sensor networks and IoT devices and discussed data management issues: filtering, synchronization, and knowledge management. We looked at practical examples and analyzed key issues using health monitoring and wellbeing enhancement as examples. We critically assessed the use of SE, including new requirements for software testing for the design, management and use of sensor systems for personal monitoring of health using wearables and mobile devices. Finally, we analyzed applications of these principles to pregnancy monitoring using WSNs and IoT devices.
Sensor networks are used in healthcare as emergency response applications, smart home applications, and continuous monitoring applications in telemedicine [21]. Although SE is essential for the development of software systems and software components of complex systems, the literature on SE applications for sensor networks applications in health and their applications is sparse [20]. This article defines the basics of SE requirements and issues in this field.
This article provides a discussion of data issues for personal health monitoring including emerging data types such as multi-sensor data streams or blockchain data, and the issues related to the management of knowledge for decision making. Further we discuss the issues related to the process of monitoring health and wellbeing, including the integration and interpretation and functionality of monitoring. The main part of this article is about software engineering challenges including testing, implementation issues, requirement engineering, and ethics. We described the principles of metamorphic testing, that offers an advantage for testing complex systems and critical application. We have provided and extension to the concept of dependability. Dependability is essential for health-related applications and is an essential part of requirements. These issues were discussed in the context of pregnancy monitoring using sensor networks, mobile devices, and IoT devices.

Sensor Networks Data and Data Analytics
Examples of embedded sensor networks include smartphones, smartwatches, health bands, vehicles (cars, trains, drones), smart homes, security systems, and IoT devices. Previously, data were collected and analyzed offline for making decisions and subsequent action. Real-time applications were rare, they were mainly critical applications such as power grid management, intensive care monitoring, or autopilot systems. These applications are designed to respond to a set of pre-defined conditions and were not adaptive, i.e. did not learn to respond to previously unseen inputs. Contemporary sensor networks are multi-agent systems that can measure variables, and perceive the state and behavior of their environment, responding accordingly. Intelligent sensor networks have an increasing ability to learn from past behaviors [22].

Emerging Data Types
Individual sensors in WSNs generate data cooperatively, and data are often processed and filtered at the source. The technical ability to design sensor networks is well established. The capture, storage and processing of data by small sensor networks is a routine practice. Learning from sensor network data brings forward several issues: understanding and dealing with the large scale of data, supply required energy for operation, and ensuring appropriate and timely responses [23]. The number of sensors may be very large, different sensor types may be connected, and they may be distributed arbitrarily. Data streams need to be combined and synchronized to enable real-time interpretations. Understanding, interpreting and learning from data and responding accordingly requires the application of AI and ML. The requirements for sensor network systems include enabling their intelligent behavior [22]. Biomedical data may be amongst the most complex to manage and usethese data are comprehensive, diverse, heterogeneous, and need to be isolated to protect individual privacy, while new types of data generated by sensor networks and their analytics requirements are continuously expanding.

Data Processing and Knowledge Management
The original raw data contains multiple layers of knowledge and data processing needs to distinguish these layers and make them available for analysis and use. The knowledge hierarchy is captured in the DIKW knowledge pyramid [24], which defines hierarchical relationships between data, information, knowledge, and wisdom. (Fig.  1a). The quantity and cost of acquisition of the levels of knowledge are reversely proportional ( Fig. 1a and 1b). The speed of data acquisition is rapidly accelerating thanks to the growth of the Internet, the advancement of instrumentation, and 5G technologies and WSN. Our ability to analyze data, extract knowledge, and develop systems for decision-making support, is growing slower than the speed of data production and accumulation, creating knowledge ( Fig. 1c), and application (Fig 1d.) gaps. Poor management of medical knowledge is a key factor preventing or delaying the development of robust and medically useful home-based or mobile sensor network systems and the use of these data in clinical practice. Health care is a knowledge-driven process and applying the right knowledge at the right time is essential. An extension of the DIKW model is shown in Fig. 2. Raw data are analyzed using statistical methods, machine learning, and other methods of artificial intelligence to obtain high value content. It may include summaries, reports, reviews or critical information that can be used to support decision making and provide appropriate actions and responses. Biomedical data can be classified by structure, data processing level, application domain, and intended purpose [25]. Data may be structured or unstructured. For example, a diagnosis can be recorded in a structured form such as ICD diagnostic codes [26], or unstructured, such as textual descriptions. Structured data are suitable for comparative analysis and statistics. Structuring of data has some negative effects such as high rate of miscoding (false positives or false negatives) [26], and the loss of information available in textual descriptions that cannot be captured in the international classification of disease (ICD10) codes. It is difficult to record a correct diagnosis in cases that combine several health conditions, typically stated as a primary diagnosis along with comorbidities [27]. . The data are basic elements without meaning; information shows the relationships or simple rules; understanding describes patterns and regularities; wisdom represents the understanding of underlying principles; vision refers to the ability to apply of these principles to new and useful designs or derive new theories.

Issues with Data Types
Biomedical data are used in various types of information systems. Examples are administrative, financial, research, operations, pharmaceutical, laboratory, and radiology systems. Clinical data are stored in electronic health records, clinical trial data, and disease registries [29]. A key issue is the interoperability of these information systems [30]. The rapid development of sensor networks and IoT have created new challenges arising from merging traditional biomedical information systems with massive data streams for real-time decisions making [31]. The most granular level of biomedical data is specialized data types, including demographics and socioeconomic data, patient encounters, medication, symptoms, diagnoses, diagnostics tests (laboratory, imaging, etc.), genetics, and family history. New data types used in healthcare include lifestyle (fitness, shopping preferences), environmental data and exposure (climate, weather, pollution, health maps), and content from social networks. The growth of Big Data generated by data streaming has created challenges for integrating Big Data into information systems. New data-processing algorithms are needed for the utilization of Big Data. The main issues related to sensor networks for personal and mobile health monitoring include signal processing, data accuracy, interoperability of sensors and networked IoT devices, interpretation of patterns in data for decision making, summarization of data for medical use (reporting), networking, security, compliance, and ethics.

Monitoring Health and Wellbeing
WSN applications are already commonly used for monitoring and management of health conditions in individuals [32]. There is an increased focus on improving the quality of life and human wellbeing. The concept of individual wellbeing refers to the psychological, social and physical resources needed to meet a variety of individual needs, such as psychological, social and physical needs specific for an individual. Wellbeing has three dimensions: life satisfaction, pleasant affect, and unpleasant affect [33]. While wellbeing data largely overlap health data, and the same infrastructure can be used for data collection and processing, there are major differences between addressing health and welfare needs. Medical diagnosis devices typically require a governmental agency certification, while wellbeing sensor devices typically do not. This situation is changing, and the number of FDA certified wearables (for example, in USA, China) is increasing. The distinction between medical, health, and wellbeing applications is diminishing. At a micro level, body area networks (BANs) are the primary source of data. BAN level sensors are wearable, non-invasive devices that quantify a physiological state or activity of the wearer [34]. Examples include electroencephalogram (EEG) headsets, heart rate (HR) bands and straps, and pedometers. Concerns have been highlighted over the validity and accuracy of consumer grade devices [35]. At the macro level, the combinations of multiple redundant sensors at the BAN level enable cross-calibration, improvement of the accuracy, and reliability of the measurements. Raw measurements by individual sensors are often imprecise, but their combinations offer resilience against individual source errors in the network. Real-time algorithms enable responses such as adjustments of the environment or alerts to the individual requesting responses. Continuous monitoring using sensors and wearables is becoming ever more important for both health care delivery and a healthier lifestyle [36]. The application of ubiquitous WSNs to health monitoring and societal wellbeing is a major technological disruptive trend for a traditional care-giving system. The collection of highly individualized data and their processing by smart systems enables a healthier lifestyle. Highly personalized and physically 'close' sensors will lead to every individual being responsible for creating their own Big Data driving further developments towards more ubiquitous BANs and PANs. Existing BAN applications are primarily used in fitness devices, mainly focusing on activity monitoring. The insights can be used to improve wellbeing e.g. habit-forming, gamified exercising and the introduction of social accountability. WSNs are used for health and medical monitoring, require greater cautionhealth care providers should be informed or involved in decision-making in response to the analysis of data streams from wearables.

Integration and Interpretation of Data and Knowledge Management
Integration of multi-sensor data, their interpretation, and ensuring the accuracy of measurements of individual sensors and the overall network are important SE considerations. Dealing with these issues becomes increasingly complex as the number of sensors grows, particularly when dealing with the swarms of sensors. The application of BAN level sensors for health monitoring requires interoperability with the existing health records. For example, chronic lung disease patients may be highly sensitive to variations in air pollution relative to the normal population. When provided with information that monitored individual suffers from a chronic condition, the smart system can adjust its recommendations, actions and reporting accordingly. For example, suggestions for physical activity might be more conservative when the pollution level is high. A smart environment may use more air filtration, but this can be costly and energy consuming. Integration of existing medical record data into a smart system, while respecting the privacy of the individuals, and the local legal system represents another challenge. Knowledge management is needed for developing "smart algorithms"this refers to enabling the understanding and wisdom levels of the DIUWV hierarchy shown in Figure 1. Adequate responses to changes detected in sensor data streams require management and use of appropriate knowledge. For example, the system must be aware of thresholds that define safe levels of air pollutants for both immediate and chronic exposures so that appropriate action can be made. The system should be aware of the lower values of these thresholds if high-risk or vulnerable groups (including children, pregnant women, and chronic patients), are present in the environment. Integration of wisdom level (Fig. 1) knowledge is needed to ensure adequate decision making.
Scientific and professional literature, including books, journal and conference articles, technical reports, guidelines, and databases, represent a rich source of data, information and knowledge. The accurate, up-to-date, and applicable knowledge that is essential for design, application and adequate use of WSNs for health monitoring. Medical alerts or health advice or intervention must be made using the best scientific and clinical evidence [5]. The quality of medical knowledge in literature varies across the sources, and large proportion of the data and derived knowledge are of poor quality [37]. Clinical decision making is improving due to access to complementary sources, such as Electronic Health Record, clinical research databases, and software for rapid chart analysis [38]. Health monitoring is personalizedindividuals with increased risk for a health condition should be screened thoroughly. Risk factors, diagnostic variables, and diagnostic values of these variables for various classes of patients are available in systematic reviews. Systematic review researchers use meta-analysis along with the assessment of the relevance, adequacy, completeness, and quality of studies and provide validated results that can be used in clinical practice. Systematic review goals in health care include a) assessing the effects and economic value of intervention, b) assessing the frequency of a condition, c) estimating of a diagnostic test performance, d) determining the cause and risk factors, and e) assessing the predictability of a condition [39].

Sensor Systems and Functionality of Monitoring
Until recently, continuous monitoring of vital signs and diagnostic variables was possible only in clinical settings, such as in intensive care units. The emergence of wearable wireless senor networks (wWSN) along with interconnected IoTs enable continuous monitoring of variables at sub-second scale. Some of the key differences between wearable WSNs and clinical monitoring systems (CMS) include a) the population that is monitoredgeneral or at-risk individuals (wWSN) vs. very ill individuals (CMS), b) focus on early detection of health problems (wWSN) vs. focus on critical care (CMS), c) limited ability for data processing due to energy requirements (wWSN) vs. readily available power supply (CMS), and d) use of lower accuracy sensor systems (wWSN) vs. certified devices (CMS). Similar functionality, but significantly different operating conditions between wWSNs and CMS mandate the development of new implementation models, including ultra-efficient algorithms for processing of Big Data streams, robust decision making algorithms using continuous data, cross-calibration of sensors to ensure accuracy, autocorrection of errors, the ability to safely store and transmit data for offline analysis, and the ability to verify sensor measurements when needed. wWSN enable large-scale collection of multiple vital measurement (such as blood sugar, blood pressure, physical activity, and heart rate) and their cross-linking with health status, improving the potential for early diagnosis. We anticipate that large numbers of measurements for large numbers of variables will be collected into health monitoring registries and used as a basis for decision making. Smart environments are promising areas for WSN applications in health and wellbeing. Modelling health characteristics of an individual's environment in real-time and over historical periods enables understanding of an individual's exposure to potentially harmful substances. The critical data include environmental health factors, including air pollutants (such as particulate matter, formaldehyde, or volatile organic compounds) concentrations, temperature, and humidity. The detection of increased levels of pollution can trigger air-purification systems in the home or workplace. Conversely, low levels of pollution may trigger normal ventilation where external air is introduced into the living environment, providing a supply of fresh air in an energy-efficient manner.

Software Engineering Challenges
One variable may be measured by multiple independent sensors, and at the same time, one sensor device may measure multiple variables. Sensor networks commonly perform continuous concurrent measurement of variables at different scales. For example, weight, blood pressure (BP), heart rate (HR), heart rate variation (HRV), and electrocardiogram (ECG) data should be measured and captured concurrently for monitoring heart health. Given the number and diversity of network sensors and the data coming from multiple devices, a key challenge of the system design is to ensure that data are trustworthy -accurate, precise, and reliable. If, for example, several sensors that simultaneously cover the same variable produce differing or even conflicting values, we need to consider several key questions: • What is the system intended to do? • Which source (if any) should be considered canonical?
• What degrees of 'trust' or 'authority' should be given to one measure or another? • How should the trust priority be established?
• How do we evaluate the correctness in uncertain-by-design environments?

Oracle Problem and Metamorphic Testing
This situation, known as the "Oracle Problem" is common and well-studied in software testing [40]: Given a system whose output or behavior can be observed, how can it be determined if the observations are correct? A mechanism that the observer can use to decide correctness is called an Oracle. If Oracle is not available or it is not practical to use it (e.g. owing to excessive cost or time requirement), then the system has the Oracle problem. In a large, distributed, free-form sensor networks, the Oracle problem is common. In sensor systems, the Oracle Problem can occur at the data acquisition end (sensors) and the data processing or interpretation (software) end. When multiple sensors report different values for the same variable (data source) is analogous to SE n-version programming (NVP) [41]. NVP builds several implementations from the same specifications, and then executes all n versions for any given input. Voting or polling methods can be used to determine the correct and incorrect outputs or behaviors. For large, complex sensor networks, the choice of the decision algorithm employed in NVP is critical, and possibly undecidable, given the nature of the measures being observed [42]. Fundamentally, we are uncertain as to what a correct answer is at any given moment. Metamorphic Testing (MT) an approach to address the Oracle problem [43,44]. Rather than focusing on identifying the correctness of individual outputs (or executions), MT examines relationships amongst multiple executions that should hold for the system. These relationships are called metamorphic relations (MRs). Identification of a violation of the MR is sufficient to detect a fault in the system. MT has been applied to analyzing and verifying Big Data systems [36,45] and to large bioinformatics and health systems [46].

Implementation Issues
The design and implementation of a WSN system for health monitoring bring forward additional practical issues and challenges. Here, we discuss these issues and suggest solutions using a case study on pregnancy monitoring.

Pregnancy Monitoring Systems
Pregnancy-related complications affect the health of both mother and baby throughout the pregnancy and at birth. These complications are associated with higher incidence and earlier onset of chronic disease in both mother and baby later in life. Early signs of possible pregnancy complications can be discovered using wearable sensors and confirmed through certified diagnostic devices. Early diagnosis reduces the incidence and severity of complications, and therefore reduces the burden of both acute and chronic disease [47]. For example, hypertensive disorders represent a major cause of maternal death and illness of both mothers and babies. Hypertensive disorders are estimated to affect 5.2% of all pregnancies in China [48]. Gestational diabetes is present in approximately 14% of pregnancies in China and is rapidly rising (3% in 1999, 9% in 2011) [49]. Studies have shown that regular prenatal testing can help reduce the risk of complications [50]. A recent study found that a simple mobile application that uses manual input from patients to alert them to complication symptoms resulted in the improvement of baby birth weight in 25% of monitored pregnancies [51]. Continuous monitoring using wearable sensors should be even more effective. A typical home pregnancy monitoring system is shown in Figs. 3 and 4. A simple system may combine wearables and IoT devices for measuring HR, BP, blood sugar, weight, and physical activity. This system takes input from continuous activity monitoring devices (smartwatch or health band), smart devices that are used several times a day (smart scale, blood pressure monitor and blood sugar). Similar systems have been proposed [52][53][54] but a truly functional system is not yet available [55].

Key requirements for pregnancy monitoring system
Failure of pregnancy monitoring systems may result in injury to the health that may be prevented if the system worked properly. In some instances, preventable complications can cause death or permanent disability to both mother and the baby. Therefore, pregnancy monitoring systems, both at home and in hospital, must be considered as safety critical systems [56]. The design of such systems must provide the resistance to failure and the ability to detect a failure. The requirements of pregnancy monitoring systems include a) the ability to timely produce adequate responses, b) dependability [56], and c) ensuring that system operation and data management provide a good balance between ethics and social responsibility [57]. Assuming the hardware, software, and operation of the system work correctly (i.e. that operation is free of faults), the system must incorporate best and up-to-date medical algorithms. For example, the weight gain of the pregnant woman should be compared with tables that are accurate and adequate (e.g. body mass index, race/ethnicity, or multiple pregnancies) [58,59]. The standard approach is to use pre-defined pregnancy weight charts and find the best fit for a given individual. "Normal" pregnancy weight gain charts are available in recent papers [60,61]. These data should be combined with knowledge represented in in systematic reviews to personalize target weight gain charts for specific individuals [62]. Because the system takes daily weight measurements through a smart scale, unhealthy pregnancy weight gain -too low or too high -can then be detected early. Similar methods for injection of knowledge into the system should be used for each of the observed diagnostic variables.   4. Schematic data/information flow in the system shown in Fig. 3. Various sensors capture values that assess vital functions (physical activity, heart status, or weight). Machine learning algorithm compares current values and patterns with common diagnostic values from systematic reviews, as well as with the patient's own history. The results are then used to adjust decision making. GPSglobal positioning system; ECGelectrocardiogram; PPGphotoplethysmography; MLmachine learning. Dependability of a system is a software engineering concept that defines the ability of a system to provide trustworthy services (Table 3). Failure is a situation when system performance or functioning is not in accordance to specifications. Failure modes may refer to incorrect values, timing, or execution of a function. Examples include false alarms, degradation of services, software crashing, incorrect service (such as measurement recordings). An error is a hardware or software system component that may cause a failure. A fault is an actual or hypothesized cause of an error. The faults can be due to inadequate design, hardware (physical) problems, or interaction causes [56]. Availability and reliability ensure that the system is ready for correct service and that service is uninterrupted. Safety ensures that there is an absence of damage to service users and to the environment. Security refers to the prevention of unauthorized use of the system and data. Integrity and maintainability mean that the system is no degraded or altered, and it can be repaired and upgraded. Dependability is achieved using: fault prevention, ability to deliver proper service even in the presence of faults (fault tolerance), reduction of the number and severity of faults (fault removal), and estimating the number, future incidence, and consequence of faults (fault forecasting) [56]. Because of high interconnectivity and a broad range of operating conditions of our system, we added two threats -suboptimal performance and misuse, two attributes -robustness and interoperability, and three methods to deal with the threats -quality assurance, quality control, and forensic analysis (Table 3). Table 3. SE concept of dependability, adapted from [56] (items in bold), and expanded. Health monitoring systems present an expanded set of ethical issues to system developers. They combine SE ethics (engineering and professional ethics applied to the design, development, and implementation of software systems) with medical ethics. SE has eight basic ethical principles: serve consistently with public interest, protect the best interest of client and employer, ensure highest possible professional standards of the product, maintain integrity and independence in professional judgement, promote an ethical approach to the management of software development and maintenance, advance the integrity and reputation of the profession, be fair to and supportive of colleagues, and participate in lifelong learning regarding the SE practice [63]. Medical ethics principles include patient self-determination, honesty/integrity, confidentiality, fairness and equity, and balance of harm vs. benefit [64]. Key issues include ensuring a high degree of dependability of the system, appropriate data governance and ownership, and making data accessible when needed. Pregnancy data must involve consideration of the rights of both mother and yet unborn baby as well as the rights of the father. Access to data and medical decision-making issues in pregnancy are complex and require novel solutions in the rapidly changing health care and societal frameworks.

Addressing Software Engineering Issues
SE issues to be resolved in a satisfactory manner include [65]: system accuracy, system and data dependability, oversight and governance of patient data, accuracy and adequacy of medical knowledge, reasonable cost of the system and system operation, system compatibility and data portability, and standards.
The system should ensure accuracy and suggest adequate responses to alerts. System and data dependability are essential for health monitoring, including pregnancy monitoring. Dependability threats, attributes, and techniques are shown in Table 3. Currently, dependability options are limited because there is a lack of standards, patient data and software are owned by sensor device manufacturers, not by the patients, and the versions of sensor systems along with associated software are changing every year. WSN devices are generally of consumer quality and the number of FDA certified devices is low. This is a major area of development and improvement. It is unclear about the quality of medical knowledge used for decision making. We suggest that clinical grade guidelines and data from systematic reviews (see Section 3) are used for developing and improving decision making algorithms. The development of standards for both hardware and software applications in WSN should be a priority. This improves compatibility, persistence, exchange, and the durability of data.

Ethics
Health monitoring systems allow health care services in patient homes and other places. These systems generate large amounts of personal health data. These data are used to assess health status and can help making health care decisions. The issues of privacy, trust and safety, accessibility, and ownership of data require serious consideration. Data safety considers the combination of data accuracy, integrity availability and persistence. Data from wearable devices are typically owned by sensor devices manufacturers and data privacy is not their priority. Corporations sell personal data for commercial gain, but people are reluctant to provide their data for such purpose [66]. Private health and financial data are sold to third parties [67]. Aggregated anonymized data can be sold legally, but many loopholes open privacy and security threats [68]. Conceptual Privacy Framework is defined as a coherent set of actionable principles to protect Patients health information privacy [69]. New SE models and algorithms for enhancing privacy and security of personal data have been proposed [66,69], but their broad application is not yet a common practice. The proposed pregnancy monitoring system (Fig. 3) generates alerts and health recommendations based on the patient's health data and sensor system historical data, for example, it can detect healthy or unhealthy pregnancy weight gain. An inaccurate assessment of pregnancy weight gain may create nutritional or psychological problems for the monitored person. It is essential that the system is robust, reliable, and accurate to provide for both quality health care and high comfort for the patient.
The long-term solution for data privacy and safety is that the ownership of the data is transferred to the patient. Aggregation of health monitoring data is important for understanding patterns that correlate to healthy or disease states. Sharing these data is essential for advancing medical research, a better understanding of disease, improving public health care management, and improvement of health care services. Sharing health monitoring data is, therefore, a part of social responsibility, but it must be done using anonymization to protect patient privacy. Sharing health data involves specific privacy risks such as privacy abuse by authorized users, access by unauthorized users, re-identification of publicly available anonymized data. Safety risks involve loss or corruption of data. The key security measures designing should achieve the following objectives [70]: protecting the confidentiality, integrity, and availability of health data; ensure the security of the use and disclosure of health care data; protect the security of personal information, public interest, and national security; and ensure that health care data meets both business and security requirements.
Ethics is an emerging concern for both the design and use of sensor networks in health monitoring and needs to be considered as an emerging SE issue.

Discussion
Health data, such as vital signs, should produce similar values when detected by different sensors that may be located at different parts of the body, or within the personal environment. The value of each data point for a given variable in health streaming depends on its previous value, change of the status of the organism, and responses to various stimuli. Interpretation of these data requires use of medical knowledge, particularly medically established "normal values" that define threshold values for healthy state. Different states of the organism (such as resting, sleeping, exercising, walking, or running) follow characteristic trends of observed variables. Pathological values are defined by defined thresholds and trend deviations. The functional monitoring system shows the same trends for a given variable even when the measurements are done by multiple sensors. The values should agree with medical knowledge and conform to the value ranges characteristic for the identified state.
Integration of WSNs with the IoT devices, such as those that record atmospheric variables or air pollution provide additional information relevant to health monitoring. This new information can help the interpretation of measured changes and the health effects on individual, as well as provide for the calibration of the sensor networks. For example, changes in wearable BP measurements from a smart wrist band can be verified by an FDA certified IoT BP monitor. The verification can be requested automatically by the system, followed by BP data comparison with HRV and weight data to identify possible causes of variability. Calibration of multiple sensors from the network can be done at the time when measurement with a certified instrument is performed. The recorded data update the individual's health history, and the past data can be corrected for systematic errors and explainable deviations. In our opinion, the following starting points are suitable for addressing the Oracle problem questions [24]: What is the system intended to do? The system is intended to collect vital data from individuals and the environment. The accuracy, validity, and relevance of the data must be assured, supported by interpretations, and patterns recognized in the data should trigger responses.

Which source (if any) should be considered canonical?
The primary canonical data are those collected from FDA certified medical devices. For pregnancy monitoring certified devices should be available for both calibration and validation of WSN measurements.

What degrees of 'trust' or 'authority' should be given to one measure or another?
Higher trust is given to data of higher granularity, certified sensors, and certified medical instruments. For pregnancy monitoring, all findings from WSNs should be verified by clinical-grade FDA certified instruments.
How should the trust priority be established? Unusual behavior or discrepancies can be explained, responded to, or corrected, through use of primary canonical data and the data from highly reliable IoT linked devices. For pregnancy monitoring FDA certified devices should be used for calibration of wearables and the trust should be assessed through experimental validation and regular checking.

How do we evaluate the correctness in uncertain-by-design environments?
Compare data with the expected behavior and validate through regular medical diagnostic tests (done on a regular schedule or on demand). For pregnancy monitoring we propose three-prong approach. Regular system testing provides for recalibration of the system using certified devices. The system design maximizes fault prevention, tolerance, and removal, while aberrations of regular patterns should be investigated as fault forecasting predictors. Finally, the system should address the Oracle problem by continuous deployment of metamorphic testing.

Conclusion
We foresee the proliferation of systems that combine large sensor networks. These systems have embedded redundancy, where multiple sensors measure the same variable and stream data to a control unit. The control unit captures data from different streams, compares them with expected behavior using medical knowledge and the subject's individual characteristics. The system must apply filtering and error corrections to gather evidence, provide reports, and offer appropriate advice. In some cases, standard medical diagnostic testing should be initiated and requested to validate observations indicated by WSN data streams.
The filtered, corrected, and summarized streamed data are stored to form personal health histories. These personal health records will complement professional health records and enhance personal care both for health and wellbeing. Ownership and governance of the data must provide a good balance between ensuring their safety and privacy, and social responsibility. The emerging technologies, such as blockchain [71] and artificial intelligence may offer solution to the emerging challenges of mobile wearable health care and wellbeing. The systems for mobile healthcare and wellbeing rapidly grow in size and complexity. Information technology and sensor networks are at the core of these systems and SE is critical for assuring appropriate design, dependability, knowledge management, and ensuring that system specifications are properly addressed. These specifications should address not only the technical requirements, but also the compliance with legal and ethical frameworks and resistance to abuse. New algorithmic and engineering solutions are needed to deal with connectivity, data analytics, and decision making in the era of Big Data.