Stream: shorthand
Topic: RuleSet containig parameter with closing bracket fails
Christian Nau (Apr 28 2021 at 06:39):
Hello,
I'm using RuleSets for simplifying Questionnaire-Definitions, so I can remove repetitive code from the item definitions.
I found a bug where RuleSet
-paramaters cannot have values containing closing brackets )
.
RuleSet: Question(linkId, title)
* item[+].linkId = "{linkId}"
* item[=].type = #string
* item[=].text = {title}
Instance: MyQuestionnaire
InstanceOf: Questionnaire
Title: "My Questionnaire"
Usage: #definition
Description: "An example for bug report."
* status = #active
* date = 2021-04-27
* publisher = "Me"
* id = "my-questionnaire"
* subjectType = #Patient
* title = "My Questionnaire"
* name = "MyQuestionnaire"
* purpose = "An example for bug report."
// this works:
* insert Question(link1, "Some text (without closing bracket?")
// this fails:
* insert Question(link2, "Some text (with closing bracket)?")
// use this for a workaround of above issue:
/*
* insert Question(link2, "overwriteme")
* item[=].text = "Some text (with closing bracket)?"
*/
This will lead to sushi output with error error extraneous input '?")' expecting {<EOF>, KW_ALIAS, KW_PROFILE, KW_EXTENSION, KW_INSTANCE, KW_INVARIANT, KW_VALUESET, KW_CODESYSTEM, KW_RULESET, KW_MAPPING, KW_LOGICAL, KW_RESOURCE}
See my example here: https://fshschool.org/FSHOnline/#/share/2R6t7pK
Christian Nau (Apr 28 2021 at 06:41):
What is strange for me, that this only fails when using rulesets. If I set any text field directly to a value containing a closing bracket, everything is fine.
Nick Freiter (Apr 28 2021 at 13:06):
In this case, I believe SUSHI treats )
like a special character, so if you want to include it in a parameter, escaping it with \
should do the trick. Here is a very slightly modified version of the example you set: https://fshschool.org/FSHOnline/#/share/3nrI5CA. Note that there I've escaped the )
, and it runs without error.
Christian Nau (Apr 28 2021 at 13:16):
Thank you @Nick Freiter ! Worked for me.
I'm wondering why one needs to escape )
in strings when using in rule sets but when I try escaping them without using rulesets, it will fail. Strange.
But thanks for your solution!
Nick Freiter (Apr 28 2021 at 13:20):
I believe it is because SUSHI is very permissive in what it accepts as params to a RuleSet. It basically accepts any and all characters in any order. So the characters that split apart and contain those parameters ,
and ()
need special treatment.
Last updated: Apr 12 2022 at 19:14 UTC