Skip to content

Application architecture and workflow

idelcano edited this page Jun 6, 2016 · 13 revisions

Short summary of the Malaria Case Surveillance components

Activities Diagram.

User workflow.

Background services.


Activities:

Activity Description
EyeSeeTeaApplication Is the first activity to be launched. It starts the Fabric Crashlytics, the AppSettingsBuilder, the PreferenceState, the LocationMemory, the FlowManager, and create the DB indexes. After go to dashboardActivity or loginActivity. This class extends from Dhis2Application class
BaseActivity It contains the application menu, logout, wipedata, preparelocationlistener...
DashboardActivity This is the main aplication activity.
LoginActivity This class is used to check if the user is logged-in before open the DashboardActivity And if the user is not logged, It need sing-in and pull the metadata.
ProgressActivity The progressActivity is a progessbar of a pull/push actions.
SettingsActivity This activity is used to change the Application Settings
MonitorActivity This activity is used to display the monitor webapp
SurveyActivity This activity is used to display edit and save one survey

Fragments:

Fragment Description
DashboardSentFragment This fragment is called "Improve" in QApp hnqis, and show all the sent surveys and filters.
DashboardUnsentFragment This fragment is called "Assess" in QApp hnqis, and shows all the unsent surveys.

Database:

File/Folder Description
iomodules.dhis,exporter Contains the files to convert from Malaria Case Surveillance to SDK using the Visitor Pattern.
iomodules.dhis.importer Contains the files to convert from SDK to Malaria Case Surveillance using the Visitor Pattern.
migrations Contains all the DB migrations from the first version.
model Contain all the Malaria Case Surveillance POJOS.
AppDatabase Contains the last datatabase version and name.
utils Contains the Malaria Case Surveillance utils.
utils/PopulateDB.java Populates the Database from the csv.
utils/ReadWriteDB.java Read and write values in the DB.
utils/Session.java An application scoped object that stoes transversal information: User, Survey, location, ServiceValues, tabsCache, phoneMetadata.
utils/LocationMemory.java Used to get and save in sharedPreferences the coordinates for a given survey.
utils/PreferenceState.java Contains some general variables like the maxEvents, if the location is required, the scale, if the planningtab is hide... And contains an android context.
utils/SurveyAnsweredRatio.java VO That holds the completion radio of answered/expected questions and compulsory questions ratio if exists.
utils/SurveyAnsweredRatioCache.java Cache used for calculating the ratio of completion just once.

Layout:

Folder Description
adapters Contains all the application adapters (dashboard, filters, general, and survey adapters).
listeners Contains listeners like (SurveyLocationListener, SwipeDimissListViewTouchListener and SwipeDimissTouchListener).
score Contains ScoreRegister class and some utils to calculate the scores.
utils Contains layout utils.

Monitor:

Folder Description
Monitor It contains all the Monitorbuilder clases.

Network:

Class Description
PushClient It is used to send REST push request using the API.
PushResult It is used to catch the result of each push.
ServerApiController Utility class that shows specific operations to check server status with the given config.
ServerInfo Minimum VO to save the latest server url + version in a pojo.
UnsafeOkHttpsClientFactory Used to connect with unsafe https url.

PhoneMetaData:

Java Class Description
PhoneMetaData It's a data class that contains the telephone imei, serial number, and number.

Receivers:

Java Class Description
AlarmPushReceiver Create a background alarm and try send the completed surveys each time period.

Utils:

Java Class Description
Utils Aplication utils.
Constants Aplication constants.
ExceptionHandler Aplication exceptions.

Other components in main/

Folder Description
views Overwrite of some views to add new funcionality or changes its functionality.
views.UncheckeableRadioButton Is a special RadioButton, this radiobutton can change a selected button to a unchecked button.
file Description
views.AutoCompleteEditTextPreference.java This class is used to overwritte the EditPreference to include a autocomplete function.
DynamicTabAdapter Create a dynamic tab adapter with the pictureapp components.
SwipeDismissTouchListener and SwipeDismissListViewTouchListener It is used to control the swip between pictureapp components.
ProgressTabStatus VO that holds info related to the progress of completion in a DynamicTab

The res folder contains all the usual android assets, resources, drawables, layouts...

"Malaria Case Surveillace" have some special components. These special components are created by DynamicTabAdapter class.

Type Description
IMAGES 2, 4, or 6 This type shows a table with two columns by row and one image inside each column.
IMAGES 5 This type shows a table with two rows like Images 4, and a bottom row with only one image.
IMAGES_3 This type shows a table with three rows and one image inside each row.
PHONE This type is a numeric user input. This component filters the user input to allow only a valid phone number or null number.

Activities Workflow

image


PictureApp user workflow


How the service works:

The service does its operations on background.

The service saves all the data in session and when is finished it, the service will send a broadcast intent with its name.

All the components who are listening for that service receive that broadcast message and can work with the data stored in session..

  • Push Service: A service that runs pushing process for pending surveys.

The service name is a concatenation of the constants SERVICE_METHOD + PENDING_SURVEYS_ACTION.

That service call the pushAllPendingSurveys method.

  • SurveyService: A service that looks for current Surveys to show on each tab in async manner.

ALL_UNSENT_SURVEYS_ACTION:

This service stores in session a list with all the unsent surveys.

This service is used by dashboardUnsentFragment.

ALL_UNCOMPLETED_SURVEYS_ACTION:

This service stores in session a list with all the uncompleted surveys.

ALL_SENT_SURVEYS_ACTION:

This service stores in session a list with all the sent surveys.

This service is used by dashboardSentFragment.

REMOVE_SENT_SURVEYS_ACTION:

This service remove all the surveys listed as survey to be removed.

RELOAD_DASHBOARD_ACTION:

This service stores in session all the lists used for each of the fragments.

This service is used by allt the fragments.

PREPARE_SURVEY_ACTION:

Prepares required data to show a survey completely (tabs and composite scores). This service stores in session the lists of composite Scores as "PREPARE_SURVEY_ACTION_COMPOSITE_SCORES", tabs for the current program as "PREPARE_SURVEY_ACTION_TABS".

This service is used by SurveyFragment.

  • MonitorService: A service that looks prepares monitor data in async manner