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

Me/dpc 4501 remove get total #2436

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really necessary, but I was getting a warning that this was deprecated while rebuilding so I got rid of it.

services:
base:
image: dpc-base:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ private Optional<Patient> fetchPatient(JobQueueBatch job, String mbi) {
}

// If we get more than one unique Patient for an MBI then we've got some upstream problems.
if (patients.getTotal() == 1) {
if (patients.getEntry().size() == 1) {
return Optional.of((Patient) patients.getEntryFirstRep().getResource());
}

logger.error("Expected 1 Patient to match MBI but found {}", patients.getTotal());
logger.error("Expected 1 Patient to match MBI but found {}", patients.getEntry().size());
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public Optional<OrganizationPrincipal> authenticate(DPCAuthCredentials credentia
searchParams.put("organization", Collections.singletonList(credentials.getOrganization().getId()));

// Special handling of Group resources, which use tags instead of resource properties.
// TODO: Remove with DPC-552
if (credentials.getPathAuthorizer().type() == DPCResourceType.Group) {
searchParams.put("_tag", Collections.singletonList(String.format("%s|%s", DPCIdentifierSystem.DPC.getSystem(), credentials.getOrganization().getId())));
}
Expand All @@ -65,7 +64,7 @@ public Optional<OrganizationPrincipal> authenticate(DPCAuthCredentials credentia
.encodedJson()
.execute();

if (bundle.getTotal() == 0) {
if (bundle.getEntry().isEmpty()) {
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void test_authenticate_resource_authorized() {
when(searchQuery.whereMap(searchParams)).thenReturn(whereMapQuery);

IQuery<Bundle> bundleQuery = mock(IQuery.class);
Bundle bundle = mock(Bundle.class);
when(bundle.getTotal()).thenReturn(1);
Bundle bundle = mock(Bundle.class, RETURNS_DEEP_STUBS);
when(bundle.getEntry().size()).thenReturn(1);
when(whereMapQuery.returnBundle(Bundle.class).encodedJson()).thenReturn(bundleQuery);
when(bundleQuery.execute()).thenReturn(bundle);

Expand Down Expand Up @@ -132,8 +132,8 @@ void test_authenticate_resource_group() {
when(searchQuery.whereMap(searchParams)).thenReturn(whereMapQuery);

IQuery<Bundle> bundleQuery = mock(IQuery.class);
Bundle bundle = mock(Bundle.class);
when(bundle.getTotal()).thenReturn(1);
Bundle bundle = mock(Bundle.class, RETURNS_DEEP_STUBS);
when(bundle.getEntry().size()).thenReturn(1);
when(whereMapQuery.returnBundle(Bundle.class).encodedJson()).thenReturn(bundleQuery);
when(bundleQuery.execute()).thenReturn(bundle);

Expand Down
3 changes: 1 addition & 2 deletions dpc-attribution/patient_bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"resource": {
"resourceType": "Bundle",
"type": "searchset",
"total": 100,
"link": [
{
"relation": "search",
Expand Down Expand Up @@ -42454,4 +42453,4 @@
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ void shouldGetEOBFromPatientID() {
Bundle response = bbc.requestEOBFromServer(TEST_PATIENT_ID, TEST_LAST_UPDATED, null);

assertNotNull(response, "The demo patient should have a non-null EOB bundle");
assertEquals(32, response.getTotal(), "The demo patient should have exactly 32 EOBs");
assertEquals(10, response.getEntry().size(), "The demo patient's first bundle should have exactly 10 EOBs");
}

@Test
void shouldNotHaveNextBundle() {
Bundle response = bbc.requestEOBFromServer(TEST_SINGLE_EOB_PATIENT_ID, TEST_LAST_UPDATED, null);

assertNotNull(response, "The demo patient should have a non-null EOB bundle");
assertEquals(1, response.getTotal(), "The demo patient should have exactly 1 EOBs");
assertEquals(1, response.getEntry().size(), "The demo patient should have exactly 1 EOBs");
assertNull(response.getLink(Bundle.LINK_NEXT), "Should have no next link since all the resources are in the bundle");
}

Expand Down Expand Up @@ -230,7 +230,7 @@ void shouldGetCoverageFromPatientID() {
final Bundle response = bbc.requestCoverageFromServer(TEST_PATIENT_ID, TEST_LAST_UPDATED, null);

assertNotNull(response, "The demo patient should have a non-null Coverage bundle");
assertEquals(3, response.getTotal(), "The demo patient should have exactly 3 Coverage");
assertEquals(3, response.getEntry().size(), "The demo patient should have exactly 3 Coverage");
}

@Test
Expand All @@ -245,7 +245,7 @@ void shouldReturnCapabilitiesStatement() {
@Test
void shouldHandlePatientsWithOnlyOneEOB() {
final Bundle response = bbc.requestEOBFromServer(TEST_SINGLE_EOB_PATIENT_ID, TEST_LAST_UPDATED, null);
assertEquals(1, response.getTotal(), "This demo patient should have exactly 1 EOB");
assertEquals(1, response.getEntry().size(), "This demo patient should have exactly 1 EOB");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MockBlueButtonClientUnitTest {
@Test
void testRequestPatientFromServerByMbi() {
Bundle resultBundle = client.requestPatientFromServerByMbi(mbi, Map.of());
assertEquals(1, resultBundle.getTotal());
assertEquals(1, resultBundle.getEntry().size());

Patient pat = (Patient) resultBundle.getEntryFirstRep().getResource();
assertEquals(pat.getIdPart(), id);
Expand All @@ -37,7 +37,7 @@ void testRequestPatientFromServer() {
.setLowerBound("2000-12-31")
.setUpperBound("2100-01-01");
Bundle resultBundle = client.requestPatientFromServer(id, dateRangeParam, Map.of());
assertEquals(1, resultBundle.getTotal());
assertEquals(1, resultBundle.getEntry().size());

Patient pat = (Patient) resultBundle.getEntryFirstRep().getResource();
assertEquals(pat.getIdPart(), id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Organization createOrganization(FhirContext ctx, IGenericClient cl
.encodedJson()
.execute();

if (searchBundle.getTotal() > 0) {
if (searchBundle.isEmpty()) {
return (Organization) searchBundle.getEntryFirstRep().getResource();
}
}
Expand Down
3 changes: 1 addition & 2 deletions dpc-web/public/practitioner_bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@
}
],
"resourceType": "Bundle",
"total": 4,
"type": "searchset"
}
}
]
}
}
Loading
Loading