@Test public void testExecute() throws IOException, SimpleMarshallerException, XPathExpressionException { String c32FileName = "MIE_SampleC32.xml"; String factmodelXml = fileReader.readFile(TEST_PATH + FACTMODEL_PATH + c32FileName); String c32 = embeddedClinicalDocumentExtractor.extractClinicalDocumentFromFactModel(factmodelXml); String ruleExecutionContainerXml = fileReader.readFile(TEST_PATH + RULEEXECUTIONCONTAINER_PATH + c32FileName); RuleExecutionContainer ruleExecutionContainer = marshaller.unmarshalFromXml(RuleExecutionContainer.class, ruleExecutionContainerXml); Document c32Document = documentXmlConverter.loadDocument(c32); Document factModelDocument = documentXmlConverter.loadDocument(factmodelXml); FactModel factModel = marshaller.unmarshalFromXml(FactModel.class, factmodelXml); List<Node> listOfNodes = new LinkedList<Node>(); Set<String> redactSectionCodesAndGeneratedEntryIds = new HashSet<String>(); Set<String> redactSensitiveCategoryCodes = new HashSet<String>(); ClinicalFact fact = factModel.getClinicalFactList().get(8); Set<String> valueSetCategories = new HashSet<String>(); valueSetCategories.add("HIV"); valueSetCategories.add("ETH"); fact.setValueSetCategories(valueSetCategories); sut.execute(c32Document, factModel.getXacmlResult(), factModel, factModelDocument, fact, ruleExecutionContainer, listOfNodes, redactSectionCodesAndGeneratedEntryIds, redactSensitiveCategoryCodes); assertEquals(2, listOfNodes.size()); assertEquals(1, redactSectionCodesAndGeneratedEntryIds.size()); assertEquals(1, redactSensitiveCategoryCodes.size()); assertEquals("content", listOfNodes.get(0).getNodeName()); assertEquals("CondRefId_0_9", listOfNodes.get(0).getAttributes().getNamedItem("ID").getNodeValue()); assertEquals(Node.TEXT_NODE, listOfNodes.get(1).getNodeType()); assertEquals(" , ", listOfNodes.get(1).getNodeValue()); assertEquals("d1e282", redactSectionCodesAndGeneratedEntryIds.toArray()[0]); assertEquals("HIV", redactSensitiveCategoryCodes.toArray()[0]); }
@Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, ClinicalFact fact, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds, Set<String> redactSensitiveCategoryCodes) throws XPathExpressionException { String foundCategory = findMatchingCategory(xacmlResult, fact); if (foundCategory != null) { NodeList references = getEntryReferenceIdNodeList( factModelDocument, fact); for (int i = 0; i < references.getLength(); i++) { addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE, fact.getEntry(), references.item(i).getNodeValue()); addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE, fact.getEntry(), references.item(i).getNodeValue()); } redactSensitiveCategoryCodes.add(foundCategory); } }
HumanReadableContentElementById extends
		AbstractClinicalFactLevelRedactionHandler { @Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, ClinicalFact fact, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds, Set<String> redactSensitiveCategoryCodes) throws XPathExpressionException { String foundCategory = findMatchingCategory(xacmlResult, fact); if (foundCategory != null) { NodeList references = getEntryReferenceIdNodeList( factModelDocument, fact); for (int i = 0; i < references.getLength(); i++) { addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE, fact.getEntry(), references.item(i).getNodeValue()); addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE, fact.getEntry(), references.item(i).getNodeValue()); } redactSensitiveCategoryCodes.add(foundCategory); } } }
HumanReadableContentElementById extends
		AbstractClinicalFactLevelRedactionHandler { @Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, ClinicalFact fact, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds, Set<String> redactSensitiveCategoryCodes) throws XPathExpressionException { String foundCategory = findMatchingCategory(xacmlResult, fact); if (foundCategory != null) { NodeList references = getEntryReferenceIdNodeList( factModelDocument, fact); for (int i = 0; i < references.getLength(); i++) { addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE, fact.getEntry(), references.item(i).getNodeValue()); addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE, fact.getEntry(), references.item(i).getNodeValue()); } redactSensitiveCategoryCodes.add(foundCategory); } } HumanReadableContentElementById(
			DocumentAccessor documentAccessor); }
HumanReadableContentElementById extends
		AbstractClinicalFactLevelRedactionHandler { @Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, ClinicalFact fact, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds, Set<String> redactSensitiveCategoryCodes) throws XPathExpressionException { String foundCategory = findMatchingCategory(xacmlResult, fact); if (foundCategory != null) { NodeList references = getEntryReferenceIdNodeList( factModelDocument, fact); for (int i = 0; i < references.getLength(); i++) { addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE, fact.getEntry(), references.item(i).getNodeValue()); addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE, fact.getEntry(), references.item(i).getNodeValue()); } redactSensitiveCategoryCodes.add(foundCategory); } } HumanReadableContentElementById(
			DocumentAccessor documentAccessor); @Override void execute(Document xmlDocument, XacmlResult xacmlResult,
			FactModel factModel, Document factModelDocument, ClinicalFact fact,
			RuleExecutionContainer ruleExecutionContainer,
			List<Node> listOfNodes,
			Set<String> redactSectionCodesAndGeneratedEntryIds,
			Set<String> redactSensitiveCategoryCodes); }
HumanReadableContentElementById extends
		AbstractClinicalFactLevelRedactionHandler { @Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, ClinicalFact fact, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds, Set<String> redactSensitiveCategoryCodes) throws XPathExpressionException { String foundCategory = findMatchingCategory(xacmlResult, fact); if (foundCategory != null) { NodeList references = getEntryReferenceIdNodeList( factModelDocument, fact); for (int i = 0; i < references.getLength(); i++) { addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE, fact.getEntry(), references.item(i).getNodeValue()); addNodesToList(xmlDocument, listOfNodes, redactSectionCodesAndGeneratedEntryIds, XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE, fact.getEntry(), references.item(i).getNodeValue()); } redactSensitiveCategoryCodes.add(foundCategory); } } HumanReadableContentElementById(
			DocumentAccessor documentAccessor); @Override void execute(Document xmlDocument, XacmlResult xacmlResult,
			FactModel factModel, Document factModelDocument, ClinicalFact fact,
			RuleExecutionContainer ruleExecutionContainer,
			List<Node> listOfNodes,
			Set<String> redactSectionCodesAndGeneratedEntryIds,
			Set<String> redactSensitiveCategoryCodes); static final String XPATH_HUMAN_READABLE_CONTENT_ELEMENT_BY_REFERENCE; static final String XPATH_HUMAN_READABLE_CONTENT_ELEMENT_NEXT_TEXT_NODE; }