OCL/Iniz: New Documentation: How to add your Dictionaries to your config, AND support offline sites

Thanks to @ibacher, @suruchi, @ruhanga and @mseaton, Initializer now supports an /ocl config folder. I’m finding this very useful, because (1) it means I don’t have to keep re-subscribing to collections if our demo server goes down, (2) it means our 3.x RefApp is ready-to-go with demo concept collections (see here), and (3) offline sites can be set up with concepts originally created in OCL, without needing an internet connection.

@aojwang @christine @moshon @ssmusoke @eudson @samuel34 I thought you’d all be especially interested in this.

Documentation

Video Tutorial:

4 Likes

Is Iniz currently able to read files within an OpenMRS module or do we always have to deploy files into a folder on the file system rather than in the resources folder of an api sub-module

By design, Initializer only reads files from the configuration directory in the OpenMRS Application Directory. Bundling metadata into modules is, of course, a way to get a module quickly working, but it reduces the reusability of the module itself. The discussions around “packaging” represent the sort of evolving notion of how we can bundle up both metadata with executable code. Ideally, packaging and a reliance on more generic methods for concept identification (like using concept maps in place of concept UUIDs) will help us get to a better state.

2 Likes

@ibacher In our case packaging is centralized as the concepts are packaged once for distribution within a WAR file so sites do not have to create and manage a configuration folder or file

You could always add functionality to your module activator to expand whatever resources it wants loaded to the configuration folder in the app directory. Iniz doesn’t do anything until it’s module activator is called which is usually quite late in the initialization process, since Iniz depends on most other modules.

1 Like

At PIH we control the invocation of Initializer loading programmatically, to ensure that it is done at a specific time in the module loading process, that certain domains are loaded in certain ways, with certain validation rules, and that some custom metadata loading can be interspersed in the process. So as @ibacher points out @ssmusoke , you can use Iniz and still retain the control you want from within your own modules and distribution startup process.

1 Like

@mseaton Is there a code link I can look at, I suspect I may be overthinking it also

@ssmusoke you first need to tell initializer not to load automatically at startup by setting the initializer.startup.load=disabled runtime property ( see here: openmrs-module-initializer/rtprops.md at master · mekomsolutions/openmrs-module-initializer · GitHub).

Then, you can do whatever you need to do in code to move CSVs from your module resources into the configuration directory and then invoke initializer loading programmatically like we do here:

3 Likes

@mksd @mksrom How can I set Iniz not to start as I already have a runtime properties file created and cannot hand-edit it? Is there another option like a global property?

Hi @ssmusoke, you could probably pass the property at startup i.e.

-Dinitializer.startup.load=disabled

Correct @ruhanga . @ssmusoke from the README:

As an alternative or complement to runtime properties, any property may also be specified as a system property. The order of precedence if both are used on the same system is that any property set via a system property will override any value set as a runtime property. If a system property is specified with an empty value, this will also override the runtime property with this empty value.

Runtime properties can be specified at server startup with -DpropertyName=propertyValue. They can also be specified in SDK environments by adding these properties to one’s openmrs-server.properties file

@ruhanga I cannot try to make this change for 1,300 installations

@ssmusoke, I’d think that hooking into one of your custom module’s activation lifecycle might suffice for you, adding something along the following lines - maybe in it’s willStart() hook.

Properties props = Context.getRuntimeProperties();
props.putIfAbsent("initializer.startup.load", "disabled");
Context.setRuntimeProperties(props);
2 Likes

@ruhanga Now you are talking

@solemabrothers FYA