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:
jmarchionatto 2021-10-06 16:56:30 -04:00 committed by GitHub
parent bc2cd7cafc
commit 71e2b82128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 182 additions and 55 deletions

View File

@ -104,7 +104,7 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
@Override
public IBaseResource fetchCodeSystem(String theSystem) {
if (TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(theSystem)) {
if (TermReadSvcUtil.isLoincUnversionedCodeSystem(theSystem)) {
Optional<IBaseResource> currentCSOpt = getCodeSystemCurrentVersion(new UriType(theSystem));
if (! currentCSOpt.isPresent()) {
ourLog.info("Couldn't find current version of CodeSystem: " + theSystem);
@ -128,7 +128,7 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
@Override
public IBaseResource fetchValueSet(String theSystem) {
if (TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(theSystem)) {
if (TermReadSvcUtil.isLoincUnversionedValueSet(theSystem)) {
Optional<IBaseResource> currentVSOpt = getValueSetCurrentVersion(new UriType(theSystem));
return currentVSOpt.orElseThrow(() -> new ResourceNotFoundException(
"Unable to find current version of ValueSet for url: " + theSystem));

View File

@ -2348,7 +2348,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
*/
@Override
public Optional<TermValueSet> findCurrentTermValueSet(String theUrl) {
if (TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(theUrl)) {
if (TermReadSvcUtil.isLoincUnversionedValueSet(theUrl)) {
Optional<String> vsIdOpt = TermReadSvcUtil.getValueSetId(theUrl);
if (! vsIdOpt.isPresent()) {
return Optional.empty();

View File

@ -67,7 +67,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
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 org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_ALL_VALUESET_ID;
/*
* #%L
@ -719,10 +719,9 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc {
String codeSystemVersionId = theUploadProperties.getProperty(LOINC_CODESYSTEM_VERSION.getCode());
String valueSetId;
if (codeSystemVersionId != null) {
valueSetId = "loinc-all" + "-" + codeSystemVersionId;
valueSetId = LOINC_ALL_VALUESET_ID + "-" + codeSystemVersionId;
} else {
valueSetId = "loinc-all";
codeSystemVersionId = "1.0.0";
valueSetId = LOINC_ALL_VALUESET_ID;
}
retVal.setId(valueSetId);
retVal.setUrl("http://loinc.org/vs");

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.util.Optional;
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_PLUS_SLASH;
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_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);
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 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 isNoVersion = ! theUrl.contains("|");

View File

@ -44,28 +44,28 @@ class TermReadSvcUtilTest {
@Test
void doesntContainLoincReturnsFalse() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
"http://l-oinc.org/vs/radiology-playbook");
assertFalse(result);
}
@Test
void containsVersionDelimiterReturnsFalse() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
"http://loinc.org/vs/radiology-playbook|v2.68");
assertFalse(result);
}
@Test
void isLoincGenericValueSetUrlReturnsFalse() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
void isLoincAllValueSetUrlReturnsTrue() {
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
"http://loinc.org/vs");
assertFalse(result);
assertTrue(result);
}
@Test
void isLoincWithoutVersionAndNotGenericValuesetUrlReturnsTrue() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet(
boolean result = TermReadSvcUtil.isLoincUnversionedValueSet(
"http://loinc.org/vs/radiology-playbook");
assertTrue(result);
}
@ -78,21 +78,21 @@ class TermReadSvcUtilTest {
@Test
void doesntContainLoincReturnsFalse() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
"http://loin-c.org");
assertFalse(result);
}
@Test
void hasVersionDelimiterReturnsFalse() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
"http://loinc.org|v2.68");
assertFalse(result);
}
@Test
void containsLoincNadNoVersionDelimiterReturnsTrue() {
boolean result = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem(
boolean result = TermReadSvcUtil.isLoincUnversionedCodeSystem(
"http://loinc.org");
assertTrue(result);
}

View File

@ -34,7 +34,6 @@ import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
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);
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) {

View File

@ -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.Matchers.contains;
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.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@ -414,10 +415,10 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
assertNull(vs.getVersion());
// All LOINC codes
assertTrue(valueSets.containsKey("loinc-all"));
vs = valueSets.get("loinc-all");
assertTrue(valueSets.containsKey(LOINC_ALL_VALUESET_ID));
vs = valueSets.get(LOINC_ALL_VALUESET_ID);
assertEquals("http://loinc.org/vs", vs.getUrl());
assertEquals("1.0.0", vs.getVersion());
assertNull(vs.getVersion());
assertEquals("All LOINC codes", vs.getName());
assertEquals(Enumerations.PublicationStatus.ACTIVE, vs.getStatus());
assertTrue(vs.hasDate());
@ -428,7 +429,7 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
assertTrue(vs.getCompose().hasInclude());
assertEquals(1, vs.getCompose().getInclude().size());
assertEquals(ITermLoaderSvc.LOINC_URI, vs.getCompose().getInclude().get(0).getSystem());
assertEquals("1.0.0", vs.getVersion());
assertNull(vs.getVersion());
// IEEE Medical Device Codes
conceptMap = conceptMaps.get(LoincIeeeMedicalDeviceCodeHandler.LOINC_IEEE_CM_ID);
@ -520,8 +521,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
for (ValueSet loincVS : loincVS_resources) {
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
assertEquals("Beta.1", loincVS.getVersion());
} else if (loincVS.getId().equals("loinc-all")) {
assertEquals("1.0.0", loincVS.getVersion());
} else {
assertNull(loincVS.getVersion());
}
@ -573,8 +572,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
for (ValueSet loincVS : loincVS_resources) {
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
assertEquals("Beta.1", loincVS.getVersion());
} else if (loincVS.getId().equals("loinc-all")) {
assertEquals("1.0.0", loincVS.getVersion());
} else {
assertNull(loincVS.getVersion());
}
@ -626,8 +623,6 @@ public class TerminologyLoaderSvcLoincTest extends BaseLoaderTest {
for (ValueSet loincVS : loincVS_resources) {
if (loincVS.getId().startsWith("LL1000-0") || loincVS.getId().startsWith("LL1001-8") || loincVS.getId().startsWith("LL1892-0")) {
assertEquals("Beta.1", loincVS.getVersion());
} else if (loincVS.getId().equals("loinc-all")) {
assertEquals("1.0.0", loincVS.getVersion());
} else {
assertNull(loincVS.getVersion());
}

View File

@ -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 org.hamcrest.MatcherAssert.assertThat;
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.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ -92,23 +93,27 @@ import static org.mockito.Mockito.when;
public class TerminologySvcImplCurrentVersionR4Test extends BaseJpaR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(TerminologySvcImplCurrentVersionR4Test.class);
public 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_URL = "http://loinc.org";
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
public 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;
public 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_ID = "loinc-rsna-radiology-playbook";
private 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_FIRST_CODE = "17787-3";
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
public 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;
public 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_ID = "LL1000-0";
private static final String VS_VERSIONED_ON_UPLOAD = BASE_LOINC_VS_URL + VS_VERSIONED_ON_UPLOAD_ID;
private static final String VS_VERSIONED_ON_UPLOAD_FIRST_CODE = "LA13825-7";
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";
public static final Set<String> possibleVersions = Sets.newHashSet("2.67", "2.68", "2.69");
private static final String VS_ANSWER_LIST_VERSION = "Beta.1";
private static final Set<String> possibleVersions = Sets.newHashSet("2.67", "2.68", "2.69");
private static final int ALL_VS_QTY = 81;
@Mock
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)
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
* and their displays match the expected versions

View File

@ -125,51 +125,51 @@ class ITermReadSvcTest {
@Nested
public class IsLoincNotGenericUnversionedCodeSystem {
public class IsLoincUnversionedCodeSystem {
@Test
void doesntContainLoincReturnsFalse() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://boing.org");
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://boing.org");
assertFalse(ret);
}
@Test
void hasVersionReturnsFalse() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://boing.org|v2.68");
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://boing.org|v2.68");
assertFalse(ret);
}
@Test
void containsLoincAndNoVersionReturnsTrue() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedCodeSystem("http://anything-plus-loinc.org");
boolean ret = TermReadSvcUtil.isLoincUnversionedCodeSystem("http://anything-plus-loinc.org");
assertTrue(ret);
}
}
@Nested
public class IsLoincNotGenericUnversionedValueSet {
public class IsLoincUnversionedValueSet {
@Test
void notLoincReturnsFalse() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://anything-but-loin-c.org");
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://anything-but-loin-c.org");
assertFalse(ret);
}
@Test
void isLoincAndHasVersionReturnsFalse() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org|v2.67");
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org|v2.67");
assertFalse(ret);
}
@Test
void isLoincNoVersionButEqualsGenericValueSetUrlReturnsFalse() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org/vs");
assertFalse(ret);
void isLoincNoVersionButEqualsLoincAllReturnsTrue() {
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org/vs");
assertTrue(ret);
}
@Test
void isLoincNoVersionStartsWithGenericValueSetPlusSlashPlusIdReturnsTrue() {
boolean ret = TermReadSvcUtil.isLoincNotGenericUnversionedValueSet("http://loinc.org/vs/vs-id");
boolean ret = TermReadSvcUtil.isLoincUnversionedValueSet("http://loinc.org/vs/vs-id");
assertTrue(ret);
}

View File

@ -23,6 +23,7 @@ package org.hl7.fhir.common.hapi.validation.support;
public class ValidationConstants {
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_VALUESET_URL = LOINC_GENERIC_CODE_SYSTEM_URL + "/vs";
public static final String LOINC_GENERIC_VALUESET_URL_PLUS_SLASH = LOINC_GENERIC_VALUESET_URL + "/";