FML: strip '-' from rules names when parsing

This commit is contained in:
Grahame Grieve 2024-04-03 20:11:40 +11:00
parent 2c6f1b6a59
commit a8b40a3946
2 changed files with 10 additions and 2 deletions

View File

@ -401,7 +401,7 @@ public class FmlParser extends ParserBase {
if (newFmt) {
if (lexer.isConstant()) {
if (lexer.isStringConstant()) {
rule.makeElement("name").markLocation(lexer.getCurrentLocation()).setValue(lexer.readConstant("ruleName"));
rule.makeElement("name").markLocation(lexer.getCurrentLocation()).setValue(fixName(lexer.readConstant("ruleName")));
} else {
rule.makeElement("name").markLocation(lexer.getCurrentLocation()).setValue(lexer.take());
}
@ -417,6 +417,10 @@ public class FmlParser extends ParserBase {
}
}
private String fixName(String c) {
return c.replace("-", "");
}
private void parseRuleReference(Element rule, FHIRLexer lexer) throws FHIRLexerException {
Element ref = rule.addElement("dependent").markLocation(lexer.getCurrentLocation());
ref.makeElement("name").markLocation(lexer.getCurrentLocation()).setValue(lexer.take());

View File

@ -990,7 +990,7 @@ public class StructureMapUtilities {
if (newFmt) {
if (lexer.isConstant()) {
if (lexer.isStringConstant()) {
rule.setName(lexer.readConstant("ruleName"));
rule.setName(fixName(lexer.readConstant("ruleName")));
} else {
rule.setName(lexer.take());
}
@ -1009,6 +1009,10 @@ public class StructureMapUtilities {
}
}
private String fixName(String c) {
return c.replace("-", "");
}
private boolean isSimpleSyntax(StructureMapGroupRuleComponent rule) {
return
(rule.getSource().size() == 1 && rule.getSourceFirstRep().hasContext() && rule.getSourceFirstRep().hasElement() && !rule.getSourceFirstRep().hasVariable()) &&