Stream: conformance
Topic: Adding Narrative Templates to IG
Simone Heckmann (Feb 24 2020 at 14:23):
We currently have a need to add Narrative Templates to an IG which are supposed to be mandatory for all implementers .
The customer is currently considering XSLT. But since we neet to generate narrative for a composition and the entries have multiple extensions, I'm afraid that navigating through the Bundle with XPath will be extremely cumbersome.
Are there any available alternatives? At least some sort of narrative templating that is supported by both the Java and the .NET libraries...?
Jose Costa Teixeira (Feb 24 2020 at 18:46):
Can you give an example of what a narrative template would do?
Lloyd McKenzie (Feb 24 2020 at 18:47):
Grahame has support or narrative templates that use Liquid. Would that work for you?
Simone Heckmann (Feb 24 2020 at 20:52):
@Jose Costa Teixeira there‘d be a fixed html representation for a FHIR document that all implementations need to adhere to.
@Lloyd McKenzie we‘be been looking at liquid language and that’s the most interesting candidate so far. But we‘be been wondering how implementers using HAPI or the .Net libraries could leverage that...
Lloyd McKenzie (Feb 24 2020 at 20:54):
@Grahame Grieve, @James Agnew, @Michel Rutten
Grahame Grieve (Feb 24 2020 at 20:58):
the engine is built into HAPI. I don't know anything about dotnet in that regard
James Agnew (Feb 24 2020 at 21:25):
FWIW Liquid isn't too hard to manually code.. Not completely trivial but it's certainly conceivable that a basic implementation could be written in dotnet. Marten (from Firely) and I did a POC at one point, before Grahame did a better one :)
I guess the big challenge is that we haven't actually documented this "liquid+fhirpath" format anywhere. I love the idea of using (especially compared to XSLT.. shudder :p ) but without some documentation there's no guarantee that Java / .NET / anything else would actually behave consistently
Grahame Grieve (Feb 24 2020 at 21:30):
well, there is documentation - see https://confluence.hl7.org/display/FHIR/FHIR+Liquid+Profile
And test cases: https://github.com/FHIR/fhir-test-cases/blob/master/r4/liquid/liquid-tests.json
Grahame Grieve (Feb 24 2020 at 21:31):
and all that is already in HAPI
Grahame Grieve (Feb 24 2020 at 21:31):
and Liquid is relatively trivial if you have a nice FHIRPath implementation sitting around, since that does all the heavy lifting. Otherwise... not so simple
James Agnew (Feb 24 2020 at 21:34):
I stand corrected, I was not aware of that confluence page. That's awesome.
Eric Haas (Feb 25 2020 at 01:51):
I use Jinja2 and a little Python to suck up a package and spit it out with a custom CapabilityStatement Narrative. ( Jinja has a lot more functionality that liquid like being able to use all the class methods and creating custom filters and it is Python. But liquid could do the trick too. )
Marten Smits (Feb 25 2020 at 12:42):
James Agnew said:
FWIW Liquid isn't too hard to manually code.. Not completely trivial but it's certainly conceivable that a basic implementation could be written in dotnet. Marten (from Firely) and I did a POC at one point, before Grahame did a better one :)
I guess the big challenge is that we haven't actually documented this "liquid+fhirpath" format anywhere. I love the idea of using (especially compared to XSLT.. shudder :p ) but without some documentation there's no guarantee that Java / .NET / anything else would actually behave consistently
Yeah, we meant to call it liquifhir. Cool that there's documentation now for this. I'll go take a look at it as well
Simone Heckmann (Feb 27 2020 at 11:01):
Is there documentation somewhere about how to use this in HAPI?
Simone Heckmann (Feb 27 2020 at 11:05):
Our use case requires that we have interoperable narrative templates, so the minimum requirement would be that they are useable both for .NET as well as HAPI developers...
So what I gather is that currently we have two competing implementations in HAPI (Liquid and Thymeleaf) but none in .NET, is that correct?
Is it the consensus that Liquid is the way to move forward?
Simone Heckmann (Feb 27 2020 at 11:21):
I noticed that the documentation repeatedly uses examples with uneven braces, e.g. {{ expression ]}
Is that on purpose?
Grahame Grieve (Feb 27 2020 at 12:07):
possibly a markdown limitation?
Grahame Grieve (Feb 27 2020 at 12:09):
it was, with a comment, but it's not necessary on Confluence, so I fixed it up
Brian Postlethwaite (Mar 10 2020 at 08:11):
My dotnet implementation is using Razor Templates. Though that very much isn't cross platform.
Brian Postlethwaite (Mar 10 2020 at 08:13):
@Grahame Grieve did you implement a Liquid parser, or interfacing to the Ruby gem for this?
Grahame Grieve (Mar 10 2020 at 08:57):
sure it's fully implemented in the IG publisher, and part of HAPI core
Brian Postlethwaite (Mar 10 2020 at 12:00):
Cool, I'll take a peek sometime.
Brian Postlethwaite (Mar 10 2020 at 12:01):
Is there a way to feed custom narrative templates to the publisher?
(or is it just compiled in)
Grahame Grieve (Mar 10 2020 at 18:06):
yes you can
Grahame Grieve (Mar 10 2020 at 18:15):
you specify the liquid path (using liquid
in the path
object of the json config file, or the parameter path-liquid
of the implementation guide resource). In that folder is a series of .liquid files, where the name of the file is [type].liquid, and that liquid template will be used for resources of [type]. Use this spec: https://confluence.hl7.org/display/FHIR/FHIR+Liquid+Profile
Lloyd McKenzie (Mar 10 2020 at 18:24):
Have we thought at all about the possibility of multiple templates per resource type - perhaps driven by profile? E.g. different template for lab than vital signs? (Not sure how critical that is as not sure how easy/hard it is to create a single liquid template that works well for both.)
Grahame Grieve (Mar 10 2020 at 18:47):
I thought about it, but I didn't do anything about it
Jose Costa Teixeira (Mar 10 2020 at 21:41):
Lloyd McKenzie said:
Have we thought at all about the possibility of multiple templates per resource type - perhaps driven by profile?
you mean we could have different templates in the same ig? I'd like that.
Jose Costa Teixeira (Mar 10 2020 at 21:42):
By resource type - could we have it in a way that StructureDefs for Profiles and for Logical Models would be different?
Jose Costa Teixeira (Mar 10 2020 at 21:43):
or equivalently, a CarePlan instance for profile 1 would have a different template than for profile 2?
Lloyd McKenzie (Mar 10 2020 at 22:42):
This is different liquid templates - and you can do that by resource type already. The question was whether we could do it by profile
Grahame Grieve (Mar 10 2020 at 22:43):
we can put it on the todo list but no one is really using them yet
Last updated: Apr 12 2022 at 19:14 UTC