Search in sources :

Example 86 with FINAL

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

the class TestData method newMedication.

/**
 * Returns a FHIR medication to be contained to a medication request for testing purposes.
 */
public static Medication newMedication() {
    final Medication medication = new Medication();
    medication.setId("test-med");
    final MedicationIngredientComponent ingredient = new MedicationIngredientComponent();
    final CodeableConcept item = new CodeableConcept();
    item.addCoding().setSystem("test/ingredient/system").setCode("test-code");
    ingredient.setItem(item);
    medication.addIngredient(ingredient);
    return medication;
}
Also used : MedicationIngredientComponent(org.hl7.fhir.r4.model.Medication.MedicationIngredientComponent)

Example 87 with FINAL

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

the class QueryHelpers method join.

/**
 * Joins any number of {@link FhirPath} expressions, using equality between their respective
 * resource ID columns.
 *
 * @param parserContext the current {@link ParserContext}
 * @param fhirPaths a list of {@link FhirPath} expressions
 * @param joinType a {@link JoinType}
 * @return a new {@link Dataset}
 */
@Nonnull
public static Dataset<Row> join(@Nonnull final ParserContext parserContext, @Nonnull final List<FhirPath> fhirPaths, @Nonnull final JoinType joinType) {
    checkArgument(fhirPaths.size() > 1, "fhirPaths must contain more than one FhirPath");
    final FhirPath left = fhirPaths.get(0);
    final List<FhirPath> joinTargets = fhirPaths.subList(1, fhirPaths.size());
    // Only non-literal paths will trigger a join.
    final List<FhirPath> nonLiteralTargets = joinTargets.stream().filter(t -> t instanceof NonLiteralPath).collect(Collectors.toList());
    if (left instanceof NonLiteralPath && nonLiteralTargets.isEmpty()) {
        // to join.
        return left.getDataset();
    } else if (left instanceof LiteralPath && !nonLiteralTargets.isEmpty()) {
        // right without any need to join.
        return nonLiteralTargets.get(0).getDataset();
    }
    Dataset<Row> dataset = left.getDataset();
    final List<Column> groupingColumns = parserContext.getGroupingColumns();
    final Column idColumn = parserContext.getInputContext().getIdColumn();
    final List<Column> leftColumns = checkColumnsAndFallback(left.getDataset(), groupingColumns, idColumn);
    for (final FhirPath right : nonLiteralTargets) {
        final List<Column> resolvedGroupingColumns = checkColumnsAndFallback(right.getDataset(), leftColumns, idColumn);
        dataset = join(dataset, resolvedGroupingColumns, right.getDataset(), resolvedGroupingColumns, joinType);
    }
    return dataset;
}
Also used : Arrays(java.util.Arrays) Getter(lombok.Getter) Dataset(org.apache.spark.sql.Dataset) NonLiteralPath(au.csiro.pathling.fhirpath.NonLiteralPath) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) ArrayList(java.util.ArrayList) Value(lombok.Value) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Strings.randomAlias(au.csiro.pathling.utilities.Strings.randomAlias) FhirEncoders(au.csiro.pathling.encoders.FhirEncoders) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Map(java.util.Map) org.apache.spark.sql.functions.lit(org.apache.spark.sql.functions.lit) Strings(au.csiro.pathling.utilities.Strings) Nonnull(javax.annotation.Nonnull) SparkSession(org.apache.spark.sql.SparkSession) Column(org.apache.spark.sql.Column) Collection(java.util.Collection) Set(java.util.Set) Preconditions.checkArgument(au.csiro.pathling.utilities.Preconditions.checkArgument) Row(org.apache.spark.sql.Row) Collectors(java.util.stream.Collectors) ParserContext(au.csiro.pathling.fhirpath.parser.ParserContext) ExpressionEncoder(org.apache.spark.sql.catalyst.encoders.ExpressionEncoder) List(java.util.List) Stream(java.util.stream.Stream) LiteralPath(au.csiro.pathling.fhirpath.literal.LiteralPath) FhirPath(au.csiro.pathling.fhirpath.FhirPath) org.apache.spark.sql.functions.col(org.apache.spark.sql.functions.col) Optional(java.util.Optional) org.apache.spark.sql.functions(org.apache.spark.sql.functions) Comparator(java.util.Comparator) Collections(java.util.Collections) FhirPath(au.csiro.pathling.fhirpath.FhirPath) NonLiteralPath(au.csiro.pathling.fhirpath.NonLiteralPath) LiteralPath(au.csiro.pathling.fhirpath.literal.LiteralPath) Column(org.apache.spark.sql.Column) Row(org.apache.spark.sql.Row) NonLiteralPath(au.csiro.pathling.fhirpath.NonLiteralPath) Nonnull(javax.annotation.Nonnull)

