Project Development

Technical Achievement


Listed below are the technical achievement the team has achieved over the development of the project.

  • Setting up OpenMRS platform on individual computer and Bupa Server
  • Posting and receiving data from OpenMRS server to and fro mobile app
  • Implementing local database for offline viewing
  • GoogleFit API integration
  • Fitbit API integration
  • FatSecret API integration
  • Graph visualization
  • Health data analytics
  • Chat messaging and notification
  • Implementation Details


    SyncData - Fitbit Authentication implementation

    Fitbit Authentication carried out by ChromeTab and once user has authenticate, they will be redirected back to app via callback url and intent filter.

    Steps Details
    1 Implementation of Chrome Custom Tabs to allow user to access Fitbit Authentication page
    2 User will be asked to login to their Fitbit account and allow our app to view their data
    3 Upon user consent, user will be redirected back to our app by a redirect url (openmrs://logincallback )
    4 An intent filter (SyncFitbitAuthorization class) has been set up in our app to capture the redirect url from Fitbit
    5 Redirect URL contains authorization code which we will extract and save in our app
    6 A request is sent to Fitbit with the user Authorization code to exchange for an access and refresh token
    7 The Fitbit response is then transformed into a JSON object to extract the access and refresh token to be saved to the app
    8 User can now pull their own Fitbit data by clicking "Sync Fitbit" button on SyncData page.
    9 When Sync Fitbit button is clicked, the SyncFitbitService will be called (See SyncFitbitService implementation details)

    SyncFitbitService implementation

    Automatically download appropriate Fitbit data and upload it to OpenMRS server, followed by checking the data from OpenMRS and saving it to app local database

    Steps Details
    1 An array of String containing the activities (activity, heartRate, food, sleep ) URL is initiated.
    2 The String array is passed as a parameter to getUserData method which uses a for loop to loop through the activities and requesting data from Fitbit. (This is needed because Fitbit doesn't provide all the needed data under one URL request )
    3 The individual response from each activities is converted into a JSON Object which is then passed to "getFitbitData" method which extracts the necessary data that our app requires and stores it in a variable which will be used to upload to the OpenMRS server.
    4 Once all the needed data has been extracted, the "syncFitBit" method is called to check if the data from FItbit is correct before uploading it to the OpenMRS server
    5 The SyncGraphService service is called to download the data from OpenMRS to our local database ( Data downloaded from OpenMRS instead of using the data from Fitbit because the data might be different as there are other way of uploading data to OpenMRS server as well [ GoogleFit and Manual input ].)

    SyncGraphService implementation

    Downloads data from OpenMRS server, process it and then stores it into app local database

    Steps Details
    1 Array of String, Dates and GraphData are initialised which will be used to store the data obtained from OpenMRS over the past 5 days
    2 "pullData" function is called which takes in the array of dates (past 5 days), and the REST GET response from OpenMRS containing the user's data. The function then check the response for observations we require (heart rate, steps, etc..) and calls the "checkExerciseDate" function.
    3 The "checkExerciseDate" function checks the response if it matches the dates we are looking for (past 5 days), and if it does it will store the data into the GraphData object.
    4 Array of GraphData is then inserted/updated into the local database according to dates.

    SyncData - GoogleFit Authentication implementation

    Steps Details
    1 First time user will be asked to choose the Google Account they used for Google Fit in a pop up dialog.
    2 This allows the app to connect to Fitness APIs.
    3 The app will automatically invoke readings of Step count and Calories data using Fitness APIs.
    4 Readings will be displayed in an edit box above the sync button.

    SyncGoogleFitService implementation

    Automatically download GoogleFit data and upload it to OpenMRS server

    Steps Details
    1 Two strings are initiated containing results of Step count and Calories from GoogleFit, user UUID, date and concept UUID.
    2 Results are obtained by calling getStep() and getCal() methods from SyncData respectively that invoke the Fitness APIs and extract the raw data.
    3 SyncGoogleFit method will submit the following strings to the OpenMRS database and return true in the info log if it succeed or an error otherwise.

    NotifyService implementation

    Issue a notification when there’s a new chat message from the doctor while user is not currently on the chat page

    Steps Details
    1 An alarm manager is initiated when user first launch the app that is set to repeat every minute.
    2 AlarmManagerService would then invoke the NotifyService to run in the background.
    3 checkForNewMessage() would issue a POST request to OpenMRS server to check for the latest message from the doctor.
    4 obsDatetime of latest message on the server is used to check again a date variable, if obsDatetime is newer than the date variable then issue a notification.
    5 The date variable is updated everytime a notification is issued or when chat activity is alive to avoid repetitions.

    SearchFood - FatSecret API Implementation

    Allows the user to manually search for any type of food

    Steps Details
    1 The user is automatically logged in where the OAuth authentication is done using the token key and and secret key provided in the FatSecretUtils.java.
    2 Searching for the specific food the user has requested is done in the search() method where a GET request is called onto the FatSecret server containing as a parameter the name of the food the user has typed in.
    3 Displaying the response from the server is done in the displayListView() method where an arrayAdapter is used to populate the listView which will be displayed on the screen.