Reporting module integration: How to do it the right way?

Hello @mseaton, @dkayiwa and other devs familiar with the reporting module

I have been able to integrate reporting module in DHIS Report module. I am using evaluation context of reporting module to pull in values as shown here. I am not sure if this is the correct way. This serves the point of getting values from reporting module but, this does not help generate a reporting module report. I believe it would really be helpful if a report is run and we are able to extract values from the run report.

Purpose: have a history of the reports requested

My question: Is there a way from API where I can request to run the report and extract the values from the generated output or is using reporting rest the way to go, and will that run a report, generate the result output and be available in the report history

1 Like

Hi @maurya - if I’m understanding you correctly, then yes. The main recommended way to use the reporting module API is as follows:

  1. Create a ReportRequest which contains:
  • The Mapped<ReportDefinition> you wish to evaluate (a Mapped construct encapsulates both a Definition and parameter values)
  • The RenderingMode which indicates what ReportRenderer to use. A ReportRenderer is what should be used to take the ReportData and transform it into the desired output.
  1. Use the ReportService to run the report, either:
  • Synchronously - using ReportService.runReport(ReportRequest), or
  • Asyncronously - using ReportService.queueReport(ReportRequest)
  1. The result from running the report can then be retrieved using methods within ReportService, and can be further used as needed.

For DHIS2, what I had always figured we would do is:

  1. Create a DHISReportRenderer, which extends ReportDesignRenderer, and which supports one or more ReportDesignResources that contain the specifications of what DataSet elements from the ReportDefinition map to what DHIS2 Report Elements.

  2. Create Report Definitions (I wouldn’t restrict these to PeriodIndicatorReportDefinitions, but would allow for more flexibility than this) which contain startDate, endDate, and location parameters, and which contain dataSets that have the indicators and metrics of interest.

  3. Associate an instance of the DHIS2ReportRenderer with each ReportDefinition, with appropriate ReportDesigns

  4. Run these as needed, either on a schedule or on demand using the standard reporting module tools and API.

Let me know if you need any clarification on any of these points…

Mike

1 Like

Thank you @mseaton, this gives me a start to work with. Hopefully, we would be able to do this without issues. But, if I get stuck at any point I will respond here.