Skip to content

Commit

Permalink
fix(fhir.rest.tests): Add assertions for "designation-use-context"...
Browse files Browse the repository at this point in the history
...extensions in CodeSystem$lookup and ValueSet$expand test cases
  • Loading branch information
apeteri committed Nov 7, 2024
1 parent 401291e commit 9293d5e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.b2international.snowowl.fhir.rest.tests;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.HashSet;
import java.util.Set;

Expand All @@ -23,9 +25,12 @@
import org.junit.Rule;

import com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants;
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts;
import com.b2international.snowowl.test.commons.TestMethodNameRule;
import com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests;

import io.restassured.path.json.JsonPath;

/**
* Superclass for common REST-related test functionality. All tests receive a single Code System to test/verify/use as test fixture. The CodeSystemId
* can be accessed with the {@link #getTestCodeSystemId()} method and it is available at the start of the test and will be removed once the test
Expand Down Expand Up @@ -80,4 +85,15 @@ protected final String getTestCodeSystemUrl() {
return CodeSystemRestRequests.getSnomedIntUrl(getTestCodeSystemId());
}

protected final static void checkDesignationUseContext(JsonPath jsonPath, String rootPath, String refsetId, String typeId) {
jsonPath.setRootPath(rootPath);
assertThat(jsonPath.getString("url")).isEqualTo("http://snomed.info/fhir/StructureDefinition/designation-use-context");

assertThat(jsonPath.getString("extension[0].url")).isEqualTo("context");
assertThat(jsonPath.getString("extension[0].valueCoding.code")).isEqualTo(refsetId);
assertThat(jsonPath.getString("extension[1].url")).isEqualTo("role");
assertThat(jsonPath.getString("extension[1].valueCoding.code")).isEqualTo(Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED);
assertThat(jsonPath.getString("extension[2].url")).isEqualTo("type");
assertThat(jsonPath.getString("extension[2].valueCoding.code")).isEqualTo(typeId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.b2international.snowowl.fhir.rest.tests.FhirRestTest.Endpoints.CODESYSTEM_LOOKUP;
import static com.b2international.snowowl.test.commons.rest.RestExtensions.givenAuthenticatedRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
Expand All @@ -33,6 +34,8 @@
import com.b2international.snowowl.test.commons.codesystem.CodeSystemRestRequests;
import com.b2international.snowowl.test.commons.rest.RestExtensions;

import io.restassured.path.json.JsonPath;

/**
* CodeSystem $lookup operation for FHIR code systems REST end-point test cases
*
Expand Down Expand Up @@ -197,7 +200,7 @@ public class FhirSnomedCodeSystemLookupTest extends FhirRestTest {

@Test
public void GET_CodeSystem_$lookup_Designations() throws Exception {
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT)
JsonPath jsonPath = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT)
.queryParam("system", SNOMEDCT_URL)
.queryParam("code", CLINICAL_FINDING)
.queryParam("property", "designation")
Expand All @@ -210,30 +213,33 @@ public class FhirSnomedCodeSystemLookupTest extends FhirRestTest {
.body("parameter[0].valueString", equalTo("SNOMEDCT"))
.body("parameter[1].name", equalTo("display"))
.body("parameter[1].valueString", equalTo("Clinical finding"))
.body("parameter[2].name", equalTo("designation"))
.body("parameter[2].part[0].valueCode", equalTo("en"))
.body("parameter[2].part[1].valueCoding.code", equalTo("900000000000013009"))
.body("parameter[2].part[2].valueString", equalTo("Clinical finding"))
.body("parameter[3].name", equalTo("designation"))
.body("parameter[3].part[0].valueCode", equalTo("en-x-" + Concepts.REFSET_LANGUAGE_TYPE_UK))
.body("parameter[3].part[1].valueCoding.code", equalTo("900000000000013009"))
.body("parameter[3].part[2].valueString", equalTo("Clinical finding"))
.body("parameter[4].name", equalTo("designation"))
.body("parameter[4].part[0].valueCode", equalTo("en-x-" + Concepts.REFSET_LANGUAGE_TYPE_US))
.body("parameter[4].part[1].valueCoding.code", equalTo("900000000000013009"))
.body("parameter[4].part[2].valueString", equalTo("Clinical finding"))
.body("parameter[5].name", equalTo("designation"))
.body("parameter[5].part[0].valueCode", equalTo("en"))
.body("parameter[5].part[1].valueCoding.code", equalTo("900000000000003001"))
.body("parameter[5].part[2].valueString", equalTo("Clinical finding (finding)"))
.body("parameter[6].name", equalTo("designation"))
.body("parameter[6].part[0].valueCode", equalTo("en-x-" + Concepts.REFSET_LANGUAGE_TYPE_UK))
.body("parameter[6].part[1].valueCoding.code", equalTo("900000000000003001"))
.body("parameter[6].part[2].valueString", equalTo("Clinical finding (finding)"))
.body("parameter[7].name", equalTo("designation"))
.body("parameter[7].part[0].valueCode", equalTo("en-x-" + Concepts.REFSET_LANGUAGE_TYPE_US))
.body("parameter[7].part[1].valueCoding.code", equalTo("900000000000003001"))
.body("parameter[7].part[2].valueString", equalTo("Clinical finding (finding)"));
.extract()
.jsonPath();

jsonPath.setRootPath("parameter[2]");
assertThat(jsonPath.getString("name")).isEqualTo("designation");

assertThat(jsonPath.getString("part[0].name")).isEqualTo("language");
assertThat(jsonPath.getString("part[0].valueCode")).isEqualTo("en");
assertThat(jsonPath.getString("part[1].name")).isEqualTo("use");
assertThat(jsonPath.getString("part[1].valueCoding.code")).isEqualTo(Concepts.FULLY_SPECIFIED_NAME);
assertThat(jsonPath.getString("part[2].name")).isEqualTo("value");
assertThat(jsonPath.getString("part[2].valueString")).isEqualTo("Clinical finding (finding)");

jsonPath.setRootPath("parameter[3]");
assertThat(jsonPath.getString("name")).isEqualTo("designation");

assertThat(jsonPath.getString("part[0].name")).isEqualTo("language");
assertThat(jsonPath.getString("part[0].valueCode")).isEqualTo("en");
assertThat(jsonPath.getString("part[1].name")).isEqualTo("use");
assertThat(jsonPath.getString("part[1].valueCoding.code")).isEqualTo(Concepts.SYNONYM);
assertThat(jsonPath.getString("part[2].name")).isEqualTo("value");
assertThat(jsonPath.getString("part[2].valueString")).isEqualTo("Clinical finding");

checkDesignationUseContext(jsonPath, "parameter[2].extension[0]", Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.FULLY_SPECIFIED_NAME);
checkDesignationUseContext(jsonPath, "parameter[2].extension[1]", Concepts.REFSET_LANGUAGE_TYPE_US, Concepts.FULLY_SPECIFIED_NAME);
checkDesignationUseContext(jsonPath, "parameter[3].extension[0]", Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.SYNONYM);
checkDesignationUseContext(jsonPath, "parameter[3].extension[1]", Concepts.REFSET_LANGUAGE_TYPE_US, Concepts.SYNONYM);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
import com.b2international.commons.json.Json;
import com.b2international.snowowl.fhir.rest.tests.FhirRestTest;
import com.b2international.snowowl.snomed.common.SnomedTerminologyComponentConstants;
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts;
import com.b2international.snowowl.test.commons.rest.RestExtensions;

import io.restassured.path.json.JsonPath;

/**
* @since 8.0
*/
Expand Down Expand Up @@ -111,7 +114,7 @@ public void expandSnomedCodeSystemURL_FhirVsEclChildOfRoot() throws Exception {

@Test
public void expandSnomedCodeSystemURL_IncludeDesignations() throws Exception {
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT)
JsonPath jsonPath = givenAuthenticatedRequest(FHIR_ROOT_CONTEXT)
.queryParam("url", RestExtensions.encodeQueryParameter(SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/900000000000207008?fhir_vs=ecl/<!138875005"))
.queryParam("includeDesignations", true)
.when().get("/ValueSet/$expand")
Expand All @@ -125,16 +128,15 @@ public void expandSnomedCodeSystemURL_IncludeDesignations() throws Exception {
.body("expansion.contains[0].display", equalTo("Substance (substance)"))
.body("expansion.contains[0].designation[0].value", equalTo("Substance"))
.body("expansion.contains[0].designation[0].language", equalTo("en"))
.body("expansion.contains[0].designation[1].value", equalTo("Substance"))
.body("expansion.contains[0].designation[1].language", equalTo("en-x-900000000000508004"))
.body("expansion.contains[0].designation[2].value", equalTo("Substance"))
.body("expansion.contains[0].designation[2].language", equalTo("en-x-900000000000509007"))
.body("expansion.contains[0].designation[3].value", equalTo("Substance (substance)"))
.body("expansion.contains[0].designation[3].language", equalTo("en"))
.body("expansion.contains[0].designation[4].value", equalTo("Substance (substance)"))
.body("expansion.contains[0].designation[4].language", equalTo("en-x-900000000000508004"))
.body("expansion.contains[0].designation[5].value", equalTo("Substance (substance)"))
.body("expansion.contains[0].designation[5].language", equalTo("en-x-900000000000509007"));
.body("expansion.contains[0].designation[1].value", equalTo("Substance (substance)"))
.body("expansion.contains[0].designation[1].language", equalTo("en"))
.extract()
.jsonPath();

checkDesignationUseContext(jsonPath, "expansion.contains[0].designation[0].extension[0]", Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.SYNONYM);
checkDesignationUseContext(jsonPath, "expansion.contains[0].designation[0].extension[1]", Concepts.REFSET_LANGUAGE_TYPE_US, Concepts.SYNONYM);
checkDesignationUseContext(jsonPath, "expansion.contains[0].designation[1].extension[0]", Concepts.REFSET_LANGUAGE_TYPE_UK, Concepts.FULLY_SPECIFIED_NAME);
checkDesignationUseContext(jsonPath, "expansion.contains[0].designation[1].extension[1]", Concepts.REFSET_LANGUAGE_TYPE_US, Concepts.FULLY_SPECIFIED_NAME);
}

@Test
Expand Down

0 comments on commit 9293d5e

Please sign in to comment.