384 lines
18 KiB
Plaintext
384 lines
18 KiB
Plaintext
package drools
|
||
|
||
import java.util.Set;
|
||
|
||
import com.iqser.red.service.redaction.v1.server.settings.RedactionServiceSettings;
|
||
import com.iqser.red.service.redaction.v1.server.redaction.model.*;
|
||
|
||
global RedactionServiceSettings redactionServiceSettings;
|
||
global Dictionary dictionary;
|
||
|
||
|
||
// --------------------------------------- AI rules -------------------------------------------------------------------
|
||
rule "-1: find entities from dictionary"
|
||
salience 100
|
||
no-loop true
|
||
when
|
||
section: Section()
|
||
then
|
||
section.findDictionaryEntities(dictionary, redactionServiceSettings);
|
||
update(section);
|
||
end
|
||
|
||
rule "0: Add CBI_author from ai"
|
||
when
|
||
section: Section(aiMatchesType("CBI_author"))
|
||
then
|
||
section.addAiEntities("CBI_author", "CBI_author", dictionary);
|
||
end
|
||
|
||
rule "0: Combine address parts from ai to CBI_address (org is mandatory)"
|
||
when
|
||
section: Section(aiMatchesType("ORG"))
|
||
then
|
||
section.combineAiTypes("ORG", "STREET,POSTAL,COUNTRY,CARDINAL,CITY,STATE", 20, "CBI_address", 3, false, dictionary);
|
||
end
|
||
|
||
rule "0: Combine address parts from ai to CBI_address (street is mandatory)"
|
||
when
|
||
section: Section(aiMatchesType("STREET"))
|
||
then
|
||
section.combineAiTypes("STREET", "ORG,POSTAL,COUNTRY,CARDINAL,CITY,STATE", 20, "CBI_address", 3, false, dictionary);
|
||
end
|
||
|
||
rule "0: Combine address parts from ai to CBI_address (city is mandatory)"
|
||
when
|
||
section: Section(aiMatchesType("CITY"))
|
||
then
|
||
section.combineAiTypes("CITY", "ORG,STREET,POSTAL,COUNTRY,CARDINAL,STATE", 20, "CBI_address", 3, false, dictionary);
|
||
end
|
||
|
||
|
||
// --------------------------------------- CBI rules -------------------------------------------------------------------
|
||
|
||
rule "1: Redact CBI Authors (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("CBI_author"))
|
||
then
|
||
section.redact("CBI_author", 1, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
rule "2: Redact CBI Authors (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("CBI_author"))
|
||
then
|
||
section.redact("CBI_author", 2, "Author found", "Article 39(e)(2) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
|
||
rule "3: Redact not CBI Address (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("CBI_address"))
|
||
then
|
||
section.redactNot("CBI_address", 3, "Address found for non vertebrate study");
|
||
section.ignoreRecommendations("CBI_address");
|
||
end
|
||
|
||
rule "4: Redact CBI Address (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("CBI_address"))
|
||
then
|
||
section.redact("CBI_address", 4, "Address found", "Article 39(e)(2) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
|
||
rule "5: Do not redact genitive CBI_author"
|
||
when
|
||
section: Section(matchesType("CBI_author"))
|
||
then
|
||
section.expandToFalsePositiveByRegEx("CBI_author", "['’’'ʼˈ´`‘′ʻ’']s", false, 0, dictionary);
|
||
end
|
||
|
||
|
||
rule "6: Redact Author(s) cells in Tables with Author(s) header (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && hasTableHeader("Author(s)") && !hasTableHeader("Vertebrate study Y/N"))
|
||
then
|
||
section.redactCell("Author(s)", 6, "CBI_author", false, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "7: Redact Author(s) cells in Tables with Author(s) header (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && hasTableHeader("Author(s)") && !hasTableHeader("Vertebrate study Y/N"))
|
||
then
|
||
section.redactCell("Author(s)", 7, "CBI_author", false, "Author found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
|
||
rule "8: Redact Author cells in Tables with Author header (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && hasTableHeader("Author") && !hasTableHeader("Vertebrate study Y/N"))
|
||
then
|
||
section.redactCell("Author", 8, "CBI_author", false, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "9: Redact Author cells in Tables with Author header (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && hasTableHeader("Author") && !hasTableHeader("Vertebrate study Y/N"))
|
||
then
|
||
section.redactCell("Author", 9, "CBI_author", false, "Author found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
|
||
rule "10: Redact and recommand Authors in Tables with Vertebrate study Y/N header (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && (rowEquals("Vertebrate study Y/N", "Y") || rowEquals("Vertebrate study Y/N", "Yes") || rowEquals("Vertebrate study Y/N", "N") || rowEquals("Vertebrate study Y/N", "No")))
|
||
then
|
||
section.redactCell("Author(s)", 10, "CBI_author", true, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "11: Redact and recommand Authors in Tables with Vertebrate study Y/N header (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && (rowEquals("Vertebrate study Y/N", "Y") || rowEquals("Vertebrate study Y/N", "Yes") || rowEquals("Vertebrate study Y/N", "N") || rowEquals("Vertebrate study Y/N", "No")))
|
||
then
|
||
section.redactCell("Author(s)", 11, "CBI_author", true, "Author found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "14: Redact and add recommendation for et al. author (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText contains "et al")
|
||
then
|
||
section.redactAndRecommendByRegEx("\\b([A-ZÄÖÜ][^\\s\\.,]+( [A-ZÄÖÜ]{1,2}\\.?)?( ?[A-ZÄÖÜ]\\.?)?) et al\\.?", false, 1, "CBI_author", 14, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "15: Redact and add recommendation for et al. author (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText contains "et al")
|
||
then
|
||
section.redactAndRecommendByRegEx("\\b([A-ZÄÖÜ][^\\s\\.,]+( [A-ZÄÖÜ]{1,2}\\.?)?( ?[A-ZÄÖÜ]\\.?)?) et al\\.?", false, 1, "CBI_author", 15, "Author found", "Article 39(e)(2) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
|
||
rule "16: Add recommendation for Addresses in Test Organism sections"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText (contains "Species:" && contains "Source:"))
|
||
then
|
||
section.recommendLineAfter("Source:", "CBI_address");
|
||
end
|
||
|
||
rule "17: Add recommendation for Addresses in Test Animals sections"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText (contains "Species" && contains "Source") )
|
||
then
|
||
section.recommendLineAfter("Source", "CBI_address");
|
||
end
|
||
|
||
/*
|
||
|
||
rule "18: Do not redact Names and Addresses if Published Information found"
|
||
when
|
||
section: Section(matchesType("published_information"))
|
||
then
|
||
section.redactNotAndReference("CBI_author","published_information", 18, "Published Information found");
|
||
section.redactNotAndReference("CBI_address","published_information", 18, "Published Information found");
|
||
end
|
||
|
||
*/
|
||
|
||
// --------------------------------------- PII rules -------------------------------------------------------------------
|
||
|
||
|
||
rule "19: Redacted PII Personal Identification Information (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("PII"))
|
||
then
|
||
section.redact("PII", 19, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
rule "20: Redacted PII Personal Identification Information (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesType("PII"))
|
||
then
|
||
section.redact("PII", 20, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
|
||
rule "21: Redact Emails by RegEx (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText contains "@")
|
||
then
|
||
section.redactByRegEx("\\b([A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z\\-]{1,23}[A-Za-z])\\b", true, 1, "PII", 21, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "22: Redact Emails by RegEx (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && searchText contains "@")
|
||
then
|
||
section.redactByRegEx("\\b([A-Za-z0-9._%+\\-]+@[A-Za-z0-9.\\-]+\\.[A-Za-z\\-]{1,23}[A-Za-z])\\b", true, 1, "PII", 22, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
|
||
rule "23: Redact contact information (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study", "Yes") &&
|
||
(text (contains "Contact point:" ||
|
||
contains "Contact:" ||
|
||
contains "Alternative contact:" ||
|
||
(contains "No:" && contains "Fax") ||
|
||
(contains "Contact:" && contains "Tel.:") ||
|
||
contains "European contact:")))
|
||
then
|
||
section.redactLineAfter("Contact point:", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("Contact:", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("Alternative contact:", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactBetween("No:", "Fax", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactBetween("Contact:", "Tel.:", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("European contact:", "PII", 23, true, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "24: Redact contact information (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") &&
|
||
(text (contains "Contact point:"
|
||
|| contains "Contact:"
|
||
|| contains"Alternative contact:"
|
||
|| (contains "No:" && contains "Fax")
|
||
|| (contains "Contact:" && contains "Tel.:")
|
||
|| contains "European contact:"
|
||
)))
|
||
then
|
||
section.redactLineAfter("Contact point:", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("Contact:", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("Alternative contact:", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactBetween("No:", "Fax", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactBetween("Contact:", "Tel.:", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
section.redactLineAfter("European contact:", "PII", 24, true, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002",dictionary);
|
||
end
|
||
|
||
rule "25: Redact Phone and Fax by RegEx (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && (
|
||
text contains "Contact"
|
||
|| contains "Telephone"
|
||
|| contains "Phone"
|
||
|| contains "Fax"
|
||
|| contains "Tel"
|
||
|| contains "Ter"
|
||
|| contains "Mobile"
|
||
|| contains "Fel"
|
||
|| contains "Fer"
|
||
))
|
||
then
|
||
section.redactByRegEx("\\b(contact|telephone|phone|fax|tel|ter|mobile|fel|fer)[a-zA-Z\\s]{0,10}[:.\\s]{0,3}([\\+\\d\\(][\\s\\d\\(\\)\\-\\/\\.]{4,100}\\d)\\b", true, 2, "PII", 25, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "26: Redact Phone and Fax by RegEx (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && (
|
||
text contains "Contact"
|
||
|| contains "Telephone"
|
||
|| contains "Phone"
|
||
|| contains "Fax"
|
||
|| contains "Tel"
|
||
|| contains "Ter"
|
||
|| contains "Mobile"
|
||
|| contains "Fel"
|
||
|| contains "Fer"
|
||
))
|
||
then
|
||
section.redactByRegEx("\\b(contact|telephone|phone|fax|tel|ter|mobile|fel|fer)[a-zA-Z\\s]{0,10}[:.\\s]{0,3}([\\+\\d\\(][\\s\\d\\(\\)\\-\\/\\.]{4,100}\\d)\\b", true, 2, "PII", 26, "Personal information found", "Article 39(e)(2) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "27: Redact AUTHOR(S) (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& (searchText contains "AUTHOR(S):"
|
||
&& contains "COMPLETION DATE:"
|
||
&& not contains "STUDY COMPLETION DATE:")
|
||
)
|
||
then
|
||
section.redactLinesBetween("AUTHOR(S):", "COMPLETION DATE:", "PII", 27, true, "Author found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "28: Redact AUTHOR(S) (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& (searchText contains "AUTHOR(S):"
|
||
&& contains "COMPLETION DATE:"
|
||
&& not contains "STUDY COMPLETION DATE:")
|
||
)
|
||
then
|
||
section.redactLinesBetween("AUTHOR(S):", "COMPLETION DATE:", "PII", 28, true, "AUTHOR(S) was found", "Article 39(e)(2) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
|
||
rule "29: Redact AUTHOR(S) (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& (searchText contains "AUTHOR(S):"
|
||
&& contains "STUDY COMPLETION DATE:")
|
||
)
|
||
then
|
||
section.redactLinesBetween("AUTHOR(S):", "STUDY COMPLETION DATE:", "PII", 29, true, "AUTHOR(S) was found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "30: Redact AUTHOR(S) (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& searchText contains "AUTHOR(S):"
|
||
&& contains "STUDY COMPLETION DATE:"
|
||
)
|
||
then
|
||
section.redactLinesBetween("AUTHOR(S):", "STUDY COMPLETION DATE:", "PII", 30, true, "AUTHOR(S) was found", "Article 39(e)(2) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
|
||
rule "31: Redact PERFORMING LABORATORY (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& searchText contains "PERFORMING LABORATORY:"
|
||
)
|
||
then
|
||
section.redactBetween("PERFORMING LABORATORY:", "LABORATORY PROJECT ID:", "CBI_address", 31, true, "PERFORMING LABORATORY was found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
section.redactNot("CBI_address", 31, "Performing laboratory found for non vertebrate study");
|
||
end
|
||
|
||
rule "32: Redact PERFORMING LABORATORY (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes")
|
||
&& searchText contains "PERFORMING LABORATORY:")
|
||
then
|
||
section.redactBetween("PERFORMING LABORATORY:", "LABORATORY PROJECT ID:", "CBI_address", 32, true, "PERFORMING LABORATORY was found", "Article 39(e)(2) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
rule "33: Redact study director abbreviation"
|
||
when
|
||
section: Section(searchText contains "KATH" || contains "BECH" || contains "KML")
|
||
then
|
||
section.redactWordPartByRegEx("((KATH)|(BECH)|(KML)) ?(\\d{4})", true, 0, 1, "PII", 34, "Personal information found", "Article 39(e)(3) of Regulation (EC) No 178/2002", dictionary);
|
||
end
|
||
|
||
|
||
// --------------------------------------- other rules -------------------------------------------------------------------
|
||
|
||
rule "34: Purity Hint"
|
||
when
|
||
section: Section(searchText.toLowerCase() contains "purity")
|
||
then
|
||
section.addHintAnnotationByRegEx("(purity ?( of|\\(.{1,20}\\))?( ?:)?) .{0,5}[\\d\\.]+( .{0,4}\\.)? ?%", true, 1, "hint_only",dictionary);
|
||
end
|
||
|
||
|
||
|
||
rule "35: Redact signatures (Non vertebrate study)"
|
||
when
|
||
section: Section(!fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesImageType("signature"))
|
||
then
|
||
section.redactImage("signature", 35, "Signature found", "Article 39(e)(3) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
rule "36: Redact signatures (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesImageType("signature"))
|
||
then
|
||
section.redactImage("signature", 36, "Signature found", "Article 39(e)(2) of Regulation (EC) No 178/2002");
|
||
end
|
||
|
||
|
||
rule "43: Redact Logos (Vertebrate study)"
|
||
when
|
||
section: Section(fileAttributeByLabelEqualsIgnoreCase("Vertebrate Study","Yes") && matchesImageType("logo"))
|
||
then
|
||
section.redactImage("logo", 43, "Logo found", "Article 39(e)(2) of Regulation (EC) No 178/2002");
|
||
end
|