0% found this document useful (0 votes)
187 views43 pages

In House Project Report

This document is a project report submitted by Aditya Oberai to Amity University for the development of a COVID-19 blood cataloguing mobile application. The application was created using Xamarin.Forms to allow cataloguing of patient contact details and test results across Android, iOS, and UWP platforms. It includes declarations by the student and faculty guide, an acknowledgements section, table of contents, and sections on introduction, materials and methods, results, and conclusions regarding the project.

Uploaded by

Aditya Oberai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
187 views43 pages

In House Project Report

This document is a project report submitted by Aditya Oberai to Amity University for the development of a COVID-19 blood cataloguing mobile application. The application was created using Xamarin.Forms to allow cataloguing of patient contact details and test results across Android, iOS, and UWP platforms. It includes declarations by the student and faculty guide, an acknowledgements section, table of contents, and sections on introduction, materials and methods, results, and conclusions regarding the project.

Uploaded by

Aditya Oberai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

In House Practical Training

on
COVID-19 Blood Cataloguing Application

Submitted to
Amity University Uttar Pradesh

In partial fulfilment of the requirements for the award of the degree


of
Bachelor of Technology
in
Computer Science and Engineering
by
Aditya Oberai
A2305218017
Under the guidance of

Dr Abhishek Singhal

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


AMITY SCHOOL OF ENGINEERING AND TECHNOLOGY
AMITY UNIVERSITY UTTAR PRADESH
Declaration by the student

I, Aditya Oberai, student of B.Tech (CSE) hereby declare that the project titled “COVID-19
Blood Cataloguing Application” which is submitted by me to Department of Computer
Science and Engineering, Amity School of Engineering and Technology, Noida, Amity
University Uttar Pradesh, in partial fulfilment of requirement for the award of the degree of
Bachelor of Technology (CSE), has not been previously formed the basis for the award of any
degree, diploma or other similar title or recognition.

The Author attests that permission has been obtained for the use of any copy righted material
appearing in the report other than brief excerpts requiring only proper acknowledgement in
scholarly writing and all such use is acknowledged.

Signature

Noida
Date:

i
CERTIFICATE

On the basis of report submitted by Aditya Oberai, student of B.Tech (CSE), I hereby
certify that the report “COVID-19 Blood Cataloguing Application” which is submitted to
Department of Computer Science and Engineering, Amity School of Engineering and
Technology, Amity University Uttar Pradesh in partial fulfilment of requirement for the award
of the degree of Bachelor of Technology (CSE) is an original contribution with existing
knowledge and faithful record of work carried out by him/her under my guidance and
supervision.

To the best of my knowledge this work has not been submitted in part or full for any Degree
or Diploma to this University or elsewhere.

Noida

Date:

Dr Abhishek Singhal
Dy. HoD (CSE)
Department of Computer Science and Engineering
(Faculty Guide)

ii
ACKNOWLEDGEMENT

The satisfaction that accompanies that the successful completion of any task would be
incomplete without the mention of people whose ceaseless cooperation made it possible, whose
constant guidance and encouragement crown all efforts with success. I would like to thank Prof
(Dr) Abhay Bansal, Head of Department-CSE, and Amity University for giving me the
opportunity to undertake this project. I would like to thank my faculty guide Dr Abhishek
Singhal who is the biggest driving force behind my successful completion of the project. He
has been always there to solve any query of mine and also guide me in the right direction
regarding the project. Without her help and inspiration, I would not have been able to complete
the project. Also I would like to thank my batchmates who guided me, helped me and gave
ideas and motivation at each step.

Aditya Oberai

iii
Table of Contents

S. no. Title Page No.


Declaration by the Student i
Certificate ii
Acknowledgement iii
Abstract 2
1 Introduction 3
2 Materials and Methods 5
3 Results 17
4 Conclusion 19
5 Implications For Future Work 19
6 References 20
7 Appendix 1: Code-Base 21

