more debugging for questionnaire validation

This commit is contained in:
Grahame Grieve 2019-03-18 13:29:36 +11:00
parent d2734245b7
commit c8c815aa44
2 changed files with 17 additions and 2 deletions

View File

@ -292,5 +292,18 @@ import com.google.gson.JsonObject;
return npm.get("canonical").getAsString();
}
public InputStream loadResource(String type, String id) throws IOException {
String file = type+"-"+id+".json";
if (content.containsKey("package/"+file))
return new ByteArrayInputStream(content.get("package/"+file));
else {
File f = new File(Utilities.path(path, "package", file));
if (f.exists())
return new FileInputStream(f);
else
return null;
}
}
}

View File

@ -2959,12 +2959,14 @@ private boolean isAnswerRequirementFulfilled(QuestionnaireItemComponent qItem, L
}
public void validateQuestionannaireResponseItem(Questionnaire qsrc, List<ValidationMessage> errors, Element element, NodeStack stack, boolean inProgress, Element questionnaireResponseRoot, QuestionnaireItemComponent qItem, List<Element> mapItem) {
boolean enabled = myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot);
if (mapItem != null){
rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot), "Item has answer, even though it is not enabled (item id = '"+qItem.getLinkId()+"')");
if (!enabled)
rule(errors, IssueType.INVALID, element.line(), element.col(), stack.getLiteralPath(), enabled, "Item has answer, even though it is not enabled (item id = '"+qItem.getLinkId()+"')");
validateQuestionannaireResponseItem(qsrc, qItem, errors, mapItem, stack, inProgress, questionnaireResponseRoot);
} else {
//item is missing, is the question enabled?
if (myEnableWhenEvaluator.isQuestionEnabled(qItem, questionnaireResponseRoot) && qItem.getRequired()) {
if (enabled && qItem.getRequired()) {
rule(errors, IssueType.REQUIRED, element.line(), element.col(), stack.getLiteralPath(), false, "No response found for required item (item id = '"+qItem.getLinkId()+"')");
}
}