A new smart healthcare framework for real-time heart disease detection based on deep and machine learning

Cardiovascular diseases (CVDs) are the most critical heart diseases. Accurate analytics for real-time heart disease is significant. This paper sought to develop a smart healthcare framework (SHDML) by using deep and machine learning techniques based on optimization stochastic gradient descent (SGD) to predict the presence of heart disease. The SHDML framework consists of two stage, the first stage of SHDML is able to monitor the heart beat rate condition of a patient. The SHDML framework to monitor patients in real-time has been developed using an ATmega32 Microcontroller to determine heartbeat rate per minute pulse rate sensors. The developed SHDML framework is able to broadcast the acquired sensor data to a Firebase Cloud database every 20 seconds. The smart application is infectious in regard to displaying the sensor data. The second stage of SHDML has been used in medical decision support systems to predict and diagnose heart diseases. Deep or machine learning techniques were ported to the smart application to analyze user data and predict CVDs in real-time. Two different methods of deep and machine learning techniques were checked for their performances. The deep and machine learning techniques were trained and tested using widely used open-access dataset. The proposed SHDML framework had very good performance with an accuracy of 0.99, sensitivity of 0.94, specificity of 0.85, and F1-score of 0.87.


General overview of application
To get the expected functionality of the project, the application has been programmed by dividing it into Two platforms. ATmega32 is the one which is collect heart beat from sensor and send BPM into android app using Bluetooth communication , the other side android app that receive BPM and path it to Machine learning module to detect heart disease 5.2 Embedded system Programming 5.2.1 Heart Beat Algorithm igh enough resolution to get First off, it's important to have a regular sample rate with h reliable measurement of the timing between each beat. To do this, we set up Timer0, an 8 bit hardware timer on the ATmega32, so that it throws an interrupt every other millisecond.
EN_G()ensures that global interrupts are enabled. Timing is important.
So, when the ATmega32 is powered up and running with Pulse Sensor Amped plugged into analog pin 0, it constantly (every 2 mS) reads the sensor value and looks for the heart beat.
Here's how that works: if (Signal < thresh && Pulse == 1){ Pulse = 0; amp = P -T; thresh = amp/2 + T; P = thresh; T = thresh; } Pulse was declared true during the upward rise in Pulse Sensor signal when we found the beat, above, so when the signal crosses thresh going down, we can figure that the pulse is over. Then the amplitude of the wave that just passed is measured, and thresh is updated with the new 50% mark. P and T are reset to the new thresh. The algorithm is now primed and ready to find the next beat.
There's one more question to ask before the ISR is done.  To use this library. First add some permissions in manifest file <uses-permission android:name="android.permission.SEND_SMS"/> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.READ_SMS" /> Then use SmsManager class to handle SMS messages, in our project SMS Messages is handled also using own background thread to improve performance. Message will be sent when heart rate is not stable

Maps Service
One of the unique features of mobile application is location awareness. App users take their devices with them everywhere, and adding location awareness to our app offers users a more contextual experience. The location APIs available in Google Play services facilitate adding location awareness to our app with automated location tracking, geofencing, and activity recognition. Some permissions are needed for foreground location when app requests either the ACCESS_COARSE_LOCATION permission or the ACCESS_FINE_LOCATION permission <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Create location services client
In your activity's onCreate() method, create an instance of the Fused Location Provider Client as the following code snippet shows. Once I have created the Location Services client i can get the last known location of device. When app is connected to these can use the fused location provider's getLastLocation() method to retrieve the device location. The precision of the location returned by this call is determined by the permission setting you put in app manifest Step Tracker Service The Android sensor framework supports a wide variety of sensor types to measure the conditions of the physical environment and read the raw data from apps. The data from these sensors is delivered through the same SensorManager APIs as the built-in Android sensors.

Coronary hearts disease
Coronary heart disease is often caused by the buildup of plaque, a waxy substance, inside the lining of larger coronary arteries.
This unique service which predict coronary heart disease for user using Deep Learning module. User insert some data to module using editTexts in page and click on button finally result will be displayed. return "no TenYearCHD"; return "yes TenYearCHD"; } module added in android app as a file so Write operation into file is easy way to insert user data into module and get prediction using some libraries implemented in android import org.pytorch.IValue; import org.pytorch.Module; import org.pytorch.Tensor;

Firebase Service
Firebase can power your app's backend, including data storage, user authentication, static hosting, and more. Focus on creating extraordinary user experiences.
Our app use firebase for many services • Real-time Database − Firebase supports JSON data and all users connected to it receive live updates after every change.
• Authentication − We can use anonymous, password or different social authentications.
• Hosting − The applications can be deployed over secured connection to Firebase servers. 3. When initializing your Activity, check to see if the user is currently signed in. Add a form to register new users with their email and password and call this new method when it is submitted.

Sign in existing users
Create a new signIn method which takes in an email address and password, validates them, and then signs a user in with the signInWithEmailAndPassword method.

Configure Realtime Database Rules
The Realtime Database provides a declarative rules language that allows you to define how your data should be structured, how it should be indexed, and when your data can be read from and written to.
By default, read and write access to your database is restricted so only authenticated users can read or write data. To get started without setting up Authentication, you can configure your rules for public access. This does make your database open to anyone, even people not using your app, so be sure to restrict your database again when you set up authentication.

Write to database
Retrieve an instance of your database using getInstance() and reference the location you want to write to.