Skip to content

Commit

Permalink
MAT-7373: Include the FHIR Bundle returned from VSAC FHIR Term Servic…
Browse files Browse the repository at this point in the history
…e in the Value Set search response.

Note: The Bundle is returned as a String because the typed Bundle object is excessively huge when serialized as it includes null/empty values by default.
  • Loading branch information
jkotanchik-SB committed Jul 12, 2024
1 parent a92583c commit f8c0212
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import gov.cms.madie.models.measure.ManifestExpansion;
import gov.cms.madie.terminology.dto.Code;
import gov.cms.madie.terminology.dto.QdmValueSet;
import gov.cms.madie.terminology.dto.ValueSetForSearch;
import gov.cms.madie.terminology.dto.ValueSetSearchResult;
import gov.cms.madie.terminology.dto.ValueSetsSearchCriteria;
import gov.cms.madie.terminology.models.CodeSystem;
import gov.cms.madie.terminology.models.UmlsUser;
Expand Down Expand Up @@ -72,7 +72,7 @@ public ResponseEntity<List<CodeSystem>> getAllCodeSystems(Principal principal) {

@GetMapping(path = "/search-value-sets", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<List<ValueSetForSearch>> searchValueSets(
public ResponseEntity<ValueSetSearchResult> searchValueSets(
Principal principal, @RequestParam Map<String, String> queryParams) {
final String username = principal.getName();
UmlsUser umlsUser = vsacService.verifyUmlsAccess(username);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gov.cms.madie.terminology.dto;

import lombok.Builder;
import lombok.Data;

import java.util.List;

@Data
@Builder
public class ValueSetSearchResult {
List<ValueSetForSearch> valueSets;
// Returning bundle as String because the FHIR Parser generates
// a typed Bundle object that is excessively huge when serialized
// since it initializes all values and arrays to null/empty array.
String resultBundle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private List<QdmValueSet.Concept> getValueSetConcepts(
return List.of();
}

public List<ValueSetForSearch> searchValueSets(String apiKey, Map<String, String> queryParams) {
public ValueSetSearchResult searchValueSets(String apiKey, Map<String, String> queryParams) {
IParser parser = fhirContext.newJsonParser();
String responseString = fhirTerminologyServiceWebClient.searchValueSets(apiKey, queryParams);
Bundle bundle = parser.parseResource(Bundle.class, responseString);
Expand Down Expand Up @@ -177,8 +177,7 @@ public List<ValueSetForSearch> searchValueSets(String apiKey, Map<String, String
}
log.info("valueSetList {}", valueSetList);
});

return valueSetList;
return ValueSetSearchResult.builder().valueSets(valueSetList).resultBundle(responseString).build();
}

public List<CodeSystem> getAllCodeSystems() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,11 @@ void testSearchValueSets() {
Principal principal = mock(Principal.class);
when(principal.getName()).thenReturn(TEST_USER);
when(vsacService.verifyUmlsAccess(anyString())).thenReturn(umlsUser);
when(fhirTerminologyService.searchValueSets(any(), any())).thenReturn(mockValueSets);
when(fhirTerminologyService.searchValueSets(any(), any())).thenReturn(ValueSetSearchResult.builder().valueSets(mockValueSets).build());
Map<String, String> queryParams = new HashMap<>();
queryParams.put("param1", "value1");
queryParams.put("param2", "value2");
ResponseEntity<List<ValueSetForSearch>> response =
ResponseEntity<ValueSetSearchResult> response =
vsacFhirTerminologyController.searchValueSets(principal, queryParams);
assertEquals(response.getStatusCode(), HttpStatus.OK);
}
Expand Down

0 comments on commit f8c0212

Please sign in to comment.