Highlight N in vertebrate study tables and fixed rule order

This commit is contained in:
deiflaender 2020-08-24 12:24:02 +02:00
parent bb1112d0d7
commit 8a471d0771
2 changed files with 29 additions and 21 deletions

View File

@ -37,15 +37,19 @@ public class Section {
public boolean isVertebrateStudy() {
return tabularData != null
&& tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("Y");
&& ((tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("Y"))
|| (tabularData.containsKey("Verte brate study Y/N")
&& tabularData.get("Verte brate study Y/N").getText().equals("Y")));
}
public boolean isNotVertebrateStudy() {
return tabularData != null
&& tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("N");
&& ((tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("N"))
|| (tabularData.containsKey("Verte brate study Y/N")
&& tabularData.get("Verte brate study Y/N").getText().equals("N")));
}
@ -176,13 +180,13 @@ public class Section {
}
public void highlightCell(String cellHeader, int ruleNumber) {
public void highlightCell(String cellHeader, int ruleNumber, String type) {
TextBlock value = tabularData.get(cellHeader);
if (value == null) {
log.warn("Could not find any data for {}.", cellHeader);
} else {
Entity entity = new Entity(value.getText(), "must_redact", 0, value.getText().length(), headline, sectionNumber);
Entity entity = new Entity(value.getText(), type, 0, value.getText().length(), headline, sectionNumber);
entity.setRedaction(false);
entity.setMatchedRule(ruleNumber);
entity.setRedactionReason(cellHeader);

View File

@ -90,28 +90,32 @@ rule "7: Redact contact information, if Producer is found"
section.redactBetween("No:", "Fax", "address", 7, "Producer was found");
end
rule "8: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
when
Section(isVertebrateStudy())
then
section.redact("name", 8, "Redacted because row is a vertebrate study");
section.redact("address", 8, "Redacted because row is a vertebrate study");
section.highlightCell("Vertebrate study Y/N", 9);
end
rule "9: Not redacted because Vertebrate Study = N"
rule "8: Not redacted because Vertebrate Study = N"
when
Section(isNotVertebrateStudy())
then
section.redactNot("name", 9, "Not redacted because row is not a vertebrate study");
section.redactNot("address", 9, "Not redacted because row is not a vertebrate study");
section.redactNot("name", 8, "Not redacted because row is not a vertebrate study");
section.redactNot("address", 8, "Not redacted because row is not a vertebrate study");
section.highlightCell("Vertebrate study Y/N", 8, "hint_only");
section.highlightCell("Verte brate study Y/N", 8, "hint_only");
end
rule "10: Redact if must redact entry is found"
rule "9: Redact if must redact entry is found"
when
eval(section.contains("must_redact")==true);
then
section.redact("name", 10, "must_redact entry was found.");
section.redact("address", 10, "must_redact entry was found.");
end
section.redact("name", 9, "must_redact entry was found.");
section.redact("address", 9, "must_redact entry was found.");
end
rule "10: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
when
Section(isVertebrateStudy())
then
section.redact("name", 10, "Redacted because row is a vertebrate study");
section.redact("address", 10, "Redacted because row is a vertebrate study");
section.highlightCell("Vertebrate study Y/N", 10, "must_redact");
section.highlightCell("Verte brate study Y/N", 10, "must_redact");
end