Skip to content

Commit

Permalink
Merge branch 'develop' into MAT-7855
Browse files Browse the repository at this point in the history
  • Loading branch information
adongare committed Dec 10, 2024
2 parents b039075 + 31836ff commit 97cdb53
Showing 13 changed files with 87 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.11</version>
<relativePath/>
<relativePath></relativePath>
<!-- lookup parent from repository -->
</parent>
<groupId>gov.cms.madie.terminologyservice</groupId>
@@ -14,7 +14,7 @@
<name>Terminology Service</name>
<description>Terminology Service for MADiE</description>
<properties>
<hapifhir.version>7.4.5</hapifhir.version>
<hapifhir.version>7.6.0</hapifhir.version>
<java.version>16</java.version>
<jxbmavenplugin.version>2.5.0</jxbmavenplugin.version>
<maven.compiler.source>17</maven.compiler.source>
@@ -174,7 +174,7 @@
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ public WebMvcConfigurer corsConfigurer() {
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
.allowedMethods("PUT", "POST", "GET")
.allowedMethods("PUT", "POST", "GET", "DELETE")
.allowedOrigins(
"http://localhost:9000",
"https://dev-madie.hcqis.org",
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@@ -134,4 +135,12 @@ public ResponseEntity<Boolean> checkUserLogin(Principal principal) {
? ResponseEntity.ok().body(Boolean.TRUE)
: new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}

@DeleteMapping("/umls-credentials")
public ResponseEntity<Boolean> umlsLogout(Principal principal) {
log.info("Entering: umlsLogout(): username = " + principal.getName());
return vsacService.logoutUMLSUser(principal.getName())
? ResponseEntity.ok().body(Boolean.TRUE)
: new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ public class ValueSetsSearchCriteria {

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

Original file line number Diff line number Diff line change
@@ -10,4 +10,6 @@ public interface UmlsUserRepository extends MongoRepository<UmlsUser, String> {
Optional<UmlsUser> findByHarpId(String harpId);

Optional<UmlsUser> findByHarpIdAndApiKey(String harpId, String apiKey);

Optional<UmlsUser> deleteByHarpId(String harpId);
}
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ public List<QdmValueSet> recursivelyRequestAllValueSetsExpansionsForQDM(
vsParam,
valueSetsSearchCriteria.getProfile(),
valueSetsSearchCriteria.getIncludeDraft(),
valueSetsSearchCriteria.getActiveOnly(),
valueSetsSearchCriteria.getManifestExpansion());

ValueSet valueSetResource = parser.parseResource(ValueSet.class, resource);
11 changes: 11 additions & 0 deletions src/main/java/gov/cms/madie/terminology/service/VsacService.java
Original file line number Diff line number Diff line change
@@ -358,4 +358,15 @@ private List<QdmValueSet.Concept> getValueSetConcepts(DescribedValueSet valueSet
public Optional<UmlsUser> findByHarpId(String harpId) {
return umlsUserRepository.findByHarpId(harpId);
}

public boolean logoutUMLSUser(String userName) {
Optional<UmlsUser> deletedUser = umlsUserRepository.deleteByHarpId(userName);
boolean deleted = deletedUser.isPresent();
if (deleted) {
log.info("Successfully deleted UMLS information for User Name: {}", userName);
} else {
log.error("Error while deleting UMLS information for User Name: {}", userName);
}
return deleted;
}
}
Original file line number Diff line number Diff line change
@@ -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";
@@ -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();
Original file line number Diff line number Diff line change
@@ -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");
}
Original file line number Diff line number Diff line change
@@ -133,4 +133,26 @@ void testInvalidUserUmlsLogin() {

assertEquals(response.getStatusCode(), HttpStatus.UNAUTHORIZED);
}

@Test
void testUserUmlsLogout() {
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn(TEST_USER);

when(vsacService.logoutUMLSUser(anyString())).thenReturn(true);
ResponseEntity<Boolean> response = vsacController.umlsLogout(principal);

assertEquals(response.getBody(), Boolean.TRUE);
}

@Test
void testUserUmlsLogoutFailed() {
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn(TEST_USER);

when(vsacService.logoutUMLSUser(anyString())).thenReturn(false);
ResponseEntity<Boolean> response = vsacController.umlsLogout(principal);

assertEquals(response.getStatusCode(), HttpStatus.UNAUTHORIZED);
}
}
Original file line number Diff line number Diff line change
@@ -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);
@@ -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")
@@ -221,6 +223,7 @@ void getsValueSetsExpansionsForQdm_withNoCodes_When_ManifestExpansionIsProvided(
any(ValueSetsSearchCriteria.ValueSetParams.class),
anyString(),
anyString(),
anyString(),
any(ManifestExpansion.class)))
.thenReturn(mockValueSetResourceWithNoCodes);
when(mappingService.getCodeSystemEntries()).thenReturn(codeSystemEntries);
Original file line number Diff line number Diff line change
@@ -592,4 +592,18 @@ void testGetCodeStatusIfCodeNotFoundInSvs() {
CodeStatus status = vsacService.getCodeStatus(code, TEST_API_KEY);
assertThat(status, is(equalTo(CodeStatus.NA)));
}

@Test
void testUserUmlsLogout() {
when(umlsUserRepository.deleteByHarpId(anyString())).thenReturn(Optional.of(umlsUser));
boolean loggedOut = vsacService.logoutUMLSUser(umlsUser.getHarpId());
assertTrue(loggedOut);
}

@Test
void testUserUmlsLogoutFailed() {
when(umlsUserRepository.deleteByHarpId(anyString())).thenReturn(Optional.empty());
boolean loggedOut = vsacService.logoutUMLSUser(umlsUser.getHarpId());
assertFalse(loggedOut);
}
}
Original file line number Diff line number Diff line change
@@ -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,13 @@ 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 +131,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 +155,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 +172,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

0 comments on commit 97cdb53

Please sign in to comment.