diff --git a/phileas-core/src/test/java/ai/philterd/test/phileas/services/filters/AgeFilterTest.java b/phileas-core/src/test/java/ai/philterd/test/phileas/services/filters/AgeFilterTest.java index aded76155..5be1b665e 100644 --- a/phileas-core/src/test/java/ai/philterd/test/phileas/services/filters/AgeFilterTest.java +++ b/phileas-core/src/test/java/ai/philterd/test/phileas/services/filters/AgeFilterTest.java @@ -36,6 +36,26 @@ public class AgeFilterTest extends AbstractFilterTest { private final AlertService alertService = Mockito.mock(AlertService.class); + @Test + public void filterWithAlternateName() throws Exception { + + final FilterConfiguration filterConfiguration = new FilterConfiguration.FilterConfigurationBuilder() + .withStrategies(List.of(new AgeFilterStrategy())) + .withAlertService(alertService) + .withAnonymizationService(new AgeAnonymizationService(new LocalAnonymizationCacheService())) + .withWindowSize(windowSize) + .build(); + + final AgeFilter filter = new AgeFilter(filterConfiguration); + + final FilterResult filterResult = filter.filter(getPolicy(), "context", "documentid", PIECE, "patient is 4161 y/o and", attributes); + + showSpans(filterResult.getSpans()); + + Assertions.assertEquals(0, filterResult.getSpans().size()); + + } + @Test public void filterIgnoredPattern1() throws Exception { diff --git a/phileas-model/src/main/java/ai/philterd/phileas/model/filter/Filter.java b/phileas-model/src/main/java/ai/philterd/phileas/model/filter/Filter.java index 8680016aa..bba047938 100644 --- a/phileas-model/src/main/java/ai/philterd/phileas/model/filter/Filter.java +++ b/phileas-model/src/main/java/ai/philterd/phileas/model/filter/Filter.java @@ -46,6 +46,11 @@ public abstract class Filter { */ protected final FilterType filterType; + /** + * When given, an alternative name to use instead of the {@link FilterType}. + */ + protected String alternativeName; + /** * The alert service. */ @@ -130,6 +135,7 @@ public Filter(final FilterType filterType, final FilterConfiguration filterConfi this.crypto = filterConfiguration.getCrypto(); this.fpe = filterConfiguration.getFPE(); this.windowSize = filterConfiguration.getWindowSize(); + this.alternativeName = filterConfiguration.getAlternativeName(); if(this.ignored == null) { this.ignored = new LinkedHashSet<>(); diff --git a/phileas-model/src/main/java/ai/philterd/phileas/model/filter/FilterConfiguration.java b/phileas-model/src/main/java/ai/philterd/phileas/model/filter/FilterConfiguration.java index 9f4f614f4..021abdd0b 100644 --- a/phileas-model/src/main/java/ai/philterd/phileas/model/filter/FilterConfiguration.java +++ b/phileas-model/src/main/java/ai/philterd/phileas/model/filter/FilterConfiguration.java @@ -40,6 +40,7 @@ public class FilterConfiguration { private final Crypto crypto; private final FPE fpe; private int windowSize = 5; + private String alternativeName; private FilterConfiguration( final List strategies, @@ -50,7 +51,8 @@ private FilterConfiguration( final List ignoredPatterns, final Crypto crypto, final FPE fpe, - final int windowSize + final int windowSize, + final String alternativeName ) { this.strategies = strategies; @@ -62,6 +64,7 @@ private FilterConfiguration( this.crypto = crypto; this.fpe = fpe; this.windowSize = windowSize; + this.alternativeName = alternativeName; } @@ -76,6 +79,7 @@ public static class FilterConfigurationBuilder { private Crypto crypto; private FPE fpe; private int windowSize; + private String alternativeName; public FilterConfiguration build() { @@ -91,7 +95,8 @@ public FilterConfiguration build() { ignoredPatterns, crypto, fpe, - windowSize + windowSize, + alternativeName ); } @@ -229,4 +234,8 @@ public int getWindowSize() { return windowSize; } + public String getAlternativeName() { + return alternativeName; + } + } diff --git a/phileas-model/src/main/java/ai/philterd/phileas/model/policy/filters/AbstractFilter.java b/phileas-model/src/main/java/ai/philterd/phileas/model/policy/filters/AbstractFilter.java index 942e5a8aa..f33552ea2 100644 --- a/phileas-model/src/main/java/ai/philterd/phileas/model/policy/filters/AbstractFilter.java +++ b/phileas-model/src/main/java/ai/philterd/phileas/model/policy/filters/AbstractFilter.java @@ -41,6 +41,18 @@ public abstract class AbstractFilter { @Expose protected List ignoredPatterns = Collections.emptyList(); + @SerializedName("alternativeName") + @Expose + protected String alternativeName; + + public String getAlternativeName() { + return alternativeName; + } + + public void setAlternativeName(String alternativeName) { + this.alternativeName = alternativeName; + } + public void setEnabled(boolean enabled) { this.enabled = enabled; }