use of au.csiro.pathling.fhirpath.element.CodingPath in project pathling by aehrc.
the class MemberOfFunctionTest method memberOfEmptyCodingDatasetDoesNotCallTerminology.
@Test
void memberOfEmptyCodingDatasetDoesNotCallTerminology() {
final Optional<ElementDefinition> optionalDefinition = FhirHelpers.getChildOfResource(fhirContext, "Encounter", "class");
assertTrue(optionalDefinition.isPresent());
final ElementDefinition definition = optionalDefinition.get();
final Dataset<Row> inputDataset = new DatasetBuilder(spark).withIdColumn().withEidColumn().withStructTypeColumns(codingStructType()).buildWithStructValue();
final CodingPath inputExpression = (CodingPath) new ElementPathBuilder(spark).dataset(inputDataset).idAndEidAndValueColumns().expression("Encounter.class").singular(false).definition(definition).buildDefined();
final StringLiteralPath argumentExpression = StringLiteralPath.fromString("'" + MY_VALUE_SET_URL + "'", inputExpression);
// Prepare the inputs to the function.
final ParserContext parserContext = new ParserContextBuilder(spark, fhirContext).idColumn(inputExpression.getIdColumn()).terminologyClientFactory(terminologyServiceFactory).build();
final NamedFunctionInput memberOfInput = new NamedFunctionInput(parserContext, inputExpression, Collections.singletonList(argumentExpression));
// Invoke the function.
final FhirPath result = new MemberOfFunction().invoke(memberOfInput);
// The outcome is somehow random with regard to the sequence passed to MemberOfMapperAnswerer.
final Dataset<Row> expectedResult = new DatasetBuilder(spark).withIdColumn().withEidColumn().withColumn(DataTypes.BooleanType).build();
// Check the result.
assertThat(result).hasExpression("Encounter.class.memberOf('" + MY_VALUE_SET_URL + "')").isElementPath(BooleanPath.class).hasFhirType(FHIRDefinedType.BOOLEAN).isNotSingular().selectOrderedResultWithEid().hasRows(expectedResult);
verifyNoMoreInteractions(terminologyService);
}
use of au.csiro.pathling.fhirpath.element.CodingPath in project pathling by aehrc.
the class SubsumesFunctionTest method createNullCodingInput.
CodingPath createNullCodingInput() {
final Dataset<Row> dataset = new DatasetBuilder(spark).withIdColumn().withEidColumn().withIdEidValueRows(ALL_RES_IDS, id -> null, id -> null).withStructTypeColumns(codingStructType()).buildWithStructValue();
final ElementPath argument = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(dataset).idAndEidAndValueColumns().build();
return (CodingPath) argument;
}
use of au.csiro.pathling.fhirpath.element.CodingPath in project pathling by aehrc.
the class SubsumesFunctionTest method createEmptyCodingInput.
CodingPath createEmptyCodingInput() {
final Dataset<Row> dataset = new DatasetBuilder(spark).withIdColumn().withEidColumn().withStructTypeColumns(codingStructType()).buildWithStructValue();
final ElementPath argument = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(dataset).idAndEidAndValueColumns().build();
return (CodingPath) argument;
}
use of au.csiro.pathling.fhirpath.element.CodingPath in project pathling by aehrc.
the class SubsumesFunctionTest method createSingularCodingInput.
CodingPath createSingularCodingInput() {
final Dataset<Row> dataset = new DatasetBuilder(spark).withIdColumn().withStructTypeColumns(codingStructType()).withRow(RES_ID1, rowFromCoding(CODING_SMALL)).withRow(RES_ID2, rowFromCoding(CODING_MEDIUM)).withRow(RES_ID3, rowFromCoding(CODING_LARGE)).withRow(RES_ID4, rowFromCoding(CODING_OTHER1)).withRow(RES_ID5, null).buildWithStructValue();
final ElementPath inputExpression = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(dataset).idAndValueColumns().singular(true).build();
return (CodingPath) inputExpression;
}
use of au.csiro.pathling.fhirpath.element.CodingPath in project pathling by aehrc.
the class SubsumesFunctionTest method createNullCodingArg.
CodingPath createNullCodingArg() {
final Dataset<Row> dataset = new DatasetBuilder(spark).withIdColumn().withStructTypeColumns(codingStructType()).withIdValueRows(ALL_RES_IDS, id -> null).buildWithStructValue();
final ElementPath argument = new ElementPathBuilder(spark).fhirType(FHIRDefinedType.CODING).dataset(dataset).idAndValueColumns().build();
return (CodingPath) argument;
}
Aggregations