A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 [email protected] +33 7...

35
Hugo EXTRAT IT IUT – Second Year – 2016/2017 Website: www.hugoextrat.com Email: [email protected] Phone: +33 7 87 00 32 53 Start date: 10/04/2017 End date: 16/06/2017 Internship Report Supervisor: S. SANI | N. WIRATUNGA University tutor: M. CONRY A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF LOW BACK PAIN

Transcript of A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 [email protected] +33 7...

Page 1: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

Hugo EXTRAT

IT IUT – Second Year – 2016/2017

Website: www.hugoextrat.com

Email: [email protected]

Phone: +33 7 87 00 32 53

Start date:

10/04/2017

End date:

16/06/2017

Internship Report

Supervisor: S. SANI | N. WIRATUNGA

University tutor: M. CONRY

A DECISION SUPPORT SYSTEM FOR

SELF-MANAGEMENT OF LOW BACK

PAIN

Page 2: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

2 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

2

I approve the release of my report on the IUT intranet.

Page 3: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

3 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

3

3

ACKNOWLEDGMENT

For this work placement, I thank,

Sadiq Sani, who is my supervisor. He helped me and coached me during my internship

by giving feedback and tips on how to approach many situations. He always had time to

answer my questions.

Nirmalie Wiratunga, who directed this project. She manages and purposes a lot of

ideas to improve this project.

Michelle Conry, who is my university tutor. I want to thank her for giving me the

opportunity to follow my internship in the Robert Gordon University.

I want to thank all the interns who worked with me and enjoyed many moments with

them during this internship: Jean-Benoit Jourget, Maxime Golfier, Alexandre Mabire and

Yanis Lagsir.

Besides my internship, I really enjoyed this trip in Aberdeen. It’s a great experience and

I will continue next year.

Page 4: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

4 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

4

Table of contents

ACKNOWLEDGMENT ............................................................................. 3

INTRODUCTION ...................................................................................... 6

1. ORGANISATION ................................................................................... 7

1.1 Robert Gordon University ......................................................................................... 7

1.2 Subject and planning ................................................................................................. 8 1.2.1 Selfback project ..................................................................................................................... 8 1.2.2 Planning ................................................................................................................................. 9

1.3 Old version of the application ................................................................................. 12

2. ANALYSIS ............................................................................................ 13

2.1 Technology used ..................................................................................................... 13 2.1.1 Android ................................................................................................................................ 13 2.1.2 Firebase and Realm ............................................................................................................. 13

2.2 Android application development ........................................................................... 14 2.2.1 Analysis of requirements and specification ......................................................................... 14

2.2.1.1 Specification of requirements....................................................................................... 14 2.2.1.2 Analysis of requirements .............................................................................................. 15

2.2.2 Conception .......................................................................................................................... 17

3. TRAXIVITY .......................................................................................... 19

3.1 The basics ............................................................................................................... 19

3.2 Traxivity features .................................................................................................... 20 3.2.1 Goal achievement ................................................................................................................ 20 3.2.2 Add a goal ............................................................................................................................ 22 3.2.3 Administration features ....................................................................................................... 23

3.3 Database ................................................................................................................. 26 3.3.1 Firebase ............................................................................................................................... 26 3.3.2 Realm................................................................................................................................... 27

4. TECHNICAL REVIEW ........................................................................ 29

5. CONCLUSION ..................................................................................... 30

6. RÉSUMÉ EN FRANÇAIS ................................................................... 31

Page 5: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

5 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

5

5

7. WEBOGRAPHY ................................................................................... 32

8. GLOSSARY .......................................................................................... 33

9. APPENDICES ...................................................................................... 34

9.1 Appendix 1: Organisational Chart ............................................................................ 34

9.2 Appendix 2: UML Class Diagram .............................................................................. 35

Page 6: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

6 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

6

INTRODUCTION

I completed my 2 months’ internship during the last year of my studies in IT IUT in the

Robert Gordon University (RGU) in Scotland. I worked in the Computer Science Department

of RGU in the ideas research hub. I have been supervised by Dr. Sadiq SANI and Nirmalie

WIRATUNGA, professor in Intelligent Systems Research.

This work placement consisted in making an Android application to improve and

