Increasing the Available Required Checks within AppContextModels

Continuing the discussion from Adding Death Date to Person Context Model in Core Apps:

I am looking for a way to add more checks for dashboard widgets in the context model. However some of the checks are complex, including encounter and observations data comparisons.

So I was wondering if there is a way to pass key/value pairs into the context model, essentially providing unlimited possible checks without having to update the model for each required check.

An example of checks I am looking for are as follows:

  1. When a patient has specific encounters

  2. For example data integrity violations - show only when there are violations

  3. Patient status - only show when the patient has specific status e.g, due for VL, Lost, Lost to Follow-up etc

@darius @wyclif @dkayiwa @dev5

The page model contains the contextModel with the key appContextModel, you can fetch it and add any key value pairs from a gsp, it would be nice to have your keys prefixed with your module id to avoid duplication.

This would certainly be nice to have… @ssmusoke not sure I understand how you’d use key/value pairs to achieve this? What values would you be adding to the context and where?

@mogoodrich Key-value pairs are what I initially had in mind, however I am also thinking of an interface which when implemented by components provides these key/value pairs from a patient object passed to them as part of the appContext model initialization.

@ssmusoke that makes sense to me…

I would be concerned that adding details of all of the patient’s encounters to the context model would lead to performance problems.

Letting other modules populate the patient appcontext as you describe makes sense, though it does invalidate a previous assumption that a page completely defines its own context model, and thus can document it. So this line would no longer be accurate. Offhand I don’t think this will break anything, but we should change our documentation of how to define apps in the app framework to indicate this change.

I would assume the flow is:

  1. Page controller sets up the initial context model like this
  2. Page controller calls a new method AppFrameworkService.extendContextModel(AppContextModel)
  • this new method iterates through all the registered components and calls something like AppContextExtender.extend(AppContextModel m, String name)
  • the “name” is so you know which page you’re on, e.g. if you wanted to allow different details on the patient dashboard vs the visit dashboard

We should avoid making a module like Data Integrity require the App Framework or Core Apps modules for this.