Search in sources :

Example 71 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class MembershipOperatorTest method worksForCodingLiterals.

@ParameterizedTest
@MethodSource("parameters")
void worksForCodingLiterals(final String operator) {
    final Coding snomedCoding = new Coding(SNOMED_URL, "56459004", null);
    final Coding loincCoding1 = new Coding(LOINC_URL, "56459004", null);
    loincCoding1.setId("fake-id-1");
    final Coding loincCoding2 = new Coding(LOINC_URL, "56459004", null);
    loincCoding2.setId("fake-id-2");
    final Coding loincCodingWithVersion = new Coding(LOINC_URL, "56459004", null);
    loincCodingWithVersion.setVersion("version1");
    final Dataset<Row> codingDataset = new DatasetBuilder(spark).withIdColumn().withStructTypeColumns(codingStructType()).withRow(StringPrimitiveRowFixture.ROW_ID_1, rowFromCoding(snomedCoding)).withRow(StringPrimitiveRowFixture.ROW_ID_1, rowFromCoding(loincCoding1)).withRow(StringPrimitiveRowFixture.ROW_ID_2, rowFromCoding(snomedCoding)).withRow(StringPrimitiveRowFixture.ROW_ID_2, rowFromCoding(loincCoding2)).withRow(StringPrimitiveRowFixture.ROW_ID_3, rowFromCoding(snomedCoding)).withRow(StringPrimitiveRowFixture.ROW_ID_3, rowFromCoding(loincCodingWithVersion)).withRow(StringPrimitiveRowFixture.ROW_ID_4, null).withRow(StringPrimitiveRowFixture.ROW_ID_4, null).buildWithStructValue();
    final ElementPath collection = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(codingDataset).idAndValueColumns().build();
    final CodingLiteralPath element = CodingLiteralPath.fromString("http://loinc.org|56459004", collection);
    parserContext = new ParserContextBuilder(spark, fhirContext).groupingColumns(Collections.singletonList(collection.getIdColumn())).build();
    final FhirPath result = testOperator(operator, collection, element);
    assertThat(result).selectOrderedResult().hasRows(RowFactory.create(StringPrimitiveRowFixture.ROW_ID_1, true), RowFactory.create(StringPrimitiveRowFixture.ROW_ID_2, true), RowFactory.create(StringPrimitiveRowFixture.ROW_ID_3, false), RowFactory.create(StringPrimitiveRowFixture.ROW_ID_4, false));
}
Also used : ElementPath(au.csiro.pathling.fhirpath.element.ElementPath) CodingLiteralPath(au.csiro.pathling.fhirpath.literal.CodingLiteralPath) FhirPath(au.csiro.pathling.fhirpath.FhirPath) SparkHelpers.rowFromCoding(au.csiro.pathling.test.helpers.SparkHelpers.rowFromCoding) Coding(org.hl7.fhir.r4.model.Coding) ParserContextBuilder(au.csiro.pathling.test.builders.ParserContextBuilder) Row(org.apache.spark.sql.Row) DatasetBuilder(au.csiro.pathling.test.builders.DatasetBuilder) ElementPathBuilder(au.csiro.pathling.test.builders.ElementPathBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 72 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class SecurityTestForOperations method assertBatchSuccess.

void assertBatchSuccess() {
    final String json = TestHelpers.getResourceAsString("requests/BatchProviderTest/mixedResourceTypes.Bundle.json");
    final Bundle bundle = (Bundle) jsonParser.parseResource(json);
    batchProvider.batch(bundle);
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle)

Example 73 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class ManifestConverterTest method convertsManifest.

@Test
void convertsManifest() {
    database = new Database(configuration, spark, fhirEncoders, executor);
    final PassportScope passportScope = new PassportScope();
    final VisaManifest manifest = new VisaManifest();
    manifest.setPatientIds(Arrays.asList(PATIENT_ID_1, PATIENT_ID_2, PATIENT_ID_3, PATIENT_ID_4));
    final ManifestConverter manifestConverter = new ManifestConverter(configuration, fhirContext);
    manifestConverter.populateScope(passportScope, manifest);
    // Convert the scope to JSON and compare it to a test fixture.
    final Gson gson = new GsonBuilder().create();
    final String json = gson.toJson(passportScope);
    assertJson("responses/ManifestConverterTest/convertsManifest.json", json);
    // our test patients.
    for (final ResourceType resourceType : passportScope.keySet()) {
        if (AVAILABLE_RESOURCE_TYPES.contains(resourceType)) {
            boolean found = false;
            for (final String filter : passportScope.get(resourceType)) {
                final Dataset<Row> dataset = assertThatResultOf(resourceType, filter).isElementPath(BooleanPath.class).selectResult().apply(result -> result.filter(result.columns()[1])).getDataset();
                if (dataset.count() > 0) {
                    found = true;
                }
            }
            assertTrue(found, "No results found for " + resourceType.toCode());
        }
    }
}
Also used : Arrays(java.util.Arrays) Dataset(org.apache.spark.sql.Dataset) DynamicPropertySource(org.springframework.test.context.DynamicPropertySource) Autowired(org.springframework.beans.factory.annotation.Autowired) DynamicPropertyRegistry(org.springframework.test.context.DynamicPropertyRegistry) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) BooleanPath(au.csiro.pathling.fhirpath.element.BooleanPath) GsonBuilder(com.google.gson.GsonBuilder) FhirContext(ca.uhn.fhir.context.FhirContext) FhirEncoders(au.csiro.pathling.encoders.FhirEncoders) Gson(com.google.gson.Gson) Assertions.assertJson(au.csiro.pathling.test.assertions.Assertions.assertJson) Nonnull(javax.annotation.Nonnull) MockBean(org.springframework.boot.test.mock.mockito.MockBean) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Configuration(au.csiro.pathling.Configuration) TestPropertySource(org.springframework.test.context.TestPropertySource) Row(org.apache.spark.sql.Row) File(java.io.File) Test(org.junit.jupiter.api.Test) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) AbstractParserTest(au.csiro.pathling.fhirpath.parser.AbstractParserTest) Database(au.csiro.pathling.io.Database) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GsonBuilder(com.google.gson.GsonBuilder) BooleanPath(au.csiro.pathling.fhirpath.element.BooleanPath) Gson(com.google.gson.Gson) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) Database(au.csiro.pathling.io.Database) Row(org.apache.spark.sql.Row) Test(org.junit.jupiter.api.Test) AbstractParserTest(au.csiro.pathling.fhirpath.parser.AbstractParserTest)

