Reporting module: Cohort cross tab dataset definition always results in a single row dataset?

Tags: #<Tag:0x00007f01ba16b008>

Hi @mseaton,

When evaluating a CohortCrossTabDataSetDefinition (in CohortDataSetEvaluator) the resulting dataset is created like this:

MapDataSet data = new MapDataSet(dataSetDefinition, context);

And when looking at MapDataSet this is documented as a comment in the code:

 * DataSet which is key-value pairs, instead of a full two-dimensional table

And indeed, when data is added to the dataset it happens here with a constant reference to a single row ID:

public void addData(DataSetColumn column, Object dataElement) {
  addColumnValue(SINGLE_ROW_ID, column, dataElement);

While I guess that the renderers know how to handle such single-row resulting datasets, it comes as a surprise at first. For example when defining a cross tab data set with 3 rows, one would expect to fetch 3 rows as a result and not just one.

Do you recall what was the rationale behind this design?

Cc: @ivange94

@mksd good question and no I don’t recall. I do remember this being intentional, but I’m not sure if it was for a a particularly good reason. I think it is likely that it was simply a reflection / continuation of the various Cohort indicator DSDs that were also created around the same time - their purpose was to enable defining the primary queries and their disaggregations and then being able to efficiently retrieve those of interest. And we didn’t have a particularly good model for identifying a particular row in a data set, whereas we did have a paradigm for getting data for a particular column. Happy to discuss revisiting this.

Best, Mike

Thanks @mseaton.

I haven’t looked into it yet but I’m already wondering if you would know from the top of your head whether this would cause issues with the default renderers? Such as tabular data coming out as one row when it shouldn’t… etc?

@mksd, if you look at renderDefaultReport.jsp, you’ll see that there is some (hacky) code in there that aims to format MapDataSets as key/value pairs, unless they are generated by CohortCrossTabDataSetDefinitions, in which case they are rendered as a 2D table.