Hi guys!
(@mseaton)
I would like to configure an OpenMRS Report where the user can select multiple locations against which the report is run. But I am not sure what is the correct Java syntax to use in my Report Manager class…
For instance, the following instructions will correctly set a Location parameter to my Report and Visit query filter:
Report parameter configuration:
ReportDefinition rd = new ReportDefinition();
rd.setParameters(Arrays.asList(new Parameter("locationList", "Visit Location", Location.class)));
Query filter configuration:
BasicVisitQuery query = new BasicVisitQuery();
Parameter location = new Parameter("locationList", "Visit Location", Location.class);
query.setParameters(Arrays.asList(location));
But this won’t allow to pass a list of Locations. This will let the user select only one location:
See how it shows in the UI:
However, I would prefer to be able to select multiple locations.
I know that the Query filter I am using can handle this just fine but it is only a matter of getting the right Java syntax to declare the parameters:
For instance, this won’t work:
new Parameter("locationList", "Visit Location", List.class)
Neither will this:
new Parameter("locationList", "Visit Location", List<Location>.class)
I haven’t been able to find an similar use case in Malawi PIH module.
Btw, I actually have found confusing info in the Malawi reports, such as this:
q.addParameter(new Parameter("locationList", "Locations", Date.class));
I know that this is supported by the OpenMRS Reports module because I can manually change the parameter type in the UI:
Thanks!
Romain