Search in sources :

Example 1 with Grouping

use of au.csiro.pathling.aggregate.AggregateResponse.Grouping in project pathling by aehrc.

the class AggregateExecutorTest method runFirstGroupingThroughSearch.

/**
 * Test that the drill-down expression from the first grouping from each aggregate result can be
 * successfully executed using the FHIRPath search.
 */
@AfterEach
void runFirstGroupingThroughSearch() {
    if (response != null) {
        final Optional<Grouping> firstGroupingOptional = response.getGroupings().stream().filter(grouping -> grouping.getDrillDown().isPresent()).findFirst();
        if (firstGroupingOptional.isPresent()) {
            final Grouping firstGrouping = firstGroupingOptional.get();
            assertTrue(firstGrouping.getDrillDown().isPresent());
            final String drillDown = firstGrouping.getDrillDown().get();
            final StringAndListParam filters = new StringAndListParam();
            filters.addAnd(new StringParam(drillDown));
            final IBundleProvider searchExecutor = new SearchExecutor(configuration, fhirContext, spark, database, Optional.of(terminologyServiceFactory), fhirEncoders, subjectResource, Optional.of(filters));
            final List<IBaseResource> resources = searchExecutor.getResources(0, 100);
            assertTrue(resources.size() > 0);
        }
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TestHelpers(au.csiro.pathling.test.helpers.TestHelpers) Autowired(org.springframework.beans.factory.annotation.Autowired) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) FhirContext(ca.uhn.fhir.context.FhirContext) Grouping(au.csiro.pathling.aggregate.AggregateResponse.Grouping) FhirEncoders(au.csiro.pathling.encoders.FhirEncoders) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TerminologyServiceFactory(au.csiro.pathling.fhir.TerminologyServiceFactory) Assertions.assertJson(au.csiro.pathling.test.assertions.Assertions.assertJson) Tag(org.junit.jupiter.api.Tag) Nonnull(javax.annotation.Nonnull) TerminologyService(au.csiro.pathling.terminology.TerminologyService) IParser(ca.uhn.fhir.parser.IParser) SparkSession(org.apache.spark.sql.SparkSession) Configuration(au.csiro.pathling.Configuration) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Database(au.csiro.pathling.io.Database) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SharedMocks(au.csiro.pathling.test.SharedMocks) StringParam(ca.uhn.fhir.rest.param.StringParam) SearchExecutor(au.csiro.pathling.search.SearchExecutor) Optional(java.util.Optional) Parameters(org.hl7.fhir.r4.model.Parameters) Mockito.mock(org.mockito.Mockito.mock) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Grouping(au.csiro.pathling.aggregate.AggregateResponse.Grouping) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) SearchExecutor(au.csiro.pathling.search.SearchExecutor) AfterEach(org.junit.jupiter.api.AfterEach)

Aggregations

Configuration (au.csiro.pathling.Configuration)1 Grouping (au.csiro.pathling.aggregate.AggregateResponse.Grouping)1 FhirEncoders (au.csiro.pathling.encoders.FhirEncoders)1 TerminologyServiceFactory (au.csiro.pathling.fhir.TerminologyServiceFactory)1 Database (au.csiro.pathling.io.Database)1 SearchExecutor (au.csiro.pathling.search.SearchExecutor)1 TerminologyService (au.csiro.pathling.terminology.TerminologyService)1 SharedMocks (au.csiro.pathling.test.SharedMocks)1 Assertions.assertJson (au.csiro.pathling.test.assertions.Assertions.assertJson)1 TestHelpers (au.csiro.pathling.test.helpers.TestHelpers)1 FhirContext (ca.uhn.fhir.context.FhirContext)1 IParser (ca.uhn.fhir.parser.IParser)1 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)1 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)1 StringParam (ca.uhn.fhir.rest.param.StringParam)1 List (java.util.List)1 Optional (java.util.Optional)1 Nonnull (javax.annotation.Nonnull)1 SparkSession (org.apache.spark.sql.SparkSession)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1