1
Abstract
We have all noticed that due to the rising trend of companies developing their mobile
applications, there has been an increase in the demand of mobile application developers
in the last few years. However, looking at the advancements in the two major mobile
operating systems Android and iOS as well as an increase in native mobile application
developers choosing to specialize in application development for one of the two
languages, companies have now started looking at alternatives which allow them to
rapidly develop applications for both the mobile operating systems. This has led to the
rise of the adoption of cross-platform frameworks such as Xamarin.Forms, Flutter and
React Native. Due to my recent experience with C# and .NET as well as my previous
experience developing Universal Windows Platform applications, I have chosen to work
with Xamarin.Forms for my project.

Looking at the current scenario with COVID-19 and the increasing infected numbers on
a daily basis, it has become more and more difficult for healthcare institutions to keep
track of patients who have been infected, especially in smaller towns and villages which
may not have the best of infrastructure and connectivity with other towns and
metropolitan cities. In order to help provide a possible solution to this problem, I have
created a cross-platform application using Xamarin.Forms to help catalogue the contact
details of patients who are visiting the healthcare institutions and getting themselves
tested. This application will definitely benefit towns and villages where healthcare
institutions such as clinics and blood banks do not have access to desktop or laptop
computers but do have accessibility to smartphones.

I have chosen to work on this project because I believe that such a project can help
impact those busy running our healthcare industry and thus, the citizens of our nation.
For this project, I am using tools such as Visual Studio Community IDE, .NET
Framework and SQLite which are available for free to the public, in this way making it
a no-cost viable solution to a possible real world problem that may come up in the times
to come.

2
1. Introduction
In the recent years, the trend for any company or organization to have its own mobile
application has grown at a huge rate. However, due to major advancements coming in
the two most commonly available mobile operating systems Android and iOS with both
having very different codebases, most mobile application developers began preferring to
specialize in one of the two platforms. This has led to a rise in cross-platform
application development frameworks such as Xamarin.Forms, Flutter, React Native, etc.

Fig 1.0.1: Cross Platform Application Development Technologies

Due to my newly found interest in mobile application development and experience in


making Windows applications as well as the current COVID-19 scenario, I decided to
work on a COVID-19 Patient Status Cataloguer Application.

1.1 Relevance

We have all been under lockdown for over the last two months due to the current
Coronavirus pandemic. With the number of infected people across the country
increasing every day, it has become extremely difficult for healthcare institutions such
as hospitals, clinics and blood banks, especially in areas that do not have quality
infrastructure and connectivity with other towns and metropolitan cities. Recognizing
this possibly emerging problem, I have created an application to help catalogue the
contact details of patients who are visiting the healthcare institutions and getting

3
themselves tested. The cataloguing application essentially accepts the name, email
address, phone number and COVID-19 status of the patient who has just gotten their
blood tested and stores the information in a local database for higher security. The
platform that has been used to create the application is Xamarin.Forms as it allows me
to develop the application for Android, iOS and UWP (Universal Windows Platform)
simultaneously. The application also features the functionality to email a patient their
result so that they can check their information and have it rectified as well as the
functionality to check the database for any patient’s contact details whenever necessary
to do so. I have created the database using SQLite as it can directly be integrated with
any Xamarin.Forms application. This application will definitely benefit towns and
villages where healthcare institutions such as clinics and blood banks do not have access
to desktop or laptop computers but do have accessibility to smartphones.

1.2 Problem Definition

The COVID-19 Patient Cataloguer application will feature two major functionalities:

 Add Patient Details to Database


 Check if Patient Details are Present

This application is designed to be used by hospital staff only so the application’s access
shall be restricted from the general patients. The staff will be able to see various input
fields such as patient name, phone number, email address and COVID-19 status (yes or
no) which they can add to the database. In case they want to update the information of
any patient, they can do so using the same input fields as well.

If the staff wants to check for the presence of any patient’s personal details, they can do
so by using the phone number of the patient. They will input the phone number based
on which they can find all the other details present in the database. They can also email
the details of the patient to the provided email address if found in the database.

1.3 Successful Completion of the Project Objective


I believe I successfully fulfilled the requirements of the application I wanted to develop
as mentioned above. I do have a few other improvements in mind that I shall discuss
later in my report. I will now discuss the application development process that I
followed.
4
2. Materials and Methods

2.1 Technologies Used

