Search in sources :

Example 1 with TerminologyService

use of au.csiro.pathling.terminology.TerminologyService in project pathling by aehrc.

the class SubsumptionMapperWithPreview method preview.

@Override
@Nonnull
public Relation preview(@Nonnull final Iterator<ImmutablePair<List<SimpleCoding>, List<SimpleCoding>>> input) {
    // Add the request ID to the logging context, so that we can track the logging for this
    // request across all workers.
    MDC.put("requestId", requestId);
    // Collect all distinct tokens used on both in inputs and arguments in this partition
    // Rows in which either input or argument are NULL are excluded as they do not need
    // to be included in closure request.
    // Also, we only include codings with both system and code defined as only they can
    // be expected to be meaningfully represented to the terminology server
    final Set<SimpleCoding> codings = Streams.streamOf(input).filter(r -> r.getLeft() != null && r.getRight() != null).flatMap(r -> concat(r.getLeft().stream(), r.getRight().stream())).filter(Objects::nonNull).collect(Collectors.toSet());
    final TerminologyService terminologyService = terminologyServiceFactory.buildService(log);
    return terminologyService.getSubsumesRelation(codings);
}
Also used : SimpleCoding(au.csiro.pathling.fhirpath.encoding.SimpleCoding) Iterator(java.util.Iterator) Set(java.util.Set) Collectors(java.util.stream.Collectors) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Streams(au.csiro.pathling.utilities.Streams) Objects(java.util.Objects) MapperWithPreview(au.csiro.pathling.sql.MapperWithPreview) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Relation(au.csiro.pathling.terminology.Relation) MDC(org.slf4j.MDC) TerminologyServiceFactory(au.csiro.pathling.fhir.TerminologyServiceFactory) Stream.concat(java.util.stream.Stream.concat) Collections(java.util.Collections) Nonnull(javax.annotation.Nonnull) TerminologyService(au.csiro.pathling.terminology.TerminologyService) Nullable(javax.annotation.Nullable) SimpleCoding(au.csiro.pathling.fhirpath.encoding.SimpleCoding) TerminologyService(au.csiro.pathling.terminology.TerminologyService) Nonnull(javax.annotation.Nonnull)

Example 2 with TerminologyService

use of au.csiro.pathling.terminology.TerminologyService in project pathling by aehrc.

the class TranslateMapperWithPreview method preview.

@Override
@Nonnull
public ConceptTranslator preview(@Nonnull final Iterator<List<SimpleCoding>> input) {
    if (!input.hasNext() || equivalences.isEmpty()) {
        return new ConceptTranslator();
    }
    // Add the request ID to the logging context, so that we can track the logging for this
    // request across all workers.
    MDC.put("requestId", requestId);
    final Set<SimpleCoding> uniqueCodings = Streams.streamOf(input).filter(Objects::nonNull).flatMap(List::stream).collect(Collectors.toSet());
    final TerminologyService terminologyService = terminologyServiceFactory.buildService(log);
    return terminologyService.translate(uniqueCodings, conceptMapUrl, reverse, equivalences);
}
Also used : SimpleCoding(au.csiro.pathling.fhirpath.encoding.SimpleCoding) TerminologyService(au.csiro.pathling.terminology.TerminologyService) ConceptTranslator(au.csiro.pathling.terminology.ConceptTranslator) Objects(java.util.Objects) Nonnull(javax.annotation.Nonnull)

Example 3 with TerminologyService

use of au.csiro.pathling.terminology.TerminologyService in project pathling by aehrc.

the class MemberOfMapperWithPreview method preview.

@Override
@Nonnull
public Set<SimpleCoding> preview(@Nonnull final Iterator<List<SimpleCoding>> input) {
    MDC.put("requestId", requestId);
    final Set<SimpleCoding> codings = Streams.streamOf(input).filter(Objects::nonNull).flatMap(List::stream).collect(Collectors.toSet());
    final TerminologyService terminologyService = terminologyServiceFactory.buildService(log);
    return terminologyService.intersect(valueSetUri, codings);
}
Also used : SimpleCoding(au.csiro.pathling.fhirpath.encoding.SimpleCoding) TerminologyService(au.csiro.pathling.terminology.TerminologyService) Nonnull(javax.annotation.Nonnull)

Aggregations

SimpleCoding (au.csiro.pathling.fhirpath.encoding.SimpleCoding)3 TerminologyService (au.csiro.pathling.terminology.TerminologyService)3 Nonnull (javax.annotation.Nonnull)3 Objects (java.util.Objects)2 TerminologyServiceFactory (au.csiro.pathling.fhir.TerminologyServiceFactory)1 MapperWithPreview (au.csiro.pathling.sql.MapperWithPreview)1 ConceptTranslator (au.csiro.pathling.terminology.ConceptTranslator)1 Relation (au.csiro.pathling.terminology.Relation)1 Streams (au.csiro.pathling.utilities.Streams)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Stream.concat (java.util.stream.Stream.concat)1 Nullable (javax.annotation.Nullable)1 Slf4j (lombok.extern.slf4j.Slf4j)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 MDC (org.slf4j.MDC)1