ClinicalDocumentProvider { public String createConsentDirective(OrganizationPolicy orgPolicy, String patientName, String patientId, String patientIdType, String patientBirthDate, String patientGender, String authorization, String intendedPOU, List<String> allowedPOU, String primaryRecipient, List<String> allowedRecipients, List<String> maskingActions, List<String> redactActions, String pdfstring, String xacml) { String res = ""; try { this.clinicalDocument = new POCDMT000040ClinicalDocument(); this.clinicalDocument.setClassCode(ActClinicalDocument.DOCCLIN); this.clinicalDocument.getMoodCode().add("EVN"); CS realmCode = new CS(); realmCode.setCode("US"); this.clinicalDocument.getRealmCode().add(realmCode); POCDMT000040InfrastructureRootTypeId cId = new POCDMT000040InfrastructureRootTypeId(); cId.setExtension("09230"); cId.setRoot("2.16.840.1.113883.1.3"); this.clinicalDocument.setTypeId(cId); List ids = getDocumentTemplates(); Iterator iter = ids.iterator(); while (iter.hasNext()) { II i = (II)iter.next(); this.clinicalDocument.getTemplateId().add(i); } II idV = new II(); idV.setExtension("221"); idV.setRoot("1.3.6.4.1.4.1.2835.888888"); this.clinicalDocument.setId(idV); this.clinicalDocument.setCode(getDocumentCode()); this.clinicalDocument.setTitle(getDocumentTitle()); this.clinicalDocument.setEffectiveTime(getDocumentEffectiveDate()); this.clinicalDocument.setConfidentialityCode(getDocumentConfidentialityCode(orgPolicy, maskingActions, redactActions)); List<POCDMT000040RecordTarget> recordTarget = getDocumentRecordTargets(patientId, patientName, patientGender, patientBirthDate, orgPolicy); this.clinicalDocument.getRecordTarget().add(recordTarget.get(0)); POCDMT000040Author author = getDocumentAuthor(orgPolicy); this.clinicalDocument.getAuthor().add(author); POCDMT000040Custodian custodian = getDocumentCustodian(orgPolicy); this.clinicalDocument.setCustodian(custodian); POCDMT000040InformationRecipient recipient = getDocumentInformationRecipient(primaryRecipient); this.clinicalDocument.getInformationRecipient().add(recipient); POCDMT000040LegalAuthenticator authenticator = getDocumentLegalAuthenticator(orgPolicy, patientName); this.clinicalDocument.setLegalAuthenticator(authenticator); POCDMT000040DocumentationOf docOf = getDocumentDocumentOf(); this.clinicalDocument.getDocumentationOf().add(docOf); POCDMT000040Component2 comp = getDocumentComponent2(getDocumentConfidentialityCode(orgPolicy, maskingActions, redactActions), intendedPOU, authorization, orgPolicy, maskingActions, redactActions, pdfstring, xacml); this.clinicalDocument.setComponent(comp); try { res = createClinicalDocumentStringFromObject(this.clinicalDocument); } catch (Exception tEx) { res = tEx.getMessage(); } } catch (Exception ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } return res; }  POCDMT000040ClinicalDocument createClinicalDocumentFromXMLString(String xml); String createConsentDirective(OrganizationPolicy orgPolicy, String patientName, String patientId, String patientIdType, String patientBirthDate, String patientGender, String authorization, String intendedPOU, List<String> allowedPOU, String primaryRecipient, List<String> allowedRecipients, List<String> maskingActions, List<String> redactActions, String pdfstring, String xacml);  }
@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: , clinicalDocumentProvider.createConsentDirective(orgPolicy, "Albert Smith", "1", "GlobalID", "03-10-1982", "M", "authorization", "intendedPOU", null, null, null, maskingActions, redactActions, "pdfString", "XACMLValue") , ignoredTags); }