mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-17 18:35:50 +00:00
Unit tests up to date and maybe we need to use r4 path
This commit is contained in:
parent
84c02d2e79
commit
69d9e5d2b2
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<artifactId>hapi-fhir-converter</artifactId>
|
<artifactId>hapi-fhir-converter</artifactId>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
<version>3.6.1-PHRFIX-SNAPSHOT</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -85,7 +85,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-client</artifactId>
|
<artifactId>hapi-fhir-client</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<artifactId>hapi-fhir-validation</artifactId>
|
<artifactId>hapi-fhir-validation</artifactId>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
<version>3.6.1-PHRFIX-SNAPSHOT</version>
|
||||||
|
|
||||||
<name>HAPI FHIR - Validation</name>
|
<name>HAPI FHIR - Validation</name>
|
||||||
|
|
||||||
@ -19,17 +19,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-base</artifactId>
|
<artifactId>hapi-fhir-base</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-utilities</artifactId>
|
<artifactId>hapi-fhir-utilities</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-converter</artifactId>
|
<artifactId>hapi-fhir-converter</artifactId>
|
||||||
<version>3.5.1-PHRFIX-SNAPSHOT</version>
|
<version>3.6.1-PHRFIX-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -64,49 +64,49 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
<artifactId>hapi-fhir-structures-dstu2</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
|
<artifactId>hapi-fhir-structures-dstu2.1</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
<artifactId>hapi-fhir-structures-dstu3</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
|
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-structures-r4</artifactId>
|
<artifactId>hapi-fhir-structures-r4</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
|
<artifactId>hapi-fhir-validation-resources-r4</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -119,13 +119,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-server</artifactId>
|
<artifactId>hapi-fhir-server</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>hapi-fhir-client</artifactId>
|
<artifactId>hapi-fhir-client</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -36,6 +36,8 @@ import org.hl7.fhir.dstu3.model.Type;
|
|||||||
import org.hl7.fhir.dstu3.model.UriType;
|
import org.hl7.fhir.dstu3.model.UriType;
|
||||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||||
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent;
|
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;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
|
||||||
|
}
|
@ -5,11 +5,15 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
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.convertors.VersionConvertorConstants;
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.PathEngineException;
|
import org.hl7.fhir.exceptions.PathEngineException;
|
||||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
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.conformance.ProfileUtilities;
|
||||||
import org.hl7.fhir.r4.context.IWorkerContext;
|
import org.hl7.fhir.r4.context.IWorkerContext;
|
||||||
import org.hl7.fhir.r4.context.IWorkerContext.ValidationResult;
|
import org.hl7.fhir.r4.context.IWorkerContext.ValidationResult;
|
||||||
@ -201,7 +205,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||||||
|
|
||||||
private IEnableWhenEvaluator myEnableWhenEvaluator = new DefaultEnableWhenEvaluator();
|
private IEnableWhenEvaluator myEnableWhenEvaluator = new DefaultEnableWhenEvaluator();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keeps track of whether a particular profile has been checked or not yet
|
* Keeps track of whether a particular profile has been checked or not yet
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user