Refrigerators
Refrigerators are a key element of the Cold Chain application. Their working status is necessary for keeping vaccines cold and effective. This application focuses on providing easy access to the working status of lists of refrigerators organized in a multitude of different ways. It also tracks basic information about the refrigerator, such as its age and model.
Refrigerators belong to Health Facilities and they contain Maintenance Records.
Lists of Refrigerators
Function
A Refrigerator List contains a clickable list of refrigerators: clicking the refrigerator will open the Refrigerator Menu. The list can be searched by the refrigerator's ID, the tracking ID, the health facility name, or the health facility ID:
The search string does not need to be a perfect match. Substrings and approximate matches can be searched and all matching records will be displayed. For example, if you searched 225 then you might get back refrigerators with ID 22500172, 22500035, and 22500032.
This page is paginated by default to 10 refrigerators per page. This can be adjusted to 20, 50, 100, or 1000 by selecting the option from the drop menu. To navigate between pages of refrigerators, use the Next and Prev buttons.
Tapping the Edit button will launch the full Survey form for this refrigerator. Each field will be prepopulated with the values shown in the menu, so that only the values that are incorrect need to be filled in.
These lists can be organized a number of ways:
By Region: This lists all refrigerators in the region and is launched by pressing the View All Refrigerators button on the Region Menu. This is what is shown above.
By Health Facility: This lists all refrigerators in a particular health facility. It is launched by pressing the Refrigerator Inventory button on the Health Facility Menu.
By Type: This lists all refrigerators in a particular region organized by type. This is launched by pressing the View All *Model ID* Refrigerators button on a Refrigerator Type Menu.
Needing Service: This lists all refrigerators in a particular region that are in need of service. This is launched by pressing the View All Refrigerators Needing Service button on the Region Menu.
Implementation
The refrigerator lists launched By Region, By Health Facility, and By Type all use config/tables/refrigerators/html/refrigerators_list.html
and achieve their different lists by passing different query parameters. This file defines the search form, the pagination drop menu, and the JavaScript functions to call on button presses. All the rest of the user interface is added dynamically in config/tables/refrigerators/js/refrigerators_list.js
. However, this file only handles populating the user interface elements defined in refrigerators-list.html
. All of the logic is handled by the shared library file config/assets/js/list_view_logic.js
. This file is discussed in the following subsection: The list_view_logic.js library.
The refrigerator list launched by Needing Service uses config/tables/refrigerators/html/refrigerators_service_list.html
and config/tables/refrigerators/js/refrigerators_service_list.js
, but these files work nearly identically to their refrigerators_list.*
. The only difference is the listQuery
variable that defines the SQL query to be run. Both files join the Refrigerators, Health Facilities, and Refrigerator Types tables in order to support filtering and sorting on facility name, facility ID, tracking ID, and refrigerator ID (see the searchParams
variable). The refrigerators_service_list.js
file differs in that it adds arguments for refrigerator maintenance priority.
The list_view_logic.js
library
This library handles the queries, ordering, search, and pagination for all the search List Views in the Cold Chain application. In this section the calling files are refrigerators_list.js
and refrigerators_service_list.js
, but there are others as well. For the rest of this section I will refer to these as the caller.
When the caller is initializing, it will use the set functions to build state. First the table ID must be set with setTableId(...)
. Then the query parameters with setListQuery(...)
, setListQueryParams(...)
, and setSearchParams(...)
. And finally the user interface elements need to be supplied with setListElement(...)
, setSearchTextElement(...)
, and so on, to allow the list_view_logic.js
file to read and write to them directly.
After state is initialized, the resumeFn(...)
can be called. This function uses session variables (via odkCommon.setSesionVariable(...)
and odkCommon.getSessionVariable(...)
to track search terms, query keys, and pagination indices. It uses these values to build SQL queries and then runs them with a series of odkData.arbitraryQuery(...)
commands to count the matching records and then retrieve the appropriate subset to display on the page. The results of that final query are used to create the list elements and populated them onto the page. Each list element contains a odkTables.openDetailView(...)
command embedded in it. This works in a generic file like this because the default Detail View for each of these tables has been set in the settings page of the corresponding .xlsx
file.
There is also more complex logic to handle the Edit and Delete buttons. The file must ensure the authenticated user has the requisite permissions for each record before displaying the button. If they do, and the button is pressed, the functions odkTables.editRowWithSurvey(...)
and odkData.deleteRow(...)
are called, respectively.
There are controls for the Next and Prev navigation buttons that ensure they do not go beyond the bounds of the full result set. Each time they are pressed, the resumeFn(...)
is called again to re-query and redraw the results. Similarly, the Search button parses the text of the search, constructs a new query, and calls resumeFn(...)
. All of these functions communicate their parameters for the redraw through session variables.
Files
config/tables/refrigerators/html/refrigerators_list.html
config/tables/refrigerators/js/refrigerators_list.js
config/tables/refrigerators/html/refrigerators_service_list.html
config/tables/refrigerators/js/refrigerators_service_list.js
config/assets/js/list_view_logic.js
Forms
None
Database Tables
Refrigerators
Health Facilities
Refrigerator Types