fix error in FML parser parsing parameters

This commit is contained in:
Grahame Grieve 2023-09-20 11:14:31 +10:00
parent bf00cc17b4
commit 96469972de
2 changed files with 4 additions and 2 deletions

View File

@ -1335,7 +1335,7 @@ public class Element extends Base {
for (Property p : property.getChildProperties(this.name, type)) {
if (p.getName().equals(name)) {
if (!p.isList()) {
if (!p.isList() && hasChild(name)) {
throw new Error(name+" on "+this.name+" is not a list, so can't add an element");
}
Element ne = new Element(name, p);

View File

@ -571,7 +571,9 @@ public class FmlParser extends ParserBase {
private void parseParameter(Element ref, FHIRLexer lexer) throws FHIRLexerException, FHIRFormatError {
boolean r5 = VersionUtilities.isR5Plus(context.getVersion());
String name = r5 ? "parameter" : "variable";
if (!lexer.isConstant()) {
if (ref.hasChildren(name) && !ref.getChildByName(name).isList()) {
throw lexer.error("variable on target is not a list, so can't add an element");
} else if (!lexer.isConstant()) {
ref.addElement(name).markLocation(lexer.getCurrentLocation()).makeElement(r5 ? "valueId" : "value").setValue(lexer.take());
} else if (lexer.isStringConstant())
ref.addElement(name).markLocation(lexer.getCurrentLocation()).makeElement(r5 ? "valueString" : "value").setValue(lexer.readConstant("??"));