reinforce self-management of non-specific low back pain. There were 4 students at the start

of this internship (2 students of IT IUT from Lyon, 2 students of IT IUT from Clermont-Ferrand)

and Maxime Golfier joining us the 10th May 2017.

This report will explain what I did and learned during my internship period at the

Robert Gordon University, as the main purpose of the internship is to learn by working in a

practical environment and to apply knowledge acquired during the studies.

The project which I worked on was very interesting and rewarding for my professional

experience. Thanks to this internship, I work on a consistent project with a small team (5

peoples).

At first I will present the university. Then the different aspects of my work for these

months and the contributions of this internship.

Page 7: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

7 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

7

7

1. ORGANISATION

1.1 Robert Gordon University

Robert Gordon University (RGU) is a public university in Aberdeen (Scotland), was

founded in 1750 as a technical college. Full university status was granted in 1992. It is

composed of 11 schools (Law, Business, Engineering, Art, Computer Science,…). In appendix

1, we have the organization of the university where we can find these 11 schools. The School

of Computing Science and Digital Media is the main area where we worked. Robert Gordon

University is now one of the largest universities in Scotland with more than 16.000 students,

it is also named Best Modern University in the UK in The Times Good University Guides 2013.

The university is located outside the city in a beautiful place close to the river Dee. We

worked in a dedicated open space called “Ideas Research Hub”, a very quiet place with other

people preparing research topics. This open space is situated in the main building “Sir Ian

Wood Building”.

Robert Gordon University allowed us to participate in various talks about the game

development with Brenda Romero, who is an American game designer and developer. She has

worked on 49 game titles since 1981. Also, we met Professor Fotis Liarokapis who gave a talk

about the Moral Dilemmas in Immersive Virtual Reality Environments. The aim of this

presentation is to explore how immersive VR can be combined with moral philosophy.

Page 8: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

8 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

8

1.2 Subject and planning

1.2.1 Selfback project

The initial subject of the internship was to build an Android application called Traxivity

and it’s a part of SelfBack project consisted to facilitate, improve and reinforce self-

management of low back pain.

SelfBack will be designed to assist the patient in deciding and reinforcing the

appropriate actions to manage own low back pain after consulting a health care professional

in primary care. The SelfBack system is a predictive case-based reasoning system. To record

the patient’s physical activity this project will use a wristband or watch. Currently, we use a

watch with Android Wear system.

At the moment only 238 pain-related apps are available in the main apps shops (App

Store, Blackberry App World, Google Play, Nokia Store, Windows App Store). None of these

applications include a decision support system and none have documented effects by

scientific publications.

Every year, about 1 of 15 people in the European population will consult their general

practitioner with low back pain and today 30% of the general population suffer from low back

pain. Accordingly, low back pain is one of the most common reasons for activity limitation,

sick leave, and work disability.

This project is supported by seven partners, balanced between the medical field and

the technical innovation development (Norwegian University of Science and Technology,

University of Glasgow, Robert Gordon University, Kiolis, Forskningscenter, Health Leads,

Syddansk Universitet). Selfback is a collaborative Horizon 2020 EU funded project to develop

a decision support system for those suffering from low back pain.

Page 9: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

9 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

9

9

1.2.2 Planning

To carry out this internship project, we organized the work each week during a meeting

with our supervisor and we set different objectives for the next week. But we can find 3

important phases:

The two first weeks, we did the first phase to fully understand the project and to avoid

mistakes, next we have worked on the second phase for 2 weeks. This second phase was

important, it enabled us to have the base of the application and then allowed us to code with

a complex architecture. Then we coded the application and we merged the part of each

member to make a first version of the application to perform some tests and fix the main

issues.

1• Understand the objectives of the application and selfback project

and begin to control the different technology.

2• Make the UML* Diagram to structure the future development and

prepare the implementation phase.

3• Code the application and do some test.

Page 10: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

10 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

10

At the beginning, we decided to split the work and each member did a presentation of

his favorite part to show his ideas for the future application and why we wanted to focus on

this specific part. A lot of ideas were proposed during this meeting and we got this division of

work:

Alexandre Mabire

• Goal achievement messages

• Information messages

• Administration application

Hugo Extrat

• Data Management

