Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-7852: set activeOnly argument to false when expansion type is Latest #107

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class ValueSetsSearchCriteria {

private String profile;
private String includeDraft;
private String activeOnly;
private ManifestExpansion manifestExpansion;
private List<ValueSetParams> valueSetParams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public List<QdmValueSet> recursivelyRequestAllValueSetsExpansionsForQDM(
vsParam,
valueSetsSearchCriteria.getProfile(),
valueSetsSearchCriteria.getIncludeDraft(),
valueSetsSearchCriteria.getActiveOnly(),
valueSetsSearchCriteria.getManifestExpansion());

ValueSet valueSetResource = parser.parseResource(ValueSet.class, resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public static URI buildValueSetResourceUri(
ValueSetsSearchCriteria.ValueSetParams valueSetParams,
String profile,
String includeDraft,
String activeOnly,
ManifestExpansion manifestExpansion) {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
String expandValueSetUri = "/ValueSet/" + valueSetParams.getOid() + "/$expand";
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,15 @@ 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")
.id("ecqm-update-2022-05-05")
.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);
Expand Down Expand Up @@ -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")
Expand All @@ -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<QdmValueSet> result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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();
Expand All @@ -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
Expand Down
Loading