Restricting the number of times an observation template can be added

Hi, I’m trying to restrict the number of times that an observation template can be added. For example in the End-TB configuration trying to save a second Baseline template will return the error: “Baseline template is already filled for this treatment”.

I’d like to be able to add a similar restriction to other observation templates. I couldn’t find any keys in the clinical app json files that looked like they controlled this behaviour. Is this behaviour configurable or is it coded into an omod? If the former, would appreciate some help on how to configure this.

Thanks

Hi Geoff, Searching for the code, looks like its done part of the endtb omod and even the form names are hard-coded :frowning:

I doubt if Bahmni provides a configuration for such validation, though it provides a hook EncounterDataPreSaveCommand which is used by this omod.
I would let someone confirm that there doesn’t exist a configuration for this in Bahmni. In case it’s important and urgent i can think of a couple of options for you

  1. modify this omod to add forms that you need to validate and rebuild and deploy it.
  2. Creating and deploying a new simple omod that has a Java class implementing the above mentioned interface/hook EncounterDataPreSaveCommand. In case you see more needs like this you can may be think of creating a custom omod for your implementation on similar lines as bahmniendtb omod.

Thanks @arjun. That’s good info and helpful to understand how this has been set up. I think the first option you outlined sounds feasible and will try it out when I get the chance.