Im 20201028 fix versioned valueset expansions (#2151)
* Fixes to ValueSet expansion for cases where CodeSystem is versioned. * Fixes to ValueSet expansion for case where URL and filter parameters specified. * Restore maven-wrapper.properties file inadvertently deleted from GitHub. * Fix JUnit tests and ValueSet exclude. Co-authored-by: ianmarshall <ian@simpatico.ai>
This commit is contained in:
parent
228e75b501
commit
38a975f09d
|
@ -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")
|
@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);
|
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")
|
@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);
|
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")
|
@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);
|
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")
|
@Query("SELECT vsc.myId FROM TermValueSetConcept vsc WHERE vsc.myValueSetPid = :pid ORDER BY vsc.myId")
|
||||||
List<Long> findIdsByTermValueSetId(@Param("pid") Long theValueSetId);
|
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) {
|
private void validateIncludes(String name, List<ConceptSetComponent> listToValidate) {
|
||||||
for (ConceptSetComponent nextExclude : 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");
|
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();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(FilterOperator.EQUAL);
|
filter.setOp(FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doExpand(source);
|
return doExpand(source);
|
||||||
|
@ -150,14 +149,13 @@ public class FhirResourceDaoValueSetDstu3 extends BaseHapiFhirResourceDao<ValueS
|
||||||
ValueSet source = new ValueSet();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(FilterOperator.EQUAL);
|
filter.setOp(FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doExpand(source, theOffset, theCount);
|
return doExpand(source, theOffset, theCount);
|
||||||
|
|
|
@ -99,14 +99,13 @@ public class FhirResourceDaoValueSetR4 extends BaseHapiFhirResourceDao<ValueSet>
|
||||||
ValueSet source = new ValueSet();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(FilterOperator.EQUAL);
|
filter.setOp(FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doExpand(source);
|
return doExpand(source);
|
||||||
|
@ -133,14 +132,13 @@ public class FhirResourceDaoValueSetR4 extends BaseHapiFhirResourceDao<ValueSet>
|
||||||
ValueSet source = new ValueSet();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(FilterOperator.EQUAL);
|
filter.setOp(FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doExpand(source, theOffset, theCount);
|
return doExpand(source, theOffset, theCount);
|
||||||
|
|
|
@ -99,14 +99,13 @@ public class FhirResourceDaoValueSetR5 extends BaseHapiFhirResourceDao<ValueSet>
|
||||||
ValueSet source = new ValueSet();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueSet retVal = doExpand(source);
|
ValueSet retVal = doExpand(source);
|
||||||
|
@ -134,14 +133,13 @@ public class FhirResourceDaoValueSetR5 extends BaseHapiFhirResourceDao<ValueSet>
|
||||||
ValueSet source = new ValueSet();
|
ValueSet source = new ValueSet();
|
||||||
source.setUrl(theUri);
|
source.setUrl(theUri);
|
||||||
|
|
||||||
source.getCompose().addInclude().addValueSet(theUri);
|
|
||||||
|
|
||||||
if (isNotBlank(theFilter)) {
|
if (isNotBlank(theFilter)) {
|
||||||
ConceptSetComponent include = source.getCompose().addInclude();
|
ConceptSetFilterComponent filter = source.getCompose().addInclude().addValueSet(theUri).addFilter();
|
||||||
ConceptSetFilterComponent filter = include.addFilter();
|
|
||||||
filter.setProperty("display");
|
filter.setProperty("display");
|
||||||
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
filter.setOp(Enumerations.FilterOperator.EQUAL);
|
||||||
filter.setValue(theFilter);
|
filter.setValue(theFilter);
|
||||||
|
} else {
|
||||||
|
source.getCompose().addInclude().addValueSet(theUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doExpand(source, theOffset, theCount);
|
return doExpand(source, theOffset, theCount);
|
||||||
|
|
|
@ -40,7 +40,7 @@ import static org.apache.commons.lang3.StringUtils.length;
|
||||||
* bork up migration tasks.
|
* bork up migration tasks.
|
||||||
*/
|
*/
|
||||||
@Table(name = "TRM_VALUESET_CONCEPT", uniqueConstraints = {
|
@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"})
|
@UniqueConstraint(name = "IDX_VS_CONCEPT_ORDER", columnNames = {"VALUESET_PID", "VALUESET_ORDER"})
|
||||||
})
|
})
|
||||||
@Entity()
|
@Entity()
|
||||||
|
@ -72,6 +72,9 @@ public class TermValueSetConcept implements Serializable {
|
||||||
@Column(name = "SYSTEM_URL", nullable = false, length = TermCodeSystem.MAX_URL_LENGTH)
|
@Column(name = "SYSTEM_URL", nullable = false, length = TermCodeSystem.MAX_URL_LENGTH)
|
||||||
private String mySystem;
|
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)
|
@Column(name = "CODEVAL", nullable = false, length = TermConcept.MAX_CODE_LENGTH)
|
||||||
private String myCode;
|
private String myCode;
|
||||||
|
|
||||||
|
@ -134,6 +137,17 @@ public class TermValueSetConcept implements Serializable {
|
||||||
return this;
|
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() {
|
public String getCode() {
|
||||||
return myCode;
|
return myCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,14 +248,13 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
return cs != null;
|
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 codeSystem = theConcept.getCodeSystemVersion().getCodeSystem().getCodeSystemUri();
|
||||||
String codeSystemVersion = theConcept.getCodeSystemVersion().getCodeSystemVersionId();
|
|
||||||
String code = theConcept.getCode();
|
String code = theConcept.getCode();
|
||||||
String display = theConcept.getDisplay();
|
String display = theConcept.getDisplay();
|
||||||
Collection<TermConceptDesignation> designations = theConcept.getDesignations();
|
Collection<TermConceptDesignation> designations = theConcept.getDesignations();
|
||||||
if (StringUtils.isNotEmpty(codeSystemVersion)) {
|
if (StringUtils.isNotEmpty(theValueSetIncludeVersion)) {
|
||||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem + "|" + codeSystemVersion, code, display);
|
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem + "|" + theValueSetIncludeVersion, code, display);
|
||||||
} else {
|
} else {
|
||||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, designations, theAdd, theCodeCounter, codeSystem, code, display);
|
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) {
|
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 (StringUtils.isNotEmpty(theCodeSystemVersion)) {
|
||||||
if (isNoneBlank(theCodeSystem, theCode)) {
|
if (isNoneBlank(theCodeSystem, theCode)) {
|
||||||
if (theAdd && theAddedCodes.add(theCodeSystem + "|" + theCode + "|" + theCodeSystemVersion)) {
|
if (theAdd && theAddedCodes.add(theCodeSystem + "|" + theCode)) {
|
||||||
theValueSetCodeAccumulator.includeConceptWithDesignations(theCodeSystem + "|" + theCodeSystemVersion, theCode, theDisplay, theDesignations);
|
theValueSetCodeAccumulator.includeConceptWithDesignations(theCodeSystem + "|" + theCodeSystemVersion, theCode, theDisplay, theDesignations);
|
||||||
theCodeCounter.incrementAndGet();
|
theCodeCounter.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!theAdd && theAddedCodes.remove(theCodeSystem + "|" + theCode + "|" + theCodeSystemVersion)) {
|
if (!theAdd && theAddedCodes.remove(theCodeSystem + "|" + theCode)) {
|
||||||
theValueSetCodeAccumulator.excludeConcept(theCodeSystem + "|" + theCodeSystemVersion, theCode);
|
theValueSetCodeAccumulator.excludeConcept(theCodeSystem + "|" + theCodeSystemVersion, theCode);
|
||||||
theCodeCounter.decrementAndGet();
|
theCodeCounter.decrementAndGet();
|
||||||
}
|
}
|
||||||
|
@ -785,7 +784,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
myConceptDao
|
myConceptDao
|
||||||
.findByCodeSystemAndCode(termCodeSystemVersion, nextConcept.getCode())
|
.findByCodeSystemAndCode(termCodeSystemVersion, nextConcept.getCode())
|
||||||
.ifPresent(concept ->
|
.ifPresent(concept ->
|
||||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter)
|
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter, nextConcept.getSystemVersion())
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// This will happen if we're expanding against a built-in (part of FHIR) ValueSet that
|
// 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
|
@Nonnull
|
||||||
private Boolean expandValueSetHandleIncludeOrExcludeUsingDatabase(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set<String> theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, FhirVersionIndependentConcept theWantConceptOrNull, String theSystem, TermCodeSystem theCs) {
|
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;
|
TermCodeSystemVersion csv;
|
||||||
if (isEmpty(codeSystemVersion)) {
|
if (isEmpty(includeOrExcludeVersion)) {
|
||||||
csv = theCs.getCurrentVersion();
|
csv = theCs.getCurrentVersion();
|
||||||
} else {
|
} else {
|
||||||
csv = myCodeSystemVersionDao.findByCodeSystemPidAndVersion(theCs.getPid(), codeSystemVersion);
|
csv = myCodeSystemVersionDao.findByCodeSystemPidAndVersion(theCs.getPid(), includeOrExcludeVersion);
|
||||||
}
|
}
|
||||||
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
FullTextEntityManager em = org.hibernate.search.jpa.Search.getFullTextEntityManager(myEntityManager);
|
||||||
|
|
||||||
|
@ -846,8 +845,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
* Filters
|
* Filters
|
||||||
*/
|
*/
|
||||||
String codeSystemUrlAndVersion;
|
String codeSystemUrlAndVersion;
|
||||||
if (codeSystemVersion != null) {
|
if (includeOrExcludeVersion != null) {
|
||||||
codeSystemUrlAndVersion = theSystem + "|" + codeSystemVersion;
|
codeSystemUrlAndVersion = theSystem + "|" + includeOrExcludeVersion;
|
||||||
} else {
|
} else {
|
||||||
codeSystemUrlAndVersion = theSystem;
|
codeSystemUrlAndVersion = theSystem;
|
||||||
}
|
}
|
||||||
|
@ -926,7 +925,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
countForBatch.incrementAndGet();
|
countForBatch.incrementAndGet();
|
||||||
TermConcept concept = (TermConcept) next;
|
TermConcept concept = (TermConcept) next;
|
||||||
try {
|
try {
|
||||||
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter);
|
addCodeIfNotAlreadyAdded(theValueSetCodeAccumulator, theAddedCodes, concept, theAdd, theCodeCounter, includeOrExcludeVersion);
|
||||||
} catch (ExpansionTooCostlyException e) {
|
} catch (ExpansionTooCostlyException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1278,7 +1277,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
|
|
||||||
if (theInclude.getConcept().isEmpty()) {
|
if (theInclude.getConcept().isEmpty()) {
|
||||||
for (TermConcept next : theVersion.getConcepts()) {
|
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)) {
|
if (!theSystem.equals(theInclude.getSystem()) && isNotBlank(theSystem)) {
|
||||||
continue;
|
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) {
|
private List<TermValueSetConcept> findByValueSetResourcePidSystemAndCode(ResourcePersistentId theResourcePid, String theSystem, String theCode) {
|
||||||
List<TermValueSetConcept> retVal = new ArrayList<>();
|
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);
|
optionalTermValueSetConcept.ifPresent(retVal::add);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,15 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get existing entity so it can be deleted.
|
// 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()) {
|
if (optionalConcept.isPresent()) {
|
||||||
TermValueSetConcept concept = optionalConcept.get();
|
TermValueSetConcept concept = optionalConcept.get();
|
||||||
|
@ -115,7 +123,13 @@ public class ValueSetConceptAccumulator implements IValueSetConceptAccumulator {
|
||||||
TermValueSetConcept concept = new TermValueSetConcept();
|
TermValueSetConcept concept = new TermValueSetConcept();
|
||||||
concept.setValueSet(myTermValueSet);
|
concept.setValueSet(myTermValueSet);
|
||||||
concept.setOrder(myConceptsSaved);
|
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);
|
concept.setCode(theCode);
|
||||||
if (isNotBlank(theDisplay)) {
|
if (isNotBlank(theDisplay)) {
|
||||||
concept.setDisplay(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_CODE_SYSTEM;
|
||||||
import static ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest.URL_MY_VALUE_SET;
|
import static ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoDstu3TerminologyTest.URL_MY_VALUE_SET;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3Test {
|
||||||
|
@ -833,6 +834,50 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3
|
||||||
assertEquals("Male", ((StringType) respParam.getParameter().get(1).getValue()).getValue());
|
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
|
@AfterEach
|
||||||
public void afterResetPreExpansionDefault() {
|
public void afterResetPreExpansionDefault() {
|
||||||
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
||||||
|
|
|
@ -1112,7 +1112,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1134,7 +1135,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1144,7 +1146,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1159,7 +1162,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1185,7 +1189,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1207,7 +1212,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1217,7 +1223,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1232,7 +1239,8 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class ResourceProviderR4CodeSystemTest extends BaseResourceProviderR4Test
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLookupOnExternalCode() {
|
public void testLookupOnExternalCode() {
|
||||||
ResourceProviderR4ValueSetTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd);
|
ResourceProviderR4ValueSetNoVerCSNoVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd);
|
||||||
|
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
|
|
@ -89,8 +89,8 @@ public class ResourceProviderR4CodeSystemVersionedTest extends BaseResourceProvi
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLookupOnExternalCodeMultiVersion() {
|
public void testLookupOnExternalCodeMultiVersion() {
|
||||||
ResourceProviderR4ValueSetVersionedTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "1");
|
ResourceProviderR4ValueSetVerCSVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "1");
|
||||||
ResourceProviderR4ValueSetVersionedTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "2");
|
ResourceProviderR4ValueSetVerCSVerTest.createExternalCs(myCodeSystemDao, myResourceTableDao, myTermCodeSystemStorageSvc, mySrd, "2");
|
||||||
|
|
||||||
// First test with no version specified (should return from last version created)
|
// First test with no version specified (should return from last version created)
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
|
|
|
@ -64,15 +64,14 @@ import static org.hamcrest.Matchers.containsStringIgnoringCase;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.stringContainsInOrder;
|
import static org.hamcrest.Matchers.stringContainsInOrder;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
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.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
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 myExtensionalCsId;
|
||||||
private IIdType myExtensionalVsId;
|
private IIdType myExtensionalVsId;
|
||||||
private IIdType myLocalValueSetId;
|
private IIdType myLocalValueSetId;
|
||||||
|
@ -923,9 +922,19 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateCodeOperationByCodeAndSystemInstance() throws Exception {
|
public void testValidateCodeOperationByCodeAndSystemInstanceBeforeExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationByCodeAndSystemInstanceAfterExpand() throws Exception {
|
||||||
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeAndSystemInstance() throws Exception {
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
.onInstance(myExtensionalVsId)
|
.onInstance(myExtensionalVsId)
|
||||||
|
@ -941,10 +950,50 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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();
|
createLocalCs();
|
||||||
createLocalVsWithIncludeConcept();
|
createLocalVsWithIncludeConcept();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstanceOnType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationByCodeAndSystemInstanceOnTypeAfterExpand() throws IOException {
|
||||||
|
createLocalCs();
|
||||||
|
createLocalVsWithIncludeConcept();
|
||||||
|
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstanceOnType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeAndSystemInstanceOnType() throws IOException {
|
||||||
String url = ourServerBase +
|
String url = ourServerBase +
|
||||||
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
||||||
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
||||||
|
@ -962,10 +1011,21 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstance() throws IOException {
|
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstanceBeforeExpand() throws IOException {
|
||||||
createLocalCs();
|
createLocalCs();
|
||||||
createLocalVsWithIncludeConcept();
|
createLocalVsWithIncludeConcept();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstanceOnInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationByCodeAndSystemInstanceOnInstanceAfterExpand() throws IOException {
|
||||||
|
createLocalCs();
|
||||||
|
createLocalVsWithIncludeConcept();
|
||||||
|
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeAndSystemInstanceOnInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeAndSystemInstanceOnInstance() throws IOException {
|
||||||
String url = ourServerBase +
|
String url = ourServerBase +
|
||||||
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
"/ValueSet/" + myLocalValueSetId.getIdPart() + "/$validate-code?system=" +
|
||||||
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
UrlUtil.escapeUrlParam(URL_MY_CODE_SYSTEM) +
|
||||||
|
@ -985,9 +1045,19 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateCodeOperationByCodeAndSystemType() throws Exception {
|
public void testValidateCodeOperationByCodeAndSystemTypeBeforeExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
testValidateCodeOperationByCodeAndSystemType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationByCodeAndSystemTypeAfterExpand() throws Exception {
|
||||||
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
myTermSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeAndSystemType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeAndSystemType() throws Exception {
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
.onInstance(myExtensionalVsId)
|
.onInstance(myExtensionalVsId)
|
||||||
|
@ -1089,9 +1159,63 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@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();
|
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");
|
Coding codingToValidate = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||||
|
|
||||||
// With correct system version specified. Should pass.
|
// With correct system version specified. Should pass.
|
||||||
|
@ -1110,8 +1234,6 @@ public class ResourceProviderR4ValueSetTest extends BaseResourceProviderR4Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean clearDeferredStorageQueue() {
|
private boolean clearDeferredStorageQueue() {
|
||||||
|
|
||||||
if(!myTerminologyDeferredStorageSvc.isStorageQueueEmpty()) {
|
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.entity.TermValueSetPreExpansionStatusEnum;
|
||||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
|
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.api.server.storage.ResourcePersistentId;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
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.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.r4.model.BooleanType;
|
import org.hl7.fhir.r4.model.BooleanType;
|
||||||
import org.hl7.fhir.r4.model.Bundle;
|
import org.hl7.fhir.r4.model.Bundle;
|
||||||
import org.hl7.fhir.r4.model.CodeSystem;
|
import org.hl7.fhir.r4.model.CodeSystem;
|
||||||
import org.hl7.fhir.r4.model.CodeSystem.CodeSystemContentMode;
|
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.CodeType;
|
||||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||||
import org.hl7.fhir.r4.model.Coding;
|
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.IdType;
|
||||||
import org.hl7.fhir.r4.model.Parameters;
|
import org.hl7.fhir.r4.model.Parameters;
|
||||||
import org.hl7.fhir.r4.model.StringType;
|
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.hl7.fhir.r4.model.codesystems.HttpVerb;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Slice;
|
import org.springframework.data.domain.Slice;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
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.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
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_v1;
|
||||||
private IIdType myExtensionalCsId_v2;
|
private IIdType myExtensionalCsId_v2;
|
||||||
private IIdType myExtensionalVsId_v1;
|
private IIdType myExtensionalVsId_v1;
|
||||||
|
@ -79,6 +74,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
private Long myExtensionalVsIdOnResourceTable_v2;
|
private Long myExtensionalVsIdOnResourceTable_v2;
|
||||||
private ValueSet myLocalVs_v1;
|
private ValueSet myLocalVs_v1;
|
||||||
private ValueSet myLocalVs_v2;
|
private ValueSet myLocalVs_v2;
|
||||||
|
@Autowired
|
||||||
|
private ITermReadSvc myTermReadSvc;
|
||||||
|
|
||||||
private void loadAndPersistCodeSystemAndValueSet() throws IOException {
|
private void loadAndPersistCodeSystemAndValueSet() throws IOException {
|
||||||
loadAndPersistCodeSystem();
|
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) {
|
private ValueSet createLocalVs(String theCodeSystemUrl, String theValueSetVersion) {
|
||||||
ValueSet myLocalVs = new ValueSet();
|
ValueSet myLocalVs = new ValueSet();
|
||||||
myLocalVs.setUrl(URL_MY_VALUE_SET);
|
myLocalVs.setUrl(URL_MY_VALUE_SET);
|
||||||
|
@ -1105,7 +1062,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1127,7 +1085,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1137,7 +1096,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1152,7 +1112,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1178,7 +1139,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1200,7 +1162,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1210,7 +1173,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1225,7 +1189,8 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1234,8 +1199,19 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateCodeOperationByCodeAndSystem() throws Exception {
|
public void testValidateCodeOperationByCodeAndSystemBeforeExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
testValidateCodeOperationByCodeAndSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationByCodeAndSystemAfterExpand() throws Exception {
|
||||||
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeAndSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeAndSystem() throws Exception {
|
||||||
|
|
||||||
// With correct system version specified. Should pass.
|
// With correct system version specified. Should pass.
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
|
@ -1270,6 +1246,37 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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.
|
// With incorrect version specified. Should fail.
|
||||||
respParam = myClient
|
respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1303,12 +1310,38 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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
|
@Test
|
||||||
public void testValidateCodeOperationOnInstanceByCodeAndSystem() throws Exception {
|
public void testValidateCodeOperationOnInstanceByCodeAndSystemBeforeExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
testValidateCodeOperationOnInstanceByCodeAndSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testValidateCodeOperationOnInstanceByCodeAndSystemAfterExpand() throws Exception {
|
||||||
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationOnInstanceByCodeAndSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationOnInstanceByCodeAndSystem() throws Exception {
|
||||||
// With correct system version specified. Should pass.
|
// With correct system version specified. Should pass.
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.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());
|
||||||
|
|
||||||
|
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.
|
// With incorrect version specified. Should fail.
|
||||||
respParam = myClient
|
respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1370,15 +1432,27 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidateCodeOperationByCoding() throws Exception {
|
public void testValidateCodeOperationByCodingBeforeExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
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");
|
Coding codingToValidate_v1 = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||||
codingToValidate_v1.setVersion("1");
|
codingToValidate_v1.setVersion("1");
|
||||||
|
|
||||||
Coding codingToValidate_v2 = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum v2");
|
Coding codingToValidate_v2 = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum v2");
|
||||||
codingToValidate_v2.setVersion("2");
|
codingToValidate_v2.setVersion("2");
|
||||||
|
|
||||||
|
Coding codingToValidate_noV = new Coding("http://acme.org", "8495-4", null);
|
||||||
|
|
||||||
// With correct system version specified. Should pass.
|
// With correct system version specified. Should pass.
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1408,6 +1482,20 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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.
|
// With incorrect version specified. Should fail.
|
||||||
respParam = myClient
|
respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1437,11 +1525,78 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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
|
@Test
|
||||||
public void testValidateCodeOperationByCodeableConcept() throws Exception {
|
public void testValidateCodeOperationByCodeableConceptAfterExpand() throws Exception {
|
||||||
loadAndPersistCodeSystemAndValueSet();
|
loadAndPersistCodeSystemAndValueSet();
|
||||||
|
myTermReadSvc.preExpandDeferredValueSetsToTerminologyTables();
|
||||||
|
testValidateCodeOperationByCodeableConcept();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testValidateCodeOperationByCodeableConcept() throws Exception {
|
||||||
|
|
||||||
Coding codingToValidate = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
Coding codingToValidate = new Coding("http://acme.org", "8495-4", "Systolic blood pressure 24 hour minimum");
|
||||||
codingToValidate.setVersion("1");
|
codingToValidate.setVersion("1");
|
||||||
|
@ -1451,6 +1606,9 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
codingToValidate.setVersion("2");
|
codingToValidate.setVersion("2");
|
||||||
CodeableConcept codeableConceptToValidate_v2 = new CodeableConcept(codingToValidate);
|
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.
|
// With correct system version specified. Should pass.
|
||||||
Parameters respParam = myClient
|
Parameters respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1480,6 +1638,20 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertTrue(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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.
|
// With incorrect version specified. Should fail.
|
||||||
respParam = myClient
|
respParam = myClient
|
||||||
.operation()
|
.operation()
|
||||||
|
@ -1509,6 +1681,62 @@ public class ResourceProviderR4ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
assertFalse(((BooleanType) respParam.getParameter().get(0).getValue()).booleanValue());
|
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() {
|
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
|
@AfterEach
|
||||||
public void afterResetPreExpansionDefault() {
|
public void afterResetPreExpansionDefault() {
|
||||||
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
myDaoConfig.setPreExpandValueSets(new DaoConfig().isPreExpandValueSets());
|
||||||
|
|
|
@ -1099,7 +1099,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1121,7 +1122,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1131,7 +1133,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1146,7 +1149,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1172,7 +1176,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
TermValueSetConcept concept = termValueSet.getConcepts().get(0);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8450-9", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure--expiration v2", concept.getDisplay());
|
||||||
assertEquals(2, concept.getDesignations().size());
|
assertEquals(2, concept.getDesignations().size());
|
||||||
|
@ -1194,7 +1199,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(1);
|
concept = termValueSet.getConcepts().get(1);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("11378-7", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure at First encounter v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
assertEquals(0, concept.getDesignations().size());
|
||||||
|
@ -1204,7 +1210,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(22);
|
concept = termValueSet.getConcepts().get(22);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8491-3", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 1 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(1, concept.getDesignations().size());
|
assertEquals(1, concept.getDesignations().size());
|
||||||
|
@ -1219,7 +1226,8 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide
|
||||||
|
|
||||||
concept = termValueSet.getConcepts().get(23);
|
concept = termValueSet.getConcepts().get(23);
|
||||||
ourLog.info("Concept:\n" + concept.toString());
|
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("8492-1", concept.getCode());
|
||||||
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
assertEquals("Systolic blood pressure 8 hour minimum v2", concept.getDisplay());
|
||||||
assertEquals(0, concept.getDesignations().size());
|
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.EmpiLink;
|
||||||
|
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||||
import ca.uhn.fhir.jpa.entity.TermConceptMap;
|
import ca.uhn.fhir.jpa.entity.TermConceptMap;
|
||||||
import ca.uhn.fhir.jpa.entity.TermValueSet;
|
import ca.uhn.fhir.jpa.entity.TermValueSet;
|
||||||
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
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.addColumn("20200923.2", "VER").nullable().type(ColumnTypeEnum.STRING, TermValueSet.MAX_VER_LENGTH);
|
||||||
trmValueSet.dropIndex("20200923.3", "IDX_VALUESET_URL");
|
trmValueSet.dropIndex("20200923.3", "IDX_VALUESET_URL");
|
||||||
trmValueSet.addIndex("20200923.4", "IDX_VALUESET_URL").unique(true).withColumns("URL", "VER");
|
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() {
|
protected void init510_20200725() {
|
||||||
|
|
Loading…
Reference in New Issue