FHIR Chat · relative dates and more generally interpolation? · shorthand

Stream: shorthand

Topic: relative dates and more generally interpolation?


view this post on Zulip Brian Kaney (Jul 16 2020 at 16:12):

We are finding a nice use for FSH to construct sample/demo/development fixtures. We would like to express the source with relative dates (not literal absolute). Is there presently (or plans to) support interpolation so we could store variables in FSH source and substitute with computed values during build time? This feature could help in other areas where we would like to have certain fields derivable.

view this post on Zulip Chris Moesel (Jul 16 2020 at 16:24):

I don't think we've thought of something like that, @Brian Kaney. That's an interesting idea! Are you thinking strict replacement of variables with provided values, or are you thinking some limited syntax for dynamic values too (like ${today() - 3 weeks})?

view this post on Zulip Lloyd McKenzie (Jul 16 2020 at 16:39):

We should think about what the equivalent would be in non-shorthand representations. Presumably some sort of extension instead of the value?

view this post on Zulip Jean Duteau (Jul 16 2020 at 16:41):

@Brian Kaney do you mean that, every time you regenerated your guide, that the examples would have values that would change based on the computation?

view this post on Zulip Chris Moesel (Jul 16 2020 at 16:43):

I don't think this makes as much sense for IG development. My understanding was that Brian is using it for other things (not IGs). And my understanding was that it gets resolved at SUSHI compile-time, so once you get to the formal FHIR representations, the variable/expression is gone.

view this post on Zulip Jean Duteau (Jul 16 2020 at 16:44):

sure, i was using "guide" in a more general sense. :) I just wanted to confirm that because if it using FSH to generate FHIR artifacts outside of a guide context, then Lloyd's question might not be relevant.

view this post on Zulip Chris Moesel (Jul 16 2020 at 16:45):

Right -- I was thinking Brian was suggesting it happen at SUSHI compile time. But... if @Lloyd McKenzie is interested in using extensions for dynamic values (esp. relative dates), I believe that @Bryn Rhodes has implemented something like that to support CQL testing w/ FHIR patients that should be a certain age, etc.

view this post on Zulip Jose Costa Teixeira (Jul 16 2020 at 17:21):

I would appreciate something like that for generating test data. A couple of simple functions, ideally a lookup function, and we could use sushi to generate a lot of instances at once

view this post on Zulip Lloyd McKenzie (Jul 16 2020 at 17:27):

FHIR-I has a back-burner initiative to allow generation of 'templated' examples (for situations where we might want to have 50+ example instances to demonstrate a given scenario). Date generation would be part of that. A key thing for me with FSH is that as "shorthand", it should still be possible to express the same content without losing information.

view this post on Zulip Jose Costa Teixeira (Jul 16 2020 at 17:47):

Lloyd McKenzie said:

We should think about what the equivalent would be in non-shorthand representations. Presumably some sort of extension instead of the value?

and the value would be empty? Or some sort of magic value?

view this post on Zulip Lloyd McKenzie (Jul 16 2020 at 18:38):

omitted. You can have an extension instead of a value

view this post on Zulip Brian Kaney (Jul 16 2020 at 18:55):

The use-case in a IG might be coordination/computation of name, url, and version (during publish-time). I imagine there could be other patterns like this for IGs. However, our use-case presently regarding dates is outside IGs.

Here is the process we roughly have:

FSH.template --( interpolate )--> FSH --( sushi )--> FHIR JSON

We find this sort of thing super useful, so I though I would share as others might think an interpolation syntax in FSH would be swimmingly.

view this post on Zulip John Silva (Jul 16 2020 at 19:11):

Is there something in FHIRPath that can be used to represent 'relative dates' , e.g. https://build.fhir.org/ig/FHIR/fluentpath/#datetime-arithmetic

view this post on Zulip Chris Moesel (Jul 16 2020 at 19:24):

John Silva said:

Is there something in FHIRPath that can be used to represent 'relative dates'

Yes, in fact the example I used above (today() - 3 weeks) is valid FHIRPath already. If we wanted to support dynamic expressions for interpolation, I'd definitely try to borrow from FHIRPath and CQL as much as possible.

view this post on Zulip John Silva (Jul 17 2020 at 00:31):

This (relative dates) would be a great help for using FSH (and SUSHI) for demo data. It might be useful to have other 'computable values', e.g. a valueDecimal as a random(x .. y) or randomized valueStrings, codes (valueCodableConcept) from a set of values, again, maybe randomly choosing one of N specified, etc. This could be useful not only for populating 'demo data' but also testing with different datasets.

view this post on Zulip Keith Boone (Jul 17 2020 at 12:01):

I like the idea of being able to write a guide using both Relative dates, and some computational capabilities. We are storing a good bit of test data in FSH format for the SANER Project, in some cases, to make it relevant, only the dates need to be adjusted, in others, we want to be able to load up some constrained random data values. I could see doing some of that with a preprocessor as well though.

view this post on Zulip Bryn Rhodes (Jul 22 2020 at 20:30):

Yes, we do this with the cqf-expression extension today, providing dynamic values for our test cases so that they remain current. It introduces a pre-processing step into the test pipeline, but it's super useful for tests that rely on the moving point now.


Last updated: Apr 12 2022 at 19:14 UTC