Example 88 with FINAL

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

the class ExtractResponse method toParameters.

/**
 * Converts this to a {@link Parameters} resource, based on the definition of the result of the
 * "extract" operation within the OperationDefinition.
 *
 * @return a new {@link Parameters} object
 */
public Parameters toParameters() {
    final Parameters parameters = new Parameters();
    final ParametersParameterComponent urlParameter = new ParametersParameterComponent();
    urlParameter.setName("url");
    urlParameter.setValue(new UrlType(url));
    parameters.getParameter().add(urlParameter);
    return parameters;
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) UrlType(org.hl7.fhir.r4.model.UrlType) ParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent)

Example 89 with FINAL

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

the class ConformanceProvider method buildResources.

@Nonnull
private List<CapabilityStatementRestResourceComponent> buildResources() {
    final List<CapabilityStatementRestResourceComponent> resources = new ArrayList<>();
    final Set<ResourceType> supported = FhirServer.supportedResourceTypes();
    final Set<ResourceType> supportedResourceTypes = supported.isEmpty() ? EnumSet.noneOf(ResourceType.class) : EnumSet.copyOf(supported);
    for (final ResourceType resourceType : supportedResourceTypes) {
        final CapabilityStatementRestResourceComponent resource = new CapabilityStatementRestResourceComponent(new CodeType(resourceType.toCode()));
        resource.setProfile(FHIR_RESOURCE_BASE + resourceType.toCode());
        // Add the search operation to all resources.
        final ResourceInteractionComponent search = new ResourceInteractionComponent();
        search.setCode(TypeRestfulInteraction.SEARCHTYPE);
        resource.getInteraction().add(search);
        // Add the create and update operations to all resources.
        final ResourceInteractionComponent create = new ResourceInteractionComponent();
        final ResourceInteractionComponent update = new ResourceInteractionComponent();
        create.setCode(TypeRestfulInteraction.CREATE);
        update.setCode(TypeRestfulInteraction.UPDATE);
        resource.getInteraction().add(create);
        resource.getInteraction().add(update);
        // Add the `aggregate` operation to all resources.
        final CanonicalType aggregateOperationUri = new CanonicalType(getOperationUri("aggregate"));
        final CapabilityStatementRestResourceOperationComponent aggregateOperation = new CapabilityStatementRestResourceOperationComponent(new StringType("aggregate"), aggregateOperationUri);
        resource.addOperation(aggregateOperation);
        // Add the `fhirPath` search parameter to all resources.
        final CapabilityStatementRestResourceOperationComponent searchOperation = new CapabilityStatementRestResourceOperationComponent();
        searchOperation.setName("fhirPath");
        searchOperation.setDefinition(getOperationUri("search"));
        resource.addOperation(searchOperation);
        resources.add(resource);
    }
    // Add the read operation to the OperationDefinition resource.
    final String opDefCode = ResourceType.OPERATIONDEFINITION.toCode();
    final CapabilityStatementRestResourceComponent opDefResource = new CapabilityStatementRestResourceComponent(new CodeType(opDefCode));
    opDefResource.setProfile(FHIR_RESOURCE_BASE + opDefCode);
    final ResourceInteractionComponent readInteraction = new ResourceInteractionComponent();
    readInteraction.setCode(TypeRestfulInteraction.READ);
    opDefResource.addInteraction(readInteraction);
    resources.add(opDefResource);
    return resources;
}
Also used : ResourceInteractionComponent(org.hl7.fhir.r4.model.CapabilityStatement.ResourceInteractionComponent) StringType(org.hl7.fhir.r4.model.StringType) ArrayList(java.util.ArrayList) CodeType(org.hl7.fhir.r4.model.CodeType) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) CapabilityStatementRestResourceComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceComponent) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) CapabilityStatementRestResourceOperationComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResourceOperationComponent) Nonnull(javax.annotation.Nonnull)

Example 90 with FINAL

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

the class ConformanceProvider method buildRestComponent.

@Nonnull
private List<CapabilityStatementRestComponent> buildRestComponent() {
    final List<CapabilityStatementRestComponent> rest = new ArrayList<>();
    final CapabilityStatementRestComponent server = new CapabilityStatementRestComponent();
    server.setMode(RestfulCapabilityMode.SERVER);
    server.setSecurity(buildSecurity());
    server.setResource(buildResources());
    server.setOperation(buildOperations());
    server.setInteraction(buildSystemLevelInteractions());
    rest.add(server);
    return rest;
}
Also used : ArrayList(java.util.ArrayList) CapabilityStatementRestComponent(org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestComponent) Nonnull(javax.annotation.Nonnull)

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