Search in sources :

Example 66 with FINAL

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

the class SubsumesFunctionTest method createCodingArg.

CodingPath createCodingArg() {
    final Dataset<Row> dataset = new DatasetBuilder(spark).withIdColumn().withStructTypeColumns(codingStructType()).withIdValueRows(ALL_RES_IDS, id -> rowFromCoding(CODING_MEDIUM)).withIdValueRows(ALL_RES_IDS, id -> rowFromCoding(CODING_OTHER3)).buildWithStructValue();
    final ElementPath argument = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(dataset).idAndValueColumns().build();
    return (CodingPath) argument;
}
Also used : DatasetBuilder(au.csiro.pathling.test.builders.DatasetBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) ElementPathBuilder(au.csiro.pathling.test.builders.ElementPathBuilder) Autowired(org.springframework.beans.factory.annotation.Autowired) BooleanPath(au.csiro.pathling.fhirpath.element.BooleanPath) FhirContext(ca.uhn.fhir.context.FhirContext) Tag(org.junit.jupiter.api.Tag) Assertions.assertThat(au.csiro.pathling.test.assertions.Assertions.assertThat) DataTypes(org.apache.spark.sql.types.DataTypes) SparkHelpers.codingStructType(au.csiro.pathling.test.helpers.SparkHelpers.codingStructType) ElementPathAssertion(au.csiro.pathling.test.assertions.ElementPathAssertion) FHIRDefinedType(org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType) SparkHelpers.codeableConceptStructType(au.csiro.pathling.test.helpers.SparkHelpers.codeableConceptStructType) CodingPath(au.csiro.pathling.fhirpath.element.CodingPath) ElementPath(au.csiro.pathling.fhirpath.element.ElementPath) Test(org.junit.jupiter.api.Test) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) CodingLiteralPath(au.csiro.pathling.fhirpath.literal.CodingLiteralPath) StringLiteralPath(au.csiro.pathling.fhirpath.literal.StringLiteralPath) RelationBuilder(au.csiro.pathling.test.fixtures.RelationBuilder) Coding(org.hl7.fhir.r4.model.Coding) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Dataset(org.apache.spark.sql.Dataset) NonLiteralPath(au.csiro.pathling.fhirpath.NonLiteralPath) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) SparkHelpers.rowFromCoding(au.csiro.pathling.test.helpers.SparkHelpers.rowFromCoding) NamedFunctionInput(au.csiro.pathling.fhirpath.function.NamedFunctionInput) DatasetAssert(au.csiro.pathling.test.assertions.DatasetAssert) NamedFunction(au.csiro.pathling.fhirpath.function.NamedFunction) Relation(au.csiro.pathling.terminology.Relation) TerminologyServiceFactory(au.csiro.pathling.fhir.TerminologyServiceFactory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InvalidUserInputError(au.csiro.pathling.errors.InvalidUserInputError) Nonnull(javax.annotation.Nonnull) TerminologyService(au.csiro.pathling.terminology.TerminologyService) SparkSession(org.apache.spark.sql.SparkSession) Mockito.when(org.mockito.Mockito.when) Row(org.apache.spark.sql.Row) ParserContext(au.csiro.pathling.fhirpath.parser.ParserContext) SparkHelpers.rowFromCodeableConcept(au.csiro.pathling.test.helpers.SparkHelpers.rowFromCodeableConcept) FhirPath(au.csiro.pathling.fhirpath.FhirPath) SharedMocks(au.csiro.pathling.test.SharedMocks) ParserContextBuilder(au.csiro.pathling.test.builders.ParserContextBuilder) DatasetBuilder.makeEid(au.csiro.pathling.test.builders.DatasetBuilder.makeEid) Collections(java.util.Collections) CodingPath(au.csiro.pathling.fhirpath.element.CodingPath) ElementPath(au.csiro.pathling.fhirpath.element.ElementPath) Row(org.apache.spark.sql.Row) DatasetBuilder(au.csiro.pathling.test.builders.DatasetBuilder) ElementPathBuilder(au.csiro.pathling.test.builders.ElementPathBuilder)

Example 67 with FINAL

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

the class CodingLiteralPathTest method roundTripWithQuotedComponentWithComma.

@Test
void roundTripWithQuotedComponentWithComma() {
    final String expression = "http://snomed.info/sct|'46,2'|http://snomed.info/sct/32506021000036107/version/20201231";
    final CodingLiteralPath codingLiteralPath = CodingLiteralPath.fromString(expression, inputContext);
    final Coding literalValue = codingLiteralPath.getLiteralValue();
    assertEquals("http://snomed.info/sct", literalValue.getSystem());
    assertEquals("http://snomed.info/sct/32506021000036107/version/20201231", literalValue.getVersion());
    assertEquals("46,2", literalValue.getCode());
    final String actualExpression = codingLiteralPath.getExpression();
    assertEquals(expression, actualExpression);
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 68 with FINAL

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

the class CodingLiteralPathTest method roundTripWithQuotedComponentWithSingleQuote.

@Test
void roundTripWithQuotedComponentWithSingleQuote() {
    final String expression = "'Someone\\'s CodeSystem'|166056000";
    final CodingLiteralPath codingLiteralPath = CodingLiteralPath.fromString(expression, inputContext);
    final Coding literalValue = codingLiteralPath.getLiteralValue();
    assertEquals("Someone's CodeSystem", literalValue.getSystem());
    assertEquals("166056000", literalValue.getCode());
    final String actualExpression = codingLiteralPath.getExpression();
    assertEquals(expression, actualExpression);
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 69 with FINAL

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

the class CodingLiteralPathTest method roundTripWithQuotedComponentWithSpace.

@Test
void roundTripWithQuotedComponentWithSpace() {
    final String expression = "'Some CodeSystem'|166056000";
    final CodingLiteralPath codingLiteralPath = CodingLiteralPath.fromString(expression, inputContext);
    final Coding literalValue = codingLiteralPath.getLiteralValue();
    assertEquals("Some CodeSystem", literalValue.getSystem());
    assertEquals("166056000", literalValue.getCode());
    final String actualExpression = codingLiteralPath.getExpression();
    assertEquals(expression, actualExpression);
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 70 with FINAL

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

the class CombineOperatorTest method worksWithLiteralAndNonLiteralCodingValues.

@Test
void worksWithLiteralAndNonLiteralCodingValues() {
    final Dataset<Row> leftDataset = new DatasetBuilder(spark).withIdColumn(idColumnName).withEidColumn().withStructTypeColumns(codingStructType()).withRow("observation-1", makeEid(0), rowFromCoding(new Coding("http://snomed.info/sct", "18001011000036104", null))).buildWithStructValue();
    final ElementPath left = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(leftDataset).idAndEidAndValueColumns().expression("valueCoding").singular(false).build();
    final CodingLiteralPath right = CodingLiteralPath.fromString("http://snomed.info/sct|373882004", parserContext.getInputContext());
    final OperatorInput combineInput = new OperatorInput(parserContext, left, right);
    final FhirPath result = Operator.getInstance("combine").invoke(combineInput);
    final Dataset<Row> expectedDataset = new DatasetBuilder(spark).withIdColumn(idColumnName).withStructTypeColumns(codingStructType()).withRow("observation-1", rowFromCoding(new Coding("http://snomed.info/sct", "18001011000036104", null))).withRow("observation-1", rowFromCoding(new Coding("http://snomed.info/sct", "373882004", null))).withRow("observation-2", rowFromCoding(new Coding("http://snomed.info/sct", "373882004", null))).withRow("observation-3", rowFromCoding(new Coding("http://snomed.info/sct", "373882004", null))).buildWithStructValue();
    assertThat(result).hasExpression("valueCoding combine http://snomed.info/sct|373882004").isNotSingular().isElementPath(CodingPath.class).selectResult().hasRowsUnordered(expectedDataset);
}
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) Row(org.apache.spark.sql.Row) DatasetBuilder(au.csiro.pathling.test.builders.DatasetBuilder) ElementPathBuilder(au.csiro.pathling.test.builders.ElementPathBuilder) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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