Stream: questionnaire
Topic: Restrict value set based on another answer
Elliot Silver (Oct 26 2020 at 05:36):
I have a questionnaire that includes questions for country and state/province. Is there a way to restrict the listed state/provinces based on which country is selected?
For country, the question is a choice from the ISO 3166-1-2 valueset (2 character country codes). For state/province, the question is a choice from the ISO 3166-2 valueset (three letter province codes prefixed by the appropriate two letter country code). This should make it easy to figure out which province codes belong to which country (all province codes XX-YYY belong to country code XX), but I can't see any way to filter a valueset in the questionnaire.
Lloyd McKenzie (Oct 26 2020 at 06:26):
The first question is whether the code system actually exposes the associated country code for the state code as a property. If it does, and your terminology service supports is, then you can get the property to come along in your value set expansion and have access to it and use answerExpression to adaptably define your answer set based on the answer to the country question. I don't know that our FHIR copy of 3166-2 does that though. @Grahame Grieve ?
Michael Lawley (Oct 26 2020 at 22:16):
I think it should. Much better than having people resort to code syntax hacking
Elliot Silver (Oct 26 2020 at 22:59):
I'm not sure 3166-2 does have these properties in ISO's definition. And I doubt the FHIR ValueSet does either. Using a terminology service and properties sounds like a very "elegant" way of solving the problem (read overly-complex), but it seems to me that simply being able to say give me codes from the specified value set that have the prefix of "code from of previous question" should be straight forward.
Lloyd McKenzie (Oct 26 2020 at 23:02):
I don't know if FHIRPath could do that, but presumably CQL could in answerExpression
Elliot Silver (Oct 26 2020 at 23:05):
That would be excellent. Time to brush up on CQL.
Lloyd McKenzie (Oct 27 2020 at 00:00):
If you get it working, feel free to contribute it as an example to the SDC spec :)
Brian Postlethwaite (Oct 27 2020 at 07:50):
I'll take a look too. That's roughly what I was trying at the connectathon.
Elliot Silver (Oct 29 2020 at 01:52):
Well, I'm stumped. Likely I'm just not seeing it because of my unfamiliarity with either FHIRPath or CQL, but I don't see anyway to manipulate the contents of a ValueSet/CodeSystem.
Lloyd McKenzie (Oct 29 2020 at 03:46):
@Bryn Rhodes @Paul Lynch
Paul Lynch (Oct 29 2020 at 12:18):
Do you have the expansion for the ValueSet? Then you could write an answerExpression like:
%valuesetExp.expansion.contains.where(code.startsWith(%stateCode))
Whether that will work depends in part on how picky your form rendering engine is, because it will return "contains" structures rather than Codings, which is what (strictly speaking) is required by the type. But, the essential field names in the two structures are the same (plus some extra stuff), so it might not care (as in the case of our JavaScript-based LHC-Forms renderer).
For future plans for a more proper way of transforming "contains" to "Coding", see J#29324.
Last updated: Apr 12 2022 at 19:14 UTC