Fixed ConceptMap $translation without conceptMapVersion issue.
This commit is contained in:
parent
b4a87adc64
commit
c873b6d6dd
|
@ -1937,6 +1937,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
List<TermConceptMapGroupElementTarget> cachedTargets;
|
||||
ArrayList<Predicate> predicates;
|
||||
Coding coding;
|
||||
|
||||
//-- get the latest ConceptMapVersion if theTranslationRequest has url, but ConceptMapVersion
|
||||
String latestConceptMapVersion = null;
|
||||
if (theTranslationRequest.hasUrl() && !theTranslationRequest.hasConceptMapVersion())
|
||||
latestConceptMapVersion = getLatestConceptMapVersion(theTranslationRequest);
|
||||
|
||||
for (TranslationQuery translationQuery : translationQueries) {
|
||||
cachedTargets = myTranslationCache.getIfPresent(translationQuery);
|
||||
if (cachedTargets == null) {
|
||||
|
@ -1965,10 +1971,21 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
if (translationQuery.hasUrl()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
// both url and conceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(latestConceptMapVersion)) {
|
||||
// only url and use latestConceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), latestConceptMapVersion));
|
||||
} else {
|
||||
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
}
|
||||
}
|
||||
|
||||
if (translationQuery.hasSource()) {
|
||||
|
@ -2028,6 +2045,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
List<TermConceptMapGroupElement> cachedElements;
|
||||
ArrayList<Predicate> predicates;
|
||||
Coding coding;
|
||||
|
||||
//-- get the latest ConceptMapVersion if theTranslationRequest has url, but ConceptMapVersion
|
||||
String latestConceptMapVersion = null;
|
||||
if (theTranslationRequest.hasUrl() && !theTranslationRequest.hasConceptMapVersion())
|
||||
latestConceptMapVersion = getLatestConceptMapVersion(theTranslationRequest);
|
||||
|
||||
for (TranslationQuery translationQuery : translationQueries) {
|
||||
cachedElements = myTranslationWithReverseCache.getIfPresent(translationQuery);
|
||||
if (cachedElements == null) {
|
||||
|
@ -2056,10 +2079,21 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
|
||||
if (translationQuery.hasUrl()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myUrl"), translationQuery.getUrl().getValueAsString()));
|
||||
}
|
||||
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
// both url and conceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(latestConceptMapVersion)) {
|
||||
// only url and use latestConceptMapVersion
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), latestConceptMapVersion));
|
||||
} else {
|
||||
predicates.add(criteriaBuilder.isNull(conceptMapJoin.get("myVersion")));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (translationQuery.hasConceptMapVersion()) {
|
||||
predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myVersion"), translationQuery.getConceptMapVersion().getValueAsString()));
|
||||
}
|
||||
}
|
||||
|
||||
if (translationQuery.hasTargetSystem()) {
|
||||
|
@ -2127,6 +2161,20 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc {
|
|||
throw new ResourceNotFoundException("Unknown ValueSet: " + UrlUtil.escapeUrlParam(theValueSet));
|
||||
}
|
||||
|
||||
// Special case for the translate operation with url and without
|
||||
// conceptMapVersion, find the latest conecptMapVersion
|
||||
private String getLatestConceptMapVersion(TranslationRequest theTranslationRequest) {
|
||||
|
||||
Pageable page = PageRequest.of(0, 1);
|
||||
List<TermConceptMap> theConceptMapList = myConceptMapDao.findTermConceptMapByUrl(page,
|
||||
theTranslationRequest.getUrl().asStringValue());
|
||||
if (!theConceptMapList.isEmpty()) {
|
||||
return theConceptMapList.get(0).getVersion();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
|
||||
|
|
|
@ -211,45 +211,12 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
|||
@Test
|
||||
public void testTranslateWithReverseConcaptMapUrlAndVersion() {
|
||||
|
||||
//- conceptMap1 v1
|
||||
ConceptMap conceptMap1 = new ConceptMap();
|
||||
conceptMap1.setUrl(CM_URL).setVersion("v1").setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
||||
|
||||
ConceptMapGroupComponent group1 = conceptMap1.addGroup();
|
||||
group1.setSource(CS_URL).setSourceVersion("Version 1").setTarget(CS_URL_2).setTargetVersion("Version 2");
|
||||
|
||||
SourceElementComponent element1 = group1.addElement();
|
||||
element1.setCode("12222").setDisplay("Source Code 12222");
|
||||
|
||||
TargetElementComponent target1 = element1.addTarget();
|
||||
target1.setCode("11111").setDisplay("11111");
|
||||
|
||||
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("13333").setDisplay("Source Code 13333");
|
||||
|
||||
TargetElementComponent target2 = element2.addTarget();
|
||||
target2.setCode("11111").setDisplay("Target Code 11111");
|
||||
|
||||
IIdType conceptMapId2 = myConceptMapDao.create(conceptMap2, mySrd).getId().toUnqualifiedVersionless();
|
||||
conceptMap2 = myConceptMapDao.read(conceptMapId2);
|
||||
|
||||
ourLog.info("ConceptMap: 2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap2));
|
||||
|
||||
String url = "http://url";
|
||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||
createReverseConceptMap(url, "v2", "13333", "Source Code 13333");
|
||||
|
||||
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("code").setValue(new CodeType("11111"));
|
||||
inParams.addParameter().setName("reverse").setValue(new BooleanType(true));
|
||||
|
@ -284,6 +251,163 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
|
|||
assertEquals(CS_URL, coding.getSystem());
|
||||
assertEquals("Version 1", coding.getVersion());
|
||||
part = getPartByName(param, "source");
|
||||
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
|
||||
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion() {
|
||||
|
||||
String url = "http://url";
|
||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||
createReverseConceptMap(url, "v2", "13333", "Source Code 13333");
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||
inParams.addParameter().setName("reverse").setValue(new BooleanType(true));
|
||||
|
||||
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");
|
||||
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(2, param.getPart().size());
|
||||
ParametersParameterComponent part = getPartByName(param, "concept");
|
||||
Coding coding = (Coding) part.getValue();
|
||||
assertEquals("13333", coding.getCode());
|
||||
assertEquals("Source Code 13333", coding.getDisplay());
|
||||
assertFalse(coding.getUserSelected());
|
||||
assertEquals(CS_URL, coding.getSystem());
|
||||
assertEquals("Version 1", coding.getVersion());
|
||||
part = getPartByName(param, "source");
|
||||
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion_null_v1() {
|
||||
|
||||
String url = "http://url";
|
||||
createReverseConceptMap(url, null, "12222", "Source Code 12222");
|
||||
createReverseConceptMap(url, "v2", "13333", "Source Code 13333");
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||
inParams.addParameter().setName("reverse").setValue(new BooleanType(true));
|
||||
|
||||
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");
|
||||
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(2, param.getPart().size());
|
||||
ParametersParameterComponent part = getPartByName(param, "concept");
|
||||
Coding coding = (Coding) part.getValue();
|
||||
assertEquals("13333", coding.getCode());
|
||||
assertEquals("Source Code 13333", coding.getDisplay());
|
||||
assertFalse(coding.getUserSelected());
|
||||
assertEquals(CS_URL, coding.getSystem());
|
||||
assertEquals("Version 1", coding.getVersion());
|
||||
part = getPartByName(param, "source");
|
||||
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateWithReverseConcaptMapUrl_NoVersion_null_v2() {
|
||||
|
||||
String url = "http://url";
|
||||
createReverseConceptMap(url, "v1", "12222", "Source Code 12222");
|
||||
createReverseConceptMap(url, null, "13333", "Source Code 13333");
|
||||
|
||||
Parameters inParams = new Parameters();
|
||||
inParams.addParameter().setName("url").setValue(new UriType(url));
|
||||
inParams.addParameter().setName("code").setValue(new CodeType("11111"));
|
||||
inParams.addParameter().setName("reverse").setValue(new BooleanType(true));
|
||||
|
||||
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");
|
||||
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(2, param.getPart().size());
|
||||
ParametersParameterComponent part = getPartByName(param, "concept");
|
||||
Coding coding = (Coding) part.getValue();
|
||||
assertEquals("13333", coding.getCode());
|
||||
assertEquals("Source Code 13333", coding.getDisplay());
|
||||
assertFalse(coding.getUserSelected());
|
||||
assertEquals(CS_URL, coding.getSystem());
|
||||
assertEquals("Version 1", coding.getVersion());
|
||||
part = getPartByName(param, "source");
|
||||
assertEquals(url, ((UriType) part.getValue()).getValueAsString());
|
||||
}
|
||||
|
||||
private void createReverseConceptMap(String url, String version, String sourceCode, String sourceDisplay) {
|
||||
|
||||
//- conceptMap1 v1
|
||||
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(sourceCode).setDisplay(sourceDisplay);
|
||||
|
||||
TargetElementComponent target1 = element1.addTarget();
|
||||
target1.setCode("11111").setDisplay("11111");
|
||||
|
||||
IIdType conceptMapId = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless();
|
||||
ConceptMap conceptMap1 = myConceptMapDao.read(conceptMapId);
|
||||
|
||||
ourLog.info("ConceptMap : \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap1));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,50 +26,19 @@ 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() {
|
||||
//- conceptMap v1
|
||||
ConceptMap conceptMap = new ConceptMap();
|
||||
conceptMap.setUrl(CM_URL).setVersion("v1").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("12222").setDisplay("Target Code 12222").setEquivalence(ConceptMapEquivalence.EQUAL);
|
||||
|
||||
IIdType conceptMapId1 = myConceptMapDao.create(conceptMap, mySrd).getId().toUnqualifiedVersionless();
|
||||
conceptMap = myConceptMapDao.read(conceptMapId1);
|
||||
|
||||
ourLog.info("ConceptMap: v1 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
||||
|
||||
//- conceptMap v2
|
||||
conceptMap = new ConceptMap();
|
||||
conceptMap.setUrl(CM_URL).setVersion("v2").setSource(new UriType(VS_URL)).setTarget(new UriType(VS_URL_2));
|
||||
|
||||
ConceptMapGroupComponent group2 = conceptMap.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(conceptMap, mySrd).getId().toUnqualifiedVersionless();
|
||||
conceptMap = myConceptMapDao.read(conceptMapId2);
|
||||
|
||||
ourLog.info("ConceptMap: v2 \n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
||||
|
||||
}
|
||||
|
||||
@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));
|
||||
|
@ -116,6 +85,9 @@ public class ResourceProviderDstu3ConceptMap_Ian_Test extends BaseResourceProvid
|
|||
@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));
|
||||
|
@ -162,6 +134,9 @@ public class ResourceProviderDstu3ConceptMap_Ian_Test extends BaseResourceProvid
|
|||
@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));
|
||||
|
@ -203,4 +178,119 @@ public class ResourceProviderDstu3ConceptMap_Ian_Test extends BaseResourceProvid
|
|||
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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue