@Test
public void testCreateConsentDirective() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, SAXException, IOException{

	OrganizationPolicy orgPolicy=new OrganizationPolicy();
	Field usPrivacyLaw=orgPolicy.getClass().getDeclaredField("usPrivacyLaw");
	usPrivacyLaw.setAccessible(true);
	usPrivacyLaw.set(orgPolicy, "Title38Section7332");
	
	List<String> maskingActions=new ArrayList<String>();
	maskingActions.add("action1");
	maskingActions.add("action2");
	
	Addr addr=new Addr();
	addr.setCity("Columbia");
	addr.setCountry("United States");
	addr.setCounty("Howard");
	addr.setPostalCode("21044");
	addr.setState("MD");
	addr.setStreetAddressLine("7175 Columbia Gateway Dr.");
	Field organizationConsentPolicyInfo=orgPolicy.getClass().getDeclaredField("organizationConsentPolicyInfo");
	OrganizationConsentPolicyInfo organizationConsentPolicyInfoField=new OrganizationConsentPolicyInfo();
	DefaultPatientDemographics defaultPatientDemographics=new DefaultPatientDemographics();
	defaultPatientDemographics.setAddr(addr);
	organizationConsentPolicyInfoField.setDefaultPatientDemographics(defaultPatientDemographics);
	
	Name name=new Name();
	name.setFamily("Smith");
	name.setGiven("Albert");
	AssignedPerson person=new AssignedPerson();
	person.setName(name);
	AssignedAuthor assignedAuthor=new AssignedAuthor();
	assignedAuthor.setAssignedPerson(person);
	
	ManufacturingModelName manufacturingModelName=new ManufacturingModelName();
	manufacturingModelName.setCode("1");
	manufacturingModelName.setDisplayName("Company One");
	SoftwareName softwareName=new SoftwareName();
	softwareName.setCode("2");
	softwareName.setDisplayName("Software Company");
	AssignedAuthoringDevice assignedAuthoringDevice=new AssignedAuthoringDevice();
	assignedAuthoringDevice.setManufacturingModelName(manufacturingModelName);
	assignedAuthoringDevice.setSoftwareName(softwareName);
	
	DefaultCustodianInfo defaultCustodianInfo=new DefaultCustodianInfo();
	defaultCustodianInfo.setTelcom("telcom");
	organizationConsentPolicyInfoField.setDefaultCustodianInfo(defaultCustodianInfo);
	
	
	organizationConsentPolicyInfoField.setAssignedAuthor(assignedAuthor);
	organizationConsentPolicyInfoField.setAssignedAuthoringDevice(assignedAuthoringDevice);
	organizationConsentPolicyInfo.setAccessible(true);
	organizationConsentPolicyInfo.set(orgPolicy, organizationConsentPolicyInfoField);
	
	List<String> redactActions=new ArrayList<String>();
	redactActions.add("action1");
	redactActions.add("action2");
	List<String> ignoredTags=new ArrayList<String>();
	ignoredTags.add("effectiveTime");
	XmlComparator.compareXMLs("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n<ClinicalDocument moodCode=\"EVN\" classCode=\"DOCCLIN\" xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n    <realmCode code=\"US\"/>\r\n    <typeId extension=\"09230\" root=\"2.16.840.1.113883.1.3\"/>\r\n    <templateId root=\"2.16.840.1.113883.10.20.3\"/>\r\n    <templateId root=\"2.16.840.1.113883.3.445.1\"/>\r\n    <id extension=\"221\" root=\"1.3.6.4.1.4.1.2835.888888\"/>\r\n    <code displayName=\"Privacy Policy Acknowledgement Document\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"57016-8\"/>\r\n    <title mediaType=\"text/plain\" representation=\"TXT\">Privacy Consent Authorization</title>\r\n    <effectiveTime value=\"20131230032417\"/>\r\n    <confidentialityCode displayName=\"R (restricted)\" codeSystemVersion=\"3.0\" codeSystemName=\"Confidentiality\" codeSystem=\"2.16.840.1.113883.5.25\" code=\"R\"/>\r\n    <recordTarget>\r\n        <patientRole>\r\n            <id extension=\"1\"/>\r\n            <addr>\r\n                <streetAddressLine xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">7175 Columbia Gateway Dr.</streetAddressLine>\r\n                <city xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Columbia</city>\r\n                <state xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">MD</state>\r\n                <postalCode xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">21044</postalCode>\r\n                <county xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Howard</county>\r\n                <country xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">United States</country>\r\n            </addr>\r\n            <patient>\r\n                <name>\r\n                    <given xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Albert</given>\r\n                    <family xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Smith</family>\r\n                </name>\r\n                <administrativeGenderCode code=\"M\"/>\r\n                <birthTime value=\"03-10-1982\"/>\r\n            </patient>\r\n        </patientRole>\r\n    </recordTarget>\r\n    <author>\r\n        <typeId root=\"2.16.840.1.113883.3.445.2\"/>\r\n        <time value=\"20131230032417\"/>\r\n        <assignedAuthor classCode=\"PSN\">\r\n            <typeId extension=\"999999999^^^&amp;null&amp;ISO\" root=\"1.3.5.35.1.4436.7\"/>\r\n            <assignedPerson>\r\n                <name>\r\n                    <given xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Albert</given>\r\n                    <family xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Smith</family>\r\n                </name>\r\n            </assignedPerson>\r\n            <assignedAuthoringDevice>\r\n                <manufacturerModelName displayName=\"Company One\" code=\"1\"/>\r\n                <softwareName displayName=\"Software Company\" code=\"2\"/>\r\n            </assignedAuthoringDevice>\r\n        </assignedAuthor>\r\n    </author>\r\n    <custodian>\r\n        <assignedCustodian>\r\n            <representedCustodianOrganization>\r\n                <name use=\"\"/>\r\n                <telecom value=\"telcom\"/>\r\n            </representedCustodianOrganization>\r\n        </assignedCustodian>\r\n    </custodian>\r\n    <informationRecipient typeCode=\"PRCP\">\r\n        <intendedRecipient>\r\n            <typeId extension=\"7878\"/>\r\n            <receivedOrganization determinerCode=\"INSTANCE\" classCode=\"ORG\">\r\n                <typeId root=\"2.16.840.1.113883.4.349\"/>\r\n            </receivedOrganization>\r\n        </intendedRecipient>\r\n    </informationRecipient>\r\n    <legalAuthenticator>\r\n        <time value=\"20131230032417\"/>\r\n        <signatureCode code=\"S\"/>\r\n        <assignedEntity>\r\n            <addr>\r\n                <streetAddressLine xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">7175 Columbia Gateway Dr.</streetAddressLine>\r\n                <city xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Columbia</city>\r\n                <state xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">MD</state>\r\n                <postalCode xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">21044</postalCode>\r\n                <county xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Howard</county>\r\n                <country xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">United States</country>\r\n            </addr>\r\n            <assignedPerson>\r\n                <name>\r\n                    <given xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Albert</given>\r\n                    <family xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">Smith</family>\r\n                </name>\r\n            </assignedPerson>\r\n        </assignedEntity>\r\n    </legalAuthenticator>\r\n    <documentationOf typeCode=\"DOC\">\r\n        <serviceEvent moodCode=\"EVN\">\r\n            <templateId root=\"2.16.840.1.113883.3.445.3\"/>\r\n            <id root=\"2.16.840.1.113883.3.72.4.2.5\"/>\r\n            <code displayName=\"Privacy Policy Acknowledgement Document\" codeSystemName=\"LOINC\" codeSystem=\"2.16.840.1.113883.6.1\" code=\"57016-8\"/>\r\n            <effectiveTime>\r\n                <low xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">20131230</low>\r\n                <high xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">20181230</high>\r\n            </effectiveTime>\r\n        </serviceEvent>\r\n    </documentationOf>\r\n    <component>\r\n        <structuredBody>\r\n            <component typeCode=\"COMP\">\r\n                <section moodCode=\"EVN\" classCode=\"DOCSECT\">\r\n                    <templateId root=\"2.16.840.1.113883.3.445.17\"/>\r\n                    <title>Consent Directive Detail</title>\r\n                    <confidentialityCode displayName=\"R (restricted)\" codeSystemVersion=\"3.0\" codeSystemName=\"Confidentiality\" codeSystem=\"2.16.840.1.113883.5.25\" code=\"R\"/>\r\n                    <entry typeCode=\"COMP\">\r\n                        <typeId root=\"2.16.840.1.113883.3.445.4\"/>\r\n                        <act>\r\n                            <typeId root=\"2.16.840.1.113883.3.445.4\"/>\r\n                            <code displayName=\"intendedPOU\" codeSystemName=\"ActReason\" codeSystem=\"2.16.840.1.113883.5.8\" code=\"intendedPOU\"/>\r\n                            <statusCode code=\"active\"/>\r\n                            <participant typeCode=\"IRCP\">\r\n                                <typeId root=\"2.16.840.1.113883.3.445.5\"/>\r\n                            </participant>\r\n                            <entryRelationship contextConductionInd=\"true\" typeCode=\"COMP\">\r\n                                <act negationInd=\"true\" moodCode=\"DEF\" classCode=\"ACT\">\r\n                                    <code displayName=\"Disclose\" codeSystemName=\"ActConsentType\" codeSystem=\"2.16.840.1.113883.5.4\" code=\"DISCLOSE\"/>\r\n                                </act>\r\n                            </entryRelationship>\r\n                            <entryRelationship contextConductionInd=\"true\" typeCode=\"COMP\">\r\n                                <templateId root=\"2.16.840.1.113883.3.445.13\"/>\r\n                                <act moodCode=\"DEF\" classCode=\"CONS\">\r\n                                    <code displayName=\"Title38Section7332\" codeSystemName=\"ActUSPrivacyLaw\" codeSystem=\"2.16.840.1.113883.5.1138\" code=\"Title38Section7332\"/>\r\n                                    <precondition>\r\n                                        <templateId root=\"2.16.840.1.113883.3.445.14\"/>\r\n                                        <criterion moodCode=\"EVN.CRT\" classCode=\"OBS\">\r\n                                            <code displayName=\"NORDSCLCD\" codeSystemName=\"RefrainPolicy\" codeSystem=\"2.16.840.1.113883.1.11.20446\" code=\"NORDSCLCD\"/>\r\n                                        </criterion>\r\n                                    </precondition>\r\n                                </act>\r\n                            </entryRelationship>\r\n                            <entryRelationship>\r\n                                <templateId root=\"2.16.840.1.113883.3.445.15\"/>\r\n                                <observationMedia moodCode=\"EVN\" classCode=\"OBS\">\r\n                                    <value mediaType=\"application/pdf\" representation=\"B_64\">cGRmU3RyaW5n</value>\r\n                                </observationMedia>\r\n                            </entryRelationship>\r\n                            <entryRelationship>\r\n                                <templateId root=\"2.16.840.1.113883.3.445.16\"/>\r\n                                <observationMedia moodCode=\"EVN\" classCode=\"OBS\">\r\n                                    <value mediaType=\"application/xacml+xml\" representation=\"B_64\">WEFDTUxWYWx1ZQ==</value>\r\n                                </observationMedia>\r\n                            </entryRelationship>\r\n                            <precondition>\r\n                                <typeId root=\"2.16.840.1.113883.3.445.12\"/>\r\n                                <criterion moodCode=\"EVN.CRT\" classCode=\"COND\">\r\n                                    <code displayName=\"action1\" codeSystemName=\"ActInformationSensitivity\" codeSystem=\"2.16.840.1.113883.1.11.20429\" code=\"action1\"/>\r\n                                </criterion>\r\n                            </precondition>\r\n                            <precondition>\r\n                                <typeId root=\"2.16.840.1.113883.3.445.12\"/>\r\n                                <criterion moodCode=\"EVN.CRT\" classCode=\"COND\">\r\n                                    <code displayName=\"action2\" codeSystemName=\"ActInformationSensitivity\" codeSystem=\"2.16.840.1.113883.1.11.20429\" code=\"action2\"/>\r\n                                </criterion>\r\n                            </precondition>\r\n                            <precondition>\r\n                                <typeId root=\"2.16.840.1.113883.3.445.12\"/>\r\n                                <criterion moodCode=\"EVN.CRT\" classCode=\"COND\">\r\n                                    <code displayName=\"action1\" codeSystemName=\"ActInformationSensitivity\" codeSystem=\"2.16.840.1.113883.1.11.20429\" code=\"action1\"/>\r\n                                </criterion>\r\n                            </precondition>\r\n                            <precondition>\r\n                                <typeId root=\"2.16.840.1.113883.3.445.12\"/>\r\n                                <criterion moodCode=\"EVN.CRT\" classCode=\"COND\">\r\n                                    <code displayName=\"action2\" codeSystemName=\"ActInformationSensitivity\" codeSystem=\"2.16.840.1.113883.1.11.20429\" code=\"action2\"/>\r\n                                </criterion>\r\n                            </precondition>\r\n                        </act>\r\n                    </entry>\r\n                </section>\r\n            </component>\r\n        </structuredBody>\r\n    </component>\r\n</ClinicalDocument>\r\n"
			, clinicalDocumentProvider.createConsentDirective(orgPolicy, 
					"Albert Smith", "1", "GlobalID", "03-10-1982", "M", 
					"authorization", "intendedPOU", null, null, 
					null, maskingActions, redactActions, "pdfString", "XACMLValue")
			, ignoredTags);
}