Avoid infinite loop when validating misaligned questionnaireresponseitems
This commit is contained in:
parent
a6b0cb2a6e
commit
94f0520982
|
@ -2759,7 +2759,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (qItem != null) {
|
if (qItem != null) {
|
||||||
rule(errors, IssueType.STRUCTURE, item.line(), item.col(), stack.getLiteralPath(), index > -1, "Structural Error: item is in the wrong place");
|
rule(errors, IssueType.STRUCTURE, item.line(), item.col(), stack.getLiteralPath(), index > -1, "Structural Error: item is in the wrong place");
|
||||||
NodeStack ns = stack.push(item, -1, null, null);
|
NodeStack ns = stack.push(item, -1, null, null);
|
||||||
validateQuestionannaireResponseItem(qsrc, qItem, errors, element, ns, inProgress, null);
|
validateQuestionannaireResponseItem(qsrc, qItem, errors, item, ns, inProgress, questionnaireResponseRoot);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rule(errors, IssueType.NOTFOUND, item.line(), item.col(), stack.getLiteralPath(), index > -1, "LinkId \""+linkId+"\" not found in questionnaire");
|
rule(errors, IssueType.NOTFOUND, item.line(), item.col(), stack.getLiteralPath(), index > -1, "LinkId \""+linkId+"\" not found in questionnaire");
|
||||||
|
|
|
@ -431,7 +431,28 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
|
|
||||||
String reference = qr.getQuestionnaire().getReference();
|
String reference = qr.getQuestionnaire().getReference();
|
||||||
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
||||||
|
|
||||||
ValidationResult errors = myVal.validateWithResult(qr);
|
ValidationResult errors = myVal.validateWithResult(qr);
|
||||||
|
|
||||||
|
assertThat(errors.toString(), Matchers.not(containsString("No issues")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGivenQuestionnaireResponseHasSiblingItemsWhenTheyShouldBeChildItems() throws Exception {
|
||||||
|
Questionnaire q = new Questionnaire();
|
||||||
|
QuestionnaireItemComponent item = q.addItem().setLinkId("link0").setRequired(true).setType(QuestionnaireItemType.GROUP);
|
||||||
|
item.addItem().setLinkId("link1").setRequired(true).setType(QuestionnaireItemType.STRING);
|
||||||
|
|
||||||
|
QuestionnaireResponse qr = new QuestionnaireResponse();
|
||||||
|
qr.setStatus(QuestionnaireResponseStatus.COMPLETED);
|
||||||
|
qr.getQuestionnaire().setReference("http://example.com/Questionnaire/q1");
|
||||||
|
qr.addItem().setLinkId("link0").setText("Text");
|
||||||
|
qr.addItem().setLinkId("link1").addAnswer().setValue(new StringType("Answer"));
|
||||||
|
String reference = qr.getQuestionnaire().getReference();
|
||||||
|
when(myValSupport.fetchResource(any(FhirContext.class), eq(Questionnaire.class), eq(reference))).thenReturn(q);
|
||||||
|
|
||||||
|
ValidationResult errors = myVal.validateWithResult(qr);
|
||||||
|
|
||||||
assertThat(errors.toString(), Matchers.not(containsString("No issues")));
|
assertThat(errors.toString(), Matchers.not(containsString("No issues")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue