Updated based on code review
This commit is contained in:
parent
c873b6d6dd
commit
972bdbd87d
|
@ -40,10 +40,10 @@ public interface ITermConceptMapDao extends JpaRepository<TermConceptMap, Long>
|
||||||
Optional<TermConceptMap> findTermConceptMapByResourcePid(@Param("resource_pid") Long theResourcePid);
|
Optional<TermConceptMap> findTermConceptMapByResourcePid(@Param("resource_pid") Long theResourcePid);
|
||||||
|
|
||||||
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url and cm.myVersion is null")
|
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url and cm.myVersion is null")
|
||||||
Optional<TermConceptMap> findTermConceptMapByUrl(@Param("url") String theUrl);
|
Optional<TermConceptMap> findTermConceptMapByUrlAndNullVersion(@Param("url") String theUrl);
|
||||||
|
|
||||||
@Query(value="SELECT cm FROM TermConceptMap cm INNER JOIN ResourceTable r ON r.myId = cm.myResourcePid WHERE cm.myUrl = :url ORDER BY r.myUpdated DESC")
|
@Query(value="SELECT cm FROM TermConceptMap cm INNER JOIN ResourceTable r ON r.myId = cm.myResourcePid WHERE cm.myUrl = :url ORDER BY r.myUpdated DESC")
|
||||||
List<TermConceptMap> findTermConceptMapByUrl(Pageable thePage, @Param("url") String theUrl);
|
List<TermConceptMap> getTermConceptMapEntitiesByUrlOrderByVersion(Pageable thePage, @Param("url") String theUrl);
|
||||||
|
|
||||||
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url AND cm.myVersion = :version")
|
@Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url AND cm.myVersion = :version")
|
||||||
Optional<TermConceptMap> findTermConceptMapByUrlAndVersion(@Param("url") String theUrl, @Param("version") String theVersion);
|
Optional<TermConceptMap> findTermConceptMapByUrlAndVersion(@Param("url") String theUrl, @Param("version") String theVersion);
|
||||||
|
|
|
@ -1552,7 +1552,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
String conceptMapVersion = termConceptMap.getVersion();
|
String conceptMapVersion = termConceptMap.getVersion();
|
||||||
Optional<TermConceptMap> optionalExistingTermConceptMapByUrl = null;
|
Optional<TermConceptMap> optionalExistingTermConceptMapByUrl = null;
|
||||||
if (isBlank(conceptMapVersion)) {
|
if (isBlank(conceptMapVersion)) {
|
||||||
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrl(conceptMapUrl);
|
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrlAndNullVersion(conceptMapUrl);
|
||||||
} else {
|
} else {
|
||||||
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrlAndVersion(conceptMapUrl, conceptMapVersion);
|
optionalExistingTermConceptMapByUrl = myConceptMapDao.findTermConceptMapByUrlAndVersion(conceptMapUrl, conceptMapVersion);
|
||||||
}
|
}
|
||||||
|
@ -1982,10 +1982,6 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (translationQuery.hasConceptMapVersion()) {
|
|
||||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translationQuery.hasSource()) {
|
if (translationQuery.hasSource()) {
|
||||||
|
@ -2090,10 +2086,6 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (translationQuery.hasConceptMapVersion()) {
|
|
||||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translationQuery.hasTargetSystem()) {
|
if (translationQuery.hasTargetSystem()) {
|
||||||
|
@ -2166,7 +2158,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
||||||
private String getLatestConceptMapVersion(TranslationRequest theTranslationRequest) {
|
private String getLatestConceptMapVersion(TranslationRequest theTranslationRequest) {
|
||||||
|
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theConceptMapList = myConceptMapDao.findTermConceptMapByUrl(page,
|
List<TermConceptMap> theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page,
|
||||||
theTranslationRequest.getUrl().asStringValue());
|
theTranslationRequest.getUrl().asStringValue());
|
||||||
if (!theConceptMapList.isEmpty()) {
|
if (!theConceptMapList.isEmpty()) {
|
||||||
return theConceptMapList.get(0).getVersion();
|
return theConceptMapList.get(0).getVersion();
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
|
||||||
public void testConcaptMapFindTermConceptMapByUrl() {
|
public void testConcaptMapFindTermConceptMapByUrl() {
|
||||||
|
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpConceptMapList = myTermConceptMapDao.findTermConceptMapByUrl(page, CM_URL);
|
List<TermConceptMap> theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL);
|
||||||
assertEquals(1, theExpConceptMapList.size());
|
assertEquals(1, theExpConceptMapList.size());
|
||||||
assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl());
|
assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl());
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
|
||||||
|
|
||||||
// should return the latest one which is v2
|
// should return the latest one which is v2
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.findTermConceptMapByUrl(page, theUrl);
|
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl);
|
||||||
|
|
||||||
assertEquals(1, theExpSecondOne.size());
|
assertEquals(1, theExpSecondOne.size());
|
||||||
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
||||||
|
@ -169,9 +169,9 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test {
|
||||||
assertEquals(theUrl, theExpConceptMapV1.get().getUrl());
|
assertEquals(theUrl, theExpConceptMapV1.get().getUrl());
|
||||||
assertEquals("v1", theExpConceptMapV1.get().getVersion());
|
assertEquals("v1", theExpConceptMapV1.get().getVersion());
|
||||||
|
|
||||||
// should return the latest one which is v2
|
// should return the latest one which in this case is not versioned
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.findTermConceptMapByUrl(page, theUrl);
|
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl);
|
||||||
|
|
||||||
assertEquals(1, theExpSecondOne.size());
|
assertEquals(1, theExpSecondOne.size());
|
||||||
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
||||||
|
|
|
@ -1158,7 +1158,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
||||||
public void testConcaptMapFindTermConceptMapByUrl() {
|
public void testConcaptMapFindTermConceptMapByUrl() {
|
||||||
|
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpConceptMapList = myTermConceptMapDao.findTermConceptMapByUrl(page, CM_URL);
|
List<TermConceptMap> theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL);
|
||||||
assertEquals(1, theExpConceptMapList.size());
|
assertEquals(1, theExpConceptMapList.size());
|
||||||
assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl());
|
assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl());
|
||||||
|
|
||||||
|
@ -1190,7 +1190,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
// should return the latest one which is v2
|
// should return the latest one which is v2
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.findTermConceptMapByUrl(page, theUrl);
|
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl);
|
||||||
|
|
||||||
assertEquals(1, theExpSecondOne.size());
|
assertEquals(1, theExpSecondOne.size());
|
||||||
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
||||||
|
@ -1218,7 +1218,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
// should return the latest one which is v2
|
// should return the latest one which is v2
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.findTermConceptMapByUrl(page, theUrl);
|
List<TermConceptMap> theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl);
|
||||||
|
|
||||||
assertEquals(1, theExpSecondOne.size());
|
assertEquals(1, theExpSecondOne.size());
|
||||||
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
|
||||||
|
|
|
@ -9,15 +9,15 @@ import org.hl7.fhir.dstu3.model.BooleanType;
|
||||||
import org.hl7.fhir.dstu3.model.CodeType;
|
import org.hl7.fhir.dstu3.model.CodeType;
|
||||||
import org.hl7.fhir.dstu3.model.Coding;
|
import org.hl7.fhir.dstu3.model.Coding;
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
import org.hl7.fhir.dstu3.model.ConceptMap;
|
||||||
|
import org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent;
|
||||||
|
import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent;
|
||||||
|
import org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent;
|
||||||
|
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
||||||
import org.hl7.fhir.dstu3.model.Parameters;
|
import org.hl7.fhir.dstu3.model.Parameters;
|
||||||
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
|
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
|
||||||
import org.hl7.fhir.dstu3.model.StringType;
|
import org.hl7.fhir.dstu3.model.StringType;
|
||||||
import org.hl7.fhir.dstu3.model.UriType;
|
import org.hl7.fhir.dstu3.model.UriType;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
|
||||||
|
|
||||||
public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDstu3Test {
|
public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDstu3Test {
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderDstu3ConceptMapTest.class);
|
private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderDstu3ConceptMapTest.class);
|
||||||
|
@ -129,46 +128,14 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateWithConcaptMapUrlAndVersion() {
|
public void testTranslateWithConceptMapUrlAndVersion() {
|
||||||
|
|
||||||
//- conceptMap1 v1
|
String url = "http://url";
|
||||||
ConceptMap conceptMap1 = new ConceptMap();
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
conceptMap1.setUrl(CM_URL).setVersion("v1").setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
ConceptMapGroupComponent group1 = conceptMap1.addGroup();
|
|
||||||
group1.setSource(CS_URL).setSourceVersion("Version 1").setTarget(CS_URL_2).setTargetVersion("Version 2");
|
|
||||||
|
|
||||||
SourceElementComponent element1 = group1.addElement();
|
|
||||||
element1.setCode("11111").setDisplay("Source Code 11111");
|
|
||||||
|
|
||||||
TargetElementComponent target1 = element1.addTarget();
|
|
||||||
target1.setCode("12222").setDisplay("Target Code 12222").setEquivalence(ConceptMapEquivalence.EQUAL);
|
|
||||||
|
|
||||||
IIdType conceptMapId1 = myConceptMapDao.create(conceptMap1, mySrd).getId().toUnqualifiedVersionless();
|
|
||||||
conceptMap1 = myConceptMapDao.read(conceptMapId1);
|
|
||||||
|
|
||||||
ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1));
|
|
||||||
|
|
||||||
//- conceptMap1 v2
|
|
||||||
ConceptMap conceptMap2 = new ConceptMap();
|
|
||||||
conceptMap2.setUrl(CM_URL).setVersion("v2").setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
|
||||||
|
|
||||||
ConceptMapGroupComponent group2 = conceptMap2.addGroup();
|
|
||||||
group2.setSource(CS_URL).setSourceVersion("Version 1").setTarget(CS_URL_2).setTargetVersion("Version 2");
|
|
||||||
|
|
||||||
SourceElementComponent element2 = group2.addElement();
|
|
||||||
element2.setCode("11111").setDisplay("Source Code 11111");
|
|
||||||
|
|
||||||
TargetElementComponent target2 = element2.addTarget();
|
|
||||||
target2.setCode("13333").setDisplay("Target Code 13333").setEquivalence(ConceptMapEquivalence.EQUAL);
|
|
||||||
|
|
||||||
IIdType conceptMapId2 = myConceptMapDao.create(conceptMap2, mySrd).getId().toUnqualifiedVersionless();
|
|
||||||
conceptMap2 = myConceptMapDao.read(conceptMapId2);
|
|
||||||
|
|
||||||
ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2));
|
|
||||||
|
|
||||||
Parameters inParams = new Parameters();
|
Parameters inParams = new Parameters();
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v2"));
|
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v2"));
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
@ -176,7 +143,6 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
Parameters respParams = ourClient
|
||||||
.operation()
|
.operation()
|
||||||
.onType(ConceptMap.class)
|
.onType(ConceptMap.class)
|
||||||
|
@ -205,11 +171,287 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
assertEquals("Version 2", coding.getVersion());
|
assertEquals("Version 2", coding.getVersion());
|
||||||
part = getPartByName(param, "source");
|
part = getPartByName(param, "source");
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateWithReverseConcaptMapUrlAndVersion() {
|
public void testTranslateWithVersionedConcaptMapUrl_v2() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
|
// Call translate with ConceptMap v2.
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
|
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v2"));
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
// Should return v2 since v2 specified.
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
||||||
|
param = getParametersByName(respParams, "match").get(0);
|
||||||
|
assertEquals(3, param.getPart().size());
|
||||||
|
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
||||||
|
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
||||||
|
part = getPartByName(param, "concept");
|
||||||
|
Coding coding = (Coding) part.getValue();
|
||||||
|
assertEquals("13333", coding.getCode());
|
||||||
|
assertEquals("Target Code 13333", coding.getDisplay());
|
||||||
|
assertFalse(coding.getUserSelected());
|
||||||
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
|
assertEquals("Version 2", coding.getVersion());
|
||||||
|
part = getPartByName(param, "source");
|
||||||
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithVersionedConcaptMapUrl_v1() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
|
// Call translate with ConceptMap v1.
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
|
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v1"));
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
// Should return v1 since v1 specified.
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
||||||
|
param = getParametersByName(respParams, "match").get(0);
|
||||||
|
assertEquals(3, param.getPart().size());
|
||||||
|
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
||||||
|
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
||||||
|
part = getPartByName(param, "concept");
|
||||||
|
Coding coding = (Coding) part.getValue();
|
||||||
|
assertEquals("12222", coding.getCode());
|
||||||
|
assertEquals("Target Code 12222", coding.getDisplay());
|
||||||
|
assertFalse(coding.getUserSelected());
|
||||||
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
|
assertEquals("Version 2", coding.getVersion());
|
||||||
|
part = getPartByName(param, "source");
|
||||||
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithVersionedConcaptMapUrl_NoVersion() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
|
// Call translate with no ConceptMap version.
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
// Should return v2 since v2 is the most recently updated version.
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
||||||
|
param = getParametersByName(respParams, "match").get(0);
|
||||||
|
assertEquals(3, param.getPart().size());
|
||||||
|
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
||||||
|
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
||||||
|
part = getPartByName(param, "concept");
|
||||||
|
Coding coding = (Coding) part.getValue();
|
||||||
|
assertEquals("13333", coding.getCode());
|
||||||
|
assertEquals("Target Code 13333", coding.getDisplay());
|
||||||
|
assertFalse(coding.getUserSelected());
|
||||||
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
|
assertEquals("Version 2", coding.getVersion());
|
||||||
|
part = getPartByName(param, "source");
|
||||||
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithVersionedConcaptMapUrl_NoVersion_null_v1() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, null, "12222", "Target Code 12222"); // first version is null
|
||||||
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
|
// Call translate with no ConceptMap version.
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
// Should return v2 since v2 is the most recently updated version.
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
||||||
|
param = getParametersByName(respParams, "match").get(0);
|
||||||
|
assertEquals(3, param.getPart().size());
|
||||||
|
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
||||||
|
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
||||||
|
part = getPartByName(param, "concept");
|
||||||
|
Coding coding = (Coding) part.getValue();
|
||||||
|
assertEquals("13333", coding.getCode());
|
||||||
|
assertEquals("Target Code 13333", coding.getDisplay());
|
||||||
|
assertFalse(coding.getUserSelected());
|
||||||
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
|
assertEquals("Version 2", coding.getVersion());
|
||||||
|
part = getPartByName(param, "source");
|
||||||
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithVersionedConcaptMapUrl_NoVersion_null_v2() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
|
createConceptMap(url, null, "13333", "Target Code 13333"); // second version is null
|
||||||
|
|
||||||
|
// Call translate with no ConceptMap version.
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
// Should return v2 since v2 is the most recently updated version.
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
||||||
|
param = getParametersByName(respParams, "match").get(0);
|
||||||
|
assertEquals(3, param.getPart().size());
|
||||||
|
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
||||||
|
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
||||||
|
part = getPartByName(param, "concept");
|
||||||
|
Coding coding = (Coding) part.getValue();
|
||||||
|
assertEquals("13333", coding.getCode());
|
||||||
|
assertEquals("Target Code 13333", coding.getDisplay());
|
||||||
|
assertFalse(coding.getUserSelected());
|
||||||
|
assertEquals(CS_URL_2, coding.getSystem());
|
||||||
|
assertEquals("Version 2", coding.getVersion());
|
||||||
|
part = getPartByName(param, "source");
|
||||||
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithConceptMap_WrongUrl_NoVersion() {
|
||||||
|
|
||||||
|
String url = "http://url";
|
||||||
|
createConceptMap(url, "v1", "12222", "Target Code 12222");
|
||||||
|
createConceptMap(url, "v2", "13333", "Target Code 13333");
|
||||||
|
|
||||||
|
Parameters inParams = new Parameters();
|
||||||
|
inParams.addParameter().setName("url").setValue(new UriType("http://invalid.url.com")); // no exsits url
|
||||||
|
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
||||||
|
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
||||||
|
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||||
|
|
||||||
|
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
||||||
|
|
||||||
|
Parameters respParams = ourClient
|
||||||
|
.operation()
|
||||||
|
.onType(ConceptMap.class)
|
||||||
|
.named("translate")
|
||||||
|
.withParameters(inParams)
|
||||||
|
.execute();
|
||||||
|
|
||||||
|
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
||||||
|
|
||||||
|
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
||||||
|
assertFalse(((BooleanType) param.getValue()).booleanValue());
|
||||||
|
|
||||||
|
param = getParameterByName(respParams, "message");
|
||||||
|
assertEquals("No matches found!", ((StringType) param.getValue()).getValueAsString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateWithReverseConceptMapUrlAndVersion() {
|
||||||
|
|
||||||
String url = "http://url";
|
String url = "http://url";
|
||||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||||
|
@ -255,7 +497,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion() {
|
public void testTranslateWithReverseConceptMapUrl_NoVersion() {
|
||||||
|
|
||||||
String url = "http://url";
|
String url = "http://url";
|
||||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||||
|
@ -300,7 +542,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion_null_v1() {
|
public void testTranslateWithReverseConceptMapUrl_NoVersion_null_v1() {
|
||||||
|
|
||||||
String url = "http://url";
|
String url = "http://url";
|
||||||
createReverseConceptMap(url, null, "12222", "Source Code 12222");
|
createReverseConceptMap(url, null, "12222", "Source Code 12222");
|
||||||
|
@ -345,7 +587,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion_null_v2() {
|
public void testTranslateWithReverseConceptMapUrl_NoVersion_null_v2() {
|
||||||
|
|
||||||
String url = "http://url";
|
String url = "http://url";
|
||||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||||
|
@ -389,6 +631,26 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
||||||
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createConceptMap(String url, String version, String targetCode, String targetDisplay) {
|
||||||
|
|
||||||
|
ConceptMap conceptMap = new ConceptMap();
|
||||||
|
conceptMap.setUrl(url).setVersion(version).setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
||||||
|
|
||||||
|
ConceptMapGroupComponent group1 = conceptMap.addGroup();
|
||||||
|
group1.setSource(CS_URL).setSourceVersion("Version 1").setTarget(CS_URL_2).setTargetVersion("Version 2");
|
||||||
|
|
||||||
|
SourceElementComponent element1 = group1.addElement();
|
||||||
|
element1.setCode("11111").setDisplay("Source Code 11111");
|
||||||
|
|
||||||
|
TargetElementComponent target1 = element1.addTarget();
|
||||||
|
target1.setCode(targetCode).setDisplay(targetDisplay).setEquivalence(ConceptMapEquivalence.EQUAL);
|
||||||
|
|
||||||
|
IIdType conceptMapId = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
conceptMap = myConceptMapDao.read(conceptMapId);
|
||||||
|
|
||||||
|
ourLog.info("ConceptMap: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
||||||
|
}
|
||||||
|
|
||||||
private void createReverseConceptMap(String url, String version, String sourceCode, String sourceDisplay) {
|
private void createReverseConceptMap(String url, String version, String sourceCode, String sourceDisplay) {
|
||||||
|
|
||||||
//- conceptMap1 v1
|
//- conceptMap1 v1
|
||||||
|
|
|
@ -1,296 +0,0 @@
|
||||||
package ca.uhn.fhir.jpa.provider.dstu3;
|
|
||||||
|
|
||||||
import org.hl7.fhir.dstu3.model.BooleanType;
|
|
||||||
import org.hl7.fhir.dstu3.model.CodeType;
|
|
||||||
import org.hl7.fhir.dstu3.model.Coding;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.Enumerations.ConceptMapEquivalence;
|
|
||||||
import org.hl7.fhir.dstu3.model.Parameters;
|
|
||||||
import org.hl7.fhir.dstu3.model.Parameters.ParametersParameterComponent;
|
|
||||||
import org.hl7.fhir.dstu3.model.StringType;
|
|
||||||
import org.hl7.fhir.dstu3.model.UriType;
|
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
public class ResourceProviderDstu3ConceptMap_Ian_Test extends BaseResourceProviderDstu3Test {
|
|
||||||
private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderDstu3ConceptMap_Ian_Test.class);
|
|
||||||
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
@Transactional
|
|
||||||
public void before02() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateWithVersionedConcaptMapUrl_v2() {
|
|
||||||
|
|
||||||
createConceptMap("v1", "12222", "Target Code 12222");
|
|
||||||
createConceptMap("v2", "13333", "Target Code 13333");
|
|
||||||
|
|
||||||
// Call translate with ConceptMap v2.
|
|
||||||
Parameters inParams = new Parameters();
|
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
|
||||||
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v2"));
|
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
|
||||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
|
||||||
.operation()
|
|
||||||
.onType(ConceptMap.class)
|
|
||||||
.named("translate")
|
|
||||||
.withParameters(inParams)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
|
||||||
|
|
||||||
// Should return v2 since v2 specified.
|
|
||||||
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
|
||||||
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
|
||||||
|
|
||||||
param = getParameterByName(respParams, "message");
|
|
||||||
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
|
||||||
param = getParametersByName(respParams, "match").get(0);
|
|
||||||
assertEquals(3, param.getPart().size());
|
|
||||||
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
|
||||||
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
|
||||||
part = getPartByName(param, "concept");
|
|
||||||
Coding coding = (Coding) part.getValue();
|
|
||||||
assertEquals("13333", coding.getCode());
|
|
||||||
assertEquals("Target Code 13333", coding.getDisplay());
|
|
||||||
assertFalse(coding.getUserSelected());
|
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
|
||||||
assertEquals("Version 2", coding.getVersion());
|
|
||||||
part = getPartByName(param, "source");
|
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateWithVersionedConcaptMapUrl_v1() {
|
|
||||||
|
|
||||||
createConceptMap("v1", "12222", "Target Code 12222");
|
|
||||||
createConceptMap("v2", "13333", "Target Code 13333");;
|
|
||||||
|
|
||||||
// Call translate with ConceptMap v1.
|
|
||||||
Parameters inParams = new Parameters();
|
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
|
||||||
inParams.addParameter().setName("conceptMapVersion").setValue(new StringType("v1"));
|
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
|
||||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
|
||||||
.operation()
|
|
||||||
.onType(ConceptMap.class)
|
|
||||||
.named("translate")
|
|
||||||
.withParameters(inParams)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
|
||||||
|
|
||||||
// Should return v1 since v1 specified.
|
|
||||||
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
|
||||||
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
|
||||||
|
|
||||||
param = getParameterByName(respParams, "message");
|
|
||||||
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
|
||||||
param = getParametersByName(respParams, "match").get(0);
|
|
||||||
assertEquals(3, param.getPart().size());
|
|
||||||
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
|
||||||
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
|
||||||
part = getPartByName(param, "concept");
|
|
||||||
Coding coding = (Coding) part.getValue();
|
|
||||||
assertEquals("12222", coding.getCode());
|
|
||||||
assertEquals("Target Code 12222", coding.getDisplay());
|
|
||||||
assertFalse(coding.getUserSelected());
|
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
|
||||||
assertEquals("Version 2", coding.getVersion());
|
|
||||||
part = getPartByName(param, "source");
|
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateWithVersionedConcaptMapUrl_NoVersion() {
|
|
||||||
|
|
||||||
createConceptMap("v1", "12222", "Target Code 12222");
|
|
||||||
createConceptMap("v2", "13333", "Target Code 13333");
|
|
||||||
|
|
||||||
// Call translate with no ConceptMap version.
|
|
||||||
Parameters inParams = new Parameters();
|
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
|
||||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
|
||||||
.operation()
|
|
||||||
.onType(ConceptMap.class)
|
|
||||||
.named("translate")
|
|
||||||
.withParameters(inParams)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
|
||||||
|
|
||||||
// Should return v2 since v2 is the most recently updated version.
|
|
||||||
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
|
||||||
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
|
||||||
|
|
||||||
param = getParameterByName(respParams, "message");
|
|
||||||
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
|
||||||
param = getParametersByName(respParams, "match").get(0);
|
|
||||||
assertEquals(3, param.getPart().size());
|
|
||||||
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
|
||||||
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
|
||||||
part = getPartByName(param, "concept");
|
|
||||||
Coding coding = (Coding) part.getValue();
|
|
||||||
assertEquals("13333", coding.getCode());
|
|
||||||
assertEquals("Target Code 13333", coding.getDisplay());
|
|
||||||
assertFalse(coding.getUserSelected());
|
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
|
||||||
assertEquals("Version 2", coding.getVersion());
|
|
||||||
part = getPartByName(param, "source");
|
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateWithVersionedConcaptMapUrl_NoVersion_null_v1() {
|
|
||||||
|
|
||||||
createConceptMap(null, "12222", "Target Code 12222"); // first version is null
|
|
||||||
createConceptMap("v2", "13333", "Target Code 13333");
|
|
||||||
|
|
||||||
// Call translate with no ConceptMap version.
|
|
||||||
Parameters inParams = new Parameters();
|
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
|
||||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
|
||||||
.operation()
|
|
||||||
.onType(ConceptMap.class)
|
|
||||||
.named("translate")
|
|
||||||
.withParameters(inParams)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
|
||||||
|
|
||||||
// Should return v2 since v2 is the most recently updated version.
|
|
||||||
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
|
||||||
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
|
||||||
|
|
||||||
param = getParameterByName(respParams, "message");
|
|
||||||
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
|
||||||
param = getParametersByName(respParams, "match").get(0);
|
|
||||||
assertEquals(3, param.getPart().size());
|
|
||||||
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
|
||||||
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
|
||||||
part = getPartByName(param, "concept");
|
|
||||||
Coding coding = (Coding) part.getValue();
|
|
||||||
assertEquals("13333", coding.getCode());
|
|
||||||
assertEquals("Target Code 13333", coding.getDisplay());
|
|
||||||
assertFalse(coding.getUserSelected());
|
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
|
||||||
assertEquals("Version 2", coding.getVersion());
|
|
||||||
part = getPartByName(param, "source");
|
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateWithVersionedConcaptMapUrl_NoVersion_null_v2() {
|
|
||||||
|
|
||||||
createConceptMap("v1", "12222", "Target Code 12222");
|
|
||||||
createConceptMap(null, "13333", "Target Code 13333"); // second version is null
|
|
||||||
|
|
||||||
// Call translate with no ConceptMap version.
|
|
||||||
Parameters inParams = new Parameters();
|
|
||||||
inParams.addParameter().setName("url").setValue(new UriType(CM_URL));
|
|
||||||
inParams.addParameter().setName("system").setValue(new UriType(CS_URL));
|
|
||||||
inParams.addParameter().setName("targetsystem").setValue(new UriType(CS_URL_2));
|
|
||||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
|
||||||
|
|
||||||
ourLog.info("Request Parameters:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(inParams));
|
|
||||||
|
|
||||||
Parameters respParams = ourClient
|
|
||||||
.operation()
|
|
||||||
.onType(ConceptMap.class)
|
|
||||||
.named("translate")
|
|
||||||
.withParameters(inParams)
|
|
||||||
.execute();
|
|
||||||
|
|
||||||
ourLog.info("Response Parameters\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(respParams));
|
|
||||||
|
|
||||||
// Should return v2 since v2 is the most recently updated version.
|
|
||||||
ParametersParameterComponent param = getParameterByName(respParams, "result");
|
|
||||||
assertTrue(((BooleanType) param.getValue()).booleanValue());
|
|
||||||
|
|
||||||
param = getParameterByName(respParams, "message");
|
|
||||||
assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
|
|
||||||
|
|
||||||
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
|
|
||||||
param = getParametersByName(respParams, "match").get(0);
|
|
||||||
assertEquals(3, param.getPart().size());
|
|
||||||
ParametersParameterComponent part = getPartByName(param, "equivalence");
|
|
||||||
assertEquals("equal", ((CodeType) part.getValue()).getValueAsString());
|
|
||||||
part = getPartByName(param, "concept");
|
|
||||||
Coding coding = (Coding) part.getValue();
|
|
||||||
assertEquals("13333", coding.getCode());
|
|
||||||
assertEquals("Target Code 13333", coding.getDisplay());
|
|
||||||
assertFalse(coding.getUserSelected());
|
|
||||||
assertEquals(CS_URL_2, coding.getSystem());
|
|
||||||
assertEquals("Version 2", coding.getVersion());
|
|
||||||
part = getPartByName(param, "source");
|
|
||||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createConceptMap(String version, String targetCode, String targetDisplay) {
|
|
||||||
|
|
||||||
ConceptMap conceptMap = new ConceptMap();
|
|
||||||
conceptMap.setUrl(CM_URL).setVersion(version).setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
|
||||||
|
|
||||||
ConceptMapGroupComponent group1 = conceptMap.addGroup();
|
|
||||||
group1.setSource(CS_URL).setSourceVersion("Version 1").setTarget(CS_URL_2).setTargetVersion("Version 2");
|
|
||||||
|
|
||||||
SourceElementComponent element1 = group1.addElement();
|
|
||||||
element1.setCode("11111").setDisplay("Source Code 11111");
|
|
||||||
|
|
||||||
TargetElementComponent target1 = element1.addTarget();
|
|
||||||
target1.setCode(targetCode).setDisplay(targetDisplay).setEquivalence(ConceptMapEquivalence.EQUAL);
|
|
||||||
|
|
||||||
IIdType conceptMapId = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless();
|
|
||||||
conceptMap = myConceptMapDao.read(conceptMapId);
|
|
||||||
|
|
||||||
ourLog.info("ConceptMap: \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -315,7 +315,7 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
|
||||||
@Override
|
@Override
|
||||||
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.findTermConceptMapByUrl(page, CM_URL);
|
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL);
|
||||||
assertEquals(1, optionalConceptMap.size());
|
assertEquals(1, optionalConceptMap.size());
|
||||||
|
|
||||||
TermConceptMap conceptMap = optionalConceptMap.get(0);
|
TermConceptMap conceptMap = optionalConceptMap.get(0);
|
||||||
|
@ -494,7 +494,7 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
|
||||||
@Override
|
@Override
|
||||||
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
||||||
Pageable page = PageRequest.of(0, 1);
|
Pageable page = PageRequest.of(0, 1);
|
||||||
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.findTermConceptMapByUrl(page, CM_URL);
|
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL);
|
||||||
assertEquals(1, optionalConceptMap.size());
|
assertEquals(1, optionalConceptMap.size());
|
||||||
|
|
||||||
TermConceptMap conceptMap = optionalConceptMap.get(0);
|
TermConceptMap conceptMap = optionalConceptMap.get(0);
|
||||||
|
|
Loading…
Reference in New Issue