Unit tests up to date and maybe we need to use r4 path

This commit is contained in:
Eeva Turkka 2018-11-02 15:54:34 +02:00 committed by Matti Uusitalo
parent 84c02d2e79
commit 69d9e5d2b2
6 changed files with 150 additions and 17 deletions

View File

@ -11,7 +11,7 @@
<artifactId>hapi-fhir-converter</artifactId>
<packaging>bundle</packaging>
<version>3.5.1-PHRFIX-SNAPSHOT</version>
<version>3.6.1-PHRFIX-SNAPSHOT</version>
<dependencies>
<dependency>
@ -85,7 +85,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -11,7 +11,7 @@
<artifactId>hapi-fhir-validation</artifactId>
<packaging>bundle</packaging>
<version>3.5.1-PHRFIX-SNAPSHOT</version>
<version>3.6.1-PHRFIX-SNAPSHOT</version>
<name>HAPI FHIR - Validation</name>
@ -19,17 +19,17 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-utilities</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-converter</artifactId>
<version>3.5.1-PHRFIX-SNAPSHOT</version>
<version>3.6.1-PHRFIX-SNAPSHOT</version>
</dependency>
<dependency>
@ -64,49 +64,49 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r4</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<optional>true</optional>
</dependency>
@ -119,13 +119,13 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-server</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-client</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -36,6 +36,8 @@ import org.hl7.fhir.dstu3.model.Type;
import org.hl7.fhir.dstu3.model.UriType;
import org.hl7.fhir.dstu3.model.ValueSet;
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.instance.validation.DefaultEnableWhenEvaluator;
import org.hl7.fhir.instance.validation.IEnableWhenEvaluator;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;

View File

@ -0,0 +1,110 @@
package org.hl7.fhir.instance.validation;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemEnableWhenComponent;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.dstu3.model.QuestionnaireResponse;
import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent;
import org.hl7.fhir.r4.elementmodel.Element;
public class DefaultEnableWhenEvaluator implements IEnableWhenEvaluator {
@Override
public boolean isQuestionEnabled(QuestionnaireItemComponent item, List<QuestionnaireResponseItemComponent> resp) {
boolean enabled = true;
if(item.hasEnableWhen()) {
enabled = false;
for( QuestionnaireItemEnableWhenComponent enable : item.getEnableWhen()) {
if(enable.getHasAnswer()) {
// check if referenced question has answer
String itemId = enable.getQuestion();
for(QuestionnaireResponseItemComponent respItem : resp) {
if(respItem.getLinkId().equalsIgnoreCase(itemId) && respItem.hasAnswer()) {
//TODO check answer value
enabled = true;
}
}
} else {
// and if not
String itemId = enable.getQuestion();
for(QuestionnaireResponseItemComponent respItem : resp) {
if(respItem.getLinkId().equalsIgnoreCase(itemId) && !respItem.hasAnswer()) {
//TODO check answer value
enabled = true;
}
}
}
}
}
return enabled;
}
@Override
public boolean isQuestionEnabled(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent item,
Element element) {
boolean enabled = true;
if(item.hasEnableWhen()) {
enabled = false;
for( org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemEnableWhenComponent enable : item.getEnableWhen()) {
if(enable.hasAnswer()) {
// check if referenced question has answer
String itemId = enable.getQuestion();
List<Element> items = new ArrayList<Element>();
element.getNamedChildren("item", items);
for(Element respItem : items) {
// TODO toteuta uudelleen
}
} else {
// and if not
String itemId = enable.getQuestion();
List<Element> items = new ArrayList<Element>();
element.getNamedChildren("item", items);
for(Element respItem : items) {
}
}
}
}
return enabled;
}
}

View File

@ -0,0 +1,18 @@
package org.hl7.fhir.instance.validation;
import java.util.List;
import org.hl7.fhir.dstu3.model.Questionnaire.QuestionnaireItemComponent;
import org.hl7.fhir.dstu3.model.QuestionnaireResponse;
import org.hl7.fhir.dstu3.model.QuestionnaireResponse.QuestionnaireResponseItemComponent;
import org.hl7.fhir.r4.elementmodel.Element;
public interface IEnableWhenEvaluator {
public boolean isQuestionEnabled(QuestionnaireItemComponent item, List<QuestionnaireResponseItemComponent> theResponseItems);
public boolean isQuestionEnabled(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent qItem,
Element element);
}

View File

@ -5,11 +5,15 @@ import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.exceptions.*;
import org.hl7.fhir.convertors.VersionConvertorConstants;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.PathEngineException;
import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.instance.validation.DefaultEnableWhenEvaluator;
import org.hl7.fhir.instance.validation.IEnableWhenEvaluator;
import org.hl7.fhir.r4.conformance.ProfileUtilities;
import org.hl7.fhir.r4.context.IWorkerContext;
import org.hl7.fhir.r4.context.IWorkerContext.ValidationResult;
@ -201,7 +205,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private IEnableWhenEvaluator myEnableWhenEvaluator = new DefaultEnableWhenEvaluator();
/*
* Keeps track of whether a particular profile has been checked or not yet
*/