diff --git a/src/main/java/gov/cms/madie/terminology/dto/ValueSetsSearchCriteria.java b/src/main/java/gov/cms/madie/terminology/dto/ValueSetsSearchCriteria.java index 2bdc1c3..43e99bc 100644 --- a/src/main/java/gov/cms/madie/terminology/dto/ValueSetsSearchCriteria.java +++ b/src/main/java/gov/cms/madie/terminology/dto/ValueSetsSearchCriteria.java @@ -12,6 +12,7 @@ public class ValueSetsSearchCriteria { private String profile; private String includeDraft; + private String activeOnly; private ManifestExpansion manifestExpansion; private List valueSetParams; diff --git a/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java b/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java index 213253d..cc560d7 100644 --- a/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java +++ b/src/main/java/gov/cms/madie/terminology/service/FhirTerminologyService.java @@ -64,6 +64,7 @@ public List recursivelyRequestAllValueSetsExpansionsForQDM( vsParam, valueSetsSearchCriteria.getProfile(), valueSetsSearchCriteria.getIncludeDraft(), + valueSetsSearchCriteria.getActiveOnly(), valueSetsSearchCriteria.getManifestExpansion()); ValueSet valueSetResource = parser.parseResource(ValueSet.class, resource); diff --git a/src/main/java/gov/cms/madie/terminology/util/TerminologyServiceUtil.java b/src/main/java/gov/cms/madie/terminology/util/TerminologyServiceUtil.java index 35f17e2..5ae3bb9 100644 --- a/src/main/java/gov/cms/madie/terminology/util/TerminologyServiceUtil.java +++ b/src/main/java/gov/cms/madie/terminology/util/TerminologyServiceUtil.java @@ -116,6 +116,7 @@ public static URI buildValueSetResourceUri( ValueSetsSearchCriteria.ValueSetParams valueSetParams, String profile, String includeDraft, + String activeOnly, ManifestExpansion manifestExpansion) { MultiValueMap params = new LinkedMultiValueMap<>(); String expandValueSetUri = "/ValueSet/" + valueSetParams.getOid() + "/$expand"; @@ -134,8 +135,12 @@ public static URI buildValueSetResourceUri( } else if (manifestExpansion != null && StringUtils.isNotBlank(manifestExpansion.getFullUrl())) { params.put("manifest", List.of(manifestExpansion.getFullUrl())); - } else if (StringUtils.isNotBlank(includeDraft)) { - params.put("includeDraft", List.of("true")); + } else { + if (StringUtils.isNotBlank(includeDraft)) { + params.put("includeDraft", List.of("true")); + } + + params.put("activeOnly", List.of(activeOnly)); } return UriComponentsBuilder.fromPath(expandValueSetUri).queryParams(params).build().toUri(); diff --git a/src/main/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClient.java b/src/main/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClient.java index 395054c..8ac2131 100644 --- a/src/main/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClient.java +++ b/src/main/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClient.java @@ -108,11 +108,12 @@ public String getValueSetResource( ValueSetsSearchCriteria.ValueSetParams valueSetParams, String profile, String includeDraft, + String activeOnly, ManifestExpansion manifestExpansion) { profile = StringUtils.isNotBlank(profile) ? defaultProfile : profile; URI uri = TerminologyServiceUtil.buildValueSetResourceUri( - valueSetParams, profile, includeDraft, manifestExpansion); + valueSetParams, profile, includeDraft, activeOnly, manifestExpansion); return fetchResourceFromVsac(uri.toString(), apiKey, "ValueSet"); } diff --git a/src/test/java/gov/cms/madie/terminology/service/FhirTerminologyServiceTest.java b/src/test/java/gov/cms/madie/terminology/service/FhirTerminologyServiceTest.java index 78a012d..f3b6ca1 100644 --- a/src/test/java/gov/cms/madie/terminology/service/FhirTerminologyServiceTest.java +++ b/src/test/java/gov/cms/madie/terminology/service/FhirTerminologyServiceTest.java @@ -173,6 +173,7 @@ void getValueSetsExpansionsForQdm_When_ManifestExpansionIsProvided() { .build())) .profile("test-profile") .includeDraft("false") + .activeOnly("true") .manifestExpansion( ManifestExpansion.builder() .fullUrl("https://cts.nlm.nih.gov/fhir/Library/ecqm-update-2022-05-05") @@ -180,7 +181,7 @@ void getValueSetsExpansionsForQdm_When_ManifestExpansionIsProvided() { .build()) .build(); when(fhirTerminologyServiceWebClient.getValueSetResource( - anyString(), any(), anyString(), anyString(), any())) + anyString(), any(), anyString(), anyString(), anyString(), any())) .thenReturn(mockValueSetResourceWithCodes); when(fhirContext.newJsonParser()).thenReturn(FhirContext.forR4().newJsonParser()); when(mappingService.getCodeSystemEntries()).thenReturn(codeSystemEntries); @@ -209,6 +210,7 @@ void getsValueSetsExpansionsForQdm_withNoCodes_When_ManifestExpansionIsProvided( .build())) .profile("test-profile") .includeDraft("false") + .activeOnly("false") .manifestExpansion( ManifestExpansion.builder() .fullUrl("https://cts.nlm.nih.gov/fhir/Library/ecqm-update-2022-05-05") @@ -217,11 +219,12 @@ void getsValueSetsExpansionsForQdm_withNoCodes_When_ManifestExpansionIsProvided( .build(); when(fhirContext.newJsonParser()).thenReturn(FhirContext.forR4().newJsonParser()); when(fhirTerminologyServiceWebClient.getValueSetResource( - anyString(), - any(ValueSetsSearchCriteria.ValueSetParams.class), - anyString(), - anyString(), - any(ManifestExpansion.class))) + anyString(), + any(ValueSetsSearchCriteria.ValueSetParams.class), + anyString(), + anyString(), + anyString(), + any(ManifestExpansion.class))) .thenReturn(mockValueSetResourceWithNoCodes); when(mappingService.getCodeSystemEntries()).thenReturn(codeSystemEntries); List result = diff --git a/src/test/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClientTest.java b/src/test/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClientTest.java index 10c84f2..6e9bef5 100644 --- a/src/test/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClientTest.java +++ b/src/test/java/gov/cms/madie/terminology/webclient/FhirTerminologyServiceWebClientTest.java @@ -91,11 +91,11 @@ void getLatestValueSetResourceSuccessfully_when_noCustomSearchCriteriaIsProvided .addHeader("Content-Type", "application/fhir+json")); String actualResponse = fhirTerminologyServiceWebClient.getValueSetResource( - MOCK_API_KEY, testValueSetParams, null, null, new ManifestExpansion()); + MOCK_API_KEY, testValueSetParams, null, null, "false", new ManifestExpansion()); assertNotNull(actualResponse); assertEquals(MOCK_RESPONSE_STRING, actualResponse); RecordedRequest recordedRequest = mockBackEnd.takeRequest(); - assertEquals("/ValueSet/test-vs-id/$expand", recordedRequest.getPath()); + assertEquals("/ValueSet/test-vs-id/$expand?activeOnly=false", recordedRequest.getPath()); } @Test @@ -108,11 +108,11 @@ void getDraftValueSetResourceSuccessfully_when_noCustomSearchCriteriaIsProvided( .addHeader("Content-Type", "application/fhir+json")); String actualResponse = fhirTerminologyServiceWebClient.getValueSetResource( - MOCK_API_KEY, testValueSetParams, null, "yes", new ManifestExpansion()); + MOCK_API_KEY, testValueSetParams, null, "yes", "false", new ManifestExpansion()); assertNotNull(actualResponse); assertEquals(MOCK_RESPONSE_STRING, actualResponse); RecordedRequest recordedRequest = mockBackEnd.takeRequest(); - assertEquals("/ValueSet/test-vs-id/$expand?includeDraft=true", recordedRequest.getPath()); + assertEquals("/ValueSet/test-vs-id/$expand?includeDraft=true&activeOnly=false", recordedRequest.getPath()); } @Test @@ -129,6 +129,7 @@ void getValueSetResourceSuccessfully_when_manifestExpansionIsProvided() testValueSetParams, null, null, + "true", ManifestExpansion.builder() .id("test-manifest-456") .fullUrl("https://cts.nlm.nih.gov/fhir/Library/test-manifest-456") @@ -152,7 +153,7 @@ void getValueSetResourceSuccessfully_when_ValueSetVersionIsProvided() testValueSetParams.setVersion("test-value-set-version-2024"); String actualResponse = fhirTerminologyServiceWebClient.getValueSetResource( - MOCK_API_KEY, testValueSetParams, null, null, new ManifestExpansion()); + MOCK_API_KEY, testValueSetParams, null, null, "false", new ManifestExpansion()); assertNotNull(actualResponse); assertEquals(MOCK_RESPONSE_STRING, actualResponse); RecordedRequest recordedRequest = mockBackEnd.takeRequest(); @@ -169,9 +170,9 @@ void getValueSetResource_ReturnsException() throws InterruptedException { WebClientResponseException.class, () -> fhirTerminologyServiceWebClient.getValueSetResource( - MOCK_API_KEY, testValueSetParams, null, null, new ManifestExpansion())); + MOCK_API_KEY, testValueSetParams, null, null, "false", new ManifestExpansion())); RecordedRequest recordedRequest = mockBackEnd.takeRequest(); - assertEquals("/ValueSet/test-vs-id/$expand", recordedRequest.getPath()); + assertEquals("/ValueSet/test-vs-id/$expand?activeOnly=false", recordedRequest.getPath()); } @Test