FHIR Chat · Templates based on templates · IG creation

Stream: IG creation

Topic: Templates based on templates


view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:21):

The first pass of the template mechanism allows an IG to depend on a template. The chain stops there. However, I think we're going to need to have templates that depend on other templates. For example, a Da Vinci template that depends on an HL7 International template that depends on a FHIR-logo-authorized template that depends on a generic template. (The IHE template, CA template, AU template, etc. could all depend on the FHIR-logo-authorized template). I think this should be doable.

My proposed approach is to have the package.json of the template point to the package id of its "base" template. The IG publisher - when loading a template would first check to see if the current template has a base and then recursively grab that until it gets to the end of the chain - the template with no base. Then it would copy all of the contents of that template into the template folder. Then it would work its way backward until it copies across the contents of the originally referenced template. That way templates can overwrite/supplement files of the templates they're based on.

Does that sound reasonable?

view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:22):

If we don't allow templates to depend on other templates, then we're going to have the same forking problem we have now - just with a slightly smaller set of forks.

view this post on Zulip Grahame Grieve (Aug 03 2019 at 21:28):

I can see how this would work for static content. But I can't see how it would work for scripts

view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:43):

You could choose to totally overwrite a script, but more typically your new template would define a new script that would import/include the original script. The new template would point to the new script

view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:44):

Ant can import and build on other ant files. XSLT can inherit from other transforms. I believe Javascript can do the same.

view this post on Zulip Grahame Grieve (Aug 03 2019 at 21:45):

so the files would overwrite? and then the template processing would use the final surviving config.json?

view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:51):

Yes, it would use the final surviving config.json. I guess we could get fancier and write a merged config.json where you start with the original and then add defaults and scripts, overwriting if they exist, keeping those not overwritten. That would have the positive effect that if we turn on a new fragment type, it would auto-propagate

view this post on Zulip Grahame Grieve (Aug 03 2019 at 21:52):

yes I was worried this would lead to fancy bug-ridden ideas like that

view this post on Zulip Lloyd McKenzie (Aug 03 2019 at 21:58):

The alternative is that when we want to enhance the template to address some new capability or QA requirement, we're now looking at fixing 10+ different templates maintained in different locations


Last updated: Apr 12 2022 at 19:14 UTC