...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Summary
Stock imbalance report show stock availability of all products under a given program, reporting facilities in a specified period.
Each record of the report will let the viewer know if a specified product is Stocked Out, Under Stocked, Adequately Stocked, Over Stocked or there is no demand for a give facility under a specified period.
Components
The Stock imbalance report will have the following columns:
- # (Row number starts from 1)
- Facility type
- Facility name
- District ( district where the facility is located)
- Province (province where the facilities district is located)
- Period (reporting period for the report we want to see the stock Imbalance data)
- Product (Product name)
- AMC (Average monthly consumption)
- Closing balance (closing balance for the product in the specified reporting period)
- MOS (Month of stock)
- Order quantity
- Status (status of stock availability for the give product. Available values are; Stocked Out, Under Stocked, Adequately Stocked, Overstocked, No Demand)
Report filters:
Name | Input type | Description |
Program | Dropdown list | Loads all programs that are active and based on user's supervisory node. It's a required field. |
Schedule | Dropdown list | Loads all program reporting schedule based on selected program. It is dependent on program selection. It's a required field. |
Year | Dropdown list | Required field and shows list of years starting from the program start data till current year in yyyy format. |
Period | Dropdown list | Required field and shows a list of periods based on schedule selection |
Reporting type | Iist of check boxes | Three checkboxes to fine tune the report data based on the requisition type
|
Stock status type | List of checkboxes | Six checkbox to fine tune the search based on a combination of stock status.
|
Table 1 - Report filters with description
To access this report, first the user needs to login and should have the right to access the report. Once the user browse to the report, a page with the list of report filters mentioned above will appear.
Validation
When the page loads for the first time, all report filters should be unselected except the 'All' check box from Reporting type checkboxes check boxes and 'All' checkbox from the Stock status type checkbox list.
To see report data in the report, the report viewer needs to select all the required filters - Program, Schedule, Year and Period. Once all the required fields are selected, the report will try to fetch data from server. If there are some un-selected filters which are required, the report won't try to load a data until all the required fields are selected.
For all required filters an asterisk sign with red color coded ({}{*}) will be seen beside the filter label.
Fetching
Once all the required fields are selected the report will automatically loads the data and one can change the report filters to fine tune the report data.
Fig 1: Consumption report mock up
A report user can see stock imbalance data based on the type of requisitions which are represented by the checkboxes - Regular and Emergency. By selecting both or one at a time user can fine tune stock imbalance data based on the requisition type.
In addition, the report user can fine tune the report data based on the stock statuses represented by - Stocked Out, Under Stocked, Adequately Stocked, Over Stocked and No Demand checkboxescheck-boxes.
Description | Value for 'Status' column. Font color and icons should be the same | Calculation |
If the user checks 'No Demand' filter checkbox checked, the report will shows data with AMC equals to zero (0). | ⚠No Demand (AMC=0) | AMC = 0 |
If the user checks 'Stocked Out' filter checkbox checked, the report will show only stocked out products for facilities. | Stocked Out | Stock on hand = 0 |
If the user checks 'Over Stocked' checkbox checked, the report will show only overstocked products for facilities. | Over Stocked | Stock on hand / amc > maximum month of stock |
If the user checks 'Adequately Stocked' checkbox checked, the report will show only adequately stocked products for facilities. | Adequately Stocked | Stock on hand / amc >= minimum month of stock |
If the user checks 'Under Stocked' filter checkbox checked, the report will show only under stocked products for facilities. | Under Stocked | Stock on hand / amc < minimum month of stock |
Table 2 - Status column of stock imbalance report calculation and formatting
Pagination
If there is a report data based on the selection, the data will be seen in a tabular format on the HTML page with pagination buttons at the bottom of the page. The pagination is on client side and requires all the data to be loaded prior. The pagination links will be based on the row count of the data.
Apart from the pagination, there are small, horizontally stacked list of buttons on the bottom of the page to define the number of rows to show in a single paginated page. The list of buttons will have the following labels 10, 25, 50 100 consecutively. For example, If user clicks button with label '10', the number of rows that will be shown in the current page will be 10.
Data Formatting
On the report, column values for AMC, Closing Balance, MOS and order quantity are numbers separated by thousands separator and visually right aligned. The rest column values should be left aligned. The formatting for column Status can be inferred from Table 2.
Exporting
On the upper side of the report there will be two buttons for exporting the current report to PDF or XLS format. When the user clicks the PDF button, PDF version of the report will be opened in a new tab or in a new page. When the Excel button clicked, XLS export of the report will be downloaded.
The PDF output will have the country logo and below to that Report filters data used to fetch the report.
eLMIS Implementation
Stock imbalance report on eLMIS can be accessed from UAT site at https://uat.zm.elmis-dev.org or by running eLMIS locally by checking out the source code from {+}https://bitbucket.org/elmis-tzm/open-lmis.git+ and one can follow the README.md file to quickly setup the project on local machine.
To access the report from UAT server, one needs to have a login account with role 'View Reports' attached to it.
Fig 1: Stock imbalance report viewing role.
After successful login, user can got to Reports > Stocker Stock keeping > Stock Imbalance by Facility on the upper navigation menu. If the report link is not there or not visible, check the report role 'View Reports' is added to the login account.
Fig 2: Consumption report with report data
Developer Resources
The Consumption report is developed using Jasper report from PDF and XLS output and HTML and AngularJS for the HTML preview.
In the eLMIS code base, all the reports are place under module called 'reports '
https://bitbucket.org/elmis-tzm/open-lmis/src/develop/modules/report/src/main/java/org/openlmis/report/ |
Under the report module we have three folders
- Java - Java code for fetching data from the database and transforming it to REST API
- Resources - This folder hold compiled jasper reports
- Template - This folder hold Jasper JRXML files. This is the place where we can find the report design to change report implementation.
How to compile report design file
To compile report files, user should navigate to the home directory of the project and issue the following command.
gradle compileJasperReport
Apart from the above command, run gradle task also compiles the report files as part of running the application. compileJasperReport compiles the jrxml files found under Template folder and move the compiled file under folder Resources.
Report End point
Under java folder listed above, we can find all the backend back-end resources for fetching and transforming report data from db. Under this folder there a number of other dedicated folder that their name can give some meaning. Amount all the folder there is one called controller which we can find a REST controller for the starting point for most report data.
For Consumption report, the report will fetch data from InteractiveReportController. We can see lots of REST resource in the class but for our report we will focus on getStockImbalanceData method. All export format of the report will call this resource via URL {_}http://ip:port/reports/reportdata/stockimbalance.json_ with parameter query string.
Call hierarchy
org.openlmis.report.controller.InteractiveReportController#getStockImbalanceData
...
> org.openlmis.report.service.StockImbalanceReportDataProvider#getReportBody
...
> org.openlmis.report.mapper.StockImbalanceReportMapper#getReport
> org.openlmis.report.builder.StockImbalanceQueryBuilder#getReportQuery
How is the HTML report organised
The HTML report is designed with HTML and AngularJS. Basically all report format PDF, XLS and HTML use the same java REST endpoint to fetch a report data from the db. All HTML reports gets loaded by the following file
modules/openlmis-web/src/main/webapp/public/pages/reports/main/index.html
All report related resources like js and css files and also html partial pages will be loaded in to the above file using AngularJS routing feature.
When one browse to the consumption report URL on the site, AngularJs will load index.html page and render
modules/openlmis-web/src/main/webapp/public/pages/reports/main/partials/stock-imbalance.html partial page in to it.
If one opens and see the stock-imbalance.html file its possible to see HTML section that will render the list of report filters that we saw on the screenshot. For example, to add a program filter in stock-imbalance.html we can add with the following code block.
<program-filter class="form-cell horizontalFilters" required="true"></program-filter>
The above code renders the program report filter in the report page. Each report filters are composed as angular directive. One can find the list of filter directive definitions at
modules/openlmis-web/src/main/webapp/public/js/reports/shared/directives/filters.js
Each report filter that one can see in the report can be found in filters.js. Those directives calls a backend service to populate the filter control with data. The angular services that will be called by each filters and reports are found in
modules/openlmis-web/src/main/webapp/public/js/shared/services/extension-services.js
Once the report get loaded and when the report viewer selected data on all required filters, $scope.OnFilterChanged method will be called in the following js file
modules/openlmis-web/src/main/webapp/public/js/reports/main/controller/stock-imbalance-controller.js
With in this AngularJS controller method, the java REST endpoint will be called to fetch the report data.
On the report page, there are two buttons at the top of the page for exporting the report on other formats. If a user wants to export the current HTML report to PDF, he/she need to click the button with the label PDF. When that button get clicked, $scope.exportReport method of the stock-imbalance-controller.js
file will be called.