Search in sources :

Example 1 with DirectDocuments

use of org.nhindirect.xd.common.DirectDocuments in project nhin-d by DirectProject.

the class DefaultXdsDirectDocumentsTransformer method transform.

@Override
public DirectDocuments transform(ProvideAndRegisterDocumentSetRequestType provideAndRegisterDocumentSetRequestType) throws TransformationException {
    DirectDocuments documents = new DirectDocuments();
    try {
        documents.setValues(provideAndRegisterDocumentSetRequestType.getSubmitObjectsRequest());
    } catch (MetadataException e) {
        throw new TransformationException("Unable to complete transformation due to metadata error", e);
    }
    for (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document document : provideAndRegisterDocumentSetRequestType.getDocument()) {
        byte[] data = null;
        try {
            DataHandler dataHandler = document.getValue();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            dataHandler.writeTo(outputStream);
            data = outputStream.toByteArray();
        } catch (IOException e) {
            throw new TransformationException("Unable to complete transformation due to document IO error", e);
        }
        DirectDocument2 doc = documents.getDocumentByUniqueId(document.getId());
        if (doc != null) {
            doc.setData(data);
        } else {
            documents.getDocumentById(document.getId()).setData(data);
        }
    }
    return documents;
}
Also used : TransformationException(org.nhindirect.xd.transform.exception.TransformationException) DirectDocument2(org.nhindirect.xd.common.DirectDocument2) DirectDocuments(org.nhindirect.xd.common.DirectDocuments) DataHandler(javax.activation.DataHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) MetadataException(org.nhindirect.xd.common.exception.MetadataException) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 2 with DirectDocuments

use of org.nhindirect.xd.common.DirectDocuments in project nhin-d by DirectProject.

the class NHINDClientTest method getTestDirectDocuments.

