@k.joseph, I’ll do my best to try to explain.
- All definitions can be parameterized on any property that has the @ConfigurationProperty annotation. In these cases, the name of the parameter must match exactly the name of the property. So in your case above, with a CodedObsCohortDefinition, you must parameterize it as follows:
cd.addParameter(new Parameter(“onOrAfter”, “On Or After”, Date.class));
cd.addParameter(new Parameter(“onOrBefore”, “On Or Before”, Date.class));
cd.addParameter(new Parameter(“locationList”, “Location”, Location.class));
Now, if you pass in parameters in your evaluation context named “onOrAfter”, “onOrBefore”, and “locationList”, things will work as you expect. But obviously this is rarely the case - you more commonly need to associate these with the actual parameter names/values coming in.
This is done via parameter Mapping. Specifically the use of the Mapped construct.
If you simply want to create a CohortDefinition that takes in startDate, endDate, and location parameters, you can use the adapter CohortDefinition called MappedParametersCohortDefinition. You can see an example of where we have done this here, in an attempt to standardize on “startDate”, “endDate”, and “location” parameters ourselves.
More commonly though, what you want to do is pass parameters from one definition to another - for example, from a ReportDefinition to a DataSetDefinition, a DataSetDefinition to an Indicator, or from an Indicator to a CohortDefinition. You’ll notice that most times one Definition includes other definitions, it does not include them directly. For example, the ReportDefinition does not have a Collection of DataSetDefinitions. Instead, the ReportDefinition has a Collection of Mapped. It is this Mapped construct that allows you to pass parameters through from one evaluation to another, and to change their names if necessary.
In your case, if you add your CohortDefinition to a DataSetDefinition, and this DataSetDefinition supports 3 parameters named “startDate”, “endDate”, and “location”, you would add your CohortDefinition to it as follows (pseudocode):
dsd.add(new Mapped(codedObsCohortDefinition, “onOrAfter=${startDate},onOrBefore=${endDate},locationList=${location}”);
You can see examples of this all throughout the reporting module unit tests. Have a look here specifically.
Hope this helps,
Mike