diff --git a/fhir/com.b2international.snowowl.fhir.core/src/com/b2international/snowowl/fhir/core/request/valueset/FhirValueSetExpandRequest.java b/fhir/com.b2international.snowowl.fhir.core/src/com/b2international/snowowl/fhir/core/request/valueset/FhirValueSetExpandRequest.java index 298d63687d7..bb3966b7105 100644 --- a/fhir/com.b2international.snowowl.fhir.core/src/com/b2international/snowowl/fhir/core/request/valueset/FhirValueSetExpandRequest.java +++ b/fhir/com.b2international.snowowl.fhir.core/src/com/b2international/snowowl/fhir/core/request/valueset/FhirValueSetExpandRequest.java @@ -36,6 +36,7 @@ import com.b2international.snowowl.fhir.core.codesystems.FilterOperator; import com.b2international.snowowl.fhir.core.codesystems.PublicationStatus; import com.b2international.snowowl.fhir.core.exceptions.BadRequestException; +import com.b2international.snowowl.fhir.core.model.Designation; import com.b2international.snowowl.fhir.core.model.ResourceResponseEntry; import com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem; import com.b2international.snowowl.fhir.core.model.dt.Uri; @@ -247,11 +248,16 @@ private ValueSet computeFhirValueSetUsingUrl(ServiceProvider context, String url .after(concepts.getSearchAfter()); for (Concept concept : concepts) { - expansion.addContains(Contains.builder() - .code(concept.getId()) - .system(baseUrl) - .display(concept.getTerm()) - .build()); + var contains = Contains.builder() + .system(baseUrl) + .code(concept.getId()) + .display(concept.getTerm()); + + if (Boolean.TRUE.equals(request.getIncludeDesignations())) { + contains.designations(Designation.fromDescriptions(concept.getDescriptions())); + } + + expansion.addContains(contains.build()); } return valueSet diff --git a/fhir/com.b2international.snowowl.fhir.rest.tests/src/com/b2international/snowowl/fhir/rest/tests/valueset/FhirValueSetSnomedExpandTest.java b/fhir/com.b2international.snowowl.fhir.rest.tests/src/com/b2international/snowowl/fhir/rest/tests/valueset/FhirValueSetSnomedExpandTest.java index 1ec7c1ce63a..0d69aa7bc2b 100644 --- a/fhir/com.b2international.snowowl.fhir.rest.tests/src/com/b2international/snowowl/fhir/rest/tests/valueset/FhirValueSetSnomedExpandTest.java +++ b/fhir/com.b2international.snowowl.fhir.rest.tests/src/com/b2international/snowowl/fhir/rest/tests/valueset/FhirValueSetSnomedExpandTest.java @@ -109,6 +109,34 @@ public void expandSnomedCodeSystemURL_FhirVsEclChildOfRoot() throws Exception { .body("expansion.contains[0].display", equalTo("Substance (substance)")); } + @Test + public void expandSnomedCodeSystemURL_IncludeDesignations() throws Exception { + givenAuthenticatedRequest(FHIR_ROOT_CONTEXT) + .queryParam("url", RestExtensions.encodeQueryParameter(SnomedTerminologyComponentConstants.SNOMED_URI_SCT + "/900000000000207008?fhir_vs=ecl/> expandType( .count(count) .displayLanguage(displayLanguage == null ? null : new Code(displayLanguage)) .withHistorySupplements(withHistorySupplements) + .includeDesignations(includeDesignations) .build(); return expand(expandRequest, nextUriBuilder, accept, _format, _pretty); @@ -378,6 +379,7 @@ public Promise> expandInstance( .count(count) .displayLanguage(displayLanguage == null ? null : new Code(displayLanguage)) .withHistorySupplements(withHistorySupplements) + .includeDesignations(includeDesignations) .build(); return expand(expandRequest, nextUriBuilder, accept, _format, _pretty); diff --git a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/request/SnomedConceptSearchRequestEvaluator.java b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/request/SnomedConceptSearchRequestEvaluator.java index c2ba5ac6056..9f921b57b6b 100644 --- a/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/request/SnomedConceptSearchRequestEvaluator.java +++ b/snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/request/SnomedConceptSearchRequestEvaluator.java @@ -17,6 +17,7 @@ import java.util.Comparator; import java.util.List; +import java.util.Optional; import java.util.SortedSet; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -145,7 +146,9 @@ private Concept toConcept(ResourceURI codeSystem, SnomedConcept snomedConcept, S public static SortedSet generateGenericDescriptions(SnomedDescriptions descriptions) { return descriptions.stream() .flatMap(description -> { - final String languageCode = description.getLanguageCode(); + // FIXME falling back to en when the languageCode is not available on concept descriptions + // descriptions expand is needed but only when the requestor truly needs them, but that requires a bit larger set of changes + final String languageCode = Optional.ofNullable(description.getLanguageCode()).orElse("en"); var acceptabilityDesignations = description.getAcceptabilityMap().keySet().stream() .map(refsetId -> new ExtendedLocale(languageCode, null, refsetId)) .map(language -> new Description(description.getTerm(), language.toString()).withInternalDescription(description));