@mksd - good quesiton, I agree this is needed. I don’t think there is a good way to do this currently.
Around a year ago I found that we had the same need, and I started spiking on a solution within the addresshierarchy module. I believe this is where the solution belongs, so it can be available to any downstream distribution. Unfortunately, I never finished it, I can’t find any ticket for it, and I can’t remember why or exactly how complete it is. I think I may have held it back since I did not yet have a good solution implemented for determining if the hierarchy has changed between system restarts (eg. if it needs to be reloaded fresh or not). It’s possible that it is largely done aside from that.
In any event, the code that I started to write is sitting in a branch called “configuration” in the addresshierarchy module in github. Here is the branch and the relevant commit.
It’d be great if you have a few cycles to have a look at what I started, see if it makes any sense, and take it over the finish line. It does a bit more than just addresshierarchy configuration - it also configures the address template fields needed for core (since these tend to be inextricably related, and have overlapping configurations). As I mention above, I think it’s pretty close to being useful.
Also, for some context, I posted this related thread around the same time, as a more general discussion of file-based OpenMRS configuration, as it is a bit of a wild west without many existing conventions to govern it, yet is being used more.
Happy to work with you on this, and to continue on the conversations.