Skip to content

Commit

Permalink
remove HAPI from props, and from FHIR client; remove attempt to persi…
Browse files Browse the repository at this point in the history
…st measure bundle to HAPI
  • Loading branch information
nmorasb committed Sep 19, 2023
1 parent 2e66368 commit d2846f0
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 126 deletions.
24 changes: 0 additions & 24 deletions src/main/java/cms/gov/madie/measure/HapiFhirConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,6 @@ public ResponseEntity<HapiOperationOutcome> validateBundle(
uri, HttpMethod.POST, measureEntity, HapiOperationOutcome.class);
}

public ResponseEntity<String> saveMeasureInHapiFhir(Measure measure, String accessToken) {
URI uri =
URI.create(
fhirServicesConfig.getMadieFhirServiceBaseUrl()
+ fhirServicesConfig.getMadieFhirServiceSaveMeasureUri());
HttpHeaders headers = new HttpHeaders();
headers.set(HttpHeaders.AUTHORIZATION, accessToken);
HttpEntity<Measure> measureEntity = new HttpEntity<>(measure, headers);
try {
return fhirServicesRestTemplate.exchange(uri, HttpMethod.POST, measureEntity, String.class);
} catch (RestClientResponseException e) {
// Ignore errors when saving Measures to HAPI as they're never retrieved.
return new ResponseEntity<>(
e.getResponseBodyAsString(), HttpStatus.valueOf(e.getRawStatusCode()));
}
}

public ResponseEntity<byte[]> getTestCaseExports(
Measure measure, String accessToken, List<String> testCaseId) {
URI uri =
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/cms/gov/madie/measure/services/VersionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,18 +314,5 @@ private void saveMeasureBundle(
"User [{}] successfully saved versioned measure's export data with ID [{}]",
username,
savedExport.getId());
ResponseEntity<String> result =
fhirServicesClient.saveMeasureInHapiFhir(savedMeasure, accessToken);
if (result.getStatusCode() == HttpStatus.OK) {
log.info(
"User [{}] successfully saved versioned measure with ID [{}] in HAPI FHIR",
username,
result.getBody());
} else {
log.info(
"User [{}] failed to save versioned measure in HAPI FHIR: {}",
username,
result.getBody());
}
}
}
9 changes: 1 addition & 8 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,4 @@ admin-api-key: ${ADMIN_API_KEY:0a51991c}

mongock:
migration-scan-package:
- cms.gov.madie.measure.config