• User Interface*

• Merge each part

Jean-Benoit Jourget

• User Interface

• Goal Management

Yanis Lagsir

• Wearable application

Page 11: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

11 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

11

11

During my internship, I created the real Gantt diagram to represent the tasks

performed: (Online version: http://www.hugoextrat.com/traxivity/GanttDiagram.svg)

Page 12: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

12 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

12

1.3 Old version of the application

When we arrived, our supervisor did a presentation to explain the project and what

we need to do on this important project. Thus we have learned the existence of a first

application created in 2016. But this application doesn’t include a database to store and

retrieve the data for each user, the wearable code was not working and we could not get the

steps number for a user. So we decide to make a new application with the bases of the old

version and improve the wearable app to prevent crashes and implements other features.

Figure 1.1: Android and Wear application (Old version)

This first version worked well on the phone, but sometimes the wear application

crashed because the app requested too many resources. We could just watch his activity in

time duration as you can see on the photo above and the data was not saved.

Page 13: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

13 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

13

13

2. ANALYSIS

2.1 Technology used

2.1.1 Android

Android is basically an operating system for smartphones. We can now find Android

on PDAs, touch pads, televisions, cars and netbooks. The OS was created by the start-up of

the same name, which is owned by Google since 2005.

At the moment Traxivity is only made for Android and Android Wear system. So we

have used Android Studio to code for these two systems. Android Studio is the officially

integrated development environment for the Android platform based on JetBrains IntelliJ

IDEA who is one of the best software to code in Java.

To do some tests we have used our Android phone or some emulator and the

University have lent us two types of smartwatches like Sony SmartWatch 3 on Android Wear

and Huawei Watch on Android Wear 2.

Probably in the next years, an iOS application will be available with Apple Watch. So all

users on the most used mobile operating system will be able to use this application.

2.1.2 Firebase and Realm

We used two types of databases on this application. The first one is Firebase Database

powered by Google. A cross-platform database so it’s available on Android, iOS and Web

applications. With Firebase your application can just use and control data, without having to

think about how data is stored. There is no need to write server side code or to deploy a

complex server framework. You don’t need to write APIs*, Firebase is your server, your API

and your data store. We have used two principal features of Firebase: Real-time Database and

Authentication.

With the real-time database feature all the data is stored in JSON* format and any

changes in data are reflects immediately in the app by performing a sync across all the

platforms and devices. The authentication feature allowed us to make an email/password

authentication and Firebase Authentication integrates directly into Firebase Real-time

Database.

Page 14: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

14 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

14

The second one is Realm Database a lightweight database designed for mobile device

launched in June 2014. This database is faster than SQLite and it’s object-oriented, so it’s a

good substitute for SQLite (Android) and CoreData (iOS). We can pass the data without

serializing* it, reading data and turning it into a continuous stream for transport.

Realm database is used to store the most important data about the user, thus it’s

totally secured because the data is not stored online.

2.2 Android application development

2.2.1 Analysis of requirements and specification

2.2.1.1 Specification of requirements

The specification of requirements is the first step when building an application or a

software. This step serves to identify the actors and find which features are necessary for the

different actors.

The features purpose for this application can be summarized in 3 categories. This

application needs to allow the user to:

Follow his activity each day on an android watch

Set a goal and watch his goal achievement

Get motivational messages according to goal achievement

Of course, the application must have a user interface design with user-friendly features

and easy-to-use. The code of this application must allow maintainability and easy scalability.

An administration application is necessary to update and add new motivation

messages and different messages for the users when he is setting a new goal. All the

administration pages need to be bound to the online database to update messages for each

user without an update for the main application.

Page 15: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

15 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

15

15

2.2.1.2 Analysis of requirements

This analysis step will link the needs of the users with the solution to be implemented.

I will establish the cases of uses for the actors. We have two types of actors: typical user and

administrator.

Figure 2.1: Use Case Diagram

When the user launches the application for the first time, he is invited to create a new

account and then he will be able to use Traxivity. I will explain each case in more details,

remembering that the user and administrator don’t use the same application of course.

Page 16: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

16 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

16

User features:

Add a new goal: The user can set a goal for the current date or for one week.

For example, he can decide to set a goal with 10000 steps for this day.

Watch his goal progress: When a user sets a goal he is allowed to watch his

goal progress in real time. For instance, he has set 10000 steps for the current

date and he has done 5000 at the moment, we show 50% goal achievement.

Add specific activity: If the user plays sport like football, basketball, … He is able

to add this activity for a day with the duration and the application will convert

this activity duration in number of steps for his goal.

The administrator application possesses 4 more features than a current user.

Manage messages: Administrator will be able to manage messages which user

will receive according to his goal achievement. He can set messages if the goal

achievement is low, moderate, high or full.

Manage activities: In this page, the administrator can manage the specific

activities and set the conversion in minutes to steps. For instance, 1 minute of

badminton is approximately 50 steps.

Manage information: When a user sets a new goal, many information

messages are shown to help the user, so the administrator can add or remove

this information message. For example, if a user wants to set a step goal an

information message said: “Recommended daily steps is 10000”.

Manage confirmation: Administrator can set confirmation message which will

print when the user sets a goal, he needs to confirm his goal to prevent a

mistake. If the user sets 10000 steps for the goal the confirmation message is:

“You wanted to do 10000 steps, is that correct?”.

Page 17: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

17 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

17

17

2.2.2 Conception

Figure 2.2: UML Class Diagram1 (Main part)

Complete version: www.hugoextrat.com/traxivity/classdiagram.svg

This is a part of the class diagram which was used in our team to make the application.

A complete version is available in appendix 1. We can easily see well how the database

management work with the DAO (Data Access Object) to abstract and encapsulate all access

to the data source. The DAO manages the connection with the data source to obtain and store

data.

The ListenerService class is used to take the data sent by the SendFileService from the watch

and then we can do some operations on this data and we can detect 3 types of activities:

Running, Walking or Inactive.

1. The complete version of this UML Class Diagram is also available in appendix 2.

Page 18: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

18 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

18

Also, we created some sequence diagram to show how the application operates. For

instance, the diagram below shows what the app does when a user adds a new goal:

Figure 2.3: Sequence Diagram to add new goal

At the start, the user needs to set a new goal to be allowed to use all the features in this

application. He sets this goal in the GoalActivity with an “EditText” where he will be able to

enter a number corresponding to his steps objective. When he has set his goal the class

“GoalDAO” will add the goal in the database and we show the main activity to the user with

the graph to show his goal progress. Thus the user will always have access to his objective.

It’s approximately the same as saving an Activity in the database except that the user doesn’t

need to do anything and the data will come from the watch.

Page 19: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

19 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

19

19

3. TRAXIVITY

3.1 The basics

An Android application is composed of many activities with a user interface that allows

the user to interact with the screen to perform actions. Android uses XML (Extensible Markup

Language) to do the design of the application called Layout. Android provides a

straightforward XML vocabulary that corresponds to the View classes and subclasses, such as

those for widgets and layouts.

“activity_main.xml”

<ScrollView

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:CircleProgressView="http://schemas.android.com/apk/res-auto"

android:orientation="vertical"

android:layout_width="match_parent"

android:layout_height="match_parent">

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical"

android:weightSum="1">

<at.grabner.circleprogress.CircleView

android:id="@+id/circleView"

android:layout_gravity="center"

android:layout_width="230sp"

android:layout_height="230sp"/>

</LinearLayout>

</ScrollView>

On this above code, we can find 3 custom tags which define elements. This is a part of

the first page which displays a circular chart with the goal progress. The first tag “ScrollView”

allow the user to scroll up or down the page when the layout content that might be longer

than the height of the device. The second is “LinearLayout”, A layout that arranges other views

either horizontally in a single column or vertically in a single row. And the last one is a little

special because it uses a path to get the elements from another library*. With this tag, we are

allowed to display a circular progress bar.

Page 20: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

20 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

20

To control this view in XML we need to declare a new Java class which extends Activity.

And we override the main method called when the activity starts to bind the XML with this

class, then we can control the view.

This method is “onCreate()”, for instance, the Java class which corresponds to this XML

code above:

“MainActivity.java”

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

CircleView dailyCircle = (CircleView)findViewById(R.id.circleView);

}

