typedbundleprovider getallresources override (#4552)

* typedbundleprovider getallresources override

* added test to immunization tests that validates pagination does not result in null pointer if over default queryCount

* moved HapiFhirDal test to its own test class

* removed unused imports

* Update to use JpaStorageSettings

* adding changelog for issue 4551

* fix changelog spacing

* changelog type  to fix

---------

Co-authored-by: justin.mckelvy <justin.mckelvy@smilecdr.com>
Co-authored-by: Jonathan Percival <jonathan.i.percival@gmail.com>
This commit is contained in:
Justin McKelvy 2023-02-16 13:59:40 -07:00 committed by Tadgh
parent 6b6f1e2e66
commit 8698abfbdb
4 changed files with 53 additions and 4 deletions

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 4551
title: "The HapifhirDal search method required use of TypedBundleProvider.getallresources to avoid null pointer issue on searches that are greater than the default querycount"

View File

@ -70,13 +70,17 @@ public class HapiFhirDal implements FhirDal {
// TODO: the search interfaces need some work
@Override
public Iterable<IBaseResource> search(String theResourceType) {
return this.myDaoRegistry.getResourceDao(theResourceType).search(SearchParameterMap.newSynchronous(), myRequestDetails)
.getAllResources();
var b = this.myDaoRegistry.getResourceDao(theResourceType)
.search(SearchParameterMap.newSynchronous(), myRequestDetails);
return TypedBundleProvider.fromBundleProvider(b).getAllResources();
}
@Override
public Iterable<IBaseResource> searchByUrl(String theResourceType, String theUrl) {
return this.myDaoRegistry.getResourceDao(theResourceType)
.search(SearchParameterMap.newSynchronous().add("url", new UriParam(theUrl)), myRequestDetails).getAllResources();
var c = this.myDaoRegistry.getResourceDao(theResourceType)
.search(SearchParameterMap.newSynchronous().add("url", new UriParam(theUrl)), myRequestDetails);
return TypedBundleProvider.fromBundleProvider(c).getAllResources();
}
}

View File

@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
*/
@ExtendWith(SpringExtension.class)
public class CqlMeasureEvaluationR4ImmunizationTest extends BaseCrR4Test {
private static final String MY_FHIR_COMMON = "ca/uhn/fhir/cr/r4/immunization/Fhir_Common.json";
private static final String MY_FHIR_HELPERS = "ca/uhn/fhir/cr/r4/immunization/Fhir_Helper.json";
private static final String MY_TEST_DATA = "ca/uhn/fhir/cr/r4/immunization/Patients_Encounters_Immunizations_Practitioners.json";
@ -27,6 +28,7 @@ public class CqlMeasureEvaluationR4ImmunizationTest extends BaseCrR4Test {
@Autowired
MeasureOperationsProvider myMeasureOperationsProvider;
//compare 2 double values to assert no difference between expected and actual measure score
protected void assertMeasureScore(MeasureReport theReport, double theExpectedScore) {
//find the predefined expected score by looking up the report identifier

View File

@ -0,0 +1,39 @@
package ca.uhn.fhir.cr.r4;
import ca.uhn.fhir.cr.BaseCrR4Test;
import ca.uhn.fhir.cr.common.HapiFhirDal;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* This class tests the functionality of HapiFhirDal operations inside the cr module
*/
@ExtendWith(SpringExtension.class)
public class HapiFhirDalR4Test extends BaseCrR4Test {
private static final String MY_TEST_DATA = "ca/uhn/fhir/cr/r4/immunization/Patients_Encounters_Immunizations_Practitioners.json";
@Autowired
JpaStorageSettings myJpaStorageSettings;
@Test
void canSearchMoreThan50Patients(){
loadBundle(MY_TEST_DATA); // load 63 patients
myJpaStorageSettings.setFetchSizeDefaultMaximum(100);
HapiFhirDal hapiFhirDal = new HapiFhirDal(this.getDaoRegistry(), null);
// get all patient resources posted
var result = hapiFhirDal.search("Patient");
// count all resources in result
int counter = 0;
for (Object i: result) {
counter++;
}
//verify all patient resources captured
assertEquals(63, counter, "Patient search results don't match available resources");
}
}