diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl index 5b163016..25f8dd09 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl @@ -155,6 +155,32 @@ rule "CBI.7.1: Do not redact Names and Addresses if published information found $authorOrAddress.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $authorOrAddress)); end +rule "CBI.7.2: Do not redact PII if published information found in Section without tables" + when + $section: Section(!hasTables(), + hasEntitiesOfType("published_information"), + hasEntitiesOfType("PII")) + then + $section.getEntitiesOfType("PII") + .forEach(redactionEntity -> { + redactionEntity.skipWithReferences( + "CBI.7.2", + "Published Information found in section", + $section.getEntitiesOfType("published_information") + ); + }); + end + +rule "CBI.7.3: Do not redact PII if published information found in same table row" + when + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("PII")) + $cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList() + $tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList() + $pii: TextEntity(type() == "PII", active()) from $tableCell.getEntities() + then + $pii.skipWithReferences("CBI.7.3", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $pii)); + end + // Rule unit: CBI.9 rule "CBI.9.0: Redact all cells with Header Author(s) as CBI_author (non vertebrate study)" diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl index a2d11999..6daf1775 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl @@ -338,6 +338,32 @@ rule "CBI.7.1: Do not redact Names and Addresses if published information found $authorOrAddress.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $authorOrAddress)); end +rule "CBI.7.2: Do not redact PII if published information found in Section without tables" + when + $section: Section(!hasTables(), + hasEntitiesOfType("published_information"), + hasEntitiesOfType("PII")) + then + $section.getEntitiesOfType("PII") + .forEach(redactionEntity -> { + redactionEntity.skipWithReferences( + "CBI.7.2", + "Published Information found in section", + $section.getEntitiesOfType("published_information") + ); + }); + end + +rule "CBI.7.3: Do not redact PII if published information found in same table row" + when + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("PII")) + $cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList() + $tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList() + $pii: TextEntity(type() == "PII", active()) from $tableCell.getEntities() + then + $pii.skipWithReferences("CBI.7.3", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $pii)); + end + // Rule unit: CBI.8 rule "CBI.8.0: Redacted because Section contains must_redact entity" diff --git a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl index a2d11999..6daf1775 100644 --- a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl +++ b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl @@ -338,6 +338,32 @@ rule "CBI.7.1: Do not redact Names and Addresses if published information found $authorOrAddress.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $authorOrAddress)); end +rule "CBI.7.2: Do not redact PII if published information found in Section without tables" + when + $section: Section(!hasTables(), + hasEntitiesOfType("published_information"), + hasEntitiesOfType("PII")) + then + $section.getEntitiesOfType("PII") + .forEach(redactionEntity -> { + redactionEntity.skipWithReferences( + "CBI.7.2", + "Published Information found in section", + $section.getEntitiesOfType("published_information") + ); + }); + end + +rule "CBI.7.3: Do not redact PII if published information found in same table row" + when + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("PII")) + $cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList() + $tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList() + $pii: TextEntity(type() == "PII", active()) from $tableCell.getEntities() + then + $pii.skipWithReferences("CBI.7.3", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $pii)); + end + // Rule unit: CBI.8 rule "CBI.8.0: Redacted because Section contains must_redact entity"