So now this class is bound with our layout and we are allowed to interact with the “CircleView”

when the activity has started.

When we understand how an Android application works we can start to implement

some features in our application to make a powerful and beautiful application.

3.2 Traxivity features

Now that we have identified the subject properly, we will see how the project was

carried out to respond to the users and administrator requirements.

3.2.1 Goal achievement

The first features we talked about, which is in a way, the heart of the application is the

feature of “Goal Achievement”. We retrieve this feature when the user sets a new goal and

some chart are displayed to show the goal progress. This is the most important feature of the

application and it was also the most complicated to put in place. Another feature allows the

user to watch his goal progress for the current week. We just have to swipe left when we are

on the first feature. To make this chart, we used a powerful and easy chart library called

“MPAndroidChart” created by Philipp Jahoda. This library allows us to create complex charts

based on our database.

Page 21: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

21 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

21

21

The following is two screenshots to show the two features defined before.

Figure 3.1: Daily and Weekly view

As you can see on the first screen, I took 85 steps that day and I had set my goal

objective at 100 steps. On the chart below the circular graph, we can find my step counter per

hours. If we swipe left, we are in the second screenshot and we can see my step counter for

the current day (Tuesday) with the steps objective bar (100 for this example) and I can also

watch my achievement for yesterday (Monday) and I realize my objective. All this data is