Before we proceed to discuss the design of the application, there are certain terms and
technologies that I would like to mention briefly about as they will benefit the
understanding of the reader.

 Xamarin.Forms

Fig 2.1.1: Traditional Xamarin vs Xamarin.Forms graphic

Xamarin.Forms is an open-source .NET based UI Framework that allows


developers to build applications for Android, iOS and Windows (via the
Universal Windows Platform). The user interfaces in Xamarin.Forms
applications are created using the Extensible Application Markup Language
(XAML). The code behind the XAML-based UI is developed using the
programming language C#. These interfaces are rendered as performant native
controls on each platform. Xamarin.Forms primarily benefits those developers
who:
o Want to develop applications across various platforms (Android, iOS and
Windows) and keep a consistent UI across all the platforms

o Share the same back-end code and have the ability to test the application
while maintaining the same business logic across multiple platforms

o Create applications on the Visual Studio Integrated Development


Environment distributed by Microsoft using the C# programming
language.

5
 Visual Studio

Fig 2.1.2: A view of Visual Studio IDE

Visual Studio is an Integrated Development Environment (IDE) distributed by


Microsoft which is used to edit, debug, build and publish applications for various
platforms such as .NET, Unity, Universal Windows Platform, Xamarin.Forms, Blazor,
etc. Over and above the standard editor and debugger that most common Integrated
Development Environments provide, Visual Studio includes the option to add compilers
for the applications, code completion tools such as IntelliSense, graphical designers
such as Blend for Visual Studio, direct integration with Azure as well as the ability to
add many other user-created features through the NuGet Package Manager within the
IDE to ease the software development process. In order to improve collaboration
between multiple developers, especially for those who are a part of the same
organization, Visual Studio also provides direct integration with GitHub to ease the
version control process as well as an exclusive feature known as Live Share that allows
a developer on one device to share their code with other developers while working on it
and allow them the edit it simultaneously. Visual Studio is available Windows, Mac OS
and Linux and recently an online version of the IDE called Visual Studio Codespaces
has been launched.

6
 SQLite

Fig 2.1.3: SQLite Logo Representation

SQLite is a publicly available software library that implements a self-contained,


serverless, zero-configuration, transactional SQL database engine. SQLite engine is not
a standalone process like other databases, meaning you can link it statically or
dynamically as per your requirement with your application. SQLite accesses its storage
files directly.

SQLite with Xamarin.Forms makes using local databases extremely easy to use as the
SQLite database engine allows the Xamarin.Forms applications to save data objects in
the shared code. All that the developer needs to do to utilize this functionality is search
“sqlite-net-pcl” in the NuGet Package Manager and install the latest stable release of the
shared code project created by Frank A. Krueger.

7
2.2 Programming Languages Used

The following two programming languages were a crucial part of developing this
Xamarin.Forms application

 C#

Fig 2.2.1: C# Logo Representation


C# is highly popular programming language that is maintained by Microsoft and used
for the development of applications that use the .NET Framework. It first appeared 20
years ago in 2000 by Anders Hejlsberg, a Danish software engineer, who is also known
as the original author of Turbo Pascal. Some key features of the C# programming
language are:

o It is an object-oriented programming language


o It supports functional programming
o C# compiler can generate machine code like traditional compilers of
C++ or Fortran, making it highly portable in nature
o C# has the ability to utilise Language Integrated Query (LINQ) using the
.NET Framework

8
 XAML

Fig 2.2.2: A view of the XAML editor in Visual Studio IDE


The Extensible Application Markup Language, also known as XAML, is a declarative
markup language that is used to create user interfaces for any application that is built
using the .NET Framework. XAML allows the developers working on the application to
create visible user interface elements. One major advantage of XAML is that enables a
workflow where separate developers can work on the user interface and the back-end
code, potentially even of separate type of development tools and editors. In text format,
XAML files are essentially XML files that are saved using the “.xaml” extension.
XAML files are generally encoded in the UTF-8 format. XAML is directly integrated
into the Visual Studio IDE, which allows developers without much front-end
application development experience to develop basic user interfaces at ease. In fact,
Visual Studio even offers support for an in-built drag-and-drop builder for XAML to
help developers building Universal Windows Platform (UWP) and Windows
Presentation Foundation (WPF) applications. It is, however, yet to extend that support
to Xamarin.Forms application development.