private DirectDocuments getTestDirectDocuments() {
    // Create a collection of documents
    DirectDocuments documents = new DirectDocuments();
    documents.getSubmissionSet().setId("1");
    documents.getSubmissionSet().setName("2");
    documents.getSubmissionSet().setDescription("3");
    documents.getSubmissionSet().setSubmissionTime(new Date());
    documents.getSubmissionSet().setIntendedRecipient(Arrays.asList("5.1", "5.2"));
    documents.getSubmissionSet().setAuthorPerson("6");
    documents.getSubmissionSet().setAuthorInstitution(Arrays.asList("7.1", "7.2"));
    documents.getSubmissionSet().setAuthorRole("8");
    documents.getSubmissionSet().setAuthorSpecialty("9");
    documents.getSubmissionSet().setAuthorTelecommunication("10");
    documents.getSubmissionSet().setContentTypeCode("11");
    documents.getSubmissionSet().setContentTypeCode_localized("12");
    documents.getSubmissionSet().setUniqueId("13");
    documents.getSubmissionSet().setSourceId("14");
    documents.getSubmissionSet().setPatientId("xxx");
    DirectDocument2 doc1 = new DirectDocument2();
    doc1.setData(new String("data1").getBytes());
    DirectDocument2.Metadata metadata1 = doc1.getMetadata();
    metadata1.setMimeType("1.1");
    metadata1.setId("1.2");
    metadata1.setDescription("1.3");
    metadata1.setCreationTime(new Date());
    metadata1.setLanguageCode("1.5");
    metadata1.setServiceStartTime(new Date());
    metadata1.setServiceStopTime(new Date());
    metadata1.setSourcePatient(new SimplePerson("1.Bob", "1.Smith"));
    metadata1.setAuthorPerson("1.10");
    metadata1.setAuthorInstitution(Arrays.asList("1.11.1", "1.11.2"));
    metadata1.setAuthorRole("1.12");
    metadata1.setAuthorSpecialty("1.13");
    metadata1.setClassCode(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata1.setClassCode_localized(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata1.setConfidentialityCode("1.16");
    metadata1.setConfidentialityCode_localized("1.17");
    metadata1.setFormatCode(FormatCodeEnum.XDS_MEDICAL_SUMMARIES);
    metadata1.setHealthcareFacilityTypeCode(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata1.setHealthcareFacilityTypeCode_localized(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata1.setPracticeSettingCode(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata1.setPracticeSettingCode_localized(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata1.setLoinc(LoincEnum.LOINC_34133_9.getValue());
    metadata1.setLoinc_localized(LoincEnum.LOINC_34133_9.getValue());
    metadata1.setPatientId("xxx");
    metadata1.setUniqueId("1.27");
    DirectDocument2 doc2 = new DirectDocument2();
    doc2.setData(new String("data2").getBytes());
    DirectDocument2.Metadata metadata2 = doc2.getMetadata();
    metadata2.setMimeType("2.1");
    metadata2.setId("2.2");
    metadata2.setDescription("2.3");
    metadata2.setCreationTime(new Date());
    metadata2.setLanguageCode("2.5");
    metadata2.setServiceStartTime(new Date());
    metadata2.setServiceStopTime(new Date());
    metadata2.setSourcePatient(new SimplePerson("2.Bob", "2.Smith"));
    metadata2.setAuthorPerson("2.10");
    metadata2.setAuthorInstitution(Arrays.asList("2.11.1", "2.11.2"));
    metadata2.setAuthorRole("2.12");
    metadata2.setAuthorSpecialty("2.13");
    metadata2.setClassCode(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata2.setClassCode_localized(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata2.setConfidentialityCode("2.16");
    metadata2.setConfidentialityCode_localized("2.17");
    metadata2.setFormatCode(FormatCodeEnum.BASIC_PATIENT_PRIVACY_CONSENTS);
    metadata2.setHealthcareFacilityTypeCode(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata2.setHealthcareFacilityTypeCode_localized(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata2.setPracticeSettingCode(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata2.setPracticeSettingCode_localized(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata2.setLoinc(LoincEnum.LOINC_34133_9.getValue());
    metadata2.setLoinc_localized(LoincEnum.LOINC_34133_9.getValue());
    metadata2.setPatientId("xxx");
    metadata2.setUniqueId("2.27");
    documents.getDocuments().add(doc1);
    documents.getDocuments().add(doc2);
    return documents;
}
Also used : DirectDocument2(org.nhindirect.xd.common.DirectDocument2) DirectDocuments(org.nhindirect.xd.common.DirectDocuments) Date(java.util.Date) SimplePerson(org.nhindirect.xd.transform.pojo.SimplePerson)

Example 3 with DirectDocuments

use of org.nhindirect.xd.common.DirectDocuments in project nhin-d by DirectProject.

the class DocumentRepositoryAbstract method provideAndRegisterDocumentSet.

/**
     * Handle an incoming ProvideAndRegisterDocumentSetRequestType object and
     * transform to XDM or relay to another XDR endponit.
     * 
     * @param prdst
     *            The incoming ProvideAndRegisterDocumentSetRequestType object
     * @return a RegistryResponseType object
     * @throws Exception
     */
protected RegistryResponseType provideAndRegisterDocumentSet(ProvideAndRegisterDocumentSetRequestType prdst) throws Exception {
    RegistryResponseType resp = null;
    try {
        getHeaderData();
        @SuppressWarnings("unused") InitialContext ctx = new InitialContext();
        DirectDocuments documents = xdsDirectDocumentsTransformer.transform(prdst);
        List<String> forwards = new ArrayList<String>();
        // Get endpoints (first check direct:to header, then go to intendedRecipients)
        if (StringUtils.isNotBlank(directTo))
            forwards = Arrays.asList((new URI(directTo).getSchemeSpecificPart()));
        else {
            forwards = ParserHL7.parseRecipients(documents);
        }
        messageId = UUID.randomUUID().toString();
        // TODO patID and subsetId
        String patId = "PATID TBD";
        String subsetId = "SUBSETID";
        getAuditMessageGenerator().provideAndRegisterAudit(messageId, remoteHost, endpoint, to, thisHost, patId, subsetId, pid);
        // Send to SMTP endpoints
        if (getResolver().hasSmtpEndpoints(forwards)) {
            // Get a reply address (first check direct:from header, then go to authorPerson)
            if (StringUtils.isNotBlank(directFrom))
                replyEmail = (new URI(directFrom)).getSchemeSpecificPart();
            else {
                replyEmail = documents.getSubmissionSet().getAuthorPerson();
                replyEmail = StringUtils.splitPreserveAllTokens(replyEmail, "^")[0];
                replyEmail = StringUtils.contains(replyEmail, "@") ? replyEmail : "nhindirect@nhindirect.org";
            }
            LOGGER.info("SENDING EMAIL TO " + getResolver().getSmtpEndpoints(forwards) + " with message id " + messageId);
            // Construct message wrapper
            DirectMessage message = new DirectMessage(replyEmail, getResolver().getSmtpEndpoints(forwards));
            message.setSubject("XD* Originated Message");
            message.setBody("Please find the attached XDM file.");
            message.setDirectDocuments(documents);
            // Send mail
            MailClient mailClient = getMailClient();
            mailClient.mail(message, messageId, suffix);
        }
        // Send to XD endpoints
        for (String reqEndpoint : getResolver().getXdEndpoints(forwards)) {
            String endpointUrl = getResolver().resolve(reqEndpoint);
            String to = StringUtils.remove(endpointUrl, "?wsdl");
            Long threadId = new Long(Thread.currentThread().getId());
            LOGGER.info("THREAD ID " + threadId);
            ThreadData threadData = new ThreadData(threadId);
            threadData.setTo(to);
            List<Document> docs = prdst.getDocument();
            // Make a copy of the original documents
            List<Document> originalDocs = new ArrayList<Document>();
            for (Document d : docs) originalDocs.add(d);
            // Clear document list
            docs.clear();
            // Re-add documents
            for (Document d : originalDocs) {
                Document doc = new Document();
                doc.setId(d.getId());
                DataHandler dh = d.getValue();
                ByteArrayOutputStream buffOS = new ByteArrayOutputStream();
                dh.writeTo(buffOS);
                byte[] buff = buffOS.toByteArray();
                DataSource source = new ByteArrayDataSource(buff, documents.getDocument(d.getId()).getMetadata().getMimeType());
                DataHandler dhnew = new DataHandler(source);
                doc.setValue(dhnew);
                docs.add(doc);
            }
            LOGGER.info(" SENDING TO ENDPOINT " + to);
            DocumentRepositoryProxy proxy = new DocumentRepositoryProxy(endpointUrl, new DirectSOAPHandlerResolver());
            RegistryResponseType rrt = proxy.provideAndRegisterDocumentSetB(prdst);
            String test = rrt.getStatus();
            if (test.indexOf("Failure") >= 0) {
                String error = "";
                try {
                    error = rrt.getRegistryErrorList().getRegistryError().get(0).getCodeContext();
                } catch (Exception x) {
                }
                throw new Exception("Failure Returned from XDR forward:" + error);
            }
            getAuditMessageGenerator().provideAndRegisterAuditSource(messageId, remoteHost, endpoint, to, thisHost, patId, subsetId, pid);
        }
        resp = getRepositoryProvideResponse(messageId);
        relatesTo = messageId;
        action = "urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-bResponse";
        to = endpoint;
        setHeaderData();
    } catch (Exception e) {
        e.printStackTrace();
        throw (e);
    }
    return resp;
}
Also used : DirectMessage(org.nhindirect.xd.common.DirectMessage) ArrayList(java.util.ArrayList) DataHandler(javax.activation.DataHandler) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document) URI(java.net.URI) InitialContext(javax.naming.InitialContext) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) DataSource(javax.activation.DataSource) DirectDocuments(org.nhindirect.xd.common.DirectDocuments) MailClient(org.nhind.xdm.MailClient) SmtpMailClient(org.nhind.xdm.impl.SmtpMailClient) DirectSOAPHandlerResolver(org.nhindirect.xd.soap.DirectSOAPHandlerResolver) ThreadData(org.nhindirect.xd.soap.ThreadData) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) RegistryResponseType(oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType) DocumentRepositoryProxy(org.nhindirect.xd.proxy.DocumentRepositoryProxy)

Example 4 with DirectDocuments

use of org.nhindirect.xd.common.DirectDocuments in project nhin-d by DirectProject.

the class DefaultMimeXdsTransformer method transform.

/*
     * (non-Javadoc)
     * 
     * @see org.nhindirect.transform.MimeXdsTransformer#transform(javax.mail.internet.MimeMessage)
     */
@Override
public ProvideAndRegisterDocumentSetRequestType transform(MimeMessage mimeMessage) throws TransformationException {
    ProvideAndRegisterDocumentSetRequestType request;
    DirectDocuments documents = new DirectDocuments();
    byte[] xdsDocument = null;
    String xdsMimeType = null;
    FormatCodeEnum xdsFormatCode = null;
    DirectDocumentType documentType = null;
    try {
        Date sentDate = mimeMessage.getSentDate();
        String subject = mimeMessage.getSubject();
        String from = mimeMessage.getFrom()[0].toString();
        Address[] recipients = mimeMessage.getAllRecipients();
        // Plain mail (no attachments)
        if (MimeType.TEXT_PLAIN.matches(mimeMessage.getContentType())) {
            LOGGER.info("Handling plain mail (no attachments) - " + mimeMessage.getContentType());
            // Get the document type
            documentType = DirectDocumentType.lookup(mimeMessage);
            // Get the format code and MIME type
            xdsFormatCode = documentType.getFormatCode();
            xdsMimeType = documentType.getMimeType().getType();
            // Get the contents
            xdsDocument = ((String) mimeMessage.getContent()).getBytes();
            // Add document to the collection of documents
            documents.getDocuments().add(getDocument(sentDate, from, xdsMimeType, xdsFormatCode, xdsDocument, documentType));
            documents.setSubmissionSet(getSubmissionSet(subject, sentDate, from, recipients, xdsDocument, documentType));
        } else // Multipart/mixed (attachments)
        if (MimeType.MULTIPART.matches(mimeMessage.getContentType())) {
            LOGGER.info("Handling multipart/mixed - " + mimeMessage.getContentType());
            MimeMultipart mimeMultipart = (MimeMultipart) mimeMessage.getContent();
            BodyPart xdmBodyPart = null;
            for (int i = 0; i < mimeMultipart.getCount(); i++) {
                //check for XDM
                BodyPart bodyPart = mimeMultipart.getBodyPart(i);
                documentType = DirectDocumentType.lookup(bodyPart);
                if (DirectDocumentType.XDM.equals(documentType)) {
                    xdmBodyPart = bodyPart;
                }
            }
            // For each BodyPart
            for (int i = 0; i < mimeMultipart.getCount(); i++) {
                /*
                     * Special handling for XDM attachments.
                     * 
                     * Spec says if XDM package is present, this will be the
                     * only attachment.
                     * 
                     * Overwrite all documents with XDM content and then break
                     */
                if (xdmBodyPart != null) {
                    XdmPackage xdmPackage = XdmPackage.fromXdmZipDataHandler(xdmBodyPart.getDataHandler());
                    // Spec says if XDM package is present, this will be the only attachment
                    // Overwrite all documents with XDM content and then break
                    System.out.println("XDM FILE FOUND");
                    documents = xdmPackage.getDocuments();
                    break;
                }
                BodyPart bodyPart = mimeMultipart.getBodyPart(i);
                // Skip empty BodyParts
                if (bodyPart.getSize() <= 0) {
                    LOGGER.warn("Empty body, skipping");
                    continue;
                }
                // Get the document type
                documentType = DirectDocumentType.lookup(bodyPart);
                if (LOGGER.isInfoEnabled()) {
                    LOGGER.info("File name: " + bodyPart.getFileName());
                }
                if (LOGGER.isInfoEnabled()) {
                    LOGGER.info("Content type: " + bodyPart.getContentType());
                }
                if (LOGGER.isInfoEnabled()) {
                    LOGGER.info("DocumentType: " + documentType.toString());
                }
                // Get the format code and MIME type
                xdsFormatCode = documentType.getFormatCode();
                xdsMimeType = documentType.getMimeType().getType();
                // Best guess for UNKNOWN MIME type
                if (DirectDocumentType.UNKNOWN.equals(documentType)) {
                    xdsMimeType = bodyPart.getContentType();
                }
                // Get the contents
                xdsDocument = read(bodyPart);
                // Add the document to the collection of documents
                documents.getDocuments().add(getDocument(sentDate, from, xdsMimeType, xdsFormatCode, xdsDocument, documentType));
                documents.setSubmissionSet(getSubmissionSet(subject, sentDate, from, recipients, xdsDocument, documentType));
            }
        } else {
            if (LOGGER.isWarnEnabled()) {
                LOGGER.warn("Message content type (" + mimeMessage.getContentType() + ") is not supported, skipping");
            }
        }
    } catch (MessagingException e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unexpected MessagingException occured while handling MimeMessage", e);
        }
        throw new TransformationException("Unable to complete transformation.", e);
    } catch (IOException e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unexpected IOException occured while handling MimeMessage", e);
        }
        throw new TransformationException("Unable to complete transformation.", e);
    } catch (Exception e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unexpected Exception occured while handling MimeMessage", e);
        }
        throw new TransformationException("Unable to complete transformation", e);
    }
    try {
        request = documents.toProvideAndRegisterDocumentSetRequestType();
    } catch (IOException e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unexpected IOException occured while transforming to ProvideAndRegisterDocumentSetRequestType", e);
        }
        throw new TransformationException("Unable to complete transformation", e);
    }
    return request;
}
Also used : BodyPart(javax.mail.BodyPart) TransformationException(org.nhindirect.xd.transform.exception.TransformationException) Address(javax.mail.Address) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException) Date(java.util.Date) MessagingException(javax.mail.MessagingException) IOException(java.io.IOException) TransformationException(org.nhindirect.xd.transform.exception.TransformationException) DirectDocumentType(org.nhindirect.xd.common.type.DirectDocumentType) MimeMultipart(javax.mail.internet.MimeMultipart) DirectDocuments(org.nhindirect.xd.common.DirectDocuments) FormatCodeEnum(org.nhindirect.xd.common.type.FormatCodeEnum) XdmPackage(org.nhindirect.xd.common.XdmPackage) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 5 with DirectDocuments

use of org.nhindirect.xd.common.DirectDocuments in project nhin-d by DirectProject.

the class DefaultXdsXdmTransformerTest method testTransform.

public void testTransform() throws Exception {
    // Create a collection of documents
    DirectDocuments documents = new DirectDocuments();
    documents.getSubmissionSet().setId("1");
    documents.getSubmissionSet().setName("2");
    documents.getSubmissionSet().setDescription("3");
    documents.getSubmissionSet().setSubmissionTime(new Date());
    documents.getSubmissionSet().setIntendedRecipient(Arrays.asList("5.1", "5.2"));
    documents.getSubmissionSet().setAuthorPerson("6");
    documents.getSubmissionSet().setAuthorInstitution(Arrays.asList("7.1", "7.2"));
    documents.getSubmissionSet().setAuthorRole("8");
    documents.getSubmissionSet().setAuthorSpecialty("9");
    documents.getSubmissionSet().setAuthorTelecommunication("10");
    documents.getSubmissionSet().setContentTypeCode("11");
    documents.getSubmissionSet().setContentTypeCode_localized("12");
    documents.getSubmissionSet().setUniqueId("13");
    documents.getSubmissionSet().setSourceId("14");
    documents.getSubmissionSet().setPatientId("xxx");
    DirectDocument2 doc1 = new DirectDocument2();
    doc1.setData(new String("data1").getBytes());
    DirectDocument2.Metadata metadata1 = doc1.getMetadata();
    metadata1.setMimeType("text/xml");
    metadata1.setId("1.2");
    metadata1.setDescription("1.3");
    metadata1.setCreationTime(new Date());
    metadata1.setLanguageCode("1.5");
    metadata1.setServiceStartTime(new Date());
    metadata1.setServiceStopTime(new Date());
    metadata1.setSourcePatient(new SimplePerson("1.Bob", "1.Smith"));
    metadata1.setAuthorPerson("1.10");
    metadata1.setAuthorInstitution(Arrays.asList("1.11.1", "1.11.2"));
    metadata1.setAuthorRole("1.12");
    metadata1.setAuthorSpecialty("1.13");
    metadata1.setClassCode(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata1.setClassCode_localized(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata1.setConfidentialityCode("1.16");
    metadata1.setConfidentialityCode_localized("1.17");
    metadata1.setFormatCode(FormatCodeEnum.HL7_CCD_DOCUMENT);
    metadata1.setHealthcareFacilityTypeCode(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata1.setHealthcareFacilityTypeCode_localized(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata1.setPracticeSettingCode(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata1.setPracticeSettingCode_localized(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata1.setLoinc(LoincEnum.LOINC_34133_9.getValue());
    metadata1.setLoinc_localized(LoincEnum.LOINC_34133_9.getValue());
    metadata1.setPatientId("xxx");
    metadata1.setUniqueId("1.27");
    DirectDocument2 doc2 = new DirectDocument2();
    doc2.setData(new String("data2").getBytes());
    DirectDocument2.Metadata metadata2 = doc2.getMetadata();
    metadata2.setMimeType("text/xml");
    metadata2.setId("2.2");
    metadata2.setDescription("2.3");
    metadata2.setCreationTime(new Date());
    metadata2.setLanguageCode("2.5");
    metadata2.setServiceStartTime(new Date());
    metadata2.setServiceStopTime(new Date());
    metadata2.setSourcePatient(new SimplePerson("2.Bob", "2.Smith"));
    metadata2.setAuthorPerson("2.10");
    metadata2.setAuthorInstitution(Arrays.asList("2.11.1", "2.11.2"));
    metadata2.setAuthorRole("2.12");
    metadata2.setAuthorSpecialty("2.13");
    metadata2.setClassCode(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata2.setClassCode_localized(ClassCodeEnum.HISTORY_AND_PHYSICAL.getValue());
    metadata2.setConfidentialityCode("2.16");
    metadata2.setConfidentialityCode_localized("2.17");
    metadata2.setFormatCode(FormatCodeEnum.IMMUNIZATION_REGISTRY_CONTENT_CRC);
    metadata2.setHealthcareFacilityTypeCode(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata2.setHealthcareFacilityTypeCode_localized(HealthcareFacilityTypeCodeEnum.OF.getValue());
    metadata2.setPracticeSettingCode(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata2.setPracticeSettingCode_localized(PracticeSettingCodeEnum.MULTIDISCIPLINARY.getValue());
    metadata2.setLoinc(LoincEnum.LOINC_34133_9.getValue());
    metadata2.setLoinc_localized(LoincEnum.LOINC_34133_9.getValue());
    metadata2.setPatientId("xxx");
    metadata2.setUniqueId("2.27");
    documents.getDocuments().add(doc1);
    documents.getDocuments().add(doc2);
    ProvideAndRegisterDocumentSetRequestType request = documents.toProvideAndRegisterDocumentSetRequestType();
    QName qname = new QName("urn:ihe:iti:xds-b:2007", "ProvideAndRegisterDocumentSet_bRequest");
    String body = XmlUtils.marshal(qname, request, ihe.iti.xds_b._2007.ObjectFactory.class);
    System.out.println(body);
    XdsXdmTransformer transformer = new DefaultXdsXdmTransformer();
    File f = transformer.transform(request);
    System.out.println(f.getAbsolutePath());
}
Also used : QName(javax.xml.namespace.QName) XdsXdmTransformer(org.nhindirect.xd.transform.XdsXdmTransformer) Date(java.util.Date) DirectDocument2(org.nhindirect.xd.common.DirectDocument2) DirectDocuments(org.nhindirect.xd.common.DirectDocuments) File(java.io.File) SimplePerson(org.nhindirect.xd.transform.pojo.SimplePerson) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Aggregations

DirectDocuments (org.nhindirect.xd.common.DirectDocuments)7 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Date (java.util.Date)3 DataHandler (javax.activation.DataHandler)3 DirectDocument2 (org.nhindirect.xd.common.DirectDocument2)3 Document (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document)2 IOException (java.io.IOException)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 DataSource (javax.activation.DataSource)2 ByteArrayDataSource (javax.mail.util.ByteArrayDataSource)2 InitialContext (javax.naming.InitialContext)2 RegistryResponseType (oasis.names.tc.ebxml_regrep.xsd.rs._3.RegistryResponseType)2 MailClient (org.nhind.xdm.MailClient)2 SmtpMailClient (org.nhind.xdm.impl.SmtpMailClient)2 DirectMessage (org.nhindirect.xd.common.DirectMessage)2 XdmPackage (org.nhindirect.xd.common.XdmPackage)2 DocumentRepositoryProxy (org.nhindirect.xd.proxy.DocumentRepositoryProxy)2 DirectSOAPHandlerResolver (org.nhindirect.xd.soap.DirectSOAPHandlerResolver)2