From edc91472b009cf5f4744cde86c66939833ff12f0 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Thu, 28 Sep 2023 12:48:19 -0700 Subject: [PATCH 01/15] wip --- .../gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java index 16781a69..914b909f 100644 --- a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java +++ b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java @@ -52,6 +52,7 @@ private static void cleanOutUnNeededData(ExplanationOfBenefit benefit) { Inherited - Identifier, resourceType, type */ // Extensions should exist in benefit: AB2D-5728 Validate Humana AB2D data dictionary for missing elements reported in STU3 + benefit.setExtension(null); benefit.setPatientTarget(null); benefit.setCreated(null); benefit.setEnterer(null); From 38e2c315bd6ca65620b5e7b2727dea5bf46eef7e Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Thu, 11 Jul 2024 11:28:46 -0700 Subject: [PATCH 02/15] AB2D-6105/TIBQ --- .../gov/cms/ab2d/bfd/client/BFDClient.java | 2 +- .../cms/ab2d/bfd/client/BFDClientImpl.java | 14 +- .../gov/cms/ab2d/bfd/client/BFDSearch.java | 2 +- .../cms/ab2d/bfd/client/BFDSearchImpl.java | 19 +- .../ab2d/bfd/client/BFDSearchImplTest.java | 270 +++++++++--------- .../bfd/client/BlueButtonClientSTU3Test.java | 41 +-- .../ab2d/bfd/client/FhirBfdServerTest.java | 2 +- build.gradle | 8 +- 8 files changed, 179 insertions(+), 179 deletions(-) diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java index 6699f664..cf3c7af1 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java @@ -11,7 +11,7 @@ public interface BFDClient { String BFD_HDR_BULK_JOBID = "BULK-JOBID"; IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, String contractNum); - IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, String contractNum); + IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, OffsetDateTime untilTime, String contractNum); IBaseBundle requestNextBundleFromServer(FhirVersion version, IBaseBundle bundle, String contractNum); /** diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java index 06642fef..9085b0e6 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java @@ -79,8 +79,7 @@ public BFDClientImpl(BFDSearch bfdSearch, BfdClientVersions bfdClientVersions) { exclude = { ResourceNotFoundException.class } ) public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, String contractNum) { - return requestEOBFromServer(version, patientID, null, contractNum); - // return requestEOBFromServer(version, patientID, null, null, contractNum); + return requestEOBFromServer(version, patientID, null, null, contractNum); } /** @@ -92,6 +91,7 @@ public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, Str * @param version The FHIR version * @param patientID The requested patient's ID * @param sinceTime The start date for the request + * @param untilTime The stop date for the request * @return {@link IBaseBundle} Containing a number (possibly 0) of Resources * objects * @throws ResourceNotFoundException when the requested patient does not exist @@ -104,12 +104,12 @@ public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, Str backoff = @Backoff(delayExpression = "${bfd.retry.backoffDelay:250}", multiplier = 2), exclude = { ResourceNotFoundException.class } ) - public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, String contractNum) { - final Segment bfdSegment = NewRelic.getAgent().getTransaction().startSegment("BFD Call for patient with patient ID " + patientID + - " using since " + sinceTime); + public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, OffsetDateTime untilTime, String contractNum) { + final Segment bfdSegment = NewRelic.getAgent().getTransaction().startSegment("BFD Call for patient with patient ID " + patientID + + " using since " + sinceTime + " and until " + untilTime); bfdSegment.setMetricName("RequestEOB"); - IBaseBundle result = bfdSearch.searchEOB(patientID, sinceTime, pageSize, getJobId(), version, contractNum); + IBaseBundle result = bfdSearch.searchEOB(patientID, sinceTime, untilTime, pageSize, getJobId(), version, contractNum); bfdSegment.end(); @@ -226,4 +226,4 @@ private String createMonthParameter(int month) { final String zeroPaddedMonth = StringUtils.leftPad("" + month, 2, '0'); return PTDCNTRCT_URL_PREFIX + zeroPaddedMonth; } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java index 637bae19..d5dcfecd 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java @@ -7,5 +7,5 @@ import java.time.OffsetDateTime; public interface BFDSearch { - IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException; + IBaseBundle searchEOB(long patientId, OffsetDateTime since, OffsetDateTime until, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException; } diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java index d6825da0..13a4f780 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java @@ -39,6 +39,7 @@ public BFDSearchImpl(HttpClient httpClient, Environment environment, BfdClientVe * * @param patientId internal beneficiary id * @param since the minimum lastUpdated date which may be null + * @param until the maximum lastUpdated date which may be null * @param pageSize maximum number of records that can be returned * @param bulkJobId header to uniquely identify what job this is coming from within BFD logs * @param version the version of FHIR that we need from BFD @@ -47,21 +48,17 @@ public BFDSearchImpl(HttpClient httpClient, Environment environment, BfdClientVe */ @Trace @Override - public IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException { + public IBaseBundle searchEOB(long patientId, OffsetDateTime since, OffsetDateTime until, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException { + String urlLocation = bfdClientVersions.getUrl(version); StringBuilder url = new StringBuilder(urlLocation + "ExplanationOfBenefit?patient=" + patientId + "&excludeSAMHSA=true"); if (since != null) { url.append("&_lastUpdated=ge").append(since); + } - //AB2D-5892 (Sprint 3)Centene customer support to provide 2 year data - if (contractNum.equals("S4802") || contractNum.equals("Z1001")) { - url.append("&_lastUpdated=le").append(since.plusMonths(1)); - } - //AB2D-6167 Create customized script for Humana - if (contractNum.equals("S5884")) { - url.append("&_lastUpdated=le").append(since.plusMonths(2)); - } + if (until != null) { + url.append("&_lastUpdated=le").append(until); } if (pageSize > 0) { @@ -85,7 +82,7 @@ public IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, } /** - Method exists to track connection to BFD for New Relic + Method exists to track connection to BFD for New Relic */ @Trace private byte[] getEOBSFromBFD(long patientId, HttpGet request) throws IOException { @@ -111,4 +108,4 @@ private byte[] getEOBSFromBFD(long patientId, HttpGet request) throws IOExceptio private IBaseBundle parseBundle(FhirVersion version, byte[] responseBytes) { return version.getJsonParser().parseResource(version.getBundleClass(), new ByteArrayInputStream(responseBytes)); } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java index 855fd0c5..77f1561d 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java @@ -25,140 +25,140 @@ class BFDSearchImplTest { - private static int patientId = 1; - private static OffsetDateTime since = OffsetDateTime.now(); - private static OffsetDateTime until = OffsetDateTime.now(); - private static int pageSize = 10; - private static String bulkJobId = "bulkJobId"; - private static FhirVersion version = FhirVersion.R4; - private static String contractNum = "contractNum"; - private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; - private static String activeProfile = "test"; - private static String bfdUrl = "http://localhost:8080"; - - HttpClient httpClient100() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); - return httpClient; - } - - HttpClient httpClient200() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); - when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); - String fileContent = Files.readString(Paths.get(filePath)); - when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); - return httpClient; - } - - HttpClient httpClient404() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); - return httpClient; - } - - HttpClient httpClient500() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); - return httpClient; - } - - @Test - void testSearchEOB100() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient100(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB200() throws IOException{ - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB200WithFalsyArgs() throws IOException{ - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { "" }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, 0, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB404() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient404(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - ResourceNotFoundException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB500() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient500(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } + private static int patientId = 1; + private static OffsetDateTime since = OffsetDateTime.now(); + private static OffsetDateTime until = OffsetDateTime.now(); + private static int pageSize = 10; + private static String bulkJobId = "bulkJobId"; + private static FhirVersion version = FhirVersion.R4; + private static String contractNum = "contractNum"; + private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; + private static String activeProfile = "test"; + private static String bfdUrl = "http://localhost:8080"; + + HttpClient httpClient100() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); + return httpClient; + } + + HttpClient httpClient200() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); + String fileContent = Files.readString(Paths.get(filePath)); + when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); + return httpClient; + } + + HttpClient httpClient404() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); + return httpClient; + } + + HttpClient httpClient500() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + return httpClient; + } + + @Test + void testSearchEOB100() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient100(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB200() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB200WithFalsyArgs() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{""}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB404() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient404(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + ResourceNotFoundException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB500() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient500(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } } diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java index 4a48a50d..fc79b954 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java @@ -182,7 +182,7 @@ public static void tearDown() { } @Test - void shouldGetTimedOutOnSlowResponse() { + public void shouldGetTimedOutOnSlowResponse() { var exception = Assertions.assertThrows(SocketTimeoutException.class, () -> bbc.requestEOBFromServer(STU3, TEST_SLOW_PATIENT_ID, CONTRACT)); var rootCause = ExceptionUtils.getRootCause(exception); @@ -192,30 +192,33 @@ void shouldGetTimedOutOnSlowResponse() { } @Test - void shouldGetEOBFromPatientID() { + public void shouldGetEOBFromPatientID() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDSince() { - org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, CONTRACT); + public void shouldGetEOBFromPatientIDSince() { + org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( + "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), null, CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDUtil() { - org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, CONTRACT); + public void shouldGetEOBFromPatientIDUtil() { + org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, OffsetDateTime.parse( + "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDSinceAndUtil() { + public void shouldGetEOBFromPatientIDSinceAndUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( - "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); + "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), OffsetDateTime.parse( + "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); validation(response); } @@ -226,19 +229,19 @@ private static void validation(Bundle response) { } @Test - void shouldGetEOBPatientNoRecords() { + public void shouldGetEOBPatientNoRecords() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID, CONTRACT); assertFalse(response.hasEntry()); } @Test - void shouldGetEOBPatientNoRecordsMBI() { + public void shouldGetEOBPatientNoRecordsMBI() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID_MBI, CONTRACT); assertFalse(response.hasEntry()); } @Test - void shouldNotHaveNextBundle() { + public void shouldNotHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -248,7 +251,7 @@ void shouldNotHaveNextBundle() { } @Test - void shouldHaveNextBundle() { + public void shouldHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -267,10 +270,10 @@ void shouldHaveNextBundle() { } @Test - void shouldReturnBundleContainingOnlyEOBs() { + public void shouldReturnBundleContainingOnlyEOBs() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); - response.getEntry().forEach(entry -> assertEquals( + response.getEntry().forEach((entry) -> assertEquals( org.hl7.fhir.dstu3.model.ResourceType.ExplanationOfBenefit, entry.getResource().getResourceType(), "EOB bundles returned by the BlueButton client should only contain EOB objects" @@ -278,13 +281,13 @@ void shouldReturnBundleContainingOnlyEOBs() { } @Test - void shouldHandlePatientsWithOnlyOneEOB() { + public void shouldHandlePatientsWithOnlyOneEOB() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertEquals(1, response.getTotal(), "This demo patient should have exactly 1 EOB"); } @Test - void shouldThrowExceptionWhenResourceNotFound() { + public void shouldThrowExceptionWhenResourceNotFound() { assertThrows( ResourceNotFoundException.class, () -> bbc.requestEOBFromServer(STU3, TEST_NONEXISTENT_PATIENT_ID, CONTRACT), @@ -294,7 +297,7 @@ void shouldThrowExceptionWhenResourceNotFound() { } @Test - void shouldGetPatientBundleFromPartDEnrolleeRequest() { + public void shouldGetPatientBundleFromPartDEnrolleeRequest() { for (int i = 1; i <= 12; i++) { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestPartDEnrolleesFromServer(STU3, CONTRACT, i); @@ -304,11 +307,11 @@ void shouldGetPatientBundleFromPartDEnrolleeRequest() { } @Test - void shouldGetMetadata() { + public void shouldGetMetadata() { org.hl7.fhir.dstu3.model.CapabilityStatement capabilityStatement = (org.hl7.fhir.dstu3.model.CapabilityStatement) bbc.capabilityStatement(STU3); assertNotNull(capabilityStatement, "There should be a non null capability statement"); assertEquals("3.0.1", capabilityStatement.getFhirVersion()); assertEquals(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE, capabilityStatement.getStatus()); } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java index 37ecea21..b17bcd70 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java @@ -11,7 +11,7 @@ class FhirBfdServerTest { @Test void testGetVersion() { - assertEquals(FhirVersion.R4, new FhirBfdServer(FhirVersion.R4).getVersion());; + assertEquals(FhirVersion.R4, new FhirBfdServer(FhirVersion.R4).getVersion()); } @Test diff --git a/build.gradle b/build.gradle index 06110c4f..335408b4 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ ext { // AB2D libraries fhirVersion='1.2.6' - bfdVersion='2.2.2' + bfdVersion='2.3.0' aggregatorVersion='1.3.4' filtersVersion='1.9.4' eventClientVersion='1.12.8' @@ -156,8 +156,8 @@ subprojects { jar { processResources.exclude('checkstyle.xml') - classifier "main".equalsIgnoreCase(gitBranch()) || "main".equalsIgnoreCase(System.getenv('BRANCH_NAME')) ? "" : "SNAPSHOT" - out.println("**** building branch - " + gitBranch() + ", classifier - " + classifier + " - CI branch - " + System.getenv('BRANCH_NAME')) +// classifier "main".equalsIgnoreCase(gitBranch()) || "main".equalsIgnoreCase(System.getenv('BRANCH_NAME')) ? "" : "SNAPSHOT" + // out.println("**** building branch - " + gitBranch() + ", classifier - " + classifier + " - CI branch - " + System.getenv('BRANCH_NAME')) } test { @@ -173,7 +173,7 @@ subprojects { jacocoTestReport { reports { - xml.enabled true + // xml.enabled true } } From 4be4dacf968493f614ee6809e756505803a38562 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Thu, 11 Jul 2024 11:30:47 -0700 Subject: [PATCH 03/15] AB2D-6105/TIBQ --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 335408b4..e54d051f 100644 --- a/build.gradle +++ b/build.gradle @@ -156,8 +156,8 @@ subprojects { jar { processResources.exclude('checkstyle.xml') -// classifier "main".equalsIgnoreCase(gitBranch()) || "main".equalsIgnoreCase(System.getenv('BRANCH_NAME')) ? "" : "SNAPSHOT" - // out.println("**** building branch - " + gitBranch() + ", classifier - " + classifier + " - CI branch - " + System.getenv('BRANCH_NAME')) + classifier "main".equalsIgnoreCase(gitBranch()) || "main".equalsIgnoreCase(System.getenv('BRANCH_NAME')) ? "" : "SNAPSHOT" + out.println("**** building branch - " + gitBranch() + ", classifier - " + classifier + " - CI branch - " + System.getenv('BRANCH_NAME')) } test { @@ -173,7 +173,7 @@ subprojects { jacocoTestReport { reports { - // xml.enabled true + xml.enabled true } } From 9ccc12c22923f42ab8080199d77eee25ccd4657c Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Tue, 16 Jul 2024 13:58:19 -0700 Subject: [PATCH 04/15] revert --- .../bfd/client/BlueButtonClientSTU3Test.java | 32 +++++++++---------- .../ExplanationOfBenefitTrimmerSTU3.java | 1 - 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java index fc79b954..832ce59f 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java @@ -182,7 +182,7 @@ public static void tearDown() { } @Test - public void shouldGetTimedOutOnSlowResponse() { + void shouldGetTimedOutOnSlowResponse() { var exception = Assertions.assertThrows(SocketTimeoutException.class, () -> bbc.requestEOBFromServer(STU3, TEST_SLOW_PATIENT_ID, CONTRACT)); var rootCause = ExceptionUtils.getRootCause(exception); @@ -192,14 +192,14 @@ public void shouldGetTimedOutOnSlowResponse() { } @Test - public void shouldGetEOBFromPatientID() { + void shouldGetEOBFromPatientID() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); validation(response); } @Test - public void shouldGetEOBFromPatientIDSince() { + void shouldGetEOBFromPatientIDSince() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), null, CONTRACT); @@ -207,7 +207,7 @@ public void shouldGetEOBFromPatientIDSince() { } @Test - public void shouldGetEOBFromPatientIDUtil() { + void shouldGetEOBFromPatientIDUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, OffsetDateTime.parse( "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); @@ -215,7 +215,7 @@ public void shouldGetEOBFromPatientIDUtil() { } @Test - public void shouldGetEOBFromPatientIDSinceAndUtil() { + void shouldGetEOBFromPatientIDSinceAndUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), OffsetDateTime.parse( "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); @@ -229,19 +229,19 @@ private static void validation(Bundle response) { } @Test - public void shouldGetEOBPatientNoRecords() { + void shouldGetEOBPatientNoRecords() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID, CONTRACT); assertFalse(response.hasEntry()); } @Test - public void shouldGetEOBPatientNoRecordsMBI() { + void shouldGetEOBPatientNoRecordsMBI() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID_MBI, CONTRACT); assertFalse(response.hasEntry()); } @Test - public void shouldNotHaveNextBundle() { + void shouldNotHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -251,7 +251,7 @@ public void shouldNotHaveNextBundle() { } @Test - public void shouldHaveNextBundle() { + void shouldHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -270,10 +270,10 @@ public void shouldHaveNextBundle() { } @Test - public void shouldReturnBundleContainingOnlyEOBs() { + void shouldReturnBundleContainingOnlyEOBs() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); - response.getEntry().forEach((entry) -> assertEquals( + response.getEntry().forEach(entry -> assertEquals( org.hl7.fhir.dstu3.model.ResourceType.ExplanationOfBenefit, entry.getResource().getResourceType(), "EOB bundles returned by the BlueButton client should only contain EOB objects" @@ -281,13 +281,13 @@ public void shouldReturnBundleContainingOnlyEOBs() { } @Test - public void shouldHandlePatientsWithOnlyOneEOB() { + void shouldHandlePatientsWithOnlyOneEOB() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertEquals(1, response.getTotal(), "This demo patient should have exactly 1 EOB"); } @Test - public void shouldThrowExceptionWhenResourceNotFound() { + void shouldThrowExceptionWhenResourceNotFound() { assertThrows( ResourceNotFoundException.class, () -> bbc.requestEOBFromServer(STU3, TEST_NONEXISTENT_PATIENT_ID, CONTRACT), @@ -297,7 +297,7 @@ public void shouldThrowExceptionWhenResourceNotFound() { } @Test - public void shouldGetPatientBundleFromPartDEnrolleeRequest() { + void shouldGetPatientBundleFromPartDEnrolleeRequest() { for (int i = 1; i <= 12; i++) { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestPartDEnrolleesFromServer(STU3, CONTRACT, i); @@ -307,11 +307,11 @@ public void shouldGetPatientBundleFromPartDEnrolleeRequest() { } @Test - public void shouldGetMetadata() { + void shouldGetMetadata() { org.hl7.fhir.dstu3.model.CapabilityStatement capabilityStatement = (org.hl7.fhir.dstu3.model.CapabilityStatement) bbc.capabilityStatement(STU3); assertNotNull(capabilityStatement, "There should be a non null capability statement"); assertEquals("3.0.1", capabilityStatement.getFhirVersion()); assertEquals(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE, capabilityStatement.getStatus()); } -} \ No newline at end of file +} diff --git a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java index c994dbd8..0240b14d 100644 --- a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java +++ b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java @@ -55,7 +55,6 @@ private static void cleanOutUnNeededData(ExplanationOfBenefit benefit) { Inherited - Identifier, resourceType, type */ // Extensions should exist in benefit: AB2D-5728 Validate Humana AB2D data dictionary for missing elements reported in STU3 - benefit.setExtension(null); benefit.setPatientTarget(null); benefit.setCreated(null); benefit.setEnterer(null); From e6a9b5f8e734a83eb2551cca95ff52d39098822c Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Wed, 17 Jul 2024 11:28:20 -0700 Subject: [PATCH 05/15] revert auto formatting --- .../ab2d/bfd/client/BFDSearchImplTest.java | 270 +++++++++--------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java index 77f1561d..8596b593 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java @@ -25,140 +25,140 @@ class BFDSearchImplTest { - private static int patientId = 1; - private static OffsetDateTime since = OffsetDateTime.now(); - private static OffsetDateTime until = OffsetDateTime.now(); - private static int pageSize = 10; - private static String bulkJobId = "bulkJobId"; - private static FhirVersion version = FhirVersion.R4; - private static String contractNum = "contractNum"; - private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; - private static String activeProfile = "test"; - private static String bfdUrl = "http://localhost:8080"; - - HttpClient httpClient100() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); - return httpClient; - } - - HttpClient httpClient200() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); - when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); - String fileContent = Files.readString(Paths.get(filePath)); - when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); - return httpClient; - } - - HttpClient httpClient404() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); - return httpClient; - } - - HttpClient httpClient500() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); - return httpClient; - } - - @Test - void testSearchEOB100() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient100(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB200() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB200WithFalsyArgs() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{""}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB404() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient404(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - ResourceNotFoundException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB500() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient500(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } + private static int patientId = 1; + private static OffsetDateTime since = OffsetDateTime.now(); + private static OffsetDateTime until = OffsetDateTime.now(); + private static int pageSize = 10; + private static String bulkJobId = "bulkJobId"; + private static FhirVersion version = FhirVersion.R4; + private static String contractNum = "contractNum"; + private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; + private static String activeProfile = "test"; + private static String bfdUrl = "http://localhost:8080"; + + HttpClient httpClient100() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); + return httpClient; + } + + HttpClient httpClient200() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); + String fileContent = Files.readString(Paths.get(filePath)); + when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); + return httpClient; + } + + HttpClient httpClient404() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); + return httpClient; + } + + HttpClient httpClient500() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + return httpClient; + } + + @Test + void testSearchEOB100() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient100(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB200() throws IOException{ + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB200WithFalsyArgs() throws IOException{ + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { "" }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB404() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient404(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + ResourceNotFoundException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB500() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient500(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } } From c5f7cfdbe5b7f7eb7b779781bbe1247431c82e24 Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava <87499456+Rwolfe-Nava@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:08:45 -0400 Subject: [PATCH 06/15] [AB2D-6101] Address Critical Code Smell - Reduce cognitive method compleixty (#403) * update tests and address codesmells * update tests * parameterize generic * bump fhirVersion * update based on review feedback * fix test method name * add setup methods in test to reduce code duplication * remove redundant variables * remove more redundant variables * fix generic so sonar is happy --- .../gov/cms/ab2d/fhir/IdentifierUtils.java | 67 +++--- .../ab2d/fhir/PatientIdentifierUtilsTest.java | 196 +++++++++++++++++- build.gradle | 2 +- 3 files changed, 239 insertions(+), 26 deletions(-) diff --git a/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java b/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java index a535209c..0731307e 100644 --- a/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java +++ b/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java @@ -5,6 +5,7 @@ import org.hl7.fhir.instance.model.api.IBaseExtension; import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.IDomainResource; +import org.hl7.fhir.dstu3.model.Coding; import java.util.ArrayList; import java.util.Date; @@ -206,41 +207,59 @@ private static PatientIdentifier.Currency getCurrencyMbiStandard(ICompositeType return getCurrencyFromTypeCodingExtension(identifier); } - private static PatientIdentifier.Currency getCurrencyFromTypeCodingExtension(ICompositeType identifier) { + public static PatientIdentifier.Currency getCurrencyFromTypeCodingExtension(ICompositeType identifier) { Object type = Versions.invokeGetMethod(identifier, "getType"); - if (type == null) { - return PatientIdentifier.Currency.UNKNOWN; - } - List vals = (List) Versions.invokeGetMethod(type, "getCoding"); - if (vals == null || vals.isEmpty()) { + List vals = (List) Versions.invokeGetMethod(type, "getCoding"); + + if (checkTypeAndCodingNotExists(type, vals)) { return PatientIdentifier.Currency.UNKNOWN; } + Object val = vals.get(0); String codeSystem = (String) Versions.invokeGetMethod(val, GET_SYSTEM); String codeValue = (String) Versions.invokeGetMethod(val, GET_CODE); - if (codeSystem != null && codeSystem.equalsIgnoreCase(MBI_ID_R4) && ("MB".equalsIgnoreCase(codeValue) || "MC".equalsIgnoreCase(codeValue))) { - List extensions = (List) Versions.invokeGetMethod(val, "getExtension"); - if (extensions != null && extensions.size() > 0) { - Object extension = extensions.get(0); - String url = (String) Versions.invokeGetMethod(extension, "getUrl"); - if (url != null && url.equalsIgnoreCase(CURRENCY_IDENTIFIER)) { - Object currValue = Versions.invokeGetMethod(extension, GET_VALUE); - String extValueSystem = (String) Versions.invokeGetMethod(currValue, GET_SYSTEM); - if (CURRENCY_IDENTIFIER.equalsIgnoreCase(extValueSystem)) { - String currValueCode = (String) Versions.invokeGetMethod(currValue, GET_CODE); - if (CURRENT_MBI.equalsIgnoreCase(currValueCode)) { - return PatientIdentifier.Currency.CURRENT; - } - if (HISTORIC_MBI.equalsIgnoreCase(currValueCode)) { - return PatientIdentifier.Currency.HISTORIC; - } - } - } + + List extensions = (List) Versions.invokeGetMethod(val, "getExtension"); + if (checkCodingIsNotValid(codeSystem, codeValue) || checkExtensionsNotExists(extensions)) { + return PatientIdentifier.Currency.UNKNOWN; + } + + Object extension = extensions.get(0); + String url = (String) Versions.invokeGetMethod(extension, "getUrl"); + if (checkCurrencyUrlIsNotValid(url)) { + return PatientIdentifier.Currency.UNKNOWN; + } + + Object currValue = Versions.invokeGetMethod(extension, GET_VALUE); + String extValueSystem = (String) Versions.invokeGetMethod(currValue, GET_SYSTEM); + if (CURRENCY_IDENTIFIER.equalsIgnoreCase(extValueSystem)) { + String currValueCode = (String) Versions.invokeGetMethod(currValue, GET_CODE); + if (CURRENT_MBI.equalsIgnoreCase(currValueCode)) { + return PatientIdentifier.Currency.CURRENT; + } + if (HISTORIC_MBI.equalsIgnoreCase(currValueCode)) { + return PatientIdentifier.Currency.HISTORIC; } } return PatientIdentifier.Currency.UNKNOWN; } + public static boolean checkTypeAndCodingNotExists(Object type, List vals) { + return (type == null || vals == null || vals.isEmpty()); + } + + public static boolean checkCodingIsNotValid(String codeSystem, String codeValue) { + return (codeSystem == null || !codeSystem.equalsIgnoreCase(MBI_ID_R4)) || (!codeValue.equalsIgnoreCase("MB") && !codeValue.equalsIgnoreCase("MC")); + } + + public static boolean checkExtensionsNotExists(List extensions) { + return (extensions == null || extensions.isEmpty()); + } + + public static boolean checkCurrencyUrlIsNotValid(String url) { + return (url == null || !url.equalsIgnoreCase(CURRENCY_IDENTIFIER)); + } + /** * If the period has a value for the identifier, return the information from that, otherwise UNKNOWN * diff --git a/ab2d-fhir/src/test/java/gov/cms/ab2d/fhir/PatientIdentifierUtilsTest.java b/ab2d-fhir/src/test/java/gov/cms/ab2d/fhir/PatientIdentifierUtilsTest.java index af4cdd93..997440f9 100644 --- a/ab2d-fhir/src/test/java/gov/cms/ab2d/fhir/PatientIdentifierUtilsTest.java +++ b/ab2d-fhir/src/test/java/gov/cms/ab2d/fhir/PatientIdentifierUtilsTest.java @@ -2,9 +2,10 @@ import org.hl7.fhir.dstu3.model.Bundle; import org.hl7.fhir.dstu3.model.Coding; -import org.hl7.fhir.dstu3.model.Extension; import org.hl7.fhir.dstu3.model.Identifier; import org.hl7.fhir.dstu3.model.Patient; +import org.hl7.fhir.dstu3.model.Extension; +import org.hl7.fhir.instance.model.api.IBaseExtension; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.ICompositeType; import org.junit.jupiter.api.Test; @@ -13,6 +14,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.ArrayList; import java.util.Set; import static gov.cms.ab2d.fhir.PatientIdentifier.CURRENT_MBI; @@ -20,6 +22,7 @@ import static gov.cms.ab2d.fhir.PatientIdentifier.Currency.HISTORIC; import static gov.cms.ab2d.fhir.PatientIdentifier.HISTORIC_MBI; import static gov.cms.ab2d.fhir.PatientIdentifier.MBI_ID; +import static gov.cms.ab2d.fhir.PatientIdentifier.MBI_ID_R4; import static gov.cms.ab2d.fhir.IdentifierUtils.CURRENCY_IDENTIFIER; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; @@ -177,6 +180,161 @@ void testGetCurrentMbiWrongType() { assertNull(IdentifierUtils.getCurrentMbi(List.of(patientIdentifier))); } + @Test + void testGetCurrentMbiTypeNotExists() { + PatientIdentifier patientIdentifier = new PatientIdentifier(); + patientIdentifier.setType(null); + patientIdentifier.setValue("test-1"); + assertNull(IdentifierUtils.getCurrentMbi(List.of(patientIdentifier))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsCurrent() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, CURRENT_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.CURRENT, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsHistoric() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, HISTORIC_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.HISTORIC, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknown() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, "unknown"); + Extension extension = setupExtensionForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknownWhenCodingEmpty() { + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(null, null); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknownWhenCodingSystemInvalid() { + Coding coding = setupCodingForTestingCurrencyTypeCode("invalid_system", "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, CURRENT_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknownWhenCodingCodeInvalid() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "invalid_code"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, CURRENT_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknownWhenUrlNull() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, CURRENT_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode(null, extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testGetCurrencyFromTypeCodingExtensionReturnsUnknownWhenUrlInvalid() { + Coding coding = setupCodingForTestingCurrencyTypeCode(MBI_ID_R4, "MB"); + + Coding extCoding = setupCodingForTestingCurrencyTypeCode(CURRENCY_IDENTIFIER, CURRENT_MBI); + Extension extension = setupExtensionForTestingCurrencyTypeCode("invalid_url", extCoding); + + Identifier identifier = setupIdentifierForTestingCurrencyTypeCode(coding, extension); + Patient patient = setupPatientForTestingCurrencyTypeCode(identifier); + + assertEquals(PatientIdentifier.Currency.UNKNOWN, IdentifierUtils.getCurrencyFromTypeCodingExtension(patient.getIdentifier().get(0))); + } + + @Test + void testReturnsTrueIfCodingNotExist() { + PatientIdentifier patientIdentifier = new PatientIdentifier(); + patientIdentifier.setType(PatientIdentifier.Type.MBI); + patientIdentifier.setValue("test-1"); + + Object type = Versions.invokeGetMethod(patientIdentifier, "getType"); + List vals = (List) Versions.invokeGetMethod(type, "getCode"); + + assertTrue(IdentifierUtils.checkTypeAndCodingNotExists(type, vals)); + } + + @Test + void testReturnsTrueIfCodingNotValid() { + assertTrue(IdentifierUtils.checkCodingIsNotValid("invalid_system", "invalid_value")); + } + + @Test + void testReturnsFalseIfCodingValid() { + assertFalse(IdentifierUtils.checkCodingIsNotValid(MBI_ID_R4, "MB")); + assertFalse(IdentifierUtils.checkCodingIsNotValid(MBI_ID_R4, "MC")); + } + + @Test + void testReturnsTrueIfExtensionsNotExists() { + assertTrue(IdentifierUtils.checkExtensionsNotExists(new ArrayList<>())); + } + + @Test + void testReturnsFalseIfExtensionsExists() { + List extensions = new ArrayList<>(); + Extension extension = new Extension(); + extensions.add(extension); + assertFalse(IdentifierUtils.checkExtensionsNotExists(extensions)); + } + + @Test + void testReturnsFalseIfURLValid() { + assertFalse(IdentifierUtils.checkCurrencyUrlIsNotValid(IdentifierUtils.CURRENCY_IDENTIFIER)); + } + + @Test + void testReturnsTrueIfURLInvalid() { + assertTrue(IdentifierUtils.checkCurrencyUrlIsNotValid("invalid_url")); + } + @Test void testR4ExtractIds() throws IOException { List beneIds = List.of("-19990000001101", "-19990000001102", "-19990000001103"); @@ -212,6 +370,42 @@ void testR4ExtractIds() throws IOException { } } + Extension setupExtensionForTestingCurrencyTypeCode(String url, Coding extCoding) { + Extension extension = new Extension(); + extension.setUrl(url); + + if (extCoding != null) { + extension.setValue(extCoding); + } + return extension; + } + + Coding setupCodingForTestingCurrencyTypeCode(String system, String code) { + Coding coding = new Coding(); + coding.setSystem(system); + coding.setCode(code); + return coding; + } + + Identifier setupIdentifierForTestingCurrencyTypeCode(Coding coding, Extension extension) { + Identifier identifier = new Identifier(); + identifier.setSystem(MBI_ID); + identifier.setValue("mbi-1"); + if (coding != null) { + identifier.getType().addCoding(coding); + } + if (extension != null) { + identifier.getType().getCoding().get(0).addExtension(extension); + } + return identifier; + } + + Patient setupPatientForTestingCurrencyTypeCode(Identifier identifier) { + Patient patient = new Patient(); + patient.setIdentifier(List.of(identifier)); + return patient; + } + IBaseResource extractBundle(FhirVersion version, String fileName) throws IOException { return version.getJsonParser().parseResource(getRawJson(fileName)); } diff --git a/build.gradle b/build.gradle index 06110c4f..2f77dcd9 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ ext { : System.getenv()['ARTIFACTORY_PASSWORD'] // AB2D libraries - fhirVersion='1.2.6' + fhirVersion='1.2.7' bfdVersion='2.2.2' aggregatorVersion='1.3.4' filtersVersion='1.9.4' From ddfeaaee67f01bc73a2d8b7068e1f1c55aec3513 Mon Sep 17 00:00:00 2001 From: Anna Smirnova <132938234+smirnovaae@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:32:44 -0700 Subject: [PATCH 07/15] Ab2 d 6247/remove 2 month humana (#405) * wip * AB2D-6247/remove 2 month for Humana * AB2D-6247/remove 2 month for Humana --- .../src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java | 4 ---- build.gradle | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java index d6825da0..2c12fdf6 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java @@ -58,10 +58,6 @@ public IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, if (contractNum.equals("S4802") || contractNum.equals("Z1001")) { url.append("&_lastUpdated=le").append(since.plusMonths(1)); } - //AB2D-6167 Create customized script for Humana - if (contractNum.equals("S5884")) { - url.append("&_lastUpdated=le").append(since.plusMonths(2)); - } } if (pageSize > 0) { diff --git a/build.gradle b/build.gradle index 2f77dcd9..f6e58753 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ ext { // AB2D libraries fhirVersion='1.2.7' - bfdVersion='2.2.2' + bfdVersion='2.2.3' aggregatorVersion='1.3.4' filtersVersion='1.9.4' eventClientVersion='1.12.8' From ac96e4a9e590c8367d1ff7152a2e5baf63d13a34 Mon Sep 17 00:00:00 2001 From: Anna Smirnova <132938234+smirnovaae@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:04:07 -0700 Subject: [PATCH 08/15] Ab2d-6270/snyk (#406) AB2D-6270 Ab2d,libs -Analyze level of effort and address critical Snyk security vulnerabilities --- ab2d-events-client/build.gradle | 2 +- build.gradle | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ab2d-events-client/build.gradle b/ab2d-events-client/build.gradle index 68866036..b69c1d92 100644 --- a/ab2d-events-client/build.gradle +++ b/ab2d-events-client/build.gradle @@ -14,7 +14,7 @@ dependencies { implementation "com.slack.api:slack-api-client:${slackAPIVersion}" annotationProcessor "org.projectlombok:lombok:${lombokVersion}" compileOnly "org.projectlombok:lombok:${lombokVersion}" - runtimeOnly "org.postgresql:postgresql:42.6.0" + runtimeOnly 'org.postgresql:postgresql:42.7.3' testCompileOnly "org.projectlombok:lombok:${lombokVersion}" testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" diff --git a/build.gradle b/build.gradle index f6e58753..1c1d265d 100644 --- a/build.gradle +++ b/build.gradle @@ -22,11 +22,11 @@ ext { : System.getenv()['ARTIFACTORY_PASSWORD'] // AB2D libraries - fhirVersion='1.2.7' - bfdVersion='2.2.3' + fhirVersion='1.2.8' + bfdVersion='2.2.4' aggregatorVersion='1.3.4' - filtersVersion='1.9.4' - eventClientVersion='1.12.8' + filtersVersion='1.9.5' + eventClientVersion='1.12.9' propertiesClientVersion='1.2.5' contractClientVersion='1.2.4' snsClientVersion='0.2.4' @@ -37,7 +37,7 @@ ext { commonsLangVersion='3.12.0' lombokVersion = '1.18.28' - hapiVersion = '6.6.2' + hapiVersion = '7.2.2' springBootVersion='2.7.6' springCloudAwsVersion='2.4.4' newRelicVersion='8.4.0' From b6153483c95cd0f4bda9ac987dd525b4cd352ad1 Mon Sep 17 00:00:00 2001 From: Rwolfe-Nava <87499456+Rwolfe-Nava@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:50:21 -0400 Subject: [PATCH 09/15] [AB2D-6269] Update Spring Web Version (#408) * fix checkstyle * update eventClientVersion to 1.12.10 * update springweb to 5.3.26 --- ab2d-events-client/build.gradle | 3 ++- ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java | 2 +- build.gradle | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ab2d-events-client/build.gradle b/ab2d-events-client/build.gradle index b69c1d92..8a0535f8 100644 --- a/ab2d-events-client/build.gradle +++ b/ab2d-events-client/build.gradle @@ -3,7 +3,8 @@ dependencies { implementation(platform(annotationProcessor("com.slack.api:slack-api-client:$slackAPIVersion"))) implementation "org.springframework.boot:spring-boot-starter:${springBootVersion}" implementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}" - implementation "org.springframework:spring-web:${springBootVersion}" + implementation "org.springframework:spring-web:${springWebVersion}" + implementation "org.springframework:spring-webmvc:${springWebVersion}" implementation "org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}" implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}" implementation "io.awspring.cloud:spring-cloud-starter-aws:${springCloudAwsVersion}" diff --git a/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java b/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java index 0731307e..8e1d5a18 100644 --- a/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java +++ b/ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java @@ -229,7 +229,7 @@ public static PatientIdentifier.Currency getCurrencyFromTypeCodingExtension(ICom if (checkCurrencyUrlIsNotValid(url)) { return PatientIdentifier.Currency.UNKNOWN; } - + Object currValue = Versions.invokeGetMethod(extension, GET_VALUE); String extValueSystem = (String) Versions.invokeGetMethod(currValue, GET_SYSTEM); if (CURRENCY_IDENTIFIER.equalsIgnoreCase(extValueSystem)) { diff --git a/build.gradle b/build.gradle index 1c1d265d..22195498 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ ext { bfdVersion='2.2.4' aggregatorVersion='1.3.4' filtersVersion='1.9.5' - eventClientVersion='1.12.9' + eventClientVersion='1.12.10' propertiesClientVersion='1.2.5' contractClientVersion='1.2.4' snsClientVersion='0.2.4' @@ -40,6 +40,7 @@ ext { hapiVersion = '7.2.2' springBootVersion='2.7.6' springCloudAwsVersion='2.4.4' + springWebVersion="5.3.26" newRelicVersion='8.4.0' testContainerVersion='1.18.3' mockServerVersion='5.15.0' From 2395d12611a194b68dd2d2dfeb553243406e51d4 Mon Sep 17 00:00:00 2001 From: Anna Smirnova <132938234+smirnovaae@users.noreply.github.com> Date: Tue, 27 Aug 2024 09:17:28 -0700 Subject: [PATCH 10/15] Ab2 d 6106/snyk2 (#409) * wip * AB2D-6106/address vulnerabilities * AB2D-6106/address vulnerabilities --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 22195498..a79caf4f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,10 +22,10 @@ ext { : System.getenv()['ARTIFACTORY_PASSWORD'] // AB2D libraries - fhirVersion='1.2.8' - bfdVersion='2.2.4' + fhirVersion='1.2.9' + bfdVersion='2.2.5' aggregatorVersion='1.3.4' - filtersVersion='1.9.5' + filtersVersion='1.9.6' eventClientVersion='1.12.10' propertiesClientVersion='1.2.5' contractClientVersion='1.2.4' @@ -37,7 +37,7 @@ ext { commonsLangVersion='3.12.0' lombokVersion = '1.18.28' - hapiVersion = '7.2.2' + hapiVersion = '6.8.0' springBootVersion='2.7.6' springCloudAwsVersion='2.4.4' springWebVersion="5.3.26" From ba30f0b24a2267d1489287e717c62079f30ae7f4 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Thu, 28 Sep 2023 12:48:19 -0700 Subject: [PATCH 11/15] wip --- .../gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java index 0240b14d..c994dbd8 100644 --- a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java +++ b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java @@ -55,6 +55,7 @@ private static void cleanOutUnNeededData(ExplanationOfBenefit benefit) { Inherited - Identifier, resourceType, type */ // Extensions should exist in benefit: AB2D-5728 Validate Humana AB2D data dictionary for missing elements reported in STU3 + benefit.setExtension(null); benefit.setPatientTarget(null); benefit.setCreated(null); benefit.setEnterer(null); From 2b2b73e97d8ecde55ddba0b289b4a89118b07eb4 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Thu, 11 Jul 2024 11:28:46 -0700 Subject: [PATCH 12/15] AB2D-6105/TIBQ --- .../gov/cms/ab2d/bfd/client/BFDClient.java | 2 +- .../cms/ab2d/bfd/client/BFDClientImpl.java | 14 +- .../gov/cms/ab2d/bfd/client/BFDSearch.java | 2 +- .../cms/ab2d/bfd/client/BFDSearchImpl.java | 15 +- .../ab2d/bfd/client/BFDSearchImplTest.java | 270 +++++++++--------- .../bfd/client/BlueButtonClientSTU3Test.java | 41 +-- .../ab2d/bfd/client/FhirBfdServerTest.java | 2 +- build.gradle | 6 +- 8 files changed, 178 insertions(+), 174 deletions(-) diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java index 6699f664..cf3c7af1 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClient.java @@ -11,7 +11,7 @@ public interface BFDClient { String BFD_HDR_BULK_JOBID = "BULK-JOBID"; IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, String contractNum); - IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, String contractNum); + IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, OffsetDateTime untilTime, String contractNum); IBaseBundle requestNextBundleFromServer(FhirVersion version, IBaseBundle bundle, String contractNum); /** diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java index 06642fef..9085b0e6 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDClientImpl.java @@ -79,8 +79,7 @@ public BFDClientImpl(BFDSearch bfdSearch, BfdClientVersions bfdClientVersions) { exclude = { ResourceNotFoundException.class } ) public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, String contractNum) { - return requestEOBFromServer(version, patientID, null, contractNum); - // return requestEOBFromServer(version, patientID, null, null, contractNum); + return requestEOBFromServer(version, patientID, null, null, contractNum); } /** @@ -92,6 +91,7 @@ public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, Str * @param version The FHIR version * @param patientID The requested patient's ID * @param sinceTime The start date for the request + * @param untilTime The stop date for the request * @return {@link IBaseBundle} Containing a number (possibly 0) of Resources * objects * @throws ResourceNotFoundException when the requested patient does not exist @@ -104,12 +104,12 @@ public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, Str backoff = @Backoff(delayExpression = "${bfd.retry.backoffDelay:250}", multiplier = 2), exclude = { ResourceNotFoundException.class } ) - public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, String contractNum) { - final Segment bfdSegment = NewRelic.getAgent().getTransaction().startSegment("BFD Call for patient with patient ID " + patientID + - " using since " + sinceTime); + public IBaseBundle requestEOBFromServer(FhirVersion version, long patientID, OffsetDateTime sinceTime, OffsetDateTime untilTime, String contractNum) { + final Segment bfdSegment = NewRelic.getAgent().getTransaction().startSegment("BFD Call for patient with patient ID " + patientID + + " using since " + sinceTime + " and until " + untilTime); bfdSegment.setMetricName("RequestEOB"); - IBaseBundle result = bfdSearch.searchEOB(patientID, sinceTime, pageSize, getJobId(), version, contractNum); + IBaseBundle result = bfdSearch.searchEOB(patientID, sinceTime, untilTime, pageSize, getJobId(), version, contractNum); bfdSegment.end(); @@ -226,4 +226,4 @@ private String createMonthParameter(int month) { final String zeroPaddedMonth = StringUtils.leftPad("" + month, 2, '0'); return PTDCNTRCT_URL_PREFIX + zeroPaddedMonth; } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java index 637bae19..d5dcfecd 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearch.java @@ -7,5 +7,5 @@ import java.time.OffsetDateTime; public interface BFDSearch { - IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException; + IBaseBundle searchEOB(long patientId, OffsetDateTime since, OffsetDateTime until, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException; } diff --git a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java index 2c12fdf6..13a4f780 100644 --- a/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java +++ b/ab2d-bfd/src/main/java/gov/cms/ab2d/bfd/client/BFDSearchImpl.java @@ -39,6 +39,7 @@ public BFDSearchImpl(HttpClient httpClient, Environment environment, BfdClientVe * * @param patientId internal beneficiary id * @param since the minimum lastUpdated date which may be null + * @param until the maximum lastUpdated date which may be null * @param pageSize maximum number of records that can be returned * @param bulkJobId header to uniquely identify what job this is coming from within BFD logs * @param version the version of FHIR that we need from BFD @@ -47,17 +48,17 @@ public BFDSearchImpl(HttpClient httpClient, Environment environment, BfdClientVe */ @Trace @Override - public IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException { + public IBaseBundle searchEOB(long patientId, OffsetDateTime since, OffsetDateTime until, int pageSize, String bulkJobId, FhirVersion version, String contractNum) throws IOException { + String urlLocation = bfdClientVersions.getUrl(version); StringBuilder url = new StringBuilder(urlLocation + "ExplanationOfBenefit?patient=" + patientId + "&excludeSAMHSA=true"); if (since != null) { url.append("&_lastUpdated=ge").append(since); + } - //AB2D-5892 (Sprint 3)Centene customer support to provide 2 year data - if (contractNum.equals("S4802") || contractNum.equals("Z1001")) { - url.append("&_lastUpdated=le").append(since.plusMonths(1)); - } + if (until != null) { + url.append("&_lastUpdated=le").append(until); } if (pageSize > 0) { @@ -81,7 +82,7 @@ public IBaseBundle searchEOB(long patientId, OffsetDateTime since, int pageSize, } /** - Method exists to track connection to BFD for New Relic + Method exists to track connection to BFD for New Relic */ @Trace private byte[] getEOBSFromBFD(long patientId, HttpGet request) throws IOException { @@ -107,4 +108,4 @@ private byte[] getEOBSFromBFD(long patientId, HttpGet request) throws IOExceptio private IBaseBundle parseBundle(FhirVersion version, byte[] responseBytes) { return version.getJsonParser().parseResource(version.getBundleClass(), new ByteArrayInputStream(responseBytes)); } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java index 855fd0c5..77f1561d 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java @@ -25,140 +25,140 @@ class BFDSearchImplTest { - private static int patientId = 1; - private static OffsetDateTime since = OffsetDateTime.now(); - private static OffsetDateTime until = OffsetDateTime.now(); - private static int pageSize = 10; - private static String bulkJobId = "bulkJobId"; - private static FhirVersion version = FhirVersion.R4; - private static String contractNum = "contractNum"; - private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; - private static String activeProfile = "test"; - private static String bfdUrl = "http://localhost:8080"; - - HttpClient httpClient100() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); - return httpClient; - } - - HttpClient httpClient200() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); - when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); - String fileContent = Files.readString(Paths.get(filePath)); - when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); - return httpClient; - } - - HttpClient httpClient404() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); - return httpClient; - } - - HttpClient httpClient500() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); - return httpClient; - } - - @Test - void testSearchEOB100() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient100(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB200() throws IOException{ - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB200WithFalsyArgs() throws IOException{ - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { "" }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, 0, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB404() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient404(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - ResourceNotFoundException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB500() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient500(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum) - ); - } + private static int patientId = 1; + private static OffsetDateTime since = OffsetDateTime.now(); + private static OffsetDateTime until = OffsetDateTime.now(); + private static int pageSize = 10; + private static String bulkJobId = "bulkJobId"; + private static FhirVersion version = FhirVersion.R4; + private static String contractNum = "contractNum"; + private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; + private static String activeProfile = "test"; + private static String bfdUrl = "http://localhost:8080"; + + HttpClient httpClient100() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); + return httpClient; + } + + HttpClient httpClient200() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); + String fileContent = Files.readString(Paths.get(filePath)); + when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); + return httpClient; + } + + HttpClient httpClient404() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); + return httpClient; + } + + HttpClient httpClient500() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + return httpClient; + } + + @Test + void testSearchEOB100() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient100(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB200() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB200WithFalsyArgs() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{""}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB404() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient404(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + ResourceNotFoundException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB500() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient500(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } } diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java index 4a48a50d..fc79b954 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java @@ -182,7 +182,7 @@ public static void tearDown() { } @Test - void shouldGetTimedOutOnSlowResponse() { + public void shouldGetTimedOutOnSlowResponse() { var exception = Assertions.assertThrows(SocketTimeoutException.class, () -> bbc.requestEOBFromServer(STU3, TEST_SLOW_PATIENT_ID, CONTRACT)); var rootCause = ExceptionUtils.getRootCause(exception); @@ -192,30 +192,33 @@ void shouldGetTimedOutOnSlowResponse() { } @Test - void shouldGetEOBFromPatientID() { + public void shouldGetEOBFromPatientID() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDSince() { - org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, CONTRACT); + public void shouldGetEOBFromPatientIDSince() { + org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( + "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), null, CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDUtil() { - org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, CONTRACT); + public void shouldGetEOBFromPatientIDUtil() { + org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, OffsetDateTime.parse( + "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); validation(response); } @Test - void shouldGetEOBFromPatientIDSinceAndUtil() { + public void shouldGetEOBFromPatientIDSinceAndUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( - "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); + "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), OffsetDateTime.parse( + "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); validation(response); } @@ -226,19 +229,19 @@ private static void validation(Bundle response) { } @Test - void shouldGetEOBPatientNoRecords() { + public void shouldGetEOBPatientNoRecords() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID, CONTRACT); assertFalse(response.hasEntry()); } @Test - void shouldGetEOBPatientNoRecordsMBI() { + public void shouldGetEOBPatientNoRecordsMBI() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID_MBI, CONTRACT); assertFalse(response.hasEntry()); } @Test - void shouldNotHaveNextBundle() { + public void shouldNotHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -248,7 +251,7 @@ void shouldNotHaveNextBundle() { } @Test - void shouldHaveNextBundle() { + public void shouldHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -267,10 +270,10 @@ void shouldHaveNextBundle() { } @Test - void shouldReturnBundleContainingOnlyEOBs() { + public void shouldReturnBundleContainingOnlyEOBs() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); - response.getEntry().forEach(entry -> assertEquals( + response.getEntry().forEach((entry) -> assertEquals( org.hl7.fhir.dstu3.model.ResourceType.ExplanationOfBenefit, entry.getResource().getResourceType(), "EOB bundles returned by the BlueButton client should only contain EOB objects" @@ -278,13 +281,13 @@ void shouldReturnBundleContainingOnlyEOBs() { } @Test - void shouldHandlePatientsWithOnlyOneEOB() { + public void shouldHandlePatientsWithOnlyOneEOB() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertEquals(1, response.getTotal(), "This demo patient should have exactly 1 EOB"); } @Test - void shouldThrowExceptionWhenResourceNotFound() { + public void shouldThrowExceptionWhenResourceNotFound() { assertThrows( ResourceNotFoundException.class, () -> bbc.requestEOBFromServer(STU3, TEST_NONEXISTENT_PATIENT_ID, CONTRACT), @@ -294,7 +297,7 @@ void shouldThrowExceptionWhenResourceNotFound() { } @Test - void shouldGetPatientBundleFromPartDEnrolleeRequest() { + public void shouldGetPatientBundleFromPartDEnrolleeRequest() { for (int i = 1; i <= 12; i++) { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestPartDEnrolleesFromServer(STU3, CONTRACT, i); @@ -304,11 +307,11 @@ void shouldGetPatientBundleFromPartDEnrolleeRequest() { } @Test - void shouldGetMetadata() { + public void shouldGetMetadata() { org.hl7.fhir.dstu3.model.CapabilityStatement capabilityStatement = (org.hl7.fhir.dstu3.model.CapabilityStatement) bbc.capabilityStatement(STU3); assertNotNull(capabilityStatement, "There should be a non null capability statement"); assertEquals("3.0.1", capabilityStatement.getFhirVersion()); assertEquals(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE, capabilityStatement.getStatus()); } -} +} \ No newline at end of file diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java index 37ecea21..b17bcd70 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/FhirBfdServerTest.java @@ -11,7 +11,7 @@ class FhirBfdServerTest { @Test void testGetVersion() { - assertEquals(FhirVersion.R4, new FhirBfdServer(FhirVersion.R4).getVersion());; + assertEquals(FhirVersion.R4, new FhirBfdServer(FhirVersion.R4).getVersion()); } @Test diff --git a/build.gradle b/build.gradle index a79caf4f..9fdbe9e9 100644 --- a/build.gradle +++ b/build.gradle @@ -22,8 +22,8 @@ ext { : System.getenv()['ARTIFACTORY_PASSWORD'] // AB2D libraries - fhirVersion='1.2.9' - bfdVersion='2.2.5' + fhirVersion='1.2.10' + bfdVersion='2.3.0' aggregatorVersion='1.3.4' filtersVersion='1.9.6' eventClientVersion='1.12.10' @@ -37,7 +37,7 @@ ext { commonsLangVersion='3.12.0' lombokVersion = '1.18.28' - hapiVersion = '6.8.0' + hapiVersion = '6.6.2' springBootVersion='2.7.6' springCloudAwsVersion='2.4.4' springWebVersion="5.3.26" From 505d2edbabb4037b21eb5ac6d9a4bdf7354d957c Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Tue, 16 Jul 2024 13:58:19 -0700 Subject: [PATCH 13/15] revert --- .../bfd/client/BlueButtonClientSTU3Test.java | 32 +++++++++---------- .../ExplanationOfBenefitTrimmerSTU3.java | 1 - 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java index fc79b954..832ce59f 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BlueButtonClientSTU3Test.java @@ -182,7 +182,7 @@ public static void tearDown() { } @Test - public void shouldGetTimedOutOnSlowResponse() { + void shouldGetTimedOutOnSlowResponse() { var exception = Assertions.assertThrows(SocketTimeoutException.class, () -> bbc.requestEOBFromServer(STU3, TEST_SLOW_PATIENT_ID, CONTRACT)); var rootCause = ExceptionUtils.getRootCause(exception); @@ -192,14 +192,14 @@ public void shouldGetTimedOutOnSlowResponse() { } @Test - public void shouldGetEOBFromPatientID() { + void shouldGetEOBFromPatientID() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); validation(response); } @Test - public void shouldGetEOBFromPatientIDSince() { + void shouldGetEOBFromPatientIDSince() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), null, CONTRACT); @@ -207,7 +207,7 @@ public void shouldGetEOBFromPatientIDSince() { } @Test - public void shouldGetEOBFromPatientIDUtil() { + void shouldGetEOBFromPatientIDUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, OffsetDateTime.parse( "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); @@ -215,7 +215,7 @@ public void shouldGetEOBFromPatientIDUtil() { } @Test - public void shouldGetEOBFromPatientIDSinceAndUtil() { + void shouldGetEOBFromPatientIDSinceAndUtil() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, OffsetDateTime.parse( "2020-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), OffsetDateTime.parse( "2024-02-13T00:00:00.000-05:00", DateTimeFormatter.ISO_DATE_TIME), CONTRACT); @@ -229,19 +229,19 @@ private static void validation(Bundle response) { } @Test - public void shouldGetEOBPatientNoRecords() { + void shouldGetEOBPatientNoRecords() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID, CONTRACT); assertFalse(response.hasEntry()); } @Test - public void shouldGetEOBPatientNoRecordsMBI() { + void shouldGetEOBPatientNoRecordsMBI() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_NO_RECORD_PATIENT_ID_MBI, CONTRACT); assertFalse(response.hasEntry()); } @Test - public void shouldNotHaveNextBundle() { + void shouldNotHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -251,7 +251,7 @@ public void shouldNotHaveNextBundle() { } @Test - public void shouldHaveNextBundle() { + void shouldHaveNextBundle() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); assertNotNull(response, "The demo patient should have a non-null EOB bundle"); @@ -270,10 +270,10 @@ public void shouldHaveNextBundle() { } @Test - public void shouldReturnBundleContainingOnlyEOBs() { + void shouldReturnBundleContainingOnlyEOBs() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, CONTRACT); - response.getEntry().forEach((entry) -> assertEquals( + response.getEntry().forEach(entry -> assertEquals( org.hl7.fhir.dstu3.model.ResourceType.ExplanationOfBenefit, entry.getResource().getResourceType(), "EOB bundles returned by the BlueButton client should only contain EOB objects" @@ -281,13 +281,13 @@ public void shouldReturnBundleContainingOnlyEOBs() { } @Test - public void shouldHandlePatientsWithOnlyOneEOB() { + void shouldHandlePatientsWithOnlyOneEOB() { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_SINGLE_EOB_PATIENT_ID, CONTRACT); assertEquals(1, response.getTotal(), "This demo patient should have exactly 1 EOB"); } @Test - public void shouldThrowExceptionWhenResourceNotFound() { + void shouldThrowExceptionWhenResourceNotFound() { assertThrows( ResourceNotFoundException.class, () -> bbc.requestEOBFromServer(STU3, TEST_NONEXISTENT_PATIENT_ID, CONTRACT), @@ -297,7 +297,7 @@ public void shouldThrowExceptionWhenResourceNotFound() { } @Test - public void shouldGetPatientBundleFromPartDEnrolleeRequest() { + void shouldGetPatientBundleFromPartDEnrolleeRequest() { for (int i = 1; i <= 12; i++) { org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestPartDEnrolleesFromServer(STU3, CONTRACT, i); @@ -307,11 +307,11 @@ public void shouldGetPatientBundleFromPartDEnrolleeRequest() { } @Test - public void shouldGetMetadata() { + void shouldGetMetadata() { org.hl7.fhir.dstu3.model.CapabilityStatement capabilityStatement = (org.hl7.fhir.dstu3.model.CapabilityStatement) bbc.capabilityStatement(STU3); assertNotNull(capabilityStatement, "There should be a non null capability statement"); assertEquals("3.0.1", capabilityStatement.getFhirVersion()); assertEquals(org.hl7.fhir.dstu3.model.Enumerations.PublicationStatus.ACTIVE, capabilityStatement.getStatus()); } -} \ No newline at end of file +} diff --git a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java index c994dbd8..0240b14d 100644 --- a/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java +++ b/ab2d-filters/src/main/java/gov/cms/ab2d/filter/ExplanationOfBenefitTrimmerSTU3.java @@ -55,7 +55,6 @@ private static void cleanOutUnNeededData(ExplanationOfBenefit benefit) { Inherited - Identifier, resourceType, type */ // Extensions should exist in benefit: AB2D-5728 Validate Humana AB2D data dictionary for missing elements reported in STU3 - benefit.setExtension(null); benefit.setPatientTarget(null); benefit.setCreated(null); benefit.setEnterer(null); From ae0936b1bfa949ad4b32c40123ae1f4155242004 Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Wed, 17 Jul 2024 11:28:20 -0700 Subject: [PATCH 14/15] revert auto formatting --- .../ab2d/bfd/client/BFDSearchImplTest.java | 270 +++++++++--------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java index 77f1561d..8596b593 100644 --- a/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java +++ b/ab2d-bfd/src/test/java/gov/cms/ab2d/bfd/client/BFDSearchImplTest.java @@ -25,140 +25,140 @@ class BFDSearchImplTest { - private static int patientId = 1; - private static OffsetDateTime since = OffsetDateTime.now(); - private static OffsetDateTime until = OffsetDateTime.now(); - private static int pageSize = 10; - private static String bulkJobId = "bulkJobId"; - private static FhirVersion version = FhirVersion.R4; - private static String contractNum = "contractNum"; - private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; - private static String activeProfile = "test"; - private static String bfdUrl = "http://localhost:8080"; - - HttpClient httpClient100() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); - return httpClient; - } - - HttpClient httpClient200() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); - when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); - String fileContent = Files.readString(Paths.get(filePath)); - when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); - return httpClient; - } - - HttpClient httpClient404() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); - return httpClient; - } - - HttpClient httpClient500() throws IOException { - HttpClient httpClient = mock(HttpClient.class); - CloseableHttpResponse response = mock(CloseableHttpResponse.class); - when(httpClient.execute(any())).thenReturn(response); - when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); - when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); - return httpClient; - } - - @Test - void testSearchEOB100() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient100(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB200() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB200WithFalsyArgs() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient200(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{""}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); - assertNotNull(result); - } - - @Test - void testSearchEOB404() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient404(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - ResourceNotFoundException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } - - @Test - void testSearchEOB500() throws IOException { - // Setup mocks - HttpClient httpClient = httpClient500(); - Environment environment = mock(Environment.class); - when(environment.getActiveProfiles()).thenReturn(new String[]{activeProfile}); - - // Setup classes - BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); - BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); - - // Business logic & assertion(s) - assertThrows( - RuntimeException.class, - () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) - ); - } + private static int patientId = 1; + private static OffsetDateTime since = OffsetDateTime.now(); + private static OffsetDateTime until = OffsetDateTime.now(); + private static int pageSize = 10; + private static String bulkJobId = "bulkJobId"; + private static FhirVersion version = FhirVersion.R4; + private static String contractNum = "contractNum"; + private static String filePath = "src/test/resources/bb-test-data/eob/20010000001115.json"; + private static String activeProfile = "test"; + private static String bfdUrl = "http://localhost:8080"; + + HttpClient httpClient100() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_CONTINUE); + return httpClient; + } + + HttpClient httpClient200() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(response.getEntity()).thenReturn(mock(org.apache.http.HttpEntity.class)); + String fileContent = Files.readString(Paths.get(filePath)); + when(response.getEntity().getContent()).thenReturn(new ByteArrayInputStream(fileContent.getBytes())); + return httpClient; + } + + HttpClient httpClient404() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_NOT_FOUND); + return httpClient; + } + + HttpClient httpClient500() throws IOException { + HttpClient httpClient = mock(HttpClient.class); + CloseableHttpResponse response = mock(CloseableHttpResponse.class); + when(httpClient.execute(any())).thenReturn(response); + when(response.getStatusLine()).thenReturn(mock(org.apache.http.StatusLine.class)); + when(response.getStatusLine().getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + return httpClient; + } + + @Test + void testSearchEOB100() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient100(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB200() throws IOException{ + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB200WithFalsyArgs() throws IOException{ + // Setup mocks + HttpClient httpClient = httpClient200(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { "" }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum); + assertNotNull(result); + } + + @Test + void testSearchEOB404() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient404(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + ResourceNotFoundException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } + + @Test + void testSearchEOB500() throws IOException { + // Setup mocks + HttpClient httpClient = httpClient500(); + Environment environment = mock(Environment.class); + when(environment.getActiveProfiles()).thenReturn(new String[] { activeProfile }); + + // Setup classes + BfdClientVersions bfdClientVersions = new BfdClientVersions(bfdUrl, httpClient); + BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions); + + // Business logic & assertion(s) + assertThrows( + RuntimeException.class, + () -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum) + ); + } } From 2537e99ae2164733166c51a69b0677e3d563178b Mon Sep 17 00:00:00 2001 From: smirnovaae Date: Tue, 27 Aug 2024 13:58:07 -0700 Subject: [PATCH 15/15] AB2D-6291 Libs,AB2D versions and review changes --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9fdbe9e9..a6b95fe9 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ ext { fhirVersion='1.2.10' bfdVersion='2.3.0' aggregatorVersion='1.3.4' - filtersVersion='1.9.6' + filtersVersion='1.9.7' eventClientVersion='1.12.10' propertiesClientVersion='1.2.5' contractClientVersion='1.2.4'