hapi-fhir:
url: ${HAPI_FHIR_URL:http://localhost:8087/fhir}
patient:
uri: /Patient
bundle:
uri: /Bundle
- cms.gov.madie.measure.config
Original file line number Diff line number Diff line change
Expand Up @@ -156,57 +156,6 @@ void testValidateBundleReturnsStringData() throws JsonProcessingException {
assertThat(authorization.get(0), is(equalTo(accessToken)));
}

@Test
void testSaveMeasureInHapiFhirsStringData() {
final String goodOutcomeJson = "{ \"code\": 200, \"successful\": true }";
Measure measure =
Measure.builder()
.id("testMeasureId")
.measureSetId("testMeasureSetId")
.createdBy("testUser")
.cql("library Test1CQLLib version '2.3.001'")
.build();

when(fhirServicesConfig
.fhirServicesRestTemplate()
.exchange(any(URI.class), eq(HttpMethod.POST), any(HttpEntity.class), any(Class.class)))
.thenReturn(ResponseEntity.ok(goodOutcomeJson));
ResponseEntity<String> output = fhirServicesClient.saveMeasureInHapiFhir(measure, accessToken);
assertThat(output, is(notNullValue()));
assertThat(output.getBody(), is(notNullValue()));
assertThat(output.getBody(), is(equalTo(goodOutcomeJson)));
verify(fhirServicesConfig.fhirServicesRestTemplate(), times(1))
.exchange(
any(URI.class), eq(HttpMethod.POST), httpEntityCaptor.capture(), any(Class.class));
HttpEntity httpEntity = httpEntityCaptor.getValue();
assertThat(httpEntity.getHeaders(), is(notNullValue()));
List<String> authorization = httpEntity.getHeaders().get(HttpHeaders.AUTHORIZATION);
assertThat(authorization, is(notNullValue()));
assertThat(authorization.size(), is(equalTo(1)));
assertThat(authorization.get(0), is(equalTo(accessToken)));
}

@Test
void testSaveMeasureInHapiFhirsExceptionIgnored() {
Measure measure =
Measure.builder()
.id("testMeasureId")
.measureSetId("testMeasureSetId")
.createdBy("testUser")
.cql("library Test1CQLLib version '2.3.001'")
.build();

when(fhirServicesConfig
.fhirServicesRestTemplate()
.exchange(any(URI.class), eq(HttpMethod.POST), any(HttpEntity.class), any(Class.class)))
.thenThrow(
new RestClientResponseException(
"failure", 500, "Server Error", null, "error".getBytes(), null));
ResponseEntity<String> output = fhirServicesClient.saveMeasureInHapiFhir(measure, accessToken);
assertThat(output.getStatusCode(), not(HttpStatus.OK));
assertNotNull(output.getBody());
}

@Test
void testGetTestCaseExports() {
Measure measure =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cms.gov.madie.measure.services;

import cms.gov.madie.measure.HapiFhirConfig;
import cms.gov.madie.measure.dto.JobStatus;
import cms.gov.madie.measure.dto.MeasureTestCaseValidationReport;
import cms.gov.madie.measure.exceptions.DuplicateTestCaseNameException;
Expand Down Expand Up @@ -90,8 +89,6 @@
@ExtendWith(MockitoExtension.class)
public class TestCaseServiceTest implements ResourceUtil {
@Mock private MeasureRepository measureRepository;
@Mock private HapiFhirConfig hapiFhirConfig;
@Mock private RestTemplate hapiFhirRestTemplate;
@Mock private ActionLogService actionLogService;
@Mock private TestCaseServiceUtil testCaseServiceUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,6 @@ public void testCreateVersionMajorSuccess() throws Exception {
updatedMeasure.setMeasureMetaData(updatedMetaData);
when(measureRepository.save(any(Measure.class))).thenReturn(updatedMeasure);

when(fhirServicesClient.saveMeasureInHapiFhir(any(), anyString()))
.thenReturn(ResponseEntity.ok("Created"));

Export measureExport =
Export.builder()
.id("testId")
Expand Down Expand Up @@ -456,8 +453,6 @@ public void testCreateVersionMajorSuccess() throws Exception {
Export capturedExport = exportArgumentCaptor.getValue();
assertEquals(savedValue.getId(), capturedExport.getMeasureId());
assertEquals(measureExport.getMeasureBundleJson(), capturedExport.getMeasureBundleJson());

verify(fhirServicesClient, times(1)).saveMeasureInHapiFhir(updatedMeasure, "accesstoken");
}

@Test
Expand Down Expand Up @@ -553,9 +548,6 @@ public void testCreateFhirVersionPatchSuccess() throws Exception {
updatedMeasure.setMeasureMetaData(updatedMetaData);
when(measureRepository.save(any(Measure.class))).thenReturn(updatedMeasure);

when(fhirServicesClient.saveMeasureInHapiFhir(any(), anyString()))
.thenReturn(new ResponseEntity<>(HttpStatus.OK));

Export measureExport =
Export.builder()
.id("testId")
Expand Down Expand Up @@ -593,8 +585,6 @@ public void testCreateFhirVersionPatchSuccess() throws Exception {
Export savedExport = exportArgumentCaptor.getValue();
assertEquals(savedValue.getId(), savedExport.getMeasureId());
assertEquals(measureExport.getMeasureBundleJson(), savedExport.getMeasureBundleJson());

verify(fhirServicesClient, times(1)).saveMeasureInHapiFhir(updatedMeasure, "accesstoken");
}

@Test
Expand Down

0 comments on commit d2846f0

Please sign in to comment.