XACMLPolicyProviderForCDA { public String createPatientConsentXACMLPolicy(OrganizationPolicy orgPolicy, String patientId, String authorization, List<String> allowedPOU, List<String> allowedRecipients, List<String> redactActions, List<String> maskingActions) { String res = ""; createPolicySetHeader(patientId, orgPolicy.getHomeCommunityId()); createPolicyHeader(); createPolicyTarget(); createRuleAuthorization(); createRuleAllowedPOU(allowedPOU); createRuleAllowedRecipients(allowedRecipients); createRuleRequiredSensitivityPermissions(maskingActions); createEndPolicy(); if (!redactActions.isEmpty()) { createObligationPolicyRedact(redactActions); } if (!maskingActions.isEmpty()) { createObligationPolicyMask(maskingActions); } this.orgLaw.clear(); this.refrainPolicy.clear(); this.documentHandling.clear(); getOrganizationalPolicyTags(orgPolicy, "USPrivacyLaw"); getOrganizationalPolicyTags(orgPolicy, "RefrainPolicy"); getOrganizationalPolicyTags(orgPolicy, "DocumentHandling"); if (!this.orgLaw.isEmpty()) { createObligationPolicyUSPrivacyLaw(); } if (!this.refrainPolicy.isEmpty()) { createObligationPolicyRefrain(); } if (!this.documentHandling.isEmpty()) { createObligationPolicyDocumentHandling(); } createRuleEmergency(); createEndPolicySet(); res = this.buffer.toString(); return res; }  String createPatientConsentXACMLPolicy(OrganizationPolicy orgPolicy, String patientId, String authorization, List<String> allowedPOU, List<String> allowedRecipients, List<String> redactActions, List<String> maskingActions);  }
@Test public void testCreatePatientConsentXACMLPolicy_when_all_list_are_empty() throws SAXException, IOException { String result=xACMLPolicyProviderForCDA.createPatientConsentXACMLPolicy(new OrganizationPolicy(), null, null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>()); assertXMLEqual(result,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><PolicySet xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\" xmlns:xsi=\"http: }
@Test public void testCreatePatientConsentXACMLPolicy_when_redactActions_is_not_empty() throws SAXException, IOException { List<String> redactActions=new ArrayList<String>(); redactActions.add("treatment"); redactActions.add("diagnose"); String result=xACMLPolicyProviderForCDA.createPatientConsentXACMLPolicy(new OrganizationPolicy(), null, null, new ArrayList<String>(), new ArrayList<String>(), redactActions, new ArrayList<String>()); assertXMLEqual(result,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><PolicySet xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\" xmlns:xsi=\"http: }
@Test public void testCreatePatientConsentXACMLPolicy_when_maskingActions_is_not_empty() throws SAXException, IOException { List<String> maskingActions=new ArrayList<String>(); maskingActions.add("actionA"); maskingActions.add("actionB"); String result=xACMLPolicyProviderForCDA.createPatientConsentXACMLPolicy(new OrganizationPolicy(), null, null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), maskingActions); assertXMLEqual(result,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><PolicySet xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\" xmlns:xsi=\"http: }
@Test public void testCreatePatientConsentXACMLPolicy_when_orgLaw_refrainPolicy_and_documentHandling_is_not_empty() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, SAXException, IOException { List<String> maskingActions=new ArrayList<String>(); maskingActions.add("actionA"); maskingActions.add("actionB"); OrganizationPolicy orgPolicy=new OrganizationPolicy(); Field organizationTaggingRules = orgPolicy.getClass().getDeclaredField("organizationTaggingRules"); organizationTaggingRules.setAccessible(true); List<OrganizationTaggingRules> organizationTaggingRulesValue=new ArrayList<OrganizationTaggingRules>(); OrganizationTaggingRules OrganizationTaggingRulesEntry=new OrganizationTaggingRules(); ActUSPrivacyLaw actUSPrivacyLawValue=new ActUSPrivacyLaw(); actUSPrivacyLawValue.setCode("actUSPrivacyLaw1"); OrganizationTaggingRulesEntry.setActUSPrivacyLaw(actUSPrivacyLawValue); RefrainPolicy refrainPolicyValue=new RefrainPolicy(); refrainPolicyValue.setCode("refrainPolicy1"); OrganizationTaggingRulesEntry.setRefrainPolicy(refrainPolicyValue); OrgObligationPolicyDocument orgObligationPolicyDocumentValue=new OrgObligationPolicyDocument(); ObligationPolicy obligationPolicy=new ObligationPolicy(); obligationPolicy.setCode("obligationPolicy1"); orgObligationPolicyDocumentValue.setObligationPolicy(obligationPolicy); OrganizationTaggingRulesEntry.setOrgObligationPolicyDocument(orgObligationPolicyDocumentValue); organizationTaggingRulesValue.add(OrganizationTaggingRulesEntry); organizationTaggingRules.set(orgPolicy, organizationTaggingRulesValue); String result=xACMLPolicyProviderForCDA.createPatientConsentXACMLPolicy(orgPolicy, null, null, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), maskingActions); assertXMLEqual(result,"<?xml version=\"1.0\" encoding=\"UTF-8\"?><PolicySet xmlns=\"urn:oasis:names:tc:xacml:2.0:policy:schema:os\" xmlns:xsi=\"http: }