Clean up enableWhen testing in validator for Questionnaire resources
This commit is contained in:
parent
ed22a46775
commit
2176e7c64d
|
@ -218,7 +218,9 @@ public class InstantType extends BaseDateTimeType {
|
|||
|
||||
@Override
|
||||
public InstantType copy() {
|
||||
return new InstantType(getValue());
|
||||
InstantType ret = new InstantType();
|
||||
ret.setValueAsString(getValueAsString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,7 +218,9 @@ public class InstantType extends BaseDateTimeType {
|
|||
|
||||
@Override
|
||||
public InstantType copy() {
|
||||
return new InstantType(getValueAsString());
|
||||
InstantType ret = new InstantType();
|
||||
ret.setValueAsString(getValueAsString());
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,7 +218,8 @@ public class InstantType extends BaseDateTimeType {
|
|||
|
||||
@Override
|
||||
public InstantType copy() {
|
||||
InstantType ret = new InstantType(getValueAsString());
|
||||
InstantType ret = new InstantType();
|
||||
ret.setValueAsString(getValueAsString());
|
||||
copyValues(ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -686,8 +686,9 @@ public class ResourceFactory extends Factory {
|
|||
case 116076: return new UriType();
|
||||
case 116079: return new UrlType();
|
||||
case 3601339: return new UuidType();
|
||||
case 114035747: return new XhtmlType();
|
||||
default:
|
||||
throw new FHIRException("Unknown Resource or Type Name '"+name+"'");
|
||||
throw new FHIRException("Unknown Resource or Type Name '"+name+"': " + name.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ public class XhtmlType extends Element {
|
|||
}
|
||||
|
||||
public XhtmlType() {
|
||||
this(new Narrative());
|
||||
// "<div xmlns=\""+FormatUtilities.XHTML_NS+"\"></div>"
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,8 @@ public class InstantType extends BaseDateTimeType {
|
|||
|
||||
@Override
|
||||
public InstantType copy() {
|
||||
InstantType ret = new InstantType(getValueAsString());
|
||||
InstantType ret = new InstantType();
|
||||
ret.setValueAsString(getValueAsString());
|
||||
copyValues(ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>1.18</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -149,16 +149,22 @@ public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively look for answers to questions with the given link id
|
||||
*/
|
||||
private List<Element> findQuestionAnswers(Element questionnaireResponse, String question) {
|
||||
List<Element> matchingItems = questionnaireResponse.getChildren(ITEM_ELEMENT)
|
||||
.stream()
|
||||
.flatMap(i -> findSubItems(i).stream())
|
||||
.filter(i -> hasLinkId(i, question))
|
||||
.collect(Collectors.toList());
|
||||
return matchingItems
|
||||
.stream()
|
||||
.flatMap(e -> extractAnswer(e).stream())
|
||||
.collect(Collectors.toList());
|
||||
List<Element> retVal = new ArrayList<>();
|
||||
|
||||
List<Element> items = questionnaireResponse.getChildren(ITEM_ELEMENT);
|
||||
for (Element next : items) {
|
||||
if (hasLinkId(next, question)) {
|
||||
List<Element> answers = extractAnswer(next);
|
||||
retVal.addAll(answers);
|
||||
}
|
||||
retVal.addAll(findQuestionAnswers(next, question));
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private List<Element> extractAnswer(Element item) {
|
||||
|
@ -197,14 +203,6 @@ public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
private List<Element> findSubItems(Element item) {
|
||||
List<Element> results = item.getChildren(LINKID_ELEMENT)
|
||||
.stream()
|
||||
.flatMap(i -> findSubItems(i).stream())
|
||||
.collect(Collectors.toList());
|
||||
results.add(item);
|
||||
return results;
|
||||
}
|
||||
|
||||
private boolean hasLinkId(Element item, String linkId) {
|
||||
Element linkIdChild = item.getNamedChild(LINKID_ELEMENT);
|
||||
|
|
|
@ -149,16 +149,22 @@ public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively look for answers to questions with the given link id
|
||||
*/
|
||||
private List<Element> findQuestionAnswers(Element questionnaireResponse, String question) {
|
||||
List<Element> matchingItems = questionnaireResponse.getChildren(ITEM_ELEMENT)
|
||||
.stream()
|
||||
.flatMap(i -> findSubItems(i).stream())
|
||||
.filter(i -> hasLinkId(i, question))
|
||||
.collect(Collectors.toList());
|
||||
return matchingItems
|
||||
.stream()
|
||||
.flatMap(e -> extractAnswer(e).stream())
|
||||
.collect(Collectors.toList());
|
||||
List<Element> retVal = new ArrayList<>();
|
||||
|
||||
List<Element> items = questionnaireResponse.getChildren(ITEM_ELEMENT);
|
||||
for (Element next : items) {
|
||||
if (hasLinkId(next, question)) {
|
||||
List<Element> answers = extractAnswer(next);
|
||||
retVal.addAll(answers);
|
||||
}
|
||||
retVal.addAll(findQuestionAnswers(next, question));
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private List<Element> extractAnswer(Element item) {
|
||||
|
@ -197,14 +203,6 @@ public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
private List<Element> findSubItems(Element item) {
|
||||
List<Element> results = item.getChildren(ITEM_ELEMENT)
|
||||
.stream()
|
||||
.flatMap(i -> findSubItems(i).stream())
|
||||
.collect(Collectors.toList());
|
||||
results.add(item);
|
||||
return results;
|
||||
}
|
||||
|
||||
private boolean hasLinkId(Element item, String linkId) {
|
||||
Element linkIdChild = item.getNamedChild(LINKID_ELEMENT);
|
||||
|
|
Loading…
Reference in New Issue