9
2.3 Application Flow and Design

Coming over to the design of the application, the application’s user experience
flowchart is as follows:

Fig 2.3.1: Application Flowchart

10
This application has been developed keeping the hospital staff’s perspective in mind.
The application will not directly be used by the patients. On opening the application, the
user will see the following page:

Fig 2.3.2: Application UI as shown in the Google Pixel 2 emulator

The first functionalities available at the start of the program allow the user to input the
following personal details of the patient:

 Patient Name
 Patient Phone Number
 Patient Email Address
 Patient COVID-19 Status

Based on these details, the information will be either added to the database for the first
time or updated in case it is already present through the “Add” and “Update” buttons.

11
If the staff needs to then check if the patient details have been added to the database or
not, they can do so clicking on the “Check” button. In order to do so, they must input
the patient’s phone number first. If the patient’s phone number is not found in the
database, it shall tell us that the information was not found using the text boxes below
the button. If the details are found however, the patient’s name, email address and
COVID-19 status shall become visible in the same text boxes. Another feature that will
be unlocked if the details are found in the database is the “Email Details” button.
Clicking on this button will allow the user to automatically send the patient information
that has just been checked to the already inputted email address.

12
2.4 Application Architecture

The main functionalities offered in the application are as follows:

 Adding/Updating a Patient in the Database:

Fig 2.4.1: Add/Update Patient Functionality Flowchart

The Add and Update functions in the applications work in almost an identical
manner. They essentially take an input of all the personal details required in the
SQLite database from the patient. Based on whether the Add button is pressed or
the Update button, the event handler calls the AddNewPatient function or the
UpdateNewPatient function in the PatientRepository class in the COVID
(project name that was used) namespace. If all the input fields required contain
the necessary data, i.e. are not null, the information is then added to the database
using the Language Integrated Queries (LINQ) which are available to C#
developers. The table in the SQLite database is created and written into using
the Patient class in the COVID.Models namespace. If any of the input fields in
the function is empty however, then the function returns an error that prevents
any of the information from being entered into the database, resulting in the end-
user having to re-enter the entire data once again. This prevents incomplete data
from being inputted into the database used by the application

13
 Checking Patient Details in the Database:

Fig 2.4.2: Check Patient Functionality Flowchart

In order to check the presence of a patient’s details, we use the phone number of
the patient. The phone number of the patient acts a primary key for our database
that has been created with the help of the Patient class in the COVID.Models
namespace. The schema of the database shall be discussed subsequently. In
order to start this process, the end-user presses on the Check button. The event
handler takes the phone number entered the getStatus function in the
PatientRepository class in the COVID namespace. Using the phone number, the
function searches the table in the database for a match with the primary key in
each row. If the primary key is found, then the details of the patient are
displayed in the application. If the phone number is not found, the function
returns “N.A.” and as a result, the “Not Found” message is displayed in the
application.

14
In case the details are found, the function unlocks an optional functionality to
email the just-checked details to the email address provided by the patient. The
.NET Libraries feature an Email class which allows the application developers to
keep the optional functionality of allowing users to send an email from the
application using the Simple Mail Transfer Protocol (SMTP). It asks for the
SMTP server host name, port, enabling SSL protocol and the user credentials for
the email address. Based on these details, it allows the application to send an
email to any other user as long as their email address is available, in this case the
patient details from the database to the matching email address.

 Database Schema
The database only requires the usage of a single table called ‘patient’. The table
‘patient’ consists of four attributes within it.

Fig 2.4.3: Schema of Database

15
The four attributes are:
 Id: Stores the phone number of the patient and acts as the primary key for the
table
 Name: Stores the name of the patient
 Email: Stores the email address of the patient and is unique
 Status: Stores the COVID-19 status of the patient

The table mentioned above is created in the database using the Patient class in the
COVID.Models namespace. The path for the database in the file system of the OS
where the application will be run is set using the FileAccessHelper function in the
COVID Namespace.

 Reset the Application UI

