Professional Documents
Culture Documents
SUBMITTED BY SUBMITTED TO
Rahul Saini Mrs. Aruna Kumari (Asst. Professor)
2202200140064
i
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to Mrs. Aruna Kumari Asst. Professor
of the Department of MCA, for her invaluable guidance and support throughout
this project. Her expertise and insights were instrumental in shaping this app.
I am also thankful to Dr. Pankaj Mishra, Director of the MCA program, for his
encouragement and support. His vision and encouragement motivated me to strive
for excellence.
Despite working alone, I was able to complete this project thanks to the
unwavering support of my professors. Their belief in me gave me the strength to
overcome challenges and achieve my goals.
Rahul Saini
MCA Department
Roll Number: 2202200140064
Date:
ii
CERTIFICATE OF ORIGINALITY
I hereby declare that the work which is being presented in this project work entitled The
Health Detectives in partial fulfillment of the requirements for the award of the degree of
Technology, Ghaziabad is an authentic record of my own work carried out during the
period 2023 to 2024 under the supervision and guidance of Asst. Prof. Aruna Kumari.
I have not submitted the matter embodied in this project work anywhere for the
Place:
iii
GUIDE/INDUSTRY /COMPANY CERTIFICATE
Certificate
This is to certify that the Project entitled The Health Detectives is a bonafide
under my supervision during MCA , in partial fulfillment of the requirements for the
in session 2023-24 and that the Project has not previously formed the basis for
the award of any other degree, Diploma, Associate ship, Fellowship or other title.
iv
Table Of Content
Acknowledgement ………………………………………………………….. ii
1. Introduction ………………………………………………………………. 1
7. Database ………………………………………………………………….. 68
8. Coding……………………………………………………………………... 73
v
Chapter1
INTRODUCTION
The Health Detective App is a comprehensive mobile application designed to
empower users with tools and information to take control of their health and well-
being. In today's fast-paced world, where health concerns are paramount, having
easy access to reliable health information and services is crucial. This app aims to
bridge the gap between users and their healthcare needs by offering a range of
features tailored to facilitate disease prediction, detection, and management.
With the Health Detective App, users can embark on a journey towards improved
1
health outcomes, equipped with valuable insights, convenient tools, and access to
professional healthcare services at their fingertips. Whether it's staying informed
about common ailments, tracking personal health metrics, or seeking expert
medical advice, this app is dedicated to empowering individuals to make informed
decisions and lead healthier lives.
Problem Statement
In the realm of healthcare, readily available, accurate information is often the first
line of defense against preventable health concerns and missed diagnoses. Yet,
navigating the complexities of medical jargon and finding reliable sources can be
daunting, particularly for individuals with limited medical background or specific
health anxieties. This often leads to delayed diagnoses, ineffective treatments, and
unnecessary stress, impacting both personal well-being and healthcare costs.
Enter Health Detective, an Android app designed to bridge the gap between
accessible knowledge and empowered health management. Recognizing the
challenges individuals face in deciphering symptoms, understanding disease
complexities, and accessing qualified healthcare professionals, Health Detective
aims to become a one-stop shop for proactive health engagement.
Through its innovative features, Health Detective empowers users to take control
of their health journey:
2
professional advice when necessary. While not intended for diagnosis, this feature
serves as a crucial first step in navigating potential health issues.
• BMI Calculator: Providing a quick and convenient tool for assessing body mass
index (BMI), the app helps users understand their weight status and make informed
lifestyle choices.
3
By addressing the core problem of limited health information accessibility and user
empowerment, Health Detective goes beyond being just an app. It aspires to be a
personalized health companion, guiding individuals towards proactive health
management, informed decision-making, and seamless access to qualified
professionals. By bridging this critical gap, Health Detective empowers users to
embark on a journey towards a healthier, happier, and more informed version of
themselves.
OBJECTIVE
The primary objective of the Health Detective App is to empower users withtools
and resources to take control of their health and well-being.
Key objectives of the project include:
4
abnormalities and enabling users to schedule appointments directly through the
app.
By achieving these objectives, the Health Detective App aims to redefine the
traditional healthcare paradigm, empowering individuals to make informed
decisions about their health and leading to improved health outcomes and
enhanced quality of life for all users.
5
Chapter 2
System Analysis
The system analysis phase of the Health Detective App project involved
studying and analyzing the requirements and functionalities of the proposed
system. This phase aimed to identify user needs, define system requirements,
and establish the foundation for system design and development.
• Identification of Need:
The identification of the need for the Health Detective App stemmed from the
recognition of several challenges and gaps in the existing healthcare system:
6
multiple sources, making it difficult for individuals to track and manage their
health effectively.
• Preliminary Investigation:
The preliminary investigation phase involved conducting research and
gathering information to assess the feasibility and viability of developing the
Health Detective App. Key activities and findings during this phase include:
7
4. Regulatory Compliance: Investigating regulatory requirements and
compliance standards related to healthcare apps, including data privacy
regulations such as HIPAA (Health Insurance Portability and Accountability
Act) and GDPR (General Data Protection Regulation).
8
Chapter 3
FEASIBILITY STUDY
9
computers, smartphones, and development tools, are readily available and
compatible with the project's needs.
4. Integration Capabilities: The app's architecture allows for seamless integration
with external services and APIs, such as doctor recommendation systems,
appointment scheduling platforms, and healthcare databases, ensuring
interoperability and scalability.
Overall, the technical feasibility assessment indicates that the Health Detective
App can be implemented successfully using the available technology and
resources, with the project team possessing the necessary expertise to execute the
project effectively.
2. Economic Feasibility:
1. Development Costs: The initial development costs for designing, coding, testing,
and deploying the app, including expenses related to hiring developers, purchasing
software licenses, and acquiring datasets for training machine learning models.
2. Operational Costs: The ongoing operational costs associated with maintaining
and supporting the app, including server hosting fees, software updates, customer
support services, and marketing expenses.
3. Revenue Potential: The potential revenue streams for the app, including
subscription fees, in-app purchases, advertising revenue, and partnerships with
healthcare providers or pharmaceutical companies.
10
4. Return on Investment (ROI): The projected ROI for the project, taking into
account the expected revenue generated from the app and the associated costs over
time.
3. Operational Feasibility:
11
By addressing these operational considerations, the Health Detective App can be
designed and implemented in a manner that maximizes user acceptance, usability,
and operational efficiency, ultimately contributing to its success and impact in
improving healthcare delivery and access.
12
Chapter 4
S/W & H/W Requirement Specification
• Software Requirements:
Android Studio:
Android Studio is the official Integrated Development Environment (IDE) for
Android app development, provided by Google. It is based on the IntelliJ IDEA
IDE and is specifically designed for building Android apps. Android Studio offers
a range of features and tools to streamline the app development process, including:
1. User Interface Designer: Android Studio includes a visual designer for creating
app layouts using XML files. The designer allows developers to drag and drop UI
components onto the screen and preview how the layout will look on different
devices.
13
2. Code Editor: Android Studio provides a powerful code editor with features like
syntax highlighting, code completion, and refactoring tools. It supports multiple
programming languages, including Kotlin, Java, and C++.
3. Build Tools: Android Studio comes with tools for building, testing, and packaging
Android apps. It includes support for Gradle, a build automation tool used for
managing dependencies and building app packages (APKs).
4. Emulator: Android Studio includes an Android Emulator that allows developers
to test their apps on virtual devices. The emulator supports various Android
versions and device configurations, making it easy to test apps across different
devices.
5. Debugging Tools: Android Studio provides tools for debugging Android apps,
including breakpoints, watches, and a debugger console. Developers can use these
tools to identify and fix issues in their code.
6. Performance Profiler: Android Studio includes a performance profiler that allows
developers to monitor the performance of their apps in real-time. The profiler
provides insights into CPU, memory, and network usage, helping developers
optimize their apps for better performance.
XML:
XML (Extensible Markup Language) is a markup language that is commonly used
for structuring and storing data. It uses tags to define the structure of data elements
and their relationships. XML is designed to be both human-readable and machine-
14
readable, making it widely used for data interchange between different systems and
applications.
1. Tags: XML uses tags to define elements in a hierarchical structure. Tags are
enclosed in angle brackets (< >) and are used to mark the beginning and end of
elements (<element>...</element>).
2. Attributes: XML elements can have attributes that provide additional information
about the element. Attributes are specified within the opening tag of an element
(<element attribute="value">).
3. Nesting: XML elements can be nested inside other elements to create complex
data structures. This allows for the representation of hierarchical data.
4. Self-closing Tags: XML allows for self-closing tags, which are used for elements
that do not have any content (<element/>).
5. Well-Formedness: XML documents must adhere to certain rules to be considered
well-formed, such as having a single root element, properly nested elements, and
correctly formatted tags.
KOTLIN:
Kotlin is a statically typed programming language that runs on the Java Virtual
Machine (JVM) and can also be compiled to JavaScript or native code. It was
developed by JetBrains and officially supported by Google for Android app
15
development since 2017. Kotlin is known for its conciseness, safety features, and
interoperability with Java, making it a popular choice for Android development
and other JVM-based applications.
1. Conciseness: Kotlin reduces boilerplate code common in Java, making code more
readable and maintainable. Features like type inference, data classes, and extension
functions contribute to this.
2. Null Safety: Kotlin's type system distinguishes between nullable and non-nullable
types, reducing the risk of null pointer exceptions. This is achieved through the use
of nullable types (Type?) and safe call operator (?.).
3. Interoperability: Kotlin is fully interoperable with Java, allowing developers to
use Kotlin and Java code together in the same project. This makes it easy to adopt
Kotlin gradually in existing Java projects.
4. Extension Functions: Kotlin allows adding new functions to existing classes
without modifying their source code. These functions are called extension
functions and can be used to extend the functionality of classes from external
libraries or SDKs.
5. Smart Casts: Kotlin's type system includes smart casts, which automatically cast a
variable to a more specific type when certain conditions are met. This reduces the
need for explicit type checks and casts in code.
6. Coroutines: Kotlin provides first-class support for coroutines, which are a way to
write asynchronous, non-blocking code. Coroutines simplify the handling of
asynchronous tasks compared to traditional callback-based approaches.
7. Functional Programming Support: Kotlin includes features from functional
programming paradigms, such as higher-order functions, lambda expressions, and
16
immutable data structures. These features enable concise and expressive code for
handling collections and other tasks.
Overall, Kotlin offers a modern and expressive syntax that improves productivity
and developer experience, especially for Android development. Its compatibility
with existing Java codebases and its safety features make it a compelling choice for
a wide range of software development projects.
17
CHAPTER 5
SYSTEM DESIGN
System Design for the Health Detective App:
The system design phase of the Health Detective App involves architecting the
overall structure and components of the app to ensure scalability, reliability, and
performance. Here are key aspects of the system design:
1. Architecture Overview:
• The app follows a client-server architecture, where the client-side
application runs on users' Android devices, and the server-side components
handle data processing, storage, and business logic.
• The client-side application communicates with the server using RESTful
APIs over HTTPS for data exchange and synchronization.
2. Component Diagram:
• The system consists of several interconnected components, including:
• User Interface (UI): Responsible for presenting information to users
and collecting user input.
• Business Logic: Implements the core functionality of the app,
including disease prediction, MRI image analysis, doctor
recommendation, and appointment scheduling.
• Data Access Layer: Manages data storage and retrieval, including
user profiles, health data, disease information, and doctor directories.
• Machine Learning Model: Implements deep learning algorithms for
disease prediction and MRI image analysis.
• Database: Utilizes SQLite for local storage of user data within the
app and possibly a remote database for server-side data storage.
18
3. User Interface Design:
• The user interface is designed to be intuitive, user-friendly, and accessible,
following Material Design principles for consistency and familiarity.
• Key UI components include screens for symptom input, disease prediction
results, doctor recommendations, appointment scheduling, BMI calculation,
and health data management.
4. Data Flow Diagram:
• The data flow diagram illustrates the flow of data and interactions between
different components of the system.
• It depicts how user input is processed, analyzed, and presented back to the
user, as well as interactions with external services and databases.
5. Security Considerations:
• Security measures are implemented to protect user data and ensure privacy
and confidentiality.
• This includes encryption of sensitive data, secure authentication
mechanisms, and adherence to relevant data protection regulations.
6. Scalability and Performance:
• The system is designed to be scalable to accommodate a growing user base
and increasing data volume.
• Performance optimizations are implemented to ensure fast response times
and smooth user experience, including efficient data caching, asynchronous
processing, and resource management.
7. Error Handling and Recovery:
• Robust error handling mechanisms are implemented to detect and handle
exceptions gracefully, ensuring that the app remains stable and responsive
even in the event of failures or unexpected conditions.
19
• Error logging and monitoring tools are employed to track and diagnose
issues, facilitating rapid resolution and continuous improvement.
DFD 0 Level
20
DFD 1 Level
21
DFD 2 Level
22
CHAPTER 6
SNAPSHOTS AND WORKING OF MODULE
1. Splash Screen:
Visual Impact:
23
• Magnifier glass: Highlights the app's role in uncovering insights and
understanding health issues.
• Sky blue background: Evokes a sense of calmness, trust, and open
communication.
Functionality:
• Splash screen: Acts as the initial screen users see when launching the app.
• Animation: Adds a touch of dynamism and makes the splash screen more
visually appealing.
• Text "The Health Detectives": Clearly communicates the app's name and
brand identity.
Overall Impression:
• The splash screen sets the tone for the app, conveying a message of
professional yet approachable healthcare assistance.
• It piques the user's interest by highlighting the app's investigative and
informative nature.
• The animation adds a touch of fun and modernity, making the app feel
engaging.
24
3. Login Screen:
The login screen of the Health Detective App consists of two text fields for
the user to enter their email and password, along with two buttons: a "Login"
button and a "Sign Up" button. Here's how the login screen works:
25
1. Email and Password Validation: When the user enters their email and
password, the app validates these fields to ensure they meet the required
criteria (e.g., valid email format, password length).
2. Login Button: When the user taps the "Login" button, the app attempts to
authenticate the user using the provided email and password. This involves
sending a request to the authentication server (e.g., Firebase Authentication)
to verify the user's credentials.
• If the credentials are valid, the user is successfully logged in, and they
are directed to the app's home screen.
• If the credentials are invalid, the app displays an error message
informing the user that their login attempt was unsuccessful.
3. Sign Up Button: If the user does not have an account or wishes to create a
new account, they can tap the "Sign Up" button. This takes them to the sign-
up screen, where they can enter their details to create a new account.
Overall, the login screen provides a simple and intuitive interface for users to
authenticate and access the Health Detective App's features and
functionalities.
4. SingUp Screen:
26
The signup screen of the Health Detective App features a unique design with
a hand holding a heart, symbolizing care and health. The screen includes four
fields for the user to enter their username, phone number, email, and
password, along with two buttons: a "Register" button and a "Click here to
login" button. Here's how the signup screen works:
1. Email and Password Validation: Similar to the login screen, the signup
screen validates the email and password fields to ensure they meet the
required criteria (e.g., valid email format, password length).
2. Empty Validation: The screen also checks for empty fields to ensure that all
required fields (username, phone number, email, password) are filled in
before proceeding with registration.
27
3. Register Button: When the user taps the "Register" button, the app attempts
to create a new account using the provided details. This involves sending a
request to the authentication server (e.g., Firebase Authentication) to create a
new user account.
• If the registration is successful, the user is notified and can proceed to
login using their newly created account.
• If there are any errors (e.g., duplicate email, weak password), the app
displays an error message informing the user of the issue and prompts
them to correct it.
4. Click Here to Login Button: If the user already has an account or wishes to
login, they can tap the "Click here to login" button. This takes them back to
the login screen, where they can enter their credentials to login.
5. Back Navigation: Optionally, you can include a way for the user to navigate
back to the previous screen if they decide not to register at that time.
5. Home Screen:
28
The Home Screen of the Health Detective App serves as the main hub where
users can access various features and functionalities of the app. The screen
features a drawer navigation menu that provides easy access to different
sections of the app, as well as a slide bar that displays project features and
options for disease detection based on symptoms and MRI images.
• The drawer navigation menu provides access to different sections of the app,
such as:
• Diseases Prediction: Allows users to enter symptoms and receive
predictions of possible diseases.
29
• Disease Detection: Provides options for disease detection based on
symptoms and MRI images.
• Disease Information: Offers detailed information about various
diseases.
• Recommended Doctors: Provides a list of doctors recommended for
specific diseases.
• Fix Doctor Appointment: Allows users to schedule appointments with
recommended doctors.
• BMI Calculator: Offers a tool for calculating Body Mass Index based
on user inputs.
• Upload Patients Data: Enables users to securely upload and manage
patient data.
2. Slide Bar:
• The slide bar displays project features and options for disease detection:
• Project Features: Provides an overview of the app's key features, such
as disease prediction, doctor recommendation, and BMI calculator.
• Diseases Detection: Offers options for disease detection based on
symptoms and MRI images.
• Users can enter their symptoms into the app, and based on the input, the app
predicts possible diseases that match those symptoms. This feature helps
users understand their health condition and seek appropriate medical advice.
30
4. Disease Detection Based on MRI Images:
• Users can upload MRI images, such as those for brain tumors, Alzheimer's,
and lung cancer, for disease detection. The app uses advanced AI algorithms
to analyze the images and provide predictions, aiding in early disease
detection and treatment.
Overall, the Home Screen of the Health Detective App provides users with a
central location to access key features and functionalities related to health
management, disease prediction, and detection. The intuitive interface and
navigation options make it easy for users to navigate the app and make
informed decisions about their health.
31
The Drawer Navigation in the Health Detective App provides users with a
convenient way to navigate between different sections of the app. It features a
welcome message, user photo, and a beautiful sky blue wave design, creating
an inviting and visually appealing interface. The navigation menu allows
users to access various features and functionalities of the app, providing a
seamless user experience. Here's a detailed overview of the Drawer
Navigation:
• The Drawer Navigation starts with a welcoming message to the user, creating
a personalized touch.
32
• It also displays the user's photo, adding a sense of familiarity and
customization to the app.
• The sky blue wave design adds a visual element to the Drawer Navigation,
making it more attractive and engaging.
• The design choice reflects the app's focus on health and well-being, creating a
calming and soothing effect.
• The Drawer Navigation provides access to key features of the app, such as:
• Diseases Prediction: Allows users to predict diseases based on
symptoms.
• Disease Detection: Offers options for disease detection using AI
algorithms.
• Disease Information: Provides detailed information about various
diseases.
• Recommended Doctors: Lists doctors recommended for specific
diseases.
• Fix Doctor Appointment: Enables users to schedule appointments with
recommended doctors.
• BMI Calculator: Provides a tool for calculating Body Mass Index.
• Upload Patients Data: Allows users to securely upload and manage
patient data.
33
4. Navigation to Other Screens:
5. User-Friendly Interface:
6. Customization Options:
• The Drawer Navigation can be customized to suit the user's preferences, such
as changing the theme color or rearranging the menu items.
• This customization allows users to personalize their app experience, making
it more enjoyable and engaging.
34
7. User Profile:
The User Profile screen in the Health Detective App serves as a centralized
location for users to view and manage their personal information. It includes
various fields such as user image, name, age, gender, phone number, address,
email, password, and read ID. The screen also features an "Edit Profile"
button, allowing users to update their information as needed. Here's a detailed
overview of the User Profile screen:
1. User Image:
35
• The User Profile screen displays the user's profile image, providing a visual
representation of the user.
• Users can upload or change their profile image to personalize their profile.
• The screen includes fields for the user's name, age, and gender, providing
basic demographic information.
• Users can update these fields to ensure their profile is up-to-date.
• The User Profile screen includes fields for the user's phone number, address,
and email address, allowing users to provide contact information.
• Users can edit these fields to update their contact details.
4. Password:
• The screen includes a field for the user's password, which is displayed as
masked characters for security reasons.
• Users can change their password by entering their current password and then
entering a new password.
5. Read ID:
36
6. Edit Profile Button:
• The "Edit Profile" button allows users to update their profile information.
• When clicked, the button opens a form or dialog where users can edit their
details and save the changes.
7. User-Friendly Interface:
• The User Profile screen is designed to be user-friendly, with clear labels and
input fields for each piece of information.
• The interface is intuitive, making it easy for users to navigate and update
their profile information.
• The User Profile screen prioritizes user privacy and security, with features
such as masked password fields and secure data storage.
• Users can feel confident that their personal information is protected.
Overall, the User Profile screen in the Health Detective App provides users
with a convenient and secure way to manage their personal information. It
enhances the user experience by offering a centralized location for users to
37
view and update their profile details, ensuring that their information is up-to-
date and accurate.
38
Once users select their symptoms, they can set them using a "Set Symptoms"
button. The selected symptoms are displayed in a RecyclerView, allowing
users to review their choices. After selecting their symptoms, users can click
a "Show Result" button to initiate the disease prediction process.
1. Text Prompt:
• The text prompt encourages users to select three or more symptoms for the
best prediction accuracy, guiding them on how to use the feature effectively.
2. Autocomplete View:
• The "Set Symptoms" button allows users to confirm their selected symptoms
and proceed with the prediction process.
• The "Show Result" button triggers the disease prediction process based on
the selected symptoms.
39
6. Disease Prediction Results:
• After clicking the "Show Result" button, the app uses a deep learning
algorithm to predict potential diseases based on the selected symptoms.
• The predicted diseases are displayed in a RecyclerView, showing the names
of the diseases and their corresponding prediction accuracy.
8. User-Friendly Interface:
• The deep learning algorithm used for disease prediction aims to provide
accurate and reliable predictions based on the selected symptoms, helping
users make informed decisions about their health.
40
Overall, the Disease Detection Based on Symptom screen provides users with
a powerful tool for predicting diseases based on their symptoms, helping
them understand their health condition and take appropriate actions.
The Disease Detection Based on MRI Images screen in the Health Detective
App allows users to predict diseases such as brain tumors, Alzheimer's, and
lung diseases based on MRI images. The screen features options to either
select an image from the gallery or capture a new image using the device's
41
camera. After selecting or capturing an image, users can click a "Show
Result" button to initiate the disease prediction process.
• The Gallery button allows users to select an MRI image from their device's
gallery.
• The Camera button enables users to capture a new MRI image using their
device's camera.
• The "Show Result" button triggers the disease prediction process based on
the selected or captured MRI image.
• After clicking the "Show Result" button, the app uses a deep learning
algorithm to predict potential diseases based on the MRI image.
• The predicted diseases are displayed, showing the names of the diseases and
their corresponding prediction accuracy.
• Each disease prediction card includes options for viewing more information
about the disease and scheduling a doctor appointment.
• Users can click on these options to access detailed disease information or
schedule an appointment with a recommended doctor.
42
5. Diseases Detected:
• The deep learning algorithm used for disease detection is capable of detecting
brain tumors, Alzheimer's disease, and lung diseases based on MRI images.
6. User-Friendly Interface:
• The deep learning algorithm aims to provide accurate and reliable predictions
based on MRI images, helping users understand their health condition and
take appropriate actions.
Overall, the Disease Detection Based on MRI Images screen provides users
with a powerful tool for predicting diseases based on MRI images, enabling
early detection and timely intervention for better health outcomes.
43
The Disease Information screen in the Health Detective App allows users to
access detailed information about various diseases. The screen features an
autocomplete view that displays a list of disease names, making it easy for
users to select a disease of interest. After selecting a disease, users can press a
"Get Information" button to load the corresponding information from a URL
in a WebView.
1. Autocomplete View:
• After pressing the "Get Information" button, the app loads the information
about the selected disease from a URL.
• The disease information is displayed in a WebView, providing users with
detailed descriptions, symptoms, causes, treatments, and other relevant
information about the disease.
4. User-Friendly Interface:
46
The Doctor Recommendation screen in the Health Detective App provides
users with a list of recommended doctors based on their selected disease and
specialist. The screen features a RecyclerView that displays doctors'
information, including their name, image, specialist, and rate. The screen also
includes a filter option that allows users to filter doctors based on disease and
specialist criteria.
2. Doctor Filtering:
• The filter option allows users to filter doctors based on their disease and
specialist criteria.
• Users can select a disease and specialist from the filter options to refine the
list of recommended doctors.
• The doctor cards feature a cool animation, making the user interface more
engaging and visually appealing.
• This animation adds a touch of interactivity to the screen, enhancing the user
experience.
47
4. User-Friendly Interface:
48
cool animations makes the screen engaging and easy to use, helping users
make informed decisions about their healthcare.
The Doctor Information screen in the Health Detective App provides users
with detailed information about a specific doctor. The screen includes various
fields such as the doctor's image, name, age, number of patients, experience
rating, specialist, about us, working at, and contact information. The screen
also features icons for calling and messaging the doctor, as well as a button to
navigate to the Fix Appointment screen.
49
1. Doctor Image, Name, Age:
• The screen displays the doctor's image, name, and age, providing users with a
visual representation of the doctor.
• This information helps users identify the doctor and build trust.
• The screen includes the number of patients treated by the doctor, their years
of experience, and their rating.
• This information helps users assess the doctor's expertise and reputation.
• The screen displays the doctor's specialist field, a brief description about the
doctor, and their current workplace.
• This information helps users understand the doctor's expertise and
background.
4. Contact Information:
• The screen includes contact information for the doctor, such as phone number
and email address.
• Users can use this information to contact the doctor directly for appointments
or inquiries.
50
• The screen features icons for calling and messaging the doctor directly from
the app.
• Users can tap these icons to initiate a call or message to the doctor, making it
convenient to communicate with them.
6. Go To Appointment Button:
51
The Fix Appointment screen in the Health Detective App allows users to
schedule an appointment with a doctor. The screen includes fields for the
patient's image, name, age, gender, phone number, address, email address,
disease, date, and time. It also features a "Set Appointment" button to
confirm the appointment. Here's a detailed overview of the Fix Appointment
screen:
• The screen displays the patient's image, name, age, and gender, providing a
visual representation of the patient.
• This information helps the doctor identify the patient and prepare for the
appointment.
52
2. Phone Number, Address, Email Address:
• The screen includes fields for the patient's phone number, address, and email
address, allowing the doctor to contact the patient and send appointment
reminders.
• This information is essential for communication and ensuring that the patient
receives important information about their appointment.
3. Disease:
• The screen includes a field for the patient's disease or reason for the
appointment, providing the doctor with context for the appointment.
• This information helps the doctor prepare for the appointment and ensure that
the patient receives the appropriate care.
• The screen includes fields for selecting the date and time of the appointment.
• Users can choose a convenient date and time for their appointment, making it
easier to schedule around their other commitments.
53
Overall, the Fix Appointment screen provides users with a convenient and
efficient way to schedule appointments with doctors, ensuring that they
receive the care they need in a timely manner.
The Appointment Status screen in the Health Detective App displays the
appointments of patients in a RecyclerView. Each appointment card includes
the patient's name, disease, date, and time of the appointment. The screen
provides users with an overview of their upcoming appointments, helping
54
them manage their healthcare schedule efficiently. Here's a detailed overview
of the Appointment Status screen:
2. Appointment Details:
• The appointment cards show the patient's name, allowing users to identify the
patient easily.
• The cards also display the patient's disease, date, and time of the
appointment, helping users plan their schedule accordingly.
3. User-Friendly Interface:
55
Overall, the Appointment Status screen provides users with a convenient and
efficient way to view and manage their appointments, ensuring that they
receive the care they need in a timely manner.
The Patient Information screen in the Health Detective App displays detailed
information about a specific patient. It includes fields such as the patient's
image, name, age, gender, phone number, address, email address, disease,
date, and time of the appointment. This screen provides healthcare providers
with essential information about their patients, helping them deliver
personalized care. Here's a detailed overview of the Patient Information
screen:
56
1. Patient Image, Name, Age, Gender:
• The screen displays the patient's image, name, age, and gender, providing a
visual representation of the patient.
• This information helps healthcare providers identify the patient and
personalize their care.
• The screen includes fields for the patient's phone number, address, and email
address, allowing healthcare providers to contact the patient and send
important information.
• This information is essential for communication and ensuring that the patient
receives the necessary care.
• The screen displays the patient's disease, date, and time of the appointment,
providing healthcare providers with context for the appointment.
• This information helps healthcare providers prepare for the appointment and
ensure that the patient receives the appropriate care.
4. User-Friendly Interface:
58
The BMI Calculation screen in the Health Detective App allows users to
calculate their Body Mass Index (BMI) based on their height and weight. The
screen features number pickers for selecting the height and weight values, as
well as a "Calculate BMI" button to perform the calculation. After calculating
the BMI, the app navigates to the BMI Result screen to display the calculated
BMI along with the height and weight values. Here's a detailed overview of
the BMI Calculation screen:
• The screen includes number pickers for selecting the height and weight
values.
• Users can use these number pickers to input their height and weight, making
it easy to enter accurate values for the BMI calculation.
• The "Calculate BMI" button triggers the BMI calculation process based on
the selected height and weight values.
• Users can tap this button to perform the BMI calculation and view the results.
• After the user selects their height and weight values and taps the "Calculate
BMI" button, the app calculates the BMI using the formula:
BMI = weight (kg) / (height (m) * height (m)).
• The calculated BMI is then sent to the BMI Result screen for display.
59
4. User-Friendly Interface:
• After calculating the BMI, the app navigates to the BMI Result screen to
display the calculated BMI along with the height and weight values.
• This seamless navigation allows users to view their BMI results quickly and
easily.
Overall, the BMI Calculation screen provides users with a convenient tool for
calculating their BMI based on their height and weight, helping them monitor
their health and fitness levels.
60
Body Mass Index (BMI) is a measure of body fat based on a person's weight
in relation to their height. It is used as an indicator of whether a person is
underweight, normal weight, overweight, or obese. The BMI categories are
defined as follows:
BMI is a useful screening tool, but it is not a diagnostic tool. Other factors
such as muscle mass, bone density, and distribution of fat can affect BMI
results. It is important to consult with a healthcare provider to determine the
most appropriate weight management plan based on individual health factors.
The BMI Result screen in the Health Detective App displays the calculated
Body Mass Index (BMI) result in terms of different categories such as
underweight, normal weight, overweight, and obese. The screen also provides
users with information about the implications of their BMI category on their
health. Additionally, the screen includes buttons for accessing disease
information and scheduling a doctor's appointment. Here's a detailed
overview of the BMI Result screen:
62
1. BMI Result Display:
• The screen provides information about each BMI category, including the
potential health risks associated with being underweight, overweight, or
obese.
• This information helps users understand the importance of maintaining a
healthy BMI and the potential consequences of being under or overweight.
• The screen includes a button for accessing information about diseases related
to BMI, such as heart disease, diabetes, and hypertension.
• Users can tap this button to learn more about the health risks associated with
their BMI category and how they can mitigate these risks.
63
5. User-Friendly Interface:
• The BMI Result screen is designed to be user-friendly, with clear labels and
intuitive controls for accessing BMI information and scheduling a doctor's
appointment.
• The interface is easy to navigate, making it simple for users to understand
their BMI results and take appropriate action.
Overall, the BMI Result screen provides users with valuable information
about their BMI status and its implications on their health. It empowers users
to make informed decisions about their health and take proactive steps to
maintain a healthy weight.
64
The Patients Records screen in the Health Detective App displays patients'
records according to the date. It includes a button to upload records, which
opens the Upload Records screen. The Upload Records screen features a
"Select Files" button to choose files from local storage. Additionally, the
screen includes an eye icon that, when clicked, opens a screen with fields for
email and read ID to fetch another patient's data. Here's a detailed overview
of the Patients Records screen:
• The screen includes a button to upload records, which opens the Upload
Records screen.
• Users can use this feature to add new records to the app for future reference
and analysis.
• The Upload Records screen features a "Select Files" button to choose files
from local storage.
• Users can select files containing patient records to upload them to the app.
66
• The screen includes an eye icon that, when clicked, opens a screen with fields
for email and read ID to fetch another patient's data.
• This feature allows users to easily access and view the records of specific
patients by entering their email and read ID.
5. User-Friendly Interface:
68
2. Authentication: Firebase Authentication provides easy-to-use SDKs and
ready-made UI libraries to authenticate users using email/password, phone
numbers, or popular third-party providers like Google, Facebook, and
Twitter.
69
3. Storage: Firebase Storage is a powerful, simple, and scalable object storage
service built for Google scale. It allows you to store user-generated content,
such as photos and videos, and serve them directly to your app.
70
Using Firebase in an Android App:
71
authentication, and file storage. It's easy to integrate Firebase into your
Android app and leverage its powerful features to enhance your app's
functionality.
72
Chapter 8
CODING
1. Splash Screen:
package com.example.healthdetectiveapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.animation.AnimationUtils
import android.widget.Toast
import
com.example.healthdetectiveapp.databinding.ActivitySplashScreenB
inding
import com.google.firebase.auth.FirebaseAuth
73
super.onCreate(savedInstanceState)
setContentView(binding.root)
auth = FirebaseAuth.getInstance()
val bounce =
AnimationUtils.loadAnimation(this,R.anim.logo_anim)
binding.logoImg.startAnimation(bounce)
val upCome =
AnimationUtils.loadAnimation(this,R.anim.come_up)
binding.hd.startAnimation(upCome)
val leftCome =
AnimationUtils.loadAnimation(this,R.anim.come_left)
binding.hdFull.startAnimation(leftCome)
val rightCome =
AnimationUtils.loadAnimation(this,R.anim.come_right)
binding.slogan.startAnimation(rightCome)
val fade =
AnimationUtils.loadAnimation(this,R.anim.fade_anim)
binding.splashImg.startAnimation(fade)
2. Login Screen :
package com.example.healthdetectiveapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.example.healthdetectiveapp.databinding.ActivityLoginBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import com.google.firebase.auth.ktx.auth
75
import com.google.firebase.ktx.Firebase
// Initializing
auth = Firebase.auth
binding.btnSignup.setOnClickListener {
startActivity(Intent(this,SignUp_Activity::class.java))
}
binding.btnLogin.setOnClickListener {
email = binding.emailLogin.text.toString().trim()
passward = binding.password.text.toString().trim()
if (!email.isEmpty()){
binding.emailLogin.error = null
76
if (email.matches("^[a-zA-Z0-9._-]+@[a-z]+\\.+[a-
z]+".toRegex())){
binding.emailLogin.error = null
if (!passward.isEmpty()){
binding.password.error = null
LoginAccount(email,passward)
}
else{
binding.password.error ="Please Fill Passward"
}
}
else{
binding.emailLogin.error = "Please Fill Valid Email"
}
}
else{
binding.emailLogin.error ="Please Fill Email"
}
}
}
auth.signInWithEmailAndPassword(email,passward).addOnCompleteListen
77
er {
result ->
if (result.isSuccessful){
val user = auth.currentUser
Toast.makeText(this, "Successfully SignIn",
Toast.LENGTH_SHORT).show()
updateUi(user)
}
else{
Toast.makeText(this, "Incorrect Email or Password",
Toast.LENGTH_SHORT).show()
}
}
}
3. SignUp Screen:
package com.example.healthdetectiveapp
78
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import
com.example.healthdetectiveapp.databinding.ActivitySignUpBi
nding
import com.example.healthdetectiveapp.model.UserModel
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.FirebaseDatabase
import java.lang.StringBuilder
import java.security.SecureRandom
import java.util.regex.Pattern
79
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.btnGotoLogin.setOnClickListener {
startActivity(Intent(this,Login_Activity::class.java))
}
binding.btnRegister.setOnClickListener {
// Geting Values
username = binding.username.text.toString().trim()
phone = binding.phone.text.toString().trim()
email = binding.email.text.toString().trim()
passward = binding.password.text.toString().trim()
// Performing Validation
if (!username.isEmpty()){
binding.username.error = null
if (!phone.isEmpty()){
binding.phone.error = null
if (phone.matches("[1-9][0-9]{9}".toRegex())){
binding.phone.error = null
if (!email.isEmpty()){
binding.email.error = null
if (email.matches("^[a-zA-Z0-9._-]+@[a-
z]+\\.+[a-z]+".toRegex())){
80
binding.email.error = null
if (!passward.isEmpty()){
binding.password.error = null
createAccount(email,passward)
}
else{
binding.password.error ="Please Fill
Passward"
}
}
else{
binding.email.error ="Please Fill Valid Email"
}
}
else{
binding.email.error ="Please Fill Email"
}
}
else{
binding.phone.error = "Please Fill Valid Phone
Number"
}
}
else{
binding.phone.error ="Please Fill Phone Number"
81
}
}
else{
binding.username.error ="Please Fill Username"
}
}
}
82
if (userId!=null){
val userRef =
database.getReference("UsersProfile").child(userId)
val userData = UserModel(key = userId, name =
username, phone = phone, email = email, passward = passward,
readid = readId)
userRef.setValue(userData).addOnSuccessListener {
Toast.makeText(this, "Account Created Successful",
Toast.LENGTH_SHORT).show()
val gotoMain = Intent(this,MainActivity::class.java)
startActivity(gotoMain)
}
}
}
fun generatePassword(length:Int):String{
val charSet = ('a'..'z')+('A'..'Z')+(0..9)+
listOf('!','@','#','$','%','^','&','*','?','+','-','/')
val secureRandom = SecureRandom()
val password = StringBuilder()
repeat(length,{
val charIndex = secureRandom.nextInt(charSet.size)
password.append(charSet[charIndex])
})
83
return password.toString()
}
}
4. Home Screen:
package com.example.healthdetectiveapp.fragment
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.denzcoskun.imageslider.constants.AnimationTypes
import com.denzcoskun.imageslider.constants.ScaleTypes
import com.denzcoskun.imageslider.interfaces.ItemClickListener
import com.denzcoskun.imageslider.models.SlideModel
import com.example.healthdetectiveapp.DieasesDiagnoseByImage
import com.example.healthdetectiveapp.Dieases_Detection_Activity
import com.example.healthdetectiveapp.R
import
com.example.healthdetectiveapp.databinding.FragmentHomeBindin
g
84
class HomeFragment : Fragment() {
private lateinit var binding: FragmentHomeBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
arguments?.let {
}
}
startActivity(Intent(requireContext(),Dieases_Detection_Activity::cl
ass.java))
}
binding.brainTumarCard.setOnClickListener {
val brainIntent =
Intent(requireContext(),DieasesDiagnoseByImage::class.java)
brainIntent.putExtra("cardKey",1)
brainIntent.putExtra("disease","Brain Tumar")
85
startActivity(brainIntent)
}
binding.AlzimerCard.setOnClickListener {
val alzimerIntent =
Intent(requireContext(),DieasesDiagnoseByImage::class.java)
alzimerIntent.putExtra("cardKey",2)
alzimerIntent.putExtra("disease","Alzimer")
startActivity(alzimerIntent)
}
binding.LungsCancerCard.setOnClickListener {
val lungsCancerIntent =
Intent(requireContext(),DieasesDiagnoseByImage::class.java)
lungsCancerIntent.putExtra("cardKey",3)
lungsCancerIntent.putExtra("disease","Lungs Cancer")
startActivity(lungsCancerIntent)
}
return binding.root
}
imageList.add(SlideModel(R.drawable.slider1,
ScaleTypes.FIT))
imageList.add(SlideModel(R.drawable.slider2,
86
ScaleTypes.FIT))
imageList.add(SlideModel(R.drawable.slider3,
ScaleTypes.FIT))
imageList.add(SlideModel(R.drawable.slider4,
ScaleTypes.FIT))
imageList.add(SlideModel(R.drawable.slider5,
ScaleTypes.FIT))
imageList.add(SlideModel(R.drawable.slider6,
ScaleTypes.FIT))
imageSlider.setSlideAnimation(AnimationTypes.DEPTH_SLIDE)
}
}
5. Dieases_Detection_Activity:
package com.example.healthdetectiveapp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.ArrayAdapter
87
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import
com.example.healthdetectiveapp.adapter.DieasesAccuracyAdapter
import com.example.healthdetectiveapp.adapter.SymptomsAdapter
import
com.example.healthdetectiveapp.databinding.ActivityDieasesDetecti
onBinding
import com.example.healthdetectiveapp.ml.Dieasesinfloat
import org.tensorflow.lite.DataType
import org.tensorflow.lite.support.tensorbuffer.TensorBuffer
import java.nio.ByteBuffer
import java.nio.ByteOrder
binding.btnResult.isEnabled = false
// Fetching dieases from dieaseslabels.txt
val fileName = "dieaseslabels.txt"
val inputString =
application.assets.open(fileName).bufferedReader().use {
it.readText() }
var finalDieases = inputString.split("\n")
// Set AutocompleteTextView
90
val autocompleteAdapter = ArrayAdapter(this,
com.google.android.material.R.layout.support_simple_spinner_drop
down_item,symList)
val autoComplete = binding.autoComplete
autoComplete.setAdapter(autocompleteAdapter)
setAdapterForDieasesAccuracy(sortedKeys,sortedValues)
usersymList.clear()
// Releases model resources if no longer used.
model.close()
for (zero in 0..symListInFloat.size-1){
symListInFloat[zero] = 0
}
}
else{
Toast.makeText(this, "Please Select Symptoms",
Toast.LENGTH_SHORT).show()
}
}
}
93
private fun
setAdapterForDieasesAccuracy(sortedKey:List<Float>,sortedValue:
MutableList<String>) {
binding.rvDieasesAccuracy.layoutManager =
LinearLayoutManager(this)
val dieasesAccuracyAdapter =
DieasesAccuracyAdapter(this,sortedKey,sortedValue)
binding.rvDieasesAccuracy.adapter = dieasesAccuracyAdapter
}
6. DieasesDiagnoseByImage:
package com.example.healthdetectiveapp
import android.app.Activity
import android.content.Intent
import android.graphics.Bitmap
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.MediaStore
import android.util.Log
import android.view.View
import android.widget.Button
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import
com.example.healthdetectiveapp.databinding.ActivityDieasesDiagno
seByImageBinding
import com.example.healthdetectiveapp.ml.BrainTumor
import org.tensorflow.lite.DataType
95
import org.tensorflow.lite.support.image.TensorImage
import org.tensorflow.lite.support.tensorbuffer.TensorBuffer
ActivityDieasesDiagnoseByImageBinding.inflate(layoutInflater)
}
lateinit var bitmap: Bitmap
lateinit var status:String
var classifier: Classifier?=null
private val CAMERA_REQUEST_CODE = 200
private var index:Int?=null
private lateinit var dieases:String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.btnShowResult.setOnClickListener {
binding.resultContainer.visibility = View.VISIBLE
when(cardvalue){
1->{
status= classifier!!.brainTumar()
binding.Result.text = status
index = 41
}
2->{
status= classifier!!.alzimerDetection()
binding.Result.text = status
index = 42
}
3->{
status= classifier!!.lungsCancerDetection()
binding.Result.text = status
index = 43
}
}
}
// Set Dieases Url Information
binding.dieasesInfoImage.setOnClickListener {
val braintumarInfoIntent =
Intent(this,DieasesInformation_Activity::class.java)
97
braintumarInfoIntent.putExtra("requestCode","dieasesInformation")
braintumarInfoIntent.putExtra("urlIndex",index)
startActivity(braintumarInfoIntent)
}
binding.doctorAppointmentImage.setOnClickListener {
val appointmentIntent = Intent(this, MainActivity::class.java)
appointmentIntent.putExtra("OpenScreen","doctorAppointment")
appointmentIntent.putExtra("dieases",dieases)
startActivity(appointmentIntent)
}
// set sample image
binding.btnSampleImage.setOnClickListener {
when(cardvalue){
1->{
binding.dieasesImage.setImageResource(R.drawable.brain_tumar)
}
2->{
binding.dieasesImage.setImageResource(R.drawable.alzimer_sampl
e_image)
}
3->{
binding.dieasesImage.setImageResource(R.drawable.lungs_cancer_s
98
ample)
}
}
}
99
startActivityForResult(cameraIntent,CAMERA_REQUEST_CODE)
}
7. DieasesInformation_Activity:
package com.example.healthdetectiveapp
import android.app.ProgressDialog
import android.graphics.Bitmap
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
100
import android.util.Log
import android.view.View
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Toast
import com.bumptech.glide.Glide
import
com.example.healthdetectiveapp.databinding.ActivityDieasesInform
ationBinding
import java.net.URLEncoder
when(request){
"dieasesInformation" ->{
val index = intent.getIntExtra("urlIndex",5)
var url = dieasesurl[index]
webview.loadUrl("$url")
}
"bmiResultInformation" ->{
var bmiResultUrl = intent.getStringExtra("bmiResultUrl")
webview.loadUrl("$bmiResultUrl")
}
"opendocument" ->{
val fileurl = intent.getStringExtra("fileurl")
val filename = intent.getStringExtra("filename")
val filemime = intent.getStringExtra("mimetype")
if (filemime!!.startsWith("image")){
binding.doctorSearch.visibility = View.GONE
binding.txtSearch.visibility = View.GONE
webview.visibility = View.GONE
binding.webimg.visibility = View.VISIBLE
Glide.with(this).load(Uri.parse(fileurl)).into(binding.webimg)
}
else{
binding.txtSearch.setText("Opening Document...")
binding.webimg.visibility = View.GONE
102
webview.visibility = View.VISIBLE
val url = URLEncoder.encode(fileurl,"UTF-8")
webview.loadUrl("http://docs.google.com/gview?embedded=true&u
rl=" + url)
}
}
}
webview.webViewClient = object : WebViewClient(){
override fun onPageStarted(view: WebView?, url: String?,
favicon: Bitmap?) {
binding.doctorSearch.visibility = View.VISIBLE
103
override fun onBackPressed() {
if (webview.canGoBack()){
webview.goBack()
}
else{
super.onBackPressed()
}
}
}
8. DoctorAppointmentFragment:
package com.example.healthdetectiveapp.fragment
import android.app.Dialog
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView
import android.widget.Button
import android.widget.Toast
104
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.healthdetectiveapp.R
import com.example.healthdetectiveapp.adapter.DoctorsListAdapter
import
com.example.healthdetectiveapp.databinding.FragmentDoctorAppoi
ntmentBinding
import com.example.healthdetectiveapp.model.doctors
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
}
105
}
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE)
dialog.setContentView(R.layout.filter_dialog)
setfilter = dialog.findViewById(R.id.btn_setfilter)
dieases = dialog.findViewById(R.id.autoComplete_filter)
}
return binding.root
}
fun filterSpecialist(specialist:String):List<doctors> {
val list = doctorsArrayList.filter {
specialist.trim().contains(it.specilist.toString().trim())
}
return list
}
})
}
9. Appointment_Status_Fragment:
package com.example.healthdetectiveapp.fragment
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.healthdetectiveapp.R
import
com.example.healthdetectiveapp.adapter.AppointmentStatusAdapter
import
com.example.healthdetectiveapp.databinding.FragmentAppointment
StatusBinding
111
import com.example.healthdetectiveapp.model.PatientModel
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
})
}
10. BMICalculatorFragment:
package com.example.healthdetectiveapp.fragment
import android.content.Intent
import android.os.Bundle
114
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.example.healthdetectiveapp.BMI_Result_Activity
import
com.example.healthdetectiveapp.DieasesInformation_Activity
import
com.example.healthdetectiveapp.databinding.FragmentBmiCalculat
orBinding
binding.inchpicker.minValue = 0
binding.inchpicker.maxValue = 12
binding.weightpicker2.minValue = 15
binding.weightpicker2.maxValue = 250
binding.calculatebmi.setOnClickListener {
var ft = binding.feetpicker.value.toDouble()
var inc = binding.inchpicker.value.toDouble()
var totalinc = ft*12 + inc
var totalcm = totalinc*2.54
var totalm = totalcm/100
var weight = binding.weightpicker2.value.toDouble()
var bmi = weight/(totalm*totalm)
totalcm = String.format("%.1f",totalcm).toDouble()
bmi = String.format("%.1f",bmi).toDouble()
val bmiResultIntent =
Intent(requireContext(),BMI_Result_Activity::class.java)
bmiResultIntent.putExtra("bmiresult",bmi)
bmiResultIntent.putExtra("height",totalcm)
bmiResultIntent.putExtra("weight",weight)
startActivity(bmiResultIntent)
}
116
binding.whatbmi.setOnClickListener {
val whatbmiIntent = Intent(requireContext(),
DieasesInformation_Activity::class.java)
whatbmiIntent.putExtra("urlIndex",47)
whatbmiIntent.putExtra("requestCode","bmiResultInformation")
startActivity(whatbmiIntent)
}
return binding.root
}
}
11. UploadDataFragment:
package com.example.healthdetectiveapp.fragment
import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
117
import android.view.ViewGroup
import android.view.Window
import android.widget.Button
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.healthdetectiveapp.R
import
com.example.healthdetectiveapp.adapter.UploadFilesAdapter
import
com.example.healthdetectiveapp.databinding.FragmentUploadD
ataBinding
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.storage.FirebaseStorage
import android.content.ContentResolver
import android.provider.MediaStore
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.Toast
import
com.example.healthdetectiveapp.adapter.PatientsRecordsAdapt
er
import
com.example.healthdetectiveapp.model.FileInformationModel
import
118
com.example.healthdetectiveapp.model.PatientsRecordsModel
import
com.google.android.material.bottomsheet.BottomSheetDialogFr
agment
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.ValueEventListener
119
}
}
binding.rvPatientsrecord.shrinkFabOnScroll(binding.btnFloat)
patientsRecordBS.show(parentFragmentManager,"RecordDialo
g")
}
120
return binding.root
}
fetchDataBottomSheetFragment.setRecyclerView(binding.rvPat
ientsrecord)
fetchDataBottomSheetFragment.show(parentFragmentManager,
"fetchdata")
}
}
return super.onOptionsItemSelected(item)
}
121
private fun fetchPatientsRecords() {
val userid = auth.currentUser!!.uid
val patientsRecordsRef =
database.reference.child("PatientsRecords")
val userIdRef = patientsRecordsRef.child(userid)
userIdRef.addValueEventListener(object :
ValueEventListener{
override fun onDataChange(snapshot: DataSnapshot) {
val
dateFilesList:MutableList<PatientsRecordsModel> =
mutableListOf()
for (dateSnapshot in snapshot.children){
Log.d("exam_dateSnapshot","${dateSnapshot}")
val date = dateSnapshot.key.toString()
Log.d("exam_date","${date}")
val filesList:MutableList<FileInformationModel> =
mutableListOf()
for (fileSnapshot in dateSnapshot.children){
Log.d("exam_fileSnapshot","${fileSnapshot}")
val eachFile =
fileSnapshot.getValue(FileInformationModel::class.java)
Log.d("exam_eachFile","${eachFile}")
eachFile?.let { filesList.add(it) }
}
122
val dateFiles =
PatientsRecordsModel(date,filesList)
dateFilesList.add(dateFiles)
}
setAdapter(dateFilesList)
}
override fun onCancelled(error: DatabaseError) {
TODO("Not yet implemented")
}
})
}
123
}
}
12. ProfileFragment:
package com.example.healthdetectiveapp.fragment
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.net.Uri
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat.getSystemService
import com.bumptech.glide.Glide
import com.example.healthdetectiveapp.R
import
com.example.healthdetectiveapp.databinding.FragmentProfileBindin
g
import com.example.healthdetectiveapp.model.UserModel
import com.google.firebase.auth.FirebaseAuth
124
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.DatabaseReference
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
import com.google.firebase.storage.FirebaseStorage
import java.lang.StringBuilder
import java.security.SecureRandom
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
125
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
binding =
FragmentProfileBinding.inflate(inflater,container,false)
var isVisible=false
val autocompleteAdapter = ArrayAdapter(requireContext(),
com.google.android.material.R.layout.support_simple_spinner_drop
down_item, genderList)
val autoComplete = binding.autocompleteProfile
autoComplete.setAdapter(autocompleteAdapter)
updateUserData(name,age,gender,address,phone,email,passward,rea
did)
}
}
return binding.root
}
128
private fun updateUserData(
name: String,
age: String,
gender: String,
address: String,
phone: String,
email: String,
passward: String,
readid:String
){
// Performing Validation
if (!name.isEmpty()){
binding.username.error = null
if (!phone.isEmpty()){
binding.phoneno.error = null
if (phone.matches("[1-9][0-9]{9}".toRegex())){
binding.phoneno.error = null
if (!email.isEmpty()){
binding.email.error = null
if (email.matches("^[a-zA-Z0-9._-]+@[a-z]+\\.+[a-
z]+".toRegex())){
binding.email.error = null
if (!passward.isEmpty()){
binding.passward.error = null
uploadData(name, age, gender, address, phone,
email, passward,readid)
129
}
else{
binding.passward.error ="Please Fill Passward"
}
}
else{
binding.email.error = "Please Fill Valid Email"
}
}
else{
binding.email.error ="Please Fill Email"
}
}
else{
binding.phoneno.error = "Please Fill Valid Phone
Number"
}
}
else{
binding.phoneno.error ="Please Fill Phone Number"
}
}
else{
binding.username.error ="Please Fill Username"
}
}
130
private fun uploadData(
name: String,
age: String,
gender: String,
address: String,
phone: String,
email: String,
passward: String,
readid: String
){
// Update Data
binding.progressBar.visibility = View.VISIBLE
val userId = auth.currentUser?.uid
userRef =
database.getReference("UsersProfile").child(userId!!)
val storageRef = FirebaseStorage.getInstance().reference
val userImageRef =
storageRef.child("users_images/${userId}.jpg")
if (userimage!=null){
if (gellaryImage){
val uploadImage = userImageRef.putFile(userimage!!)
uploadImage.addOnSuccessListener {
userImageRef.downloadUrl.addOnSuccessListener {
downloadUrl->
// User model
val userData1 = UserModel(userId, name, age,
131
gender, address, phone, email,
passward,readid,downloadUrl.toString())
userRef.setValue(userData1).addOnSuccessListener {
binding.progressBar.visibility = View.GONE
Status("Profile Successfully Update")
}
.addOnFailureListener {
binding.progressBar.visibility = View.GONE
Toast.makeText(requireContext(), "Profile Not
Updated", Toast.LENGTH_SHORT).show()
}
}
}
}
else{
// User model
val userData1 = UserModel(userId, name, age, gender,
address, phone, email, passward,readid,userimage.toString())
userRef.setValue(userData1).addOnSuccessListener {
binding.progressBar.visibility = View.GONE
Status("Profile Successfully Update")
}
.addOnFailureListener {
binding.progressBar.visibility = View.GONE
Toast.makeText(requireContext(), "Profile Not
Updated", Toast.LENGTH_SHORT).show()
}
132
}
}
else{
// User model
val userData2 = UserModel(userId, name, age, gender,
address, phone, email, passward,readid,userimage = null)
userRef.setValue(userData2).addOnSuccessListener {
binding.progressBar.visibility = View.GONE
Status("Profile Successfully Update")
}
.addOnFailureListener {
binding.progressBar.visibility = View.GONE
Toast.makeText(requireContext(), "Profile Not
Updated", Toast.LENGTH_SHORT).show()
}
}
}
Glide.with(binding.userimage.context).load(Uri.parse(user.userimag
e)).into(binding.userimage)
}
else{
binding.userimage.setImageResource(R.drawable.account)
}
if (user.age!=null){
binding.age.setText(user.age)
}
if (user.gender!=null){
binding.autocompleteProfile.setText(user.gender)
}
if (user.address!=null){
binding.address.setText(user.address)
}
binding.username.setText(user.name)
binding.phoneno.setText(user.phone)
binding.email.setText(user.email)
134
binding.passward.setText(user.passward)
binding.readid.setText(user.readid)
}
}
}
})
}
}
// Pick Image From Gallery
val pickimage =
registerForActivityResult(ActivityResultContracts.GetContent()){
uri->
if (uri!=null){
binding.userimage.setImageURI(uri)
userimage = uri
gellaryImage = true
}
}
fun Status(s1:String){
Toast.makeText(requireContext(), "${s1}",
Toast.LENGTH_SHORT).show()
}
135
fun generatePassword(length:Int):String{
val charSet = ('a'..'z')+('A'..'Z')+(0..9)+
listOf('!','@','#','$','%','^','&','*','?','+','-','/')
val secureRandom = SecureRandom()
val password = StringBuilder()
repeat(length,{
val charIndex = secureRandom.nextInt(charSet.size)
password.append(charSet[charIndex])
})
return password.toString()
}
fun copyToClipboard(){
val copy =
activity?.getSystemService(Context.CLIPBOARD_SERVICE) as
ClipboardManager
val clip = ClipData.newPlainText("readid",binding.readid.text)
copy.setPrimaryClip(clip)
}
}
136
Chapter 9
TESTING
Testing is a crucial phase in software development that involves evaluating the
functionality, performance, and usability of an application to ensure it meets the
specified requirements and performs as expected. In the context of the Health
Detective App, testing would have involved several key aspects:
137
Function Input Expected Error
Name Output
Input 9897778988 Expected
phonenu output _
mber isseen
138
Health Detective App would have involved checking the layout, navigation, and
user interactions in the app.
4. Performance Testing: Performance testing assesses how well the app performs
under various conditions, such as high user loads or limited network connectivity.
For the Health Detective App, performance testing would have involved measuring
the app's responsiveness, load times, and resource usage to ensure it meets
acceptable performance standards.
5. User Acceptance Testing (UAT): UAT involves testing the app with real users to
validate that it meets their requirements and expectations. This type of testing helps
ensure that the app is user-friendly and meets the needs of its target audience. UAT
for the Health Detective App would have involved gathering feedback from users
on the app's features, usability, and overall experience.
By conducting thorough testing, the development team can identify and fix issues
early in the development process, ensuring that the Health Detective App meets the
highest quality standards and provides a seamless user experience.
139
Chapter 10
Maintenance
1. Introduction
The maintenance phase of the Health Detective App involves ongoing activities to
ensure the app remains functional, up-to-date, and meets user needs. This phase
includes bug fixes, performance optimizations, feature enhancements, and updates
to comply with new Android versions and security standards.
2. Bug Fixing
3. Performance Optimization
4. Feature Enhancements
Based on user feedback and market trends, new features and functionalities may be
added to the app to improve user experience and provide additional value. Feature
140
enhancements should be carefully planned and tested to ensure they integrate
seamlessly with existing functionalities.
5. Compatibility Updates
As new versions of Android are released, the app may require updates to maintain
compatibility and take advantage of new features and improvements. Compatibility
updates may involve updating libraries, APIs, and SDKs used in the app, as well as
adapting the app's UI/UX to meet new design guidelines.
6. Security Updates
Regular security updates are critical to protect user data and ensure the app is not
vulnerable to security threats. This includes updating libraries and dependencies to
address known vulnerabilities, implementing secure coding practices, and ensuring
data encryption and secure communication protocols are in place.
Providing user support and collecting feedback are essential for maintaining a
positive user experience. The development team should respond to user queries
and feedback promptly and use this information to prioritize future updates and
improvements.
8. Conclusion
The maintenance phase of the Health Detective App is crucial for ensuring the app
remains functional, secure, and competitive in the market. By regularly updating
and enhancing the app, the development team can continue to meet user needs and
provide a valuable tool for health management and healthcare access.
141
Chapter 11
System Security Measures
1. Data Encryption: Encrypt sensitive data such as patient information, user
credentials, and AI model data using strong encryption algorithms. Use HTTPS to
encrypt data transmitted between the app and the server to protect against
eavesdropping.
2. Secure Authentication: Implement secure authentication mechanisms, such as
OAuth or Firebase Authentication, to verify the identity of users accessing the app.
Use strong password policies and consider implementing multi-factor
authentication for added security.
3. Secure Data Storage: Use secure storage mechanisms, such as Firebase Realtime
Database or Firestore, which provide built-in security features like data validation
and access control. Avoid storing sensitive information in local storage or shared
preferences.
4. Secure Communication: Use secure communication protocols, such as TLS/SSL,
to encrypt data transmitted between the app and external servers. Implement
certificate pinning to protect against man-in-the-middle attacks.
5. Secure AI Model Deployment: Ensure that AI models used in the app are secure
and do not expose sensitive information. Use secure deployment practices and
consider obfuscating the model to protect it from reverse engineering.
6. User Permissions: Implement fine-grained permissions to control access to
sensitive features and data within the app. Only request permissions that are
necessary for the app's functionality and provide clear explanations to users about
why each permission is needed.
142
7. Secure Code Practices: Follow secure coding practices to reduce vulnerabilities
in the app's code. This includes input validation, avoiding hardcoded credentials,
and using secure libraries and frameworks.
8. Regular Security Audits: Conduct regular security audits and vulnerability
assessments to identify and mitigate potential security risks. This should include
testing the app for common security vulnerabilities such as SQL injection, cross-
site scripting (XSS), and insecure data storage.
9. User Education: Educate users about best practices for using the app securely,
such as avoiding sharing sensitive information and keeping their devices and apps
updated with the latest security patches.
10.Data Minimization: Minimize the collection and storage of sensitive data to
reduce the risk of data breaches. Only collect data that is necessary for the app's
functionality and ensure that it is stored securely.
Implementing these security measures will help protect the Health Detective App
from security threats and ensure the privacy and security of user data. Regularly
updating the app and its dependencies, monitoring for security vulnerabilities, and
responding promptly to security incidents are also essential for maintaining a
secure app environment.
143
Chapter 12
FUTURE SCOPE OF THE PROJECT
1. Enhanced Disease Detection: Improve the accuracy and capabilities of disease
detection by integrating more advanced AI models and machine learning
algorithms. Explore the use of additional medical imaging techniques and data
sources to enhance disease prediction.
2. Personalized Health Recommendations: Implement personalized health
recommendations based on user data and AI analysis. Provide users with
personalized advice on diet, exercise, and lifestyle changes to improve their overall
health.
3. Telemedicine Integration: Integrate telemedicine features to allow users to
consult with healthcare providers remotely. Provide video consultations, online
prescriptions, and virtual follow-ups to improve access to healthcare services.
4. Health Monitoring Devices Integration: Integrate with health monitoring devices
such as fitness trackers, smart watches, and medical sensors to provide real-time
health data. Use this data to enhance disease prediction and provide personalized
health recommendations.
5. Community Health Tracking: Implement features to allow users to track and
contribute to community health data. Provide insights and trends based on
aggregated data to help communities identify and address health issues.
6. Health Insurance Integration: Integrate with health insurance providers to
provide users with information on insurance coverage, claims, and benefits.
Provide tools to help users understand their insurance policies and make informed
decisions about their healthcare.
144
7. Advanced Data Analytics: Use advanced data analytics techniques to analyze
user data and provide actionable insights. Use machine learning and AI algorithms
to identify patterns and trends in health data and provide personalized
recommendations.
8. Enhanced User Experience: Continuously improve the app's user interface and
user experience based on user feedback and emerging design trends. Provide a
seamless and intuitive user experience across all platforms.
9. Global Expansion: Expand the app's reach to new markets and regions to provide
access to healthcare services to a wider audience. Localize the app to different
languages and cultures to make it more accessible and inclusive.
10.Research Collaboration: Collaborate with healthcare researchers and institutions
to contribute to ongoing research in the field of healthcare. Use the app's data and
insights to support research efforts and improve healthcare outcomes.
Implementing these future scope enhancements will help the Health Detective App
evolve into a comprehensive health management platform that provides
personalized, accessible, and proactive healthcare services to users.
145