It is not possible to override the display of regimen rows since TreatmentRegimen has an inbuilt comparator.
public class TreatmentRegimen {
private Set<EncounterTransaction.Concept> headers = new LinkedHashSet<>();
private SortedSet<RegimenRow> rows = new TreeSet<>(new RegimenRow.RegimenComparator());
public Set<EncounterTransaction.Concept> getHeaders() {
return headers;
}.................
We are planning to add a method in TreatmentRegimen to set rows (overloading method) along with a comparator like this.
As per the @angshuonline this new method(when called from Groovy) will change the order of the regimen rows which is like anti-pattern i.e. changing the state of the passed in parameter.
I feel groovy extension in bahmni is meant for it, it is up to the groovy writers to do whatever they want with the object passed. I hope that is the reason why groovy extension is called as last point in our controllers Eg: ObsToObsFlowSheetController, DrugOGramController