stored into Realm database no data are online and it’s totally secure.

Of course, the steps counter works with the Android watch and you can retrieve your

step counter on the screen if you don’t have your phone. The data are automatically

transferred from watch to phone; the user needs to do nothing on his watch.

Page 22: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

22 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

22

Figure 3.2: Android watch view

The watch code is very simple, we used the Google Play Services Activity Recognition

API to determine if the user walks, run or if he is inactive. We are able to detect when the

accelerometer sensor changed to increase the steps number correctly with a fairly low

margin of error.

3.2.2 Add a goal

To be able to see ones goal progress we need to declare a new goal. For this, we

designed the simplest view with an information message based on data from the online

database (Firebase) to indicate what is recommended for you to do and an “EditText” where

you can type the number of steps you want to make in one day. If you miss setting a goal the

application will use the goal set the day before. When you confirm your goal a popup will

appear with a confirmation message to confirm your goal and prevent the mistake. Presently,

we are not able to add a goal in terms of time, for instance exercising for more than 10 hours

a day but this feature is ready to be implemented in this application when the watch will be

able to detect an activity duration.

Page 23: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

23 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

23

23

Figure 3.3: Set a goal

The goal is stored in Realm database, like the step counter and this feature is only available

on your phone. You have got two choices to add a new goal, just press the floating button with

the “+” icon on the right-bottom side (Figure 3.1) or open the left menu and press “New Goal”

button (Figure 3.4).

3.2.3 Administration features

The administrator has a unique version of this application with a dedicated section

called “Administrator” when we open the left menu, then he has access to 4 sections to

Page 24: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

24 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

24

control: messages, information and confirmation messages but also the “special” activities

with a time-to-step converter.

Figure 3.4: Administrator page

The messages section includes the notification message sent to the user according to

his goal achievement. The administrator is allowed to edit, add and remove a message

synchronize with Firebase database. We have 3 categories: Low, Moderate, High; if we achieve

less than 50% we receive a “low” message, between 50%-70% a “moderate” message and

then a “high” message. The user is able to choose 3 hours in the settings page corresponding

to start of the day, mid-day and end of the day.

At each hour set in the settings, the user will receive a notification with a motivational

message according to his goal achievement. This notification also appears on the watch

screen.

Page 25: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

25 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

25

25

The administrator can manage the activities (edit and add new activity), then users will

be allowed to select one of these with an automatic time-to-step conversion set by the

administrator and stored in the Firebase database.

Figure 3.5: Manage Activities (Administrator feature)

Finally, an administrator can manage all the information and confirmation messages

which appear when one user wants to set a new goal. These messages are just written by the

administrator in the right section (information or confirmation) and then he can push this

update in Firebase and all users with our application will be able to see this new message when

they set a new goal. Firebase is very useful to do that, we can update the messages at any

moment and users don’t need to do anything.

Page 26: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

26 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

26

3.3 Database

One of the most important features of the application, every data that will be used has