Example 74 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class AbstractParserTest method mockResource.

void mockResource(final ResourceType... resourceTypes) {
    for (final ResourceType resourceType : resourceTypes) {
        final Dataset<Row> dataset = TestHelpers.getDatasetForResourceType(spark, resourceType);
        when(database.read(resourceType)).thenReturn(dataset);
    }
}
Also used : ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) Row(org.apache.spark.sql.Row)

Example 75 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class ParserTest method testCodingLiterals.

@Test
void testCodingLiterals() {
    // Coding literal form [system]|[code]
    final Coding expectedCoding = new Coding("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", "S", null);
    assertThatResultOf("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus|S").isLiteralPath(CodingLiteralPath.class).hasExpression("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus|S").hasCodingValue(expectedCoding);
    // Coding literal form [system]|[code]|[version]
    final Coding expectedCodingWithVersion = new Coding("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", "S", null);
    expectedCodingWithVersion.setVersion("v1");
    assertThatResultOf("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus|S|v1").isLiteralPath(CodingLiteralPath.class).hasExpression("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus|S|v1").hasCodingValue(expectedCodingWithVersion);
}
Also used : SimpleCoding(au.csiro.pathling.fhirpath.encoding.SimpleCoding) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)229 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)85 HashMap (java.util.HashMap)83 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)59 List (java.util.List)53 Bundle (org.hl7.fhir.dstu3.model.Bundle)50 Nonnull (javax.annotation.Nonnull)48 Patient (org.hl7.fhir.dstu3.model.Patient)46 Organization (org.hl7.fhir.dstu3.model.Organization)45 ArrayList (java.util.ArrayList)44 Bundle (org.hl7.fhir.r4.model.Bundle)41 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 UUID (java.util.UUID)38 Collectors (java.util.stream.Collectors)38 Coding (org.hl7.fhir.r4.model.Coding)34 FhirContext (ca.uhn.fhir.context.FhirContext)33 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)32 IParser (ca.uhn.fhir.parser.IParser)31 IOException (java.io.IOException)29 IdType (org.hl7.fhir.dstu3.model.IdType)28