The Reset button in the application is essentially used to clear all the input fields and
outputs, essentially return the application to state in which it was opened. The Reset
button, however, does not make any changes to the database in which the patient details
are stored.

16
3. Results

The program worked in an absolutely spending manner. I received all the results I
expected. I tried inputting my own details at first to test the program. On checking
for my details, I got the exact details as inputted. I also tried emailing my details, on
which I received the following email. I even tried checking for non-existent patient
details and got the right output as well. I have attached screenshots of these tests
below.

Fig 3.2: Checking if details were


Fig 3.1: Inputting data
stored in database

17
Fig 3.4: Email received while
testing functionality

Fig 3.3: Checking false data

18
4. Conclusion
I believe that I have met the original goal that I had in mind when I began working
on the project. My application has all the basic functionalities I had in mind such as
adding/updating patient details in the database, checking for presence of the details
as well as the ability to email the details of a patient to their already provided email
address. I am extremely happy with the Xamarin.Forms platform as it has allowed
me to develop an application which is light enough to run on lower-end smartphones
as well as develop the application for both the commonly available mobile operating
systems simultaneously. Not only that, but I have to add that Visual Studio is a
really amazing IDE to work with. It makes developing applications quite a
comfortable process for a budding developer like myself as well as provides the
necessary tools for experienced developers to build advanced applications and
collaborate with other members of their organization.

5. Implications for Future Work


I do believe that there is more scope for improvement in my application, however.
While working with this project, I received a few new ideas that I was not able to
execute due to my lack of previous experience. I will soon be working on a variant
of my application which uses Azure Cosmos DB for the database instead of SQLite
to keep a unified online database that can be used by multiple verified organizations.
In case of this shift, since shifting the data online would make it more liable to
cyberattacks, I shall also implement tougher encryption for the data stored to protect
the data.

19
6. References
1. Learning Resources on developing Xamarin.Forms applications:
https://docs.microsoft.com/en-us/learn/paths/build-mobile-apps-with-xamarin-
forms/
2. Visual Studio

https://docs.microsoft.com/en-us/visualstudio/ide/?view=vs-2019

3. SQLite
https://www.sqlite.org/docs.html
4. C#
https://docs.microsoft.com/en-us/dotnet/csharp/
5. XAML
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/xaml-basics/

