Pass parameters from Report to PatientDataDefinition while constructing report

Hi @mseaton I have code that constructs a report definition in which indicators are added, these indicators are based on CohortDefinitions.

Now what I want, is to be able to evaluate Patient Data Definition when I am constructing the report, i.e I want to pass the parameters of the report definition to the PatientDataDefinition which I want to evaluate. The data which is returned by PatientDataDefinition is what I what I want to pass as my argument to CohortDefinitions which then will be then will be converted as indicator in the report.

I tried it I can not figure out pass the parameters.

public ReportDefinition constructReportDefinition() {
    ReportDefinition rd = new ReportDefinition();

    CohortIndicatorDataSetDefinition dsd = new CohortIndicatorDataSetDefinition();
    rd.addDataSetDefinition("indicators", Mapped.mapStraightThrough(dsd));
    CD4PatientDataDefinition cd4 = new CD4PatientDataDefinition()
    cd4.setStartDate(from report paramters)
    EvaluatedPatientData data = Context.getService(PatientDataService.class).evaluate(cd4,evaluationCotext);
    CohortDefinition withCD4 = new CD4CohortDefinition(data.getData())


@carapai, to do this you need to “Map” the parameters through. You are already doing this (perhaps without even realizing it), when you add the DataSetDefinition to the ReportDefinition via the “Mapped.mapStraightThrough(dsd)” method. You should have a look at what that does.

In your example above, you are never adding your CD4PatientDataDefinition or your CD4CohortDefinition to your DataSetDefinition or to your ReportDefinition. How are you intending to do this?

Have a look at these examples from our Malawi module. I think these are similar to what you are trying to accomplish:

Ultimately, you need to link definitions together by mapping their parameter, and then use these parameter values within your evaluators to produce results. You cannot perform your evaluations in your “constructReportDefinition” method above, because the purpose of this method is to produce a definition that can be evaluated, not to evaluate itself.