Merge remote-tracking branch 'origin/master' into 2161-refactor-empi
This commit is contained in:
commit
ef2041d89d
|
@ -24,6 +24,8 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
|
@ -108,4 +110,12 @@ public class CompositeParam<A extends IQueryParameterType, B extends IQueryParam
|
|||
return myRightType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
b.append("myLeftType", getLeftValue());
|
||||
b.append("myRightType", getRightValue());
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
package ca.uhn.fhir.rest.param;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
|
@ -15,16 +26,6 @@ import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
|||
import ca.uhn.fhir.rest.param.binder.QueryParameterAndBinder;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/*
|
||||
* #%L
|
||||
|
@ -114,11 +115,70 @@ public class ParameterUtil {
|
|||
* This is a utility method intended provided to help the JPA module.
|
||||
*/
|
||||
public static IQueryParameterAnd<?> parseQueryParams(FhirContext theContext, RuntimeSearchParam theParamDef,
|
||||
String theUnqualifiedParamName, List<QualifiedParamList> theParameters) {
|
||||
String theUnqualifiedParamName, List<QualifiedParamList> theParameters) {
|
||||
|
||||
RestSearchParameterTypeEnum paramType = theParamDef.getParamType();
|
||||
return parseQueryParams(theContext, paramType, theUnqualifiedParamName, theParameters);
|
||||
|
||||
if (paramType == RestSearchParameterTypeEnum.COMPOSITE) {
|
||||
|
||||
List<RuntimeSearchParam> theCompositList = theParamDef.getCompositeOf();
|
||||
|
||||
if (theCompositList == null) {
|
||||
throw new ConfigurationException("Search parameter of type " + theUnqualifiedParamName
|
||||
+ " can be found in parameter annotation, found ");
|
||||
}
|
||||
|
||||
if (theCompositList.size() != 2) {
|
||||
throw new ConfigurationException("Search parameter of type " + theUnqualifiedParamName
|
||||
+ " must have 2 composite types declared in parameter annotation, found "
|
||||
+ theCompositList.size());
|
||||
}
|
||||
|
||||
RuntimeSearchParam left = theCompositList.get(0);
|
||||
RuntimeSearchParam right = theCompositList.get(1);
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
CompositeAndListParam<IQueryParameterType, IQueryParameterType> cp = new CompositeAndListParam(
|
||||
getCompositBindingClass(left.getParamType(), left.getName()),
|
||||
getCompositBindingClass(right.getParamType(), right.getName()));
|
||||
|
||||
cp.setValuesAsQueryTokens(theContext, theUnqualifiedParamName, theParameters);
|
||||
|
||||
return cp;
|
||||
} else {
|
||||
return parseQueryParams(theContext, paramType, theUnqualifiedParamName, theParameters);
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> getCompositBindingClass(RestSearchParameterTypeEnum paramType,
|
||||
String theUnqualifiedParamName) {
|
||||
|
||||
switch (paramType) {
|
||||
case DATE:
|
||||
return DateParam.class;
|
||||
case NUMBER:
|
||||
return NumberParam.class;
|
||||
case QUANTITY:
|
||||
return QuantityParam.class;
|
||||
case REFERENCE:
|
||||
return ReferenceParam.class;
|
||||
case STRING:
|
||||
return StringParam.class;
|
||||
case TOKEN:
|
||||
return TokenParam.class;
|
||||
case URI:
|
||||
return UriParam.class;
|
||||
case HAS:
|
||||
return HasParam.class;
|
||||
case SPECIAL:
|
||||
return SpecialParam.class;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Parameter '" + theUnqualifiedParamName + "' has type " + paramType
|
||||
+ " which is currently not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes :modifiers and .chains from URL parameter names
|
||||
*/
|
||||
|
|
|
@ -41,12 +41,18 @@ public interface ITermValueSetConceptDao extends JpaRepository<TermValueSetConce
|
|||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSetPid = :pid AND vsc.mySystem = :system_url AND vsc.myCode = :codeval")
|
||||
Optional<TermValueSetConcept> findByTermValueSetIdSystemAndCode(@Param("pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSetPid = :pid AND vsc.mySystem = :system_url AND vsc.mySystemVer = :system_version AND vsc.myCode = :codeval")
|
||||
Optional<TermValueSetConcept> findByTermValueSetIdSystemAndCodeWithVersion(@Param("pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("system_version") String theSystemVersion, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSet.myResourcePid = :resource_pid AND vsc.myCode = :codeval")
|
||||
List<TermValueSetConcept> findByValueSetResourcePidAndCode(@Param("resource_pid") Long theValueSetId, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSet.myResourcePid = :resource_pid AND vsc.mySystem = :system_url AND vsc.myCode = :codeval")
|
||||
Optional<TermValueSetConcept> findByValueSetResourcePidSystemAndCode(@Param("resource_pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc FROM TermValueSetConcept vsc WHERE vsc.myValueSet.myResourcePid = :resource_pid AND vsc.mySystem = :system_url AND vsc.mySystemVer = :system_version AND vsc.myCode = :codeval")
|
||||
Optional<TermValueSetConcept> findByValueSetResourcePidSystemAndCodeWithVersion(@Param("resource_pid") Long theValueSetId, @Param("system_url") String theSystem, @Param("system_version") String theSystemVersion, @Param("codeval") String theCode);
|
||||
|
||||
@Query("SELECT vsc.myId FROM TermValueSetConcept vsc WHERE vsc.myValueSetPid = :pid ORDER BY vsc.myId")
|
||||
List<Long> findIdsByTermValueSetId(@Param("pid") Long theValueSetId);
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class FhirResourceDaoValueSetDstu3 extends BaseHapiFhirResourceDao<ValueS
|
|||
|
||||
private void validateIncludes(String name, List<ConceptSetComponent> listToValidate) {
|
||||
for (ConceptSetComponent nextExclude : listToValidate) {
|
||||
if (isBlank(nextExclude.getSystem()) && !ElementUtil.isEmpty(nextExclude.getConcept(), nextExclude.getFilter())) {
|
||||
if (isBlank(nextExclude.getSystem()) && nextExclude.getValueSet().isEmpty() && !ElementUtil.isEmpty(nextExclude.getConcept(), nextExclude.getFilter())) {
|
||||
throw new InvalidRequestException("ValueSet contains " + name + " criteria with no system defined");
|
||||
}
|
||||
}
|
||||
|
@ -116,14 +116,13 @@ public class FhirResourceDaoValueSetDstu3 extends BaseHapiFhirResourceDao<ValueS
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
return doExpand(source);
|
||||
|
@ -150,14 +149,13 @@ public class FhirResourceDaoValueSetDstu3 extends BaseHapiFhirResourceDao<ValueS
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
return doExpand(source, theOffset, theCount);
|
||||
|
|
|
@ -99,14 +99,13 @@ public class FhirResourceDaoValueSetR4 extends BaseHapiFhirResourceDao<ValueSet>
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
return doExpand(source);
|
||||
|
@ -133,14 +132,13 @@ public class FhirResourceDaoValueSetR4 extends BaseHapiFhirResourceDao<ValueSet>
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
return doExpand(source, theOffset, theCount);
|
||||
|
|
|
@ -99,14 +99,13 @@ public class FhirResourceDaoValueSetR5 extends BaseHapiFhirResourceDao<ValueSet>
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
ValueSet retVal = doExpand(source);
|
||||
|
@ -134,14 +133,13 @@ public class FhirResourceDaoValueSetR5 extends BaseHapiFhirResourceDao<ValueSet>
|
|||
ValueSet source = new ValueSet();
|
||||
source.setUrl(theUri);
|
||||
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
|
||||
if (isNotBlank(theFilter)) {
|
||||
ConceptSetComponent include = source.getCompose().addInclude();
|
||||
ConceptSetFilterComponent filter = include.addFilter();
|
||||
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||
filter.setProperty("display");
|
||||
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
||||
filter.setValue(theFilter);
|
||||
} else {
|
||||
source.getCompose().addInclude().addValueSet(theUri);
|
||||
}
|
||||
|
||||
return doExpand(source, theOffset, theCount);
|
||||
|
|
|
@ -40,7 +40,7 @@ import static org.apache.commons.lang3.StringUtils.length;
|
|||
* bork up migration tasks.
|
||||
*/
|
||||
@Table(name = "TRM_VALUESET_CONCEPT", uniqueConstraints = {
|
||||
@UniqueConstraint(name = "IDX_VS_CONCEPT_CS_CD", columnNames = {"VALUESET_PID", "SYSTEM_URL", "CODEVAL"}),
|
||||
@UniqueConstraint(name = "IDX_VS_CONCEPT_CS_CD", columnNames = {"VALUESET_PID", "SYSTEM_URL", "SYSTEM_VER", "CODEVAL"}),
|
||||
@UniqueConstraint(name = "IDX_VS_CONCEPT_ORDER", columnNames = {"VALUESET_PID", "VALUESET_ORDER"})
|
||||
})
|
||||
@Entity()
|
||||
|
@ -72,6 +72,9 @@ public class TermValueSetConcept implements Serializable {
|
|||
@Column(name = "SYSTEM_URL", nullable = false, length = TermCodeSystem.MAX_URL_LENGTH)
|
||||
private String mySystem;
|
||||
|
||||
@Column(name = "SYSTEM_VER", nullable = true, length = TermCodeSystemVersion.MAX_VERSION_LENGTH)
|
||||
private String mySystemVer;
|
||||
|
||||
@Column(name = "CODEVAL", nullable = false, length = TermConcept.MAX_CODE_LENGTH)
|
||||
private String myCode;
|
||||
|
||||
|
@ -134,6 +137,17 @@ public class TermValueSetConcept implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public String getSystemVersion() {
|
||||
return mySystemVer;
|
||||
}
|
||||
|
||||
public TermValueSetConcept setSystemVersion(String theSystemVersion) {
|
||||
ValidateUtil.isNotTooLongOrThrowIllegalArgument(theSystemVersion, TermCodeSystemVersion.MAX_VERSION_LENGTH,
|
||||
"System version exceeds maximum length (" + TermCodeSystemVersion.MAX_VERSION_LENGTH + "): " + length(theSystemVersion));
|
||||
mySystemVer = theSystemVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return myCode;
|
||||
}
|
||||
|
|
|
@ -265,26 +265,37 @@ public class QueryStack {
|
|||
return new PredicateBuilderCacheLookupResult<>(cacheHit, (T) retVal);
|
||||
}
|
||||
|
||||
private Condition createPredicateComposite(@Nullable DbColumn theSourceJoinColumn, String theResourceName, RuntimeSearchParam theParamDef, List<? extends IQueryParameterType> theNextAnd, RequestPartitionId theRequestPartitionId) {
|
||||
// TODO: fail if missing is set for a composite query
|
||||
private Condition createPredicateComposite(@Nullable DbColumn theSourceJoinColumn, String theResourceName, RuntimeSearchParam theParamDef, List<? extends IQueryParameterType> theNextAnd, RequestPartitionId theRequestPartitionId) {
|
||||
|
||||
IQueryParameterType or = theNextAnd.get(0);
|
||||
if (!(or instanceof CompositeParam<?, ?>)) {
|
||||
throw new InvalidRequestException("Invalid type for composite param (must be " + CompositeParam.class.getSimpleName() + ": " + or.getClass());
|
||||
Condition orCondidtion = null;
|
||||
for (IQueryParameterType next : theNextAnd) {
|
||||
|
||||
if (!(next instanceof CompositeParam<?, ?>)) {
|
||||
throw new InvalidRequestException("Invalid type for composite param (must be " + CompositeParam.class.getSimpleName() + ": " + next.getClass());
|
||||
}
|
||||
CompositeParam<?, ?> cp = (CompositeParam<?, ?>) next;
|
||||
|
||||
RuntimeSearchParam left = theParamDef.getCompositeOf().get(0);
|
||||
IQueryParameterType leftValue = cp.getLeftValue();
|
||||
Condition leftPredicate = createPredicateCompositePart(theSourceJoinColumn, theResourceName, left, leftValue, theRequestPartitionId);
|
||||
|
||||
RuntimeSearchParam right = theParamDef.getCompositeOf().get(1);
|
||||
IQueryParameterType rightValue = cp.getRightValue();
|
||||
Condition rightPredicate = createPredicateCompositePart(theSourceJoinColumn, theResourceName, right, rightValue, theRequestPartitionId);
|
||||
|
||||
Condition andCondition = toAndPredicate(leftPredicate, rightPredicate);
|
||||
|
||||
if (orCondidtion == null) {
|
||||
orCondidtion = toOrPredicate(andCondition);
|
||||
} else {
|
||||
orCondidtion = toOrPredicate(orCondidtion, andCondition);
|
||||
}
|
||||
}
|
||||
CompositeParam<?, ?> cp = (CompositeParam<?, ?>) or;
|
||||
|
||||
RuntimeSearchParam left = theParamDef.getCompositeOf().get(0);
|
||||
IQueryParameterType leftValue = cp.getLeftValue();
|
||||
Condition leftPredicate = createPredicateCompositePart(theSourceJoinColumn, theResourceName, left, leftValue, theRequestPartitionId);
|
||||
|
||||
RuntimeSearchParam right = theParamDef.getCompositeOf().get(1);
|
||||
IQueryParameterType rightValue = cp.getRightValue();
|
||||
Condition rightPredicate = createPredicateCompositePart(theSourceJoinColumn, theResourceName, right, rightValue, theRequestPartitionId);
|
||||
|
||||
return toAndPredicate(leftPredicate, rightPredicate);
|
||||
|
||||
return orCondidtion;
|
||||
}
|
||||
|
||||
|
||||
private Condition createPredicateCompositePart(@Nullable DbColumn theSourceJoinColumn, String theResourceName, RuntimeSearchParam theParam, IQueryParameterType theParamValue, RequestPartitionId theRequestPartitionId) {
|
||||
|
||||
switch (theParam.getParamType()) {
|
||||
|
|
|
@ -248,14 +248,13 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
return cs != null;
|
||||
}
|
||||
|
||||
private void addCodeIfNotAlreadyAdded(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set<String> theAddedCodes, TermConcept theConcept, boolean theAdd, AtomicInteger theCodeCounter) {
|
||||
private void addCodeIfNotAlreadyAdded(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set<String> theAddedCodes, TermConcept theConcept, boolean theAdd, AtomicInteger theCodeCounter, String theValueSetIncludeVersion) {
|
||||
String codeSystem = theConcept.getCodeSystemVersion().getCodeSystem().getCodeSystemUri();
|
||||
String codeSystemVersion = theConcept.getCodeSystemVersion().getCodeSystemVersionId();
|
||||
String code = theConcept.getCode();
|
||||
String display = theConcept.getDisplay();
|
||||
Collection<TermConceptDesignation> designations = theConcept.getDesignations();
|
||||
if (StringUtils.isNotEmpty(codeSystemVersion)) {
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem + "|" + codeSystemVersion, code, display);
|
||||
if (StringUtils.isNotEmpty(theValueSetIncludeVersion)) {
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem + "|" + theValueSetIncludeVersion, code, display);
|
||||
} else {
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem, code, display);
|
||||
}
|
||||
|
@ -264,12 +263,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
private void addCodeIfNotAlreadyAdded(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set<String> theAddedCodes, Collection<TermConceptDesignation> theDesignations, boolean theAdd, AtomicInteger theCodeCounter, String theCodeSystem, String theCodeSystemVersion, String theCode, String theDisplay) {
|
||||
if (StringUtils.isNotEmpty(theCodeSystemVersion)) {
|
||||
if (isNoneBlank(theCodeSystem, theCode)) {
|
||||
if (theAdd && theAddedCodes.add(theCodeSystem + "|" + theCode + "|" + theCodeSystemVersion)) {
|
||||
if (theAdd && theAddedCodes.add(theCodeSystem + "|" + theCode)) {
|
||||
theValueSetCodeAccumulator.includeConceptWithDesignations(theCodeSystem + "|" + theCodeSystemVersion, theCode, theDisplay, theDesignations);
|
||||
theCodeCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
if (!theAdd && theAddedCodes.remove(theCodeSystem + "|" + theCode + "|" + theCodeSystemVersion)) {
|
||||
if (!theAdd && theAddedCodes.remove(theCodeSystem + "|" + theCode)) {
|
||||
theValueSetCodeAccumulator.excludeConcept(theCodeSystem + "|" + theCodeSystemVersion, theCode);
|
||||
theCodeCounter.decrementAndGet();
|
||||
}
|
||||
|
@ -785,7 +784,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
myConceptDao
|
||||
.findByCodeSystemAndCode(termCodeSystemVersion, nextConcept.getCode())
|
||||
.ifPresent(concept ->
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter)
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter, nextConcept.getSystemVersion())
|
||||
);
|
||||
} else {
|
||||
// This will happen if we're expanding against a built-in (part of FHIR) ValueSet that
|
||||
|
@ -812,12 +811,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
@Nonnull
|
||||
private Boolean expandValueSetHandleIncludeOrExcludeUsingDatabase(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set<String> theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, FhirVersionIndependentConcept theWantConceptOrNull, String theSystem, TermCodeSystem theCs) {
|
||||
String codeSystemVersion = theIncludeOrExclude.getVersion();
|
||||
String includeOrExcludeVersion = theIncludeOrExclude.getVersion();
|
||||
TermCodeSystemVersion csv;
|
||||
if (isEmpty(codeSystemVersion)) {
|
||||
if (isEmpty(includeOrExcludeVersion)) {
|
||||
csv = theCs.getCurrentVersion();
|
||||
} else {
|
||||
csv = myCodeSystemVersionDao.findByCodeSystemPidAndVersion(theCs.getPid(), codeSystemVersion);
|
||||
csv = myCodeSystemVersionDao.findByCodeSystemPidAndVersion(theCs.getPid(), includeOrExcludeVersion);
|
||||
}
|
||||
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
||||
|
||||
|
@ -846,8 +845,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
* Filters
|
||||
*/
|
||||
String codeSystemUrlAndVersion;
|
||||
if (codeSystemVersion != null) {
|
||||
codeSystemUrlAndVersion = theSystem + "|" + codeSystemVersion;
|
||||
if (includeOrExcludeVersion != null) {
|
||||
codeSystemUrlAndVersion = theSystem + "|" + includeOrExcludeVersion;
|
||||
} else {
|
||||
codeSystemUrlAndVersion = theSystem;
|
||||
}
|
||||
|
@ -926,7 +925,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
countForBatch.incrementAndGet();
|
||||
TermConcept concept = (TermConcept) next;
|
||||
try {
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter);
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter, includeOrExcludeVersion);
|
||||
} catch (ExpansionTooCostlyException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1278,7 +1277,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
if (theInclude.getConcept().isEmpty()) {
|
||||
for (TermConcept next : theVersion.getConcepts()) {
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, null, theAdd, theCodeCounter, theSystem, theVersion.getCodeSystemVersionId(), next.getCode(), next.getDisplay());
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, null, theAdd, theCodeCounter, theSystem, theInclude.getVersion(), next.getCode(), next.getDisplay());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1286,7 +1285,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
if (!theSystem.equals(theInclude.getSystem()) && isNotBlank(theSystem)) {
|
||||
continue;
|
||||
}
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, null, theAdd, theCodeCounter, theSystem, theVersion.getCodeSystemVersionId(), next.getCode(), next.getDisplay());
|
||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, null, theAdd, theCodeCounter, theSystem, theInclude.getVersion(), next.getCode(), next.getDisplay());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1378,7 +1377,15 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
private List<TermValueSetConcept> findByValueSetResourcePidSystemAndCode(ResourcePersistentId theResourcePid, String theSystem, String theCode) {
|
||||
List<TermValueSetConcept> retVal = new ArrayList<>();
|
||||
Optional<TermValueSetConcept> optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCode(theResourcePid.getIdAsLong(), theSystem, theCode);
|
||||
Optional<TermValueSetConcept> optionalTermValueSetConcept;
|
||||
int versionIndex = theSystem.indexOf("|");
|
||||
if (versionIndex >= 0) {
|
||||
String systemUrl = theSystem.substring(0, versionIndex);
|
||||
String systemVersion = theSystem.substring(versionIndex+1);
|
||||
optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCodeWithVersion(theResourcePid.getIdAsLong(), systemUrl, systemVersion, theCode);
|
||||
} else {
|
||||
optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCode(theResourcePid.getIdAsLong(), theSystem, theCode);
|
||||
}
|
||||
optionalTermValueSetConcept.ifPresent(retVal::add);
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,15 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
}
|
||||
|
||||
// Get existing entity so it can be deleted.
|
||||
Optional<TermValueSetConcept> optionalConcept = myValueSetConceptDao.findByTermValueSetIdSystemAndCode(myTermValueSet.getId(), theSystem, theCode);
|
||||
Optional<TermValueSetConcept> optionalConcept;
|
||||
int versionIdx = theSystem.indexOf("|");
|
||||
if (versionIdx >= 0) {
|
||||
String systemUrl = theSystem.substring(0,versionIdx);
|
||||
String systemVersion = theSystem.substring(versionIdx+1);
|
||||
optionalConcept = myValueSetConceptDao.findByTermValueSetIdSystemAndCodeWithVersion(myTermValueSet.getId(), systemUrl, systemVersion,theCode);
|
||||
} else {
|
||||
optionalConcept = myValueSetConceptDao.findByTermValueSetIdSystemAndCode(myTermValueSet.getId(), theSystem, theCode);
|
||||
}
|
||||
|
||||
if (optionalConcept.isPresent()) {
|
||||
TermValueSetConcept concept = optionalConcept.get();
|
||||
|
@ -115,7 +123,13 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
|||
TermValueSetConcept concept = new TermValueSetConcept();
|
||||
concept.setValueSet(myTermValueSet);
|
||||
concept.setOrder(myConceptsSaved);
|
||||
concept.setSystem(theSystem);
|
||||
int versionIndex = theSystem.indexOf("|");
|
||||
if (versionIndex >= 0) {
|
||||
concept.setSystem(theSystem.substring(0, versionIndex));
|
||||
concept.setSystemVersion(theSystem.substring(versionIndex+1));
|
||||
} else {
|
||||
concept.setSystem(theSystem);
|
||||
}
|
||||
concept.setCode(theCode);
|
||||
if (isNotBlank(theDisplay)) {
|
||||
concept.setDisplay(theDisplay);
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.util.List;
|
|||
import static ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest.URL_MY_CODE_SYSTEM;
|
||||
import static ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest.URL_MY_VALUE_SET;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
||||
|
@ -833,6 +834,50 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3
|
|||
assertEquals("Male", ((StringType) respParam.getParameter().get(1).getValue()).getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByValueSetWithFilter() throws IOException {
|
||||
loadAndPersistCodeSystem();
|
||||
|
||||
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
|
||||
|
||||
Parameters respParam = ourClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "valueSet", toExpand)
|
||||
.andParameter("filter", new StringType("blood"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByUrlWithFilter() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
|
||||
Parameters respParam = ourClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("filter", new StringType("first"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void afterResetPreExpansionDefault() {
|
||||
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
||||
|
|
|
@ -1112,7 +1112,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1134,7 +1135,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1144,7 +1146,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1159,7 +1162,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1185,7 +1189,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1207,7 +1212,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1217,7 +1223,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1232,7 +1239,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
|
|
@ -0,0 +1,610 @@
|
|||
package ca.uhn.fhir.jpa.provider.r4;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
import org.hl7.fhir.r4.model.Device;
|
||||
import org.hl7.fhir.r4.model.Encounter;
|
||||
import org.hl7.fhir.r4.model.Observation;
|
||||
import org.hl7.fhir.r4.model.Observation.ObservationComponentComponent;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Period;
|
||||
import org.hl7.fhir.r4.model.Quantity;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
|
||||
|
||||
public class ResourceProviderHasParamR4Test extends BaseResourceProviderR4Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderHasParamR4Test.class);
|
||||
private CapturingInterceptor myCapturingInterceptor = new CapturingInterceptor();
|
||||
|
||||
@Override
|
||||
@AfterEach
|
||||
public void after() throws Exception {
|
||||
super.after();
|
||||
|
||||
myDaoConfig.setAllowMultipleDelete(new DaoConfig().isAllowMultipleDelete());
|
||||
myDaoConfig.setAllowExternalReferences(new DaoConfig().isAllowExternalReferences());
|
||||
myDaoConfig.setReuseCachedSearchResultsForMillis(new DaoConfig().getReuseCachedSearchResultsForMillis());
|
||||
myDaoConfig.setCountSearchResultsUpTo(new DaoConfig().getCountSearchResultsUpTo());
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
myDaoConfig.setAllowContainsSearches(new DaoConfig().isAllowContainsSearches());
|
||||
myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields());
|
||||
|
||||
myClient.unregisterInterceptor(myCapturingInterceptor);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
myFhirCtx.setParserErrorHandler(new StrictErrorHandler());
|
||||
|
||||
myDaoConfig.setAllowMultipleDelete(true);
|
||||
myClient.registerInterceptor(myCapturingInterceptor);
|
||||
myDaoConfig.setSearchPreFetchThresholds(new DaoConfig().getSearchPreFetchThresholds());
|
||||
//myDaoConfig.setUseLegacySearchBuilder(true);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void beforeDisableResultReuse() {
|
||||
myDaoConfig.setReuseCachedSearchResultsForMillis(null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testHasParameter() throws Exception {
|
||||
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:identifier=" + UrlUtil.escapeUrlParam("urn:system|FOO");
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleHasParametersOfSameType() throws Exception {
|
||||
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
{
|
||||
Encounter encounter = new Encounter();
|
||||
encounter.addIdentifier().setValue("theEncounter");
|
||||
encounter.getClass_().setCode("IMP").setSystem("urn:system");
|
||||
encounter.getPeriod().setStartElement(new DateTimeType("2020-01-01")).setEndElement(new DateTimeType("2020-09-30"));
|
||||
encounter.setSubject(new Reference(pid0));
|
||||
|
||||
myEncounterDao.create(encounter, mySrd);
|
||||
|
||||
ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter));
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Encounter:subject:class=" + UrlUtil.escapeUrlParam("urn:system|IMP") + "&_has:Encounter:subject:date=gt1950";
|
||||
|
||||
ourLog.info("uri = " + uri);
|
||||
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
System.out.println("ids.size() = " + ids.size());
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleHasParametersOfDifferentType() throws Exception {
|
||||
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
{
|
||||
Encounter encounter = new Encounter();
|
||||
encounter.addIdentifier().setValue("theEncounter");
|
||||
encounter.getClass_().setCode("IMP").setSystem("urn:system");
|
||||
encounter.getPeriod().setStartElement(new DateTimeType("2020-01-01")).setEndElement(new DateTimeType("2020-09-30"));
|
||||
encounter.setSubject(new Reference(pid0));
|
||||
|
||||
myEncounterDao.create(encounter, mySrd);
|
||||
ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter));
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:patient:code=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7") + "&_has:Encounter:subject:date=gt1950";
|
||||
|
||||
ourLog.info("uri = " + uri);
|
||||
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasCompositeParameterCodeValueQuantity() throws Exception {
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Quantity q = new Quantity();
|
||||
q.setValue(200);
|
||||
obs.setValue(q);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt180");
|
||||
ourLog.info("uri = " + uri);
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasCompositeParameterCodeValueDate() throws Exception {
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Period period = new Period();
|
||||
period.setStartElement(new DateTimeType("2020-01-01"));
|
||||
period.setEndElement(new DateTimeType("2020-09-30"));
|
||||
obs.setValue(period);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-date=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt2019");
|
||||
ourLog.info("uri = " + uri);
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasCompositeParameterCompCodeValueQuantity() throws Exception {
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Period period = new Period();
|
||||
period.setStartElement(new DateTimeType("2020-01-01"));
|
||||
period.setEndElement(new DateTimeType("2020-09-30"));
|
||||
obs.setValue(period);
|
||||
|
||||
ObservationComponentComponent comp = obs.addComponent();
|
||||
CodeableConcept compCC = comp.getCode();
|
||||
compCC.addCoding().setCode("2345-8").setSystem("http://loinc.org");
|
||||
|
||||
Quantity q = new Quantity();
|
||||
q.setValue(200);
|
||||
comp.setValue(q);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:combo-code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-8$200");
|
||||
ourLog.info("uri = " + uri);
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasCompositeParameterCodeValueStringOr() throws Exception {
|
||||
IIdType pid0;
|
||||
IIdType pid1;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid1 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
obs.setValue(new StringType("100"));
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("BAR");
|
||||
obs.getSubject().setReferenceElement(pid1);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
obs.setValue(new StringType("200"));
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-string=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$100,http://loinc.org|2345-7$200");
|
||||
ourLog.info("uri = " + uri);
|
||||
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertEquals(2, ids.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasCompositeParameterWithNoResult() throws Exception {
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Quantity q = new Quantity();
|
||||
q.setValue(200);
|
||||
obs.setValue(q);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$lt180");
|
||||
ourLog.info("uri = " + uri);
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertEquals(0, ids.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleHasParameterWithCompositeOfSameType() throws Exception {
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Quantity q = new Quantity();
|
||||
q.setValue(200);
|
||||
obs.setValue(q);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt180") + "&_has:Observation:subject:identifier=" + UrlUtil.escapeUrlParam("urn:system|FOO");
|
||||
|
||||
ourLog.info("uri = " + uri);
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleHasParameterWithCompositeOfDifferentType() throws Exception {
|
||||
|
||||
IIdType pid0;
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
pid0 = myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
}
|
||||
{
|
||||
Patient patient = new Patient();
|
||||
patient.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
patient.addName().setFamily("Tester").addGiven("Joe");
|
||||
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
{
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("FOO");
|
||||
obs.getSubject().setReferenceElement(pid0);
|
||||
CodeableConcept cc = obs.getCode();
|
||||
cc.addCoding().setCode("2345-7").setSystem("http://loinc.org");
|
||||
|
||||
Quantity q = new Quantity();
|
||||
q.setValue(200);
|
||||
obs.setValue(q);
|
||||
|
||||
myObservationDao.create(obs, mySrd);
|
||||
|
||||
ourLog.info("Observation: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(obs));
|
||||
}
|
||||
{
|
||||
Device device = new Device();
|
||||
device.addIdentifier().setValue("DEVICEID");
|
||||
IIdType devId = myDeviceDao.create(device, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
Observation obs = new Observation();
|
||||
obs.addIdentifier().setSystem("urn:system").setValue("NOLINK");
|
||||
obs.setDevice(new Reference(devId));
|
||||
myObservationDao.create(obs, mySrd);
|
||||
}
|
||||
|
||||
{
|
||||
Encounter encounter = new Encounter();
|
||||
encounter.addIdentifier().setValue("theEncounter");
|
||||
encounter.getClass_().setCode("IMP").setSystem("urn:system");
|
||||
encounter.getPeriod().setStartElement(new DateTimeType("2020-01-01")).setEndElement(new DateTimeType("2020-09-30"));
|
||||
encounter.setSubject(new Reference(pid0));
|
||||
|
||||
myEncounterDao.create(encounter, mySrd);
|
||||
ourLog.info("Encounter: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(encounter));
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?_has:Observation:subject:code-value-quantity=http://" + UrlUtil.escapeUrlParam("loinc.org|2345-7$gt180") + "&_has:Encounter:subject:date=gt1950" + "&_has:Encounter:subject:class=" + UrlUtil.escapeUrlParam("urn:system|IMP");
|
||||
|
||||
ourLog.info("uri = " + uri);
|
||||
|
||||
List<String> ids = searchAndReturnUnqualifiedVersionlessIdValues(uri);
|
||||
assertThat(ids, contains(pid0.getValue()));
|
||||
}
|
||||
|
||||
private List<String> searchAndReturnUnqualifiedVersionlessIdValues(String uri) throws IOException {
|
||||
List<String> ids;
|
||||
HttpGet get = new HttpGet(uri);
|
||||
|
||||
try (CloseableHttpResponse response = ourHttpClient.execute(get)) {
|
||||
String resp = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
ourLog.info(resp);
|
||||
Bundle bundle = myFhirCtx.newXmlParser().parseResource(Bundle.class, resp);
|
||||
ids = toUnqualifiedVersionlessIdValues(bundle);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -55,7 +55,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
|
|||
|
||||
@Test
|
||||
public void testLookupOnExternalCode() {
|
||||
ResourceProviderR4ValueSetTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd);
|
||||
ResourceProviderR4ValueSetNoVerCSNoVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd);
|
||||
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
|
|
|
@ -89,8 +89,8 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi
|
|||
|
||||
@Test
|
||||
public void testLookupOnExternalCodeMultiVersion() {
|
||||
ResourceProviderR4ValueSetVersionedTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "1");
|
||||
ResourceProviderR4ValueSetVersionedTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "2");
|
||||
ResourceProviderR4ValueSetVerCSVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "1");
|
||||
ResourceProviderR4ValueSetVerCSVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "2");
|
||||
|
||||
// First test with no version specified (should return from last version created)
|
||||
Parameters respParam = myClient
|
||||
|
|
|
@ -64,15 +64,14 @@ import static org.hamcrest.Matchers.containsStringIgnoringCase;
|
|||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||
public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProviderR4Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4ValueSetTest.class);
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4ValueSetNoVerCSNoVerTest.class);
|
||||
private IIdType myExtensionalCsId;
|
||||
private IIdType myExtensionalVsId;
|
||||
private IIdType myLocalValueSetId;
|
||||
|
@ -923,9 +922,19 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstance() throws Exception {
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCodeAndSystemInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystemInstance();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystemInstance() throws Exception {
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onInstance(myExtensionalVsId)
|
||||
|
@ -941,10 +950,50 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnType() throws IOException {
|
||||
public void testValidateCodeOperationByCodeAndSystemBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCodeAndSystem();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystem();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystem() throws Exception {
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8450-9"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertEquals(true, ((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnTypeBeforeExpand() throws IOException {
|
||||
createLocalCs();
|
||||
createLocalVsWithIncludeConcept();
|
||||
testValidateCodeOperationByCodeAndSystemInstanceOnType();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnTypeAfterExpand() throws IOException {
|
||||
createLocalCs();
|
||||
createLocalVsWithIncludeConcept();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystemInstanceOnType();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystemInstanceOnType() throws IOException {
|
||||
String url = ourServerBase +
|
||||
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
||||
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
||||
|
@ -962,10 +1011,21 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstance() throws IOException {
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstanceBeforeExpand() throws IOException {
|
||||
createLocalCs();
|
||||
createLocalVsWithIncludeConcept();
|
||||
testValidateCodeOperationByCodeAndSystemInstanceOnInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstanceAfterExpand() throws IOException {
|
||||
createLocalCs();
|
||||
createLocalVsWithIncludeConcept();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystemInstanceOnInstance();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystemInstanceOnInstance() throws IOException {
|
||||
String url = ourServerBase +
|
||||
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
||||
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
||||
|
@ -985,9 +1045,19 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemType() throws Exception {
|
||||
public void testValidateCodeOperationByCodeAndSystemTypeBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCodeAndSystemType();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemTypeAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystemType();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystemType() throws Exception {
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onInstance(myExtensionalVsId)
|
||||
|
@ -1089,9 +1159,63 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCoding() throws Exception {
|
||||
public void testValidateCodeOperationByCodingBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCoding();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodingAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCoding();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByValueSetWithFilter() throws IOException {
|
||||
loadAndPersistCodeSystem();
|
||||
|
||||
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
|
||||
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "valueSet", toExpand)
|
||||
.andParameter("filter", new StringType("blood"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByUrlWithFilter() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("filter", new StringType("first"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCoding() throws Exception {
|
||||
Coding codingToValidate = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||
|
||||
// With correct system version specified. Should pass.
|
||||
|
@ -1110,8 +1234,6 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean clearDeferredStorageQueue() {
|
||||
|
||||
if(!myTerminologyDeferredStorageSvc.isStorageQueueEmpty()) {
|
File diff suppressed because it is too large
Load Diff
|
@ -12,25 +12,19 @@ import ca.uhn.fhir.jpa.entity.TermValueSetConceptDesignation;
|
|||
import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
||||
import ca.uhn.fhir.jpa.term.api.ITermReadSvc;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import com.google.common.base.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode;
|
||||
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
|
||||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
|
@ -41,6 +35,7 @@ import org.hl7.fhir.r4.model.ValueSet.FilterOperator;
|
|||
import org.hl7.fhir.r4.model.codesystems.HttpVerb;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -66,9 +61,9 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
|||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProviderR4Test {
|
||||
public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProviderR4Test {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4ValueSetVersionedTest.class);
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderR4ValueSetVerCSVerTest.class);
|
||||
private IIdType myExtensionalCsId_v1;
|
||||
private IIdType myExtensionalCsId_v2;
|
||||
private IIdType myExtensionalVsId_v1;
|
||||
|
@ -79,6 +74,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
private Long myExtensionalVsIdOnResourceTable_v2;
|
||||
private ValueSet myLocalVs_v1;
|
||||
private ValueSet myLocalVs_v2;
|
||||
@Autowired
|
||||
private ITermReadSvc myTermReadSvc;
|
||||
|
||||
private void loadAndPersistCodeSystemAndValueSet() throws IOException {
|
||||
loadAndPersistCodeSystem();
|
||||
|
@ -191,46 +188,6 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
}
|
||||
|
||||
private void createLocalCs() {
|
||||
CodeSystem codeSystem = new CodeSystem();
|
||||
codeSystem.setUrl(URL_MY_CODE_SYSTEM);
|
||||
codeSystem.setContent(CodeSystemContentMode.COMPLETE);
|
||||
codeSystem
|
||||
.addConcept().setCode("A").setDisplay("Code A")
|
||||
.addConcept(new ConceptDefinitionComponent().setCode("AA").setDisplay("Code AA")
|
||||
.addConcept(new ConceptDefinitionComponent().setCode("AAA").setDisplay("Code AAA"))
|
||||
)
|
||||
.addConcept(new ConceptDefinitionComponent().setCode("AB").setDisplay("Code AB"));
|
||||
codeSystem
|
||||
.addConcept().setCode("B").setDisplay("Code B")
|
||||
.addConcept(new ConceptDefinitionComponent().setCode("BA").setDisplay("Code BA"))
|
||||
.addConcept(new ConceptDefinitionComponent().setCode("BB").setDisplay("Code BB"));
|
||||
myCodeSystemDao.create(codeSystem, mySrd);
|
||||
}
|
||||
|
||||
private void createLocalVsWithIncludeConcept() {
|
||||
myLocalVs_v1 = new ValueSet();
|
||||
myLocalVs_v1.setUrl(URL_MY_VALUE_SET);
|
||||
myLocalVs_v1.setVersion("1");
|
||||
ConceptSetComponent include = myLocalVs_v1.getCompose().addInclude();
|
||||
include.setSystem(URL_MY_CODE_SYSTEM);
|
||||
include.setVersion("1");
|
||||
include.addConcept().setCode("A").setDisplay("A v1");
|
||||
include.addConcept().setCode("AA").setDisplay("AA v1");
|
||||
myLocalValueSetId_v1 = myValueSetDao.create(myLocalVs_v1, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
myLocalVs_v2 = new ValueSet();
|
||||
myLocalVs_v2.setUrl(URL_MY_VALUE_SET);
|
||||
myLocalVs_v2.setVersion("2");
|
||||
include = myLocalVs_v2.getCompose().addInclude();
|
||||
include.setSystem(URL_MY_CODE_SYSTEM);
|
||||
include.setVersion("2");
|
||||
include.addConcept().setCode("A").setDisplay("A v2");
|
||||
include.addConcept().setCode("AA").setDisplay("AA v2");
|
||||
myLocalValueSetId_v2 = myValueSetDao.create(myLocalVs_v2, mySrd).getId().toUnqualifiedVersionless();
|
||||
|
||||
}
|
||||
|
||||
private ValueSet createLocalVs(String theCodeSystemUrl, String theValueSetVersion) {
|
||||
ValueSet myLocalVs = new ValueSet();
|
||||
myLocalVs.setUrl(URL_MY_VALUE_SET);
|
||||
|
@ -1105,7 +1062,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1127,7 +1085,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1137,7 +1096,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1152,7 +1112,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1178,7 +1139,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1200,7 +1162,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1210,7 +1173,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1225,7 +1189,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1234,8 +1199,19 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystem() throws Exception {
|
||||
public void testValidateCodeOperationByCodeAndSystemBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCodeAndSystem();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeAndSystemAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeAndSystem();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeAndSystem() throws Exception {
|
||||
|
||||
// With correct system version specified. Should pass.
|
||||
Parameters respParam = myClient
|
||||
|
@ -1270,6 +1246,37 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version specified and latest code system version. Should pass.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8495-4"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.andParameter("systemVersion", new StringType("2"))
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version specified and no code system version. Should pass.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8495-4"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With incorrect version specified. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
|
@ -1303,12 +1310,38 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version specified and older code system version. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8495-4"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.andParameter("systemVersion", new StringType("1"))
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationOnInstanceByCodeAndSystem() throws Exception {
|
||||
public void testValidateCodeOperationOnInstanceByCodeAndSystemBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationOnInstanceByCodeAndSystem();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationOnInstanceByCodeAndSystemAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationOnInstanceByCodeAndSystem();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationOnInstanceByCodeAndSystem() throws Exception {
|
||||
// With correct system version specified. Should pass.
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
|
@ -1338,6 +1371,35 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no CodeSystem version specified. Should pass as the code and system exist in both ValueSet versions.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onInstance(myExtensionalVsId_v2)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8495-4"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onInstance(myExtensionalVsId_v1)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "code", new CodeType("8495-4"))
|
||||
.andParameter("system", new UriType("http://acme.org"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With incorrect version specified. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
|
@ -1370,15 +1432,27 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCoding() throws Exception {
|
||||
public void testValidateCodeOperationByCodingBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCoding();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodingAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCoding();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCoding() throws Exception {
|
||||
Coding codingToValidate_v1 = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||
codingToValidate_v1.setVersion("1");
|
||||
|
||||
Coding codingToValidate_v2 = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum v2");
|
||||
codingToValidate_v2.setVersion("2");
|
||||
|
||||
Coding codingToValidate_noV = new Coding("http://acme.org", "8495-4", null);
|
||||
|
||||
// With correct system version specified. Should pass.
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
|
@ -1408,6 +1482,20 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version, and newer CodeSystem version. Should pass.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "coding", codingToValidate_v2)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With incorrect version specified. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
|
@ -1437,11 +1525,78 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version and older CodeSystem version. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "coding", codingToValidate_v1)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no CodeSystem version. Should pass, regardless of ValueSet version.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "coding", codingToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("valueSetVersion", new StringType("1"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "coding", codingToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("valueSetVersion", new StringType("2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "coding", codingToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeableConceptBeforeExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
testValidateCodeOperationByCodeableConcept();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateCodeOperationByCodeableConcept() throws Exception {
|
||||
public void testValidateCodeOperationByCodeableConceptAfterExpand() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet();
|
||||
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||
testValidateCodeOperationByCodeableConcept();
|
||||
}
|
||||
|
||||
private void testValidateCodeOperationByCodeableConcept() throws Exception {
|
||||
|
||||
Coding codingToValidate = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||
codingToValidate.setVersion("1");
|
||||
|
@ -1451,6 +1606,9 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
codingToValidate.setVersion("2");
|
||||
CodeableConcept codeableConceptToValidate_v2 = new CodeableConcept(codingToValidate);
|
||||
|
||||
codingToValidate = new Coding("http://acme.org", "8495-4", null);
|
||||
CodeableConcept codeableConceptToValidate_noV = new CodeableConcept(codingToValidate);
|
||||
|
||||
// With correct system version specified. Should pass.
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
|
@ -1480,6 +1638,20 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version and latest CodeSystem version. Should pass.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "codeableConcept", codeableConceptToValidate_v2)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With incorrect version specified. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
|
@ -1509,6 +1681,62 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no ValueSet version and older CodeSystem version. Should fail.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "codeableConcept", codeableConceptToValidate_v1)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
// With no CodeSystem version. Should pass for all ValueSet versions.
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "codeableConcept", codeableConceptToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("valueSetVersion", new StringType("1"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "codeableConcept", codeableConceptToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("valueSetVersion", new StringType("2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("validate-code")
|
||||
.withParameter(Parameters.class, "codeableConcept", codeableConceptToValidate_noV)
|
||||
.andParameter("url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.execute();
|
||||
|
||||
resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(respParam);
|
||||
ourLog.info(resp);
|
||||
|
||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
||||
|
||||
}
|
||||
|
||||
private boolean clearDeferredStorageQueue() {
|
|
@ -1417,6 +1417,50 @@ public class ResourceProviderR5ValueSetTest extends BaseResourceProviderR5Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByValueSetWithFilter() throws IOException {
|
||||
loadAndPersistCodeSystem(HTTPVerb.POST);
|
||||
|
||||
ValueSet toExpand = loadResourceFromClasspath(ValueSet.class, "/extensional-case-3-vs.xml");
|
||||
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "valueSet", toExpand)
|
||||
.andParameter("filter", new StringType("blood"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExpandByUrlWithFilter() throws Exception {
|
||||
loadAndPersistCodeSystemAndValueSet(HTTPVerb.POST);
|
||||
|
||||
Parameters respParam = myClient
|
||||
.operation()
|
||||
.onType(ValueSet.class)
|
||||
.named("expand")
|
||||
.withParameter(Parameters.class, "url", new UriType("http://www.healthintersections.com.au/fhir/ValueSet/extensional-case-2"))
|
||||
.andParameter("filter", new StringType("first"))
|
||||
.execute();
|
||||
ValueSet expanded = (ValueSet) respParam.getParameter().get(0).getResource();
|
||||
|
||||
String resp = myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(expanded);
|
||||
ourLog.info(resp);
|
||||
assertThat(resp, stringContainsInOrder(
|
||||
"<code value=\"11378-7\"/>",
|
||||
"<display value=\"Systolic blood pressure at First encounter\"/>"));
|
||||
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void afterResetPreExpansionDefault() {
|
||||
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
||||
|
|
|
@ -1099,7 +1099,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1121,7 +1122,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1131,7 +1133,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1146,7 +1149,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|1", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("1", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1172,7 +1176,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8450-9", concept.getCode());
|
||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||
assertEquals(2, concept.getDesignations().size());
|
||||
|
@ -1194,7 +1199,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(1);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("11378-7", concept.getCode());
|
||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
@ -1204,7 +1210,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(22);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8491-3", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(1, concept.getDesignations().size());
|
||||
|
@ -1219,7 +1226,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
|||
|
||||
concept = termValueSet.getConcepts().get(23);
|
||||
ourLog.info("Concept:\n" + concept.toString());
|
||||
assertEquals("http://acme.org|2", concept.getSystem());
|
||||
assertEquals("http://acme.org", concept.getSystem());
|
||||
assertEquals("2", concept.getSystemVersion());
|
||||
assertEquals("8492-1", concept.getCode());
|
||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||
assertEquals(0, concept.getDesignations().size());
|
||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.migrate.tasks;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.entity.EmpiLink;
|
||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||
import ca.uhn.fhir.jpa.entity.TermConceptMap;
|
||||
import ca.uhn.fhir.jpa.entity.TermValueSet;
|
||||
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
||||
|
@ -157,6 +158,12 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
trmValueSet.addColumn("20200923.2", "VER").nullable().type(ColumnTypeEnum.STRING, TermValueSet.MAX_VER_LENGTH);
|
||||
trmValueSet.dropIndex("20200923.3", "IDX_VALUESET_URL");
|
||||
trmValueSet.addIndex("20200923.4", "IDX_VALUESET_URL").unique(true).withColumns("URL", "VER");
|
||||
|
||||
//Term ValueSet Component add system version
|
||||
Builder.BuilderWithTableName trmValueSetComp = version.onTable("TRM_VALUESET_CONCEPT");
|
||||
trmValueSetComp.addColumn("20201028.1", "SYSTEM_VER").nullable().type(ColumnTypeEnum.STRING, TermCodeSystemVersion.MAX_VERSION_LENGTH);
|
||||
trmValueSetComp.dropIndex("20201028.2", "IDX_VS_CONCEPT_CS_CD");
|
||||
trmValueSetComp.addIndex("20201028.3", "IDX_VS_CONCEPT_CS_CD").unique(true).withColumns("VALUESET_PID", "SYSTEM_URL", "SYSTEM_VER", "CODEVAL");
|
||||
}
|
||||
|
||||
protected void init510_20200725() {
|
||||
|
|
Loading…
Reference in New Issue