20
7. Appendix I : Code-Base
(Also available at https://github.com/adityaoberai/InHousePracticalTraining)

 MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

xmlns:d="http://xamarin.com/schemas/2014/forms/design"

xmlns:mc="http://schemas.openxmlformats.org/markup-
compatibility/2006"

mc:Ignorable="d"

x:Class="COVID.MainPage">

<StackLayout>

<!-- Place new controls here -->

<Label Text="Welcome to COVID-19 Patient Cataloguer"

FontSize="Large"

HorizontalOptions="Center"

VerticalOptions="StartAndExpand" />

<Label Text="Add Patient Details to Database:"

VerticalOptions="CenterAndExpand"

HorizontalOptions="CenterAndExpand" />

<Entry x:Name="name" Placeholder="Patient Name" />

<Entry x:Name="pid1" Placeholder="Patient Phone Number" />

21
<Entry x:Name="email" Placeholder="Patient Email Address" />

<Entry x:Name="cstatus" Placeholder="COVID-19 Status (Yes or No)" />

<Grid>

<Grid.ColumnDefinitions>

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition Height="*" />

</Grid.RowDefinitions>

<Button x:Name="addPatientButton" Text="Add"

Clicked="addPatientButton_Clicked"

HorizontalOptions="Center"

VerticalOptions="CenterAndExpand"

Grid.Row="0"

Grid.Column="0"/>

<Button x:Name="updatePatientButton" Text="Update"

Clicked="updatePatientButton_Clicked"

HorizontalOptions="Center"

VerticalOptions="CenterAndExpand"

Grid.Row="0"

Grid.Column="1"/>

</Grid>

22
<Label Text="Check if Patient Details are present:"

VerticalOptions="CenterAndExpand"

HorizontalOptions="CenterAndExpand" />

<Entry x:Name="pid2" Placeholder="Patient Phone Number" />

<Grid>

<Grid.ColumnDefinitions>

<ColumnDefinition Width="*" />

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition Height="*" />

</Grid.RowDefinitions>

<Button x:Name="checkPatientButton" Text="Check"

Clicked="checkPatientButton_Clicked"

HorizontalOptions="CenterAndExpand "

VerticalOptions="CenterAndExpand"

Grid.Row="0"

Grid.Column="0"/>

<Button x:Name="emailPatientButton" Text="Email Details"

Clicked="emailPatientButton_Clicked"

HorizontalOptions="CenterAndExpand "

VerticalOptions="CenterAndExpand"

23
IsEnabled="False"

Grid.Row="0"

Grid.Column="1"/>

<Entry x:Name="idCheck" Text=""

Placeholder="Name of Patient"

VerticalOptions="CenterAndExpand"

HorizontalOptions="CenterAndExpand"

IsReadOnly="True"

Grid.Row="1"

Grid.Column="0"/>

<Entry x:Name="emailCheck" Text=""

Placeholder="Email address"

VerticalOptions="CenterAndExpand"

HorizontalOptions="CenterAndExpand"

IsReadOnly="True"

Grid.Row="1"

Grid.Column="1"/>

<Entry x:Name="covidStatus" Text=""

Placeholder="COVID-19 Status"

VerticalOptions="CenterAndExpand"

HorizontalOptions="CenterAndExpand"

24
IsReadOnly="True"

Grid.Row="2"

Grid.Column="0"/>

</Grid>

<Button x:Name="resetButton" Text="Reset"

Clicked="resetButton_Clicked"

HorizontalOptions="CenterAndExpand "

VerticalOptions="CenterAndExpand"/>

</StackLayout>

</ContentPage>

 MainPage.xaml.cs

using System;

using System.ComponentModel;

using System.Diagnostics;

using System.Net.Mail;

using Xamarin.Essentials;

using Xamarin.Forms;

namespace COVID

25
// Learn more about making custom code visible in the Xamarin.Forms previewer

// by visiting https://aka.ms/xamarinforms-previewer

[DesignTimeVisible(false)]

public partial class MainPage : ContentPage

public MainPage()

InitializeComponent();

private void checkPatientButton_Clicked(object sender, EventArgs e)

Debug.WriteLine(pid2.Text);

if (App.PatientRepo.getStatus(long.Parse(pid2.Text)).Equals("N.A."))

idCheck.Text = "No";

emailCheck.Text="N.A.";

else

idCheck.Text = App.PatientRepo.getName(long.Parse(pid2.Text));

emailCheck.Text = App.PatientRepo.getEmail(long.Parse(pid2.Text));

emailPatientButton.IsEnabled=true;

26
}

covidStatus.Text = App.PatientRepo.getStatus(long.Parse(pid2.Text));

private void addPatientButton_Clicked(object sender, EventArgs e)

Debug.WriteLine(name.Text + " " + pid1.Text + " " + cstatus.Text+"


"+email.Text);

App.PatientRepo.AddNewPatient(long.Parse(pid1.Text), name.Text,
cstatus.Text, email.Text);

name.Text = "";

pid1.Text = "";

cstatus.Text = "";

email.Text = "";

private void resetButton_Clicked(object sender, EventArgs e)

name.Text = "";

pid1.Text = "";

email.Text = "";

27
cstatus.Text = "";

pid2.Text = "";

idCheck.Text = "";

emailCheck.Text = "";

covidStatus.Text = "";

emailPatientButton.IsEnabled = false;

private void updatePatientButton_Clicked(object sender, EventArgs e)

Debug.WriteLine(name.Text + " " + pid1.Text + " " + cstatus.Text+"


"+email.Text);

App.PatientRepo.UpdateNewPatient(long.Parse(pid1.Text), name.Text,
cstatus.Text, email.Text);

name.Text = "";

pid1.Text = "";

cstatus.Text = "";

private void emailPatientButton_Clicked(object sender, EventArgs e)

try

28
MailMessage mail = new MailMessage();

SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

mail.From = new MailAddress("[email protected]");

mail.To.Add(App.PatientRepo.getEmail(long.Parse(pid2.Text)));

mail.Subject = "COVID-19 Status";

mail.Body = "Here are your details:\n\nName: " +


App.PatientRepo.getName(long.Parse(pid2.Text)) + "\nPhone Number: " +
pid2.Text + "\nCOVID-19 Status: " +
App.PatientRepo.getStatus(long.Parse(pid2.Text));

SmtpServer.Port = 587;

SmtpServer.Host = "smtp.gmail.com";

SmtpServer.EnableSsl = true;

SmtpServer.UseDefaultCredentials = false;

SmtpServer.Credentials = new
System.Net.NetworkCredential("[email protected]", "racers1234");

SmtpServer.Send(mail);

emailPatientButton.IsEnabled = false;

catch (Exception ex)

DisplayAlert("Failed", ex.Message, "OK");

}
29
}

 App.xaml.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Xamarin.Forms;

