Extension point for Average Consumption calculations

Description

As an implementor (such as Malawi team member),
I want to program an Extension that I can plug into the Requisition Service and UI,
So that I can add a new Average Consumption calculation to make it available in my Requisition Template.

Warning:

This ticket does not accurately capture the current design. This was discussed at April 18 2017 Tech Committee: https://openlmis.atlassian.net/wiki/display/OP/2017-04-18+Meeting+note . The Malawi implementation team is weighing this need and evaluating the design (there is a wiki page linked from Tech Committee with work-in-progress).

Background

Malawi wants to use a country-specific Average Consumption calculation (formerly called AMC). The Malawi formula might look back multiple years to pull consumption data from the same period (eg March period) over multiple prior years (Mar2016, Mar2015, Mar2014, ...). The final formula is not yet decided. But regardless of that, we want the core OpenLMIS product to have an extension point where users can define an additional calculation that will be available. The calculation will be available as an option on the Admin UI as part of the Requisition Template. The new calculation might not be used for every program in Malawi, so it's important that the extension merely makes the new calculation available, and the configuration of the Requisition Template determines what calculation is enabled for that program's template.

Admin UI

When an extension is active in the Requisition service, the additional calculation is provides will be available as an option in a radio selection for the relevant field. (See sketch)

Requisition UI

The UI does not need to visibly change, however the calculations of Average Consumption need to use the new extension-defined formula. The API needs a way to tell the UI which formula to use on each Requisition (because some program templates will use the default calculation, not the custom extension calculation). See sketch:

Open Questions

  • Average Consumption column also updates on the fly in Javascript in the AngularJS app. Do we need an extension point for this in the AngularJS UI app? How do we "connect" that Javascript code to the per-program configuration on the API side to control when the custom calculation is used?

  • The new Average Consumption calculation that Malawi wants might need to have many past years of Requisitions available in order to calculate based on. (They are working on migrating 5 years of data for this purpose.) But our Requisition JSON API endpoints does not put prior year's data into the Requisition object. So when the new UI calculation code runs, will it make a bunch of API calls to query for many past years' data? OR alternatively, when the extension mechanism is active in the API code, will that code add more historical data for past years into a Requisition object so that all this data is there for calculations to run?

  • Can we create an extension point mechanism that we could later copy onto all of the calculated fields? Ideally, we will want to add a similar extension point to most (or all) of the calculated fields.

Attachments

2

QAlity Plus - Test Management

Checklists

Activity

Brandon Bowersox-Johnson 
May 9, 2017 at 11:58 PM

Moving to Roadmap status. Still being discussed/considered, and may not be a priority.

Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Components

Priority

Time Assistant

Created April 12, 2017 at 12:05 AM
Updated February 8, 2023 at 1:29 PM