Issue 2851 upload terminology valueset parallel versioning (#3051)
* Fix operations for 'loinc-all' ValueSet * Fix tests Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
bc2cd7cafc
commit
71e2b82128
|
@ -104,7 +104,7 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBaseResource fetchCodeSystem(String theSystem) {
|
public IBaseResource fetchCodeSystem(String theSystem) {
|
||||||
if (TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(theSystem)) {
|
if (TermReadSvcUtil.isLoincUnversionedCodeSystem(theSystem)) {
|
||||||
Optional<IBaseResource> currentCSOpt = getCodeSystemCurrentVersion(new UriType(theSystem));
|
Optional<IBaseResource> currentCSOpt = getCodeSystemCurrentVersion(new UriType(theSystem));
|
||||||
if (! currentCSOpt.isPresent()) {
|
if (! currentCSOpt.isPresent()) {
|
||||||
ourLog.info("Couldn't find current version of CodeSystem: " + theSystem);
|
ourLog.info("Couldn't find current version of CodeSystem: " + theSystem);
|
||||||
|
@ -128,7 +128,7 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBaseResource fetchValueSet(String theSystem) {
|
public IBaseResource fetchValueSet(String theSystem) {
|
||||||
if (TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(theSystem)) {
|
if (TermReadSvcUtil.isLoincUnversionedValueSet(theSystem)) {
|
||||||
Optional<IBaseResource> currentVSOpt = getValueSetCurrentVersion(new UriType(theSystem));
|
Optional<IBaseResource> currentVSOpt = getValueSetCurrentVersion(new UriType(theSystem));
|
||||||
return currentVSOpt.orElseThrow(() -> new ResourceNotFoundException(
|
return currentVSOpt.orElseThrow(() -> new ResourceNotFoundException(
|
||||||
"Unable to find current version of ValueSet for url: " + theSystem));
|
"Unable to find current version of ValueSet for url: " + theSystem));
|
||||||
|
|
|
@ -2348,7 +2348,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<TermValueSet> findCurrentTermValueSet(String theUrl) {
|
public Optional<TermValueSet> findCurrentTermValueSet(String theUrl) {
|
||||||
if (TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(theUrl)) {
|
if (TermReadSvcUtil.isLoincUnversionedValueSet(theUrl)) {
|
||||||
Optional<String> vsIdOpt = TermReadSvcUtil.getValueSetId(theUrl);
|
Optional<String> vsIdOpt = TermReadSvcUtil.getValueSetId(theUrl);
|
||||||
if (! vsIdOpt.isPresent()) {
|
if (! vsIdOpt.isPresent()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
|
|
@ -67,7 +67,6 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.LineNumberReader;
|
import java.io.LineNumberReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.security.InvalidParameterException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -134,6 +133,7 @@ import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_UNIVERS
|
||||||
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_UPLOAD_PROPERTIES_FILE;
|
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_UPLOAD_PROPERTIES_FILE;
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
|
@ -719,10 +719,9 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
|
||||||
String codeSystemVersionId = theUploadProperties.getProperty(LOINC_CODESYSTEM_VERSION.getCode());
|
String codeSystemVersionId = theUploadProperties.getProperty(LOINC_CODESYSTEM_VERSION.getCode());
|
||||||
String valueSetId;
|
String valueSetId;
|
||||||
if (codeSystemVersionId != null) {
|
if (codeSystemVersionId != null) {
|
||||||
valueSetId = "loinc-all" + "-" + codeSystemVersionId;
|
valueSetId = LOINC_ALL_VALUESET_ID + "-" + codeSystemVersionId;
|
||||||
} else {
|
} else {
|
||||||
valueSetId = "loinc-all";
|
valueSetId = LOINC_ALL_VALUESET_ID;
|
||||||
codeSystemVersionId = "1.0.0";
|
|
||||||
}
|
}
|
||||||
retVal.setId(valueSetId);
|
retVal.setId(valueSetId);
|
||||||
retVal.setUrl("http://loinc.org/vs");
|
retVal.setUrl("http://loinc.org/vs");
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
|
||||||
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_GENERIC_VALUESET_URL;
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_GENERIC_VALUESET_URL;
|
||||||
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_GENERIC_VALUESET_URL_PLUS_SLASH;
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_GENERIC_VALUESET_URL_PLUS_SLASH;
|
||||||
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW;
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW;
|
||||||
|
@ -38,6 +39,11 @@ public class TermReadSvcUtil {
|
||||||
if (! theUrl.startsWith(LOINC_GENERIC_VALUESET_URL)) return Optional.empty();
|
if (! theUrl.startsWith(LOINC_GENERIC_VALUESET_URL)) return Optional.empty();
|
||||||
|
|
||||||
if (! theUrl.startsWith(LOINC_GENERIC_VALUESET_URL_PLUS_SLASH)) {
|
if (! theUrl.startsWith(LOINC_GENERIC_VALUESET_URL_PLUS_SLASH)) {
|
||||||
|
if (theUrl.equals(LOINC_GENERIC_VALUESET_URL)) {
|
||||||
|
// the request is for the loinc all valueset which when loading was given the name: 'loinc-all'
|
||||||
|
return Optional.of(LOINC_ALL_VALUESET_ID);
|
||||||
|
}
|
||||||
|
|
||||||
ourLog.error("Don't know how to extract ValueSet's ForcedId from url: " + theUrl);
|
ourLog.error("Don't know how to extract ValueSet's ForcedId from url: " + theUrl);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -47,16 +53,15 @@ public class TermReadSvcUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isLoincNotGenericUnversionedValueSet(String theUrl) {
|
public static boolean isLoincUnversionedValueSet(String theUrl) {
|
||||||
boolean isLoincCodeSystem = StringUtils.containsIgnoreCase(theUrl, LOINC_LOW);
|
boolean isLoincCodeSystem = StringUtils.containsIgnoreCase(theUrl, LOINC_LOW);
|
||||||
boolean isNoVersion = ! theUrl.contains("|");
|
boolean isNoVersion = ! theUrl.contains("|");
|
||||||
boolean isNotLoincGenericValueSet = ! theUrl.equals(LOINC_GENERIC_VALUESET_URL);
|
|
||||||
|
|
||||||
return isLoincCodeSystem && isNoVersion && isNotLoincGenericValueSet;
|
return isLoincCodeSystem && isNoVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isLoincNotGenericUnversionedCodeSystem(String theUrl) {
|
public static boolean isLoincUnversionedCodeSystem(String theUrl) {
|
||||||
boolean isLoincCodeSystem = StringUtils.containsIgnoreCase(theUrl, LOINC_LOW);
|
boolean isLoincCodeSystem = StringUtils.containsIgnoreCase(theUrl, LOINC_LOW);
|
||||||
boolean isNoVersion = ! theUrl.contains("|");
|
boolean isNoVersion = ! theUrl.contains("|");
|
||||||
|
|
||||||
|
|
|
@ -44,28 +44,28 @@ class TermReadSvcUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doesntContainLoincReturnsFalse() {
|
void doesntContainLoincReturnsFalse() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
|
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
|
||||||
"http://l-oinc.org/vs/radiology-playbook");
|
"http://l-oinc.org/vs/radiology-playbook");
|
||||||
assertFalse(result);
|
assertFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void containsVersionDelimiterReturnsFalse() {
|
void containsVersionDelimiterReturnsFalse() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
|
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
|
||||||
"http://loinc.org/vs/radiology-playbook|v2.68");
|
"http://loinc.org/vs/radiology-playbook|v2.68");
|
||||||
assertFalse(result);
|
assertFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isLoincGenericValueSetUrlReturnsFalse() {
|
void isLoincAllValueSetUrlReturnsTrue() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
|
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
|
||||||
"http://loinc.org/vs");
|
"http://loinc.org/vs");
|
||||||
assertFalse(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isLoincWithoutVersionAndNotGenericValuesetUrlReturnsTrue() {
|
void isLoincWithoutVersionAndNotGenericValuesetUrlReturnsTrue() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
|
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
|
||||||
"http://loinc.org/vs/radiology-playbook");
|
"http://loinc.org/vs/radiology-playbook");
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
@ -78,21 +78,21 @@ class TermReadSvcUtilTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doesntContainLoincReturnsFalse() {
|
void doesntContainLoincReturnsFalse() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
|
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
|
||||||
"http://loin-c.org");
|
"http://loin-c.org");
|
||||||
assertFalse(result);
|
assertFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void hasVersionDelimiterReturnsFalse() {
|
void hasVersionDelimiterReturnsFalse() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
|
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
|
||||||
"http://loinc.org|v2.68");
|
"http://loinc.org|v2.68");
|
||||||
assertFalse(result);
|
assertFalse(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void containsLoincNadNoVersionDelimiterReturnsTrue() {
|
void containsLoincNadNoVersionDelimiterReturnsTrue() {
|
||||||
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
|
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
|
||||||
"http://loinc.org");
|
"http://loinc.org");
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import static org.hamcrest.Matchers.empty;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
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.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test {
|
public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test {
|
||||||
|
@ -246,7 +245,7 @@ public class TerminologyLoaderSvcIntegrationDstu3Test extends BaseJpaDstu3Test {
|
||||||
|
|
||||||
IValidationSupport.CodeValidationResult result = myValueSetDao.validateCode(new UriType("http://loinc.org/vs"), null, new StringType("10013-1-9999999999"), new StringType(ITermLoaderSvc.LOINC_URI), null, null, null, mySrd);
|
IValidationSupport.CodeValidationResult result = myValueSetDao.validateCode(new UriType("http://loinc.org/vs"), null, new StringType("10013-1-9999999999"), new StringType(ITermLoaderSvc.LOINC_URI), null, null, null, mySrd);
|
||||||
assertFalse(result.isOk());
|
assertFalse(result.isOk());
|
||||||
assertEquals("Failed to expand ValueSet 'http://loinc.org/vs' (in-memory). Could not validate code http://loinc.org#10013-1-9999999999. Error was: Unable to expand ValueSet because CodeSystem could not be found: http://loinc.org|1.0.0", result.getMessage());
|
assertEquals("Failed to expand ValueSet 'http://loinc.org/vs' (in-memory). Could not validate code http://loinc.org#10013-1-9999999999", result.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> toExpandedCodes(ValueSet theExpanded) {
|
private Set<String> toExpandedCodes(ValueSet theExpanded) {
|
||||||
|
|
|
@ -72,6 +72,7 @@ import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_XML_FIL
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.contains;
|
import static org.hamcrest.Matchers.contains;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
|
||||||
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.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
@ -414,10 +415,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||||
assertNull(vs.getVersion());
|
assertNull(vs.getVersion());
|
||||||
|
|
||||||
// All LOINC codes
|
// All LOINC codes
|
||||||
assertTrue(valueSets.containsKey("loinc-all"));
|
assertTrue(valueSets.containsKey(LOINC_ALL_VALUESET_ID));
|
||||||
vs = valueSets.get("loinc-all");
|
vs = valueSets.get(LOINC_ALL_VALUESET_ID);
|
||||||
assertEquals("http://loinc.org/vs", vs.getUrl());
|
assertEquals("http://loinc.org/vs", vs.getUrl());
|
||||||
assertEquals("1.0.0", vs.getVersion());
|
assertNull(vs.getVersion());
|
||||||
assertEquals("All LOINC codes", vs.getName());
|
assertEquals("All LOINC codes", vs.getName());
|
||||||
assertEquals(Enumerations.PublicationStatus.ACTIVE, vs.getStatus());
|
assertEquals(Enumerations.PublicationStatus.ACTIVE, vs.getStatus());
|
||||||
assertTrue(vs.hasDate());
|
assertTrue(vs.hasDate());
|
||||||
|
@ -428,7 +429,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||||
assertTrue(vs.getCompose().hasInclude());
|
assertTrue(vs.getCompose().hasInclude());
|
||||||
assertEquals(1, vs.getCompose().getInclude().size());
|
assertEquals(1, vs.getCompose().getInclude().size());
|
||||||
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
|
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
|
||||||
assertEquals("1.0.0", vs.getVersion());
|
assertNull(vs.getVersion());
|
||||||
|
|
||||||
// IEEE Medical Device Codes
|
// IEEE Medical Device Codes
|
||||||
conceptMap = conceptMaps.get(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_ID);
|
conceptMap = conceptMaps.get(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_ID);
|
||||||
|
@ -520,8 +521,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||||
for (ValueSet loincVS : loincVS_resources) {
|
for (ValueSet loincVS : loincVS_resources) {
|
||||||
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
||||||
assertEquals("Beta.1", loincVS.getVersion());
|
assertEquals("Beta.1", loincVS.getVersion());
|
||||||
} else if (loincVS.getId().equals("loinc-all")) {
|
|
||||||
assertEquals("1.0.0", loincVS.getVersion());
|
|
||||||
} else {
|
} else {
|
||||||
assertNull(loincVS.getVersion());
|
assertNull(loincVS.getVersion());
|
||||||
}
|
}
|
||||||
|
@ -573,8 +572,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||||
for (ValueSet loincVS : loincVS_resources) {
|
for (ValueSet loincVS : loincVS_resources) {
|
||||||
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
||||||
assertEquals("Beta.1", loincVS.getVersion());
|
assertEquals("Beta.1", loincVS.getVersion());
|
||||||
} else if (loincVS.getId().equals("loinc-all")) {
|
|
||||||
assertEquals("1.0.0", loincVS.getVersion());
|
|
||||||
} else {
|
} else {
|
||||||
assertNull(loincVS.getVersion());
|
assertNull(loincVS.getVersion());
|
||||||
}
|
}
|
||||||
|
@ -626,8 +623,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
|
||||||
for (ValueSet loincVS : loincVS_resources) {
|
for (ValueSet loincVS : loincVS_resources) {
|
||||||
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
|
||||||
assertEquals("Beta.1", loincVS.getVersion());
|
assertEquals("Beta.1", loincVS.getVersion());
|
||||||
} else if (loincVS.getId().equals("loinc-all")) {
|
|
||||||
assertEquals("1.0.0", loincVS.getVersion());
|
|
||||||
} else {
|
} else {
|
||||||
assertNull(loincVS.getVersion());
|
assertNull(loincVS.getVersion());
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_UPLOAD_
|
||||||
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_XML_FILE;
|
import static ca.uhn.fhir.jpa.term.loinc.LoincUploadPropertiesEnum.LOINC_XML_FILE;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
|
||||||
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW;
|
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW;
|
||||||
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.assertFalse;
|
||||||
|
@ -92,23 +93,27 @@ import static org.mockito.Mockito.when;
|
||||||
public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
|
public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(TerminologySvcImplCurrentVersionR4Test.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(TerminologySvcImplCurrentVersionR4Test.class);
|
||||||
|
|
||||||
public static final String BASE_LOINC_URL = "http://loinc.org";
|
private static final String BASE_LOINC_URL = "http://loinc.org";
|
||||||
public static final String BASE_LOINC_VS_URL = BASE_LOINC_URL + "/vs/";
|
private static final String BASE_LOINC_VS_URL = BASE_LOINC_URL + "/vs/";
|
||||||
|
|
||||||
|
private static final String LOINC_ALL_VS_URL = BASE_LOINC_URL + "/vs";
|
||||||
|
|
||||||
// some ValueSets have a version specified independent of the CS version being uploaded. This one doesn't
|
// some ValueSets have a version specified independent of the CS version being uploaded. This one doesn't
|
||||||
public static final String VS_NO_VERSIONED_ON_UPLOAD_ID = "loinc-rsna-radiology-playbook";
|
private static final String VS_NO_VERSIONED_ON_UPLOAD_ID = "loinc-rsna-radiology-playbook";
|
||||||
public static final String VS_NO_VERSIONED_ON_UPLOAD = BASE_LOINC_VS_URL + VS_NO_VERSIONED_ON_UPLOAD_ID;
|
private static final String VS_NO_VERSIONED_ON_UPLOAD = BASE_LOINC_VS_URL + VS_NO_VERSIONED_ON_UPLOAD_ID;
|
||||||
public static final String VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE = "17787-3";
|
private static final String VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE = "17787-3";
|
||||||
public static final String VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY = "NM Thyroid gland Study report";
|
private static final String VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY = "NM Thyroid gland Study report";
|
||||||
|
|
||||||
// some ValueSets have a version specified independent of the CS version being uploaded. This is one of them
|
// some ValueSets have a version specified independent of the CS version being uploaded. This is one of them
|
||||||
public static final String VS_VERSIONED_ON_UPLOAD_ID = "LL1000-0";
|
private static final String VS_VERSIONED_ON_UPLOAD_ID = "LL1000-0";
|
||||||
public static final String VS_VERSIONED_ON_UPLOAD = BASE_LOINC_VS_URL + VS_VERSIONED_ON_UPLOAD_ID;
|
private static final String VS_VERSIONED_ON_UPLOAD = BASE_LOINC_VS_URL + VS_VERSIONED_ON_UPLOAD_ID;
|
||||||
public static final String VS_VERSIONED_ON_UPLOAD_FIRST_CODE = "LA13825-7";
|
private static final String VS_VERSIONED_ON_UPLOAD_FIRST_CODE = "LA13825-7";
|
||||||
public static final String VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY = "1 slice or 1 dinner roll";
|
private static final String VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY = "1 slice or 1 dinner roll";
|
||||||
|
|
||||||
public static final String VS_ANSWER_LIST_VERSION = "Beta.1";
|
private static final String VS_ANSWER_LIST_VERSION = "Beta.1";
|
||||||
public static final Set<String> possibleVersions = Sets.newHashSet("2.67", "2.68", "2.69");
|
private static final Set<String> possibleVersions = Sets.newHashSet("2.67", "2.68", "2.69");
|
||||||
|
|
||||||
|
private static final int ALL_VS_QTY = 81;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private HttpServletResponse mockServletResponse;
|
private HttpServletResponse mockServletResponse;
|
||||||
|
@ -546,8 +551,131 @@ public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
|
||||||
|
|
||||||
// tests conditions which were failing after VS expansion (before fix for issue-2995)
|
// tests conditions which were failing after VS expansion (before fix for issue-2995)
|
||||||
validateTermConcepts(Lists.newArrayList(currentVer, currentVer, nonCurrentVer));
|
validateTermConcepts(Lists.newArrayList(currentVer, currentVer, nonCurrentVer));
|
||||||
|
|
||||||
|
|
||||||
|
// this test also checks specifically the loinc-all ValueSet
|
||||||
|
validateOperationsLoincAllVS(currentVer, Lists.newArrayList(currentVer, nonCurrentVer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For input version or for current (when input is null) validates search, expand, lookup and validateCode operations
|
||||||
|
*/
|
||||||
|
private void validateOperationsLoincAllVS(String currentVersion, Collection<String> theExpectedVersions) {
|
||||||
|
validateValueSetSearchLoincAllVS(theExpectedVersions);
|
||||||
|
|
||||||
|
validateValueExpandLoincAllVS(currentVersion, theExpectedVersions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateValueSetSearchLoincAllVS(Collection<String> theExpectedIdVersions) {
|
||||||
|
// first validate search for CS ver = null VS ver = null
|
||||||
|
|
||||||
|
SearchParameterMap params = new SearchParameterMap("url", new UriParam(LOINC_ALL_VS_URL));
|
||||||
|
int expectedResultQty = theExpectedIdVersions.size() + 1; // + 1 because an extra null version (the current) is always present
|
||||||
|
IBundleProvider result = myValueSetIFhirResourceDao.search(params, mockRequestDetails, mockServletResponse);
|
||||||
|
List<IBaseResource> valueSets = result.getAllResources();
|
||||||
|
assertEquals(expectedResultQty, valueSets.size());
|
||||||
|
|
||||||
|
matchUnqualifiedIds(valueSets, theExpectedIdVersions);
|
||||||
|
|
||||||
|
// now validate each specific uploaded version
|
||||||
|
theExpectedIdVersions.forEach(this::validateValueSetSearchForVersionLoincAllVS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateValueSetSearchForVersionLoincAllVS(String theVersion) {
|
||||||
|
SearchParameterMap paramsUploadNoVer = new SearchParameterMap("url", new UriParam(LOINC_ALL_VS_URL));
|
||||||
|
paramsUploadNoVer.add("version", new TokenParam(theVersion));
|
||||||
|
|
||||||
|
IBundleProvider result = myValueSetIFhirResourceDao.search(paramsUploadNoVer, mockRequestDetails, mockServletResponse);
|
||||||
|
List<IBaseResource> valueSets = result.getAllResources();
|
||||||
|
assertEquals(1, valueSets.size());
|
||||||
|
|
||||||
|
ValueSet loadNoVersionValueSet = (ValueSet) valueSets.get(0);
|
||||||
|
String expectedUnqualifiedId = LOINC_ALL_VALUESET_ID + "-" + theVersion;
|
||||||
|
assertEquals(expectedUnqualifiedId, loadNoVersionValueSet.getIdElement().getIdPart());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void validateValueExpandLoincAllVS(String currentVersion, Collection<String> theAllVersions) {
|
||||||
|
ValueSet vs = myValueSetDao.expandByIdentifier(LOINC_ALL_VS_URL, null);
|
||||||
|
assertFalse(vs.getExpansion().getContains().isEmpty());
|
||||||
|
|
||||||
|
// version was added prefixing to some code display to validate
|
||||||
|
checkContainsElementVersion(vs, currentVersion);
|
||||||
|
|
||||||
|
// now for each uploaded version
|
||||||
|
theAllVersions.forEach(this::validateValueExpandLoincAllVsForVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkContainsElementVersion(ValueSet vs, String version) {
|
||||||
|
Optional<String> vsContainsDisplay = vs.getExpansion().getContains().stream()
|
||||||
|
.filter(c -> c.getCode().equals(VS_VERSIONED_ON_UPLOAD_FIRST_CODE))
|
||||||
|
.map(ValueSet.ValueSetExpansionContainsComponent::getDisplay)
|
||||||
|
.findAny();
|
||||||
|
assertTrue(vsContainsDisplay.isPresent());
|
||||||
|
String expectedDisplay = prefixWithVersion(version, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY);
|
||||||
|
assertEquals(expectedDisplay, vsContainsDisplay.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void validateValidateCodeLoincAllVS(String theCurrentVersion, Collection<String> allVersions) {
|
||||||
|
IValidationSupport.CodeValidationResult resultNoVersioned = myCodeSystemDao.validateCode(null,
|
||||||
|
new UriType(BASE_LOINC_URL), null, new CodeType(VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE),
|
||||||
|
null, null, null, null);
|
||||||
|
assertNotNull(resultNoVersioned);
|
||||||
|
assertEquals(prefixWithVersion(theCurrentVersion, VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultNoVersioned.getDisplay());
|
||||||
|
|
||||||
|
IValidationSupport.CodeValidationResult resultVersioned = myCodeSystemDao.validateCode(null,
|
||||||
|
new UriType(BASE_LOINC_URL), null, new CodeType(VS_VERSIONED_ON_UPLOAD_FIRST_CODE),
|
||||||
|
null, null, null, null);
|
||||||
|
assertNotNull(resultVersioned);
|
||||||
|
assertEquals(prefixWithVersion(theCurrentVersion, VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY), resultVersioned.getDisplay());
|
||||||
|
|
||||||
|
allVersions.forEach(this::validateValidateCodeForVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void validateValueExpandLoincAllVsForVersion(String theVersion) {
|
||||||
|
ValueSet vs = myValueSetDao.expandByIdentifier(LOINC_ALL_VS_URL + "|" + theVersion, null);
|
||||||
|
assertEquals(ALL_VS_QTY, vs.getExpansion().getContains().size());
|
||||||
|
|
||||||
|
// version was added before code display to validate
|
||||||
|
checkContainsElementVersion(vs, theVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates TermConcepts were created in the sequence indicated by the parameters
|
||||||
|
* and their displays match the expected versions
|
||||||
|
*/
|
||||||
|
private void validateTermConceptsLoincAllVs(ArrayList<String> theExpectedVersions) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<TermConcept> termConceptNoVerList = (List<TermConcept>) myEntityManager.createQuery(
|
||||||
|
"from TermConcept where myCode = '" + VS_NO_VERSIONED_ON_UPLOAD_FIRST_CODE + "' order by myId").getResultList();
|
||||||
|
assertEquals(theExpectedVersions.size(), termConceptNoVerList.size());
|
||||||
|
for (int i = 0; i < theExpectedVersions.size(); i++) {
|
||||||
|
assertEquals( prefixWithVersion(theExpectedVersions.get(i), VS_NO_VERSIONED_ON_UPLOAD_FIRST_DISPLAY),
|
||||||
|
termConceptNoVerList.get(i).getDisplay(), "TermCode with id: " + i + " display");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<TermConcept> termConceptWithVerList = (List<TermConcept>) myEntityManager.createQuery(
|
||||||
|
"from TermConcept where myCode = '" + VS_VERSIONED_ON_UPLOAD_FIRST_CODE + "' order by myId").getResultList();
|
||||||
|
assertEquals(theExpectedVersions.size(), termConceptWithVerList.size());
|
||||||
|
for (int i = 0; i < theExpectedVersions.size(); i++) {
|
||||||
|
assertEquals( prefixWithVersion(theExpectedVersions.get(i), VS_VERSIONED_ON_UPLOAD_FIRST_DISPLAY),
|
||||||
|
termConceptWithVerList.get(i).getDisplay(), "TermCode with id: " + i + " display");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates TermConcepts were created in the sequence indicated by the parameters
|
* Validates TermConcepts were created in the sequence indicated by the parameters
|
||||||
* and their displays match the expected versions
|
* and their displays match the expected versions
|
||||||
|
|
|
@ -125,51 +125,51 @@ class ITermReadSvcTest {
|
||||||
|
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
public class IsLoincNotGenericUnversionedCodeSystem {
|
public class IsLoincUnversionedCodeSystem {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doesntContainLoincReturnsFalse() {
|
void doesntContainLoincReturnsFalse() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://boing.org");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://boing.org");
|
||||||
assertFalse(ret);
|
assertFalse(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void hasVersionReturnsFalse() {
|
void hasVersionReturnsFalse() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://boing.org|v2.68");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://boing.org|v2.68");
|
||||||
assertFalse(ret);
|
assertFalse(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void containsLoincAndNoVersionReturnsTrue() {
|
void containsLoincAndNoVersionReturnsTrue() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://anything-plus-loinc.org");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://anything-plus-loinc.org");
|
||||||
assertTrue(ret);
|
assertTrue(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
public class IsLoincNotGenericUnversionedValueSet {
|
public class IsLoincUnversionedValueSet {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void notLoincReturnsFalse() {
|
void notLoincReturnsFalse() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://anything-but-loin-c.org");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://anything-but-loin-c.org");
|
||||||
assertFalse(ret);
|
assertFalse(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isLoincAndHasVersionReturnsFalse() {
|
void isLoincAndHasVersionReturnsFalse() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org|v2.67");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org|v2.67");
|
||||||
assertFalse(ret);
|
assertFalse(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isLoincNoVersionButEqualsGenericValueSetUrlReturnsFalse() {
|
void isLoincNoVersionButEqualsLoincAllReturnsTrue() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org/vs");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org/vs");
|
||||||
assertFalse(ret);
|
assertTrue(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isLoincNoVersionStartsWithGenericValueSetPlusSlashPlusIdReturnsTrue() {
|
void isLoincNoVersionStartsWithGenericValueSetPlusSlashPlusIdReturnsTrue() {
|
||||||
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org/vs/vs-id");
|
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org/vs/vs-id");
|
||||||
assertTrue(ret);
|
assertTrue(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ package org.hl7.fhir.common.hapi.validation.support;
|
||||||
public class ValidationConstants {
|
public class ValidationConstants {
|
||||||
|
|
||||||
public static final String LOINC_LOW = "loinc";
|
public static final String LOINC_LOW = "loinc";
|
||||||
|
public static final String LOINC_ALL_VALUESET_ID = "loinc-all";
|
||||||
public static final String LOINC_GENERIC_CODE_SYSTEM_URL = "http://loinc.org";
|
public static final String LOINC_GENERIC_CODE_SYSTEM_URL = "http://loinc.org";
|
||||||
public static final String LOINC_GENERIC_VALUESET_URL = LOINC_GENERIC_CODE_SYSTEM_URL + "/vs";
|
public static final String LOINC_GENERIC_VALUESET_URL = LOINC_GENERIC_CODE_SYSTEM_URL + "/vs";
|
||||||
public static final String LOINC_GENERIC_VALUESET_URL_PLUS_SLASH = LOINC_GENERIC_VALUESET_URL + "/";
|
public static final String LOINC_GENERIC_VALUESET_URL_PLUS_SLASH = LOINC_GENERIC_VALUESET_URL + "/";
|
||||||
|
|
Loading…
Reference in New Issue