namespace COVID

public partial class App : Application

string dbPath => FileAccessHelper.GetLocalFilePath("patients.db3");

public static PatientRepository PatientRepo { get; private set; }

public App()

InitializeComponent();

PatientRepo = new PatientRepository(dbPath);

30
MainPage = new COVID.MainPage();

protected override void OnStart()

// Handle when your app starts

protected override void OnSleep()

// Handle when your app sleeps

protected override void OnResume()

// Handle when your app resumes

 FileAccessHelper.cs

using System;

using System.Collections.Generic;

31
using System.Text;

using Xamarin.Essentials;

namespace COVID

class FileAccessHelper

public static string GetLocalFilePath(string filename)

return System.IO.Path.Combine(FileSystem.AppDataDirectory, filename);

 PatientRepository.cs

using System;

using System.Collections.Generic;

using System.Linq;

using COVID.Models;

using SQLite;

namespace COVID

public class PatientRepository

32
{

SQLiteConnection conn;

public string StatusMessage { get; set; }

public PatientRepository(string dbPath)

conn = new SQLiteConnection(dbPath);

conn.CreateTable<Patient>();

public void AddNewPatient(long id, string name, string status, string email)

int result = 0;

try

//basic validation to ensure a name was entered

if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(status) ||
string.IsNullOrEmpty(id.ToString()) || string.IsNullOrEmpty(email))

throw new Exception("Valid info required");

result = conn.Insert(new Patient { Id = id, Name = name, Status = status,


Email = email });

33
StatusMessage = string.Format("{0} record(s) added [Name: {1})", result,
name);

catch (Exception ex)

StatusMessage = string.Format("Failed to add {0}. Error: {1}", name,


ex.Message);

public void UpdateNewPatient(long id, string name, string status, string email)

//int result = 0;

try

//basic validation to ensure a name was entered

if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(status) ||
string.IsNullOrEmpty(id.ToString()) || string.IsNullOrEmpty(email))

throw new Exception("Valid info required");

conn.Update(new Patient { Id = id, Name = name, Status = status, Email =


email });

//StatusMessage = string.Format("{0} record(s) added [Name: {1})",


result, name);

34
}

catch (Exception ex)

StatusMessage = string.Format("Failed to add {0}. Error: {1}", name,


ex.Message);

public List<Patient> GetAllPatient()

try

return conn.Table<Patient>().ToList();

catch (Exception ex)

StatusMessage = string.Format("Failed to retrieve data. {0}",


ex.Message);

return new List<Patient>();

public String getStatus(long id)

35
try

return conn.Get<Patient>(id).Status;

catch (Exception)

return "N.A.";

public String getName(long id)

try

return conn.Get<Patient>(id).Name;

catch (Exception)

return "N.A.";

public String getEmail(long id)

36
try

return conn.Get<Patient>(id).Email;

catch (Exception)

return "Email missing";

 Patient.cs

using System;

using System.Collections.Generic;

using System.Text;

using SQLite;

namespace COVID.Models

[Table("patient")]

public class Patient

37
[PrimaryKey, Unique]

public long Id { get; set; }

[MaxLength(250)]

public string Name { get; set; }

[MaxLength(250), Unique]

public string Email { get; set; }

[MaxLength(250)]

public string Status { get; set; }

38
39

You might also like