Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ab2d-6105/tibq #404

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
edc9147
wip
smirnovaae Sep 28, 2023
9f1fb11
Merge remote-tracking branch 'origin/main'
smirnovaae May 15, 2024
b80593e
Merge remote-tracking branch 'origin/main'
smirnovaae May 30, 2024
f1c1cee
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 7, 2024
b59eba6
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 10, 2024
d26e6e4
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 11, 2024
54d91ec
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 11, 2024
92815da
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 17, 2024
1784629
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 21, 2024
0886bb3
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 24, 2024
bb2f752
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 25, 2024
16db122
Merge remote-tracking branch 'origin/main'
smirnovaae Jun 28, 2024
eb195f5
Merge remote-tracking branch 'origin/main'
smirnovaae Jul 5, 2024
91322fd
Merge remote-tracking branch 'origin/main'
smirnovaae Jul 11, 2024
38e2c31
AB2D-6105/TIBQ
smirnovaae Jul 11, 2024
4be4dac
AB2D-6105/TIBQ
smirnovaae Jul 11, 2024
9ccc12c
revert
smirnovaae Jul 16, 2024
e6a9b5f
revert auto formatting
smirnovaae Jul 17, 2024
c5f7cfd
[AB2D-6101] Address Critical Code Smell - Reduce cognitive method com…
Rwolfe-Nava Jul 22, 2024
ddfeaae
Ab2 d 6247/remove 2 month humana (#405)
smirnovaae Jul 30, 2024
ac96e4a
Ab2d-6270/snyk (#406)
smirnovaae Aug 22, 2024
b615348
[AB2D-6269] Update Spring Web Version (#408)
Rwolfe-Nava Aug 26, 2024
2395d12
Ab2 d 6106/snyk2 (#409)
smirnovaae Aug 27, 2024
ba30f0b
wip
smirnovaae Sep 28, 2023
2b2b73e
AB2D-6105/TIBQ
smirnovaae Jul 11, 2024
505d2ed
revert
smirnovaae Jul 16, 2024
ae0936b
revert auto formatting
smirnovaae Jul 17, 2024
2537e99
AB2D-6291 Libs,AB2D versions and review changes
smirnovaae Aug 27, 2024
4bd171f
Merge remote-tracking branch 'origin/AB2D-6105/TIBQ' into AB2D-6105/TIBQ
smirnovaae Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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
Expand All @@ -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();

Expand Down Expand Up @@ -226,4 +226,4 @@ private String createMonthParameter(int month) {
final String zeroPaddedMonth = StringUtils.leftPad("" + month, 2, '0');
return PTDCNTRCT_URL_PREFIX + zeroPaddedMonth;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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 {
Expand All @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void testSearchEOB100() throws IOException {
// Business logic & assertion(s)
assertThrows(
RuntimeException.class,
() -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum)
() -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum)
);
}

Expand All @@ -105,7 +105,7 @@ void testSearchEOB200() throws IOException{
BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions);

// Business logic & assertion(s)
IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum);
IBaseBundle result = bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum);
assertNotNull(result);
}

Expand All @@ -121,7 +121,7 @@ void testSearchEOB200WithFalsyArgs() throws IOException{
BFDSearchImpl bfdSearchImpl = new BFDSearchImpl(httpClient, environment, bfdClientVersions);

// Business logic & assertion(s)
IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, 0, bulkJobId, version, contractNum);
IBaseBundle result = bfdSearchImpl.searchEOB(patientId, null, null, 0, bulkJobId, version, contractNum);
assertNotNull(result);
}

Expand All @@ -139,7 +139,7 @@ void testSearchEOB404() throws IOException {
// Business logic & assertion(s)
assertThrows(
ResourceNotFoundException.class,
() -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum)
() -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum)
);
}

Expand All @@ -157,7 +157,7 @@ void testSearchEOB500() throws IOException {
// Business logic & assertion(s)
assertThrows(
RuntimeException.class,
() -> bfdSearchImpl.searchEOB(patientId, since, pageSize, bulkJobId, version, contractNum)
() -> bfdSearchImpl.searchEOB(patientId, since, until, pageSize, bulkJobId, version, contractNum)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,25 @@ void shouldGetEOBFromPatientID() {

@Test
void shouldGetEOBFromPatientIDSince() {
org.hl7.fhir.dstu3.model.Bundle response = (org.hl7.fhir.dstu3.model.Bundle) bbc.requestEOBFromServer(STU3, TEST_PATIENT_ID, null, CONTRACT);
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);
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() {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions ab2d-events-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -14,7 +15,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}"
Expand Down
67 changes: 43 additions & 24 deletions ab2d-fhir/src/main/java/gov/cms/ab2d/fhir/IdentifierUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Coding> 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<IBaseExtension> 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<Coding> 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<IBaseExtension> 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
*
Expand Down
Loading
Loading