Assigning a default report template for each analysis profile

Hi everyone, I have an active installation of Senaite 2.3.0 and senaite.impress 2.3.0. Currently we have 5 analysis profiles, and each profile has its corresponding custom report template. When we publish a report, we have to select the right template using the dropdown menu. This process of manually selecting the template is error-prone, and we hope to automate the selection of report template. Could anyone point us to where we should modify to implement the automatic selection of report template, based on the sample’s analysis profile?

Off the top of my head, I know that there is a default template kept in the Impress control panel which I presume is used when the report view is loaded. I would look for where that is used in the code and see if the analysis profile is available and intervene there instead of selecting the default template. You could customize the analysis profile and add a field to store template name. Alternatively the content registry is an easy place to store the relationship between profile and the template name. My 2c.