to be correctly stored in the database in order for the program to work effectively.

As I previously said, my supervisor, Alexandre and I, chose two databases; Firebase and

Realm. The first thing I had to do was to implement Realm and Firebase into the program. To

do it, I imported the both in our code. In Android to import a new library we need to update

the gradle by adding this line:

dependencies {

classpath "io.realm:realm-gradle-plugin:3.2.1"

compile 'com.google.firebase:firebase-auth:10.0.1'

}

3.3.1 Firebase

Firebase is only used for user login, specific activities and for messages administrated

by an administrator. We decided after a few weeks not to use this online database to store

each activity for security reasons and to respect user’s privacy. The advantage of this database

is the “online part”, we can update all applications which use this database by just modifying

the database with one administrator.

Figure 3.6: Login Page

Page 27: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

27 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

27

27

Firebase is totally different from the other database; it’s work like a JSON tree. Unlike a SQL

database, there are no tables or records. When you add data to the JSON tree, it becomes a

node in the existing JSON structure with an associated key.

On this screenshot below, we have an example of our database and its structure with nodes.

Figure 3.7: Firebase Database

3.3.2 Realm

We decided to use Realm to save the user’s activity detected by the watch. When the

watch is in movement or inactive it sends data by “SendFileService” class and we receipt this

data on the phone with the “ListenerService” class. These two classes include a lot of methods

provide by Android to connect and send data between the watch and the phone.

Then we did some processing on the data to simplify them and thus to store them properly

and easily in the database.

Page 28: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

28 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

28

Figure 3.8: The transfer of data

The wear app continuously reads accelerometer data from the smart watch and passes the

data through the data processing pipeline for windowing and feature extraction. Once the

data is obtained, we split them to retrieve the hours, steps count and the type of activity, we

store them by hours and then we update the user interface.

Figure 3.9: Activity and Goal tables

These 2 tables are the main tables in Realm database. Each table has an “id” and two dates,

the beginning date and ending date of the activity or goal. A new activity is inserted when we

have detected an activity with the watch if this activity is the same as the previous we just

increase the ending date of it. We have already three types of activity: Walking, Running,

Inactive and one type of goal: Steps goal. The goal with a duration will be implemented in the

next version, but the database is already ready to store this type of goal.

Realm is very useful for this application, we can display some graphs about the user activity

for the day, week or even for the month without losing any data and the data is stored

securely.

Page 29: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

29 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

29

29

4. TECHNICAL REVIEW

Under the 10 weeks, our application works well and was tested on 2 smartwatches

with Android Wear and Android Wear 2. Due to lack of time some features like notifications

are not functional. However, apart from these notifications, all the functionalities proposed at

the beginning were achieved. The architecture of the application allows easy maintainability

for future developers. The Realm database is ready to accommodate the future improvements

for the notification system, but also for the activities.

At the moment, the application is not ready to be used. The testing phase was very short and

some improvements need to be made in the certain class. During the last presentation of our

project in front of 15 people some suggestions and idea for the future release. The application

will continue to be developed to meet all requirements and maybe develop a new version on

other platforms like iOS.

Page 30: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

30 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

30

5. CONCLUSION

This internship was for me a first professional experience in the world of computer

science. In a nutshell, this internship was an excellent and rewarding experience. I was able to

meet and network with many people. I learned that I needed to be organized and have

questions ready to get feedback.

This internship offered me opportunities to learn and develop in many areas and I

gained a lot of experience in Android development and in database development notably by

learning a new and innovative database with a strong evolution in the professional field.

Thanks to this exchange I took part of the amazing Erasmus life, I improve my English

as a result of meeting a lot of people from around the world.

Finally, this internship allowed me, autonomously, to acquire skills in design and

architecture application. This is a new exercise for me: the fact that my code will be taken up

by other developers made me more rigorous and more attentive about the application design

requirements.

Page 31: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

31 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

31

31

6. RÉSUMÉ EN FRANÇAIS

Dans le cadre de mon DUT Informatique, j’ai réalisé un stage de 10 semaines au sein

de l’université Robert Gordon University situé à Aberdeen en Écosse. Ce stage a débuté le 10

Avril et c’est terminé le 16 Juin 2017. Mon superviseur était Mr. Sadiq Sani ainsi que Pr.

Nirmalie Wiratunga.

Le projet a consisté à développer une application Android dans le cadre du projet

SelfBack pour aider les personnes à suivre leurs activités et les encourager à réaliser leur

objectif afin d’éviter le mal de dos mais aussi pour aider les personnes qui ont déjà un mal de

dos présent. Aujourd’hui les premiers conseils pour gérer un mal de dos sont de bouger, de

ne pas rester inactif trop longtemps et de réaliser des exercices d’étirements.

L’application est conçue pour le système Android nous avons donc utilisé le langage

Java avec l’environnement de développement Android Studio. Après avoir analyser la version

déjà existante de l’application qui ne possédait pas beaucoup de fonctions et qui surtout

n’était pas stable sur la montre connecté Android, la première opération a été d’effectuer une

analyse des besoins afin d’obtenir les fonctions nécessaires pour l’application et ainsi les créer

plus rapidement à l’aide de différents diagrammes et de choisir les différents outils que nous

allons utiliser. Après une répartition des tâches entre les 4 membres de l’équipe travaillant sur

ce projet nous avons commencé à réaliser le diagramme de classe. Au cours de cette

répartition j’ai décidé de choisir la réalisation de la base de données avec la réalisation d’une

partie de l’interface graphique pour obtenir un visuel facilement compréhensible et utilisable

par toutes les personnes.

Nous utilisons deux types de base de données, la première Firebase une base de

données temps réel hébergée sur internet, développée par Google et Realm une base de

données orientée objets destinée aux mobiles. Nous utilisons cette seconde base de données

pour sauvegarder les données sensibles des utilisateurs comme les activités qu’ils ont

réalisées chaque jour ainsi rien n’est stocké en ligne. Enfin, Firebase est utilisé pour la

connexion utilisateur et les messages d’encouragements ou d’aides qui peuvent être

modifiées par l’administrateur.

L’application est aujourd’hui totalement fonctionnelle, les données sont correctement

stockées et si l’utilisateur possède une montre connectée Android il peut suivre son activité

en temps réel.

Page 32: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

32 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

32

7. WEBOGRAPHY

Firebase for Android:

- https://www.sitepoint.com/creating-a-cloud-backend-for-your-android-

app-using-firebase/

- https://firebase.google.com/

Realm for Android:

- http://www.androidhive.info/2016/05/android-working-with-realm-

database-replacing-sqlite-core-data/

- https://realm.io/

Android Developer:

- https://developer.android.com/

MPAndroidChart wiki:

- https://github.com/PhilJay/MPAndroidChart/wiki

Circle Progress View wiki:

- https://github.com/jakob-grabner/Circle-Progress-View

StackOverflow:

- https://stackoverflow.com/ (Forum topics)

Page 33: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

33 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

33

33

8. GLOSSARY

API: Application Programming Interface is code that allows two software

programs to communicate with each other. They define the correct way for a

developer to write a program.

JSON: JavaScript Object Notation is a way to store information in an organized

and easy-to-access manner. It gives us a human-readable collection of data.

Library: A library is a collection of non-volatile resources. These may include

configuration data, documentation, pre-written code, classes, …

Serialization: Is the process of translating data structures or object state into a

format that can be stored or transmitted and reconstructed later.

UML: Unified Modeling Language. The UML was created to make a rich visual

modeling language for the architecture, design and implementation of

software. It’s not a programming language.

User Interface (UI): The User Interface is visual part of a computer application

or operating system with which a person may interact.

Page 34: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

34 Hugo EXTRAT [email protected] +33 7 87 00 32 53 www.hugoextrat.com

34

9. APPENDICES

9.1 Appendix 1: Organisational Chart

Page 35: A DECISION SUPPORT SYSTEM FOR SELF-MANAGEMENT OF …€¦ · Hugo EXTRAT 3 extrat.h@gmail.com +33 7 87 00 32 53 3 3 ACKNOWLEDGMENT For this work placement, I thank, Sadiq Sani, who

35 Hugo EXTRAT

[email protected] +33 7 87 00 32 53 www.hugoextrat.com

35

35

9.2 Appendix 2: UML Class Diagram