All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.projecthusky.communication.xd.xdm.IndexHtm Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
/*
 * This code is made available under the terms of the Eclipse Public License v1.0 
 * in the github project https://github.com/project-husky/husky there you also 
 * find a list of the contributors and the license information.
 * 
 * This project has been developed further and modified by the joined working group Husky 
 * on the basis of the eHealth Connector opensource project from June 28, 2021, 
 * whereas medshare GmbH is the initial and main contributor/author of the eHealth Connector.
 *
 */
package org.projecthusky.communication.xd.xdm;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;

import org.projecthusky.common.model.VendorInformation;
import org.projecthusky.common.utils.XdsMetadataUtil;
import org.projecthusky.communication.utils.XdsUtil;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Document;
import org.openehealth.ipf.commons.ihe.xds.core.requests.ProvideAndRegisterDocumentSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * The Class IndexHtm represents the INDEX.HTM file, which is part of the
 * contents of an XDM volume. The file contains information about the contents
 * of the volume.
 */
public class IndexHtm {

	/** The HTML Footer */
	public static final String HTML_FOOTER = "\n" + "";

	/** The HTML Header (including headline) */
	public static final String HTML_HEADER = """
			
			
			
			  
			   Husky XDM Cross-Enterprise Document Media Interchange
			  
			  
			    

Husky - XDM Cross-Enterprise Document Media Interchange

"""; /** The HTML Separator for different languages inside this file */ public static final String HTML_SEPARATOR = "
"; /** The Constant TEMPLATE_DE. */ public static final String TEMPLATE_DE = """

Verwaltende Organisation

Informationen zu diesem XDM Paket in Deutsch.
Dieses XDM Paket wurde erstellt von: {0}.

Siehe {1}

Inhalt

{2}

Dieses Paket enthält {3} Dokumente in 1 Submission Set.

README Datei

Technische Details zu diesem XDM Paket und dessen Hersteller befinden sich hier: README.TXT.

"""; /** The Constant TEMPLATE_EN. */ public static final String TEMPLATE_EN = """

Institution

Information about this XDM volume in english.
This XDM volume was created by {0}.

See {1}

Contents

{2}

This volume contains {3} Documents in 1 Submission Set.

h3>README File

For technical details about this volume and vendor information, see: README.TXT.

"""; /** The Constant TEMPLATE_FR. */ public static final String TEMPLATE_FR = """

Organisme de gestion

Informations sur ce volume XDM en français.
Ce volume XDM a été créée par {0}.

Voir {1}

Contenu

{2}

Ce volume contient {3} Dokumente en 1 Submission Set.

Fichier README

Pour plus de informations techniques au sujet de ce volume et le fournisseur, voir: README.TXT.

"""; /** The SLF4J logger instance. */ private final Logger log = LoggerFactory.getLogger(getClass()); /** The inputStream. */ private InputStream inputStream = null; /** * Instantiates a new indexHtm. * * @param indexHtmStream the INDEX.HTM file as InputStream object. The file * contains information about the contents of the volume. */ public IndexHtm(InputStream indexHtmStream) { this.inputStream = indexHtmStream; } /** * Creates a new INDEX.HTM based on the given txnData. * * @param txnData the SubmitTransactionData data */ public IndexHtm(ProvideAndRegisterDocumentSet txnData) { this(txnData, new VendorInformation()); } /** * Creates a new INDEX.HTM based on the given txnData and vendorInfo. * * @param txnData the SubmitTransactionData data * @param vendorInfo the vendor info */ public IndexHtm(ProvideAndRegisterDocumentSet txnData, VendorInformation vendorInfo) { log.debug("Creating the Index.htm file"); Object[] values; String str; // Add html header str = HTML_HEADER; // Add html body with dynamic content values = new Object[] { vendorInfo.getVendorName(), vendorInfo.getContactInformation(), createContents(txnData), txnData.getDocuments().size() }; str = str + MessageFormat.format(TEMPLATE_EN, values); str = str + HTML_SEPARATOR; str = str + MessageFormat.format(TEMPLATE_DE, values); str = str + HTML_SEPARATOR; str = str + MessageFormat.format(TEMPLATE_FR, values); str = str + HTML_FOOTER; inputStream = new ByteArrayInputStream(str.getBytes(StandardCharsets.UTF_8)); } /** * Creates the contents. * * @param SubmitTransactionData the txn data * @return the IndexHtm contents as string */ private String createContents(ProvideAndRegisterDocumentSet txnData) { // Number of Items var contentsStr = new StringBuilder("

Submission-Set 1

\n" + "

Patient ID: " + txnData.getSubmissionSet().getPatientId().getId() + " (" + txnData.getSubmissionSet().getPatientId().getAssigningAuthority().getUniversalId() + ")" + "

\n" + "
    \n"); var i = 0; for (final Document xdsDoc : txnData.getDocuments()) { i++; if (xdsDoc != null && xdsDoc.getDocumentEntry() != null) { final var docMetadata = xdsDoc.getDocumentEntry(); var title = XdsMetadataUtil.convertInternationalStringType(docMetadata.getTitle()); if ((title == null) || "".equals(title)) { title = XdsUtil.createXdmDocName(xdsDoc, i); } contentsStr.append("
  • \n"); contentsStr.append("Document " + i + ": " + "" + title + "\n"); contentsStr.append("
  • \n"); } } contentsStr.append("
\n"); return contentsStr.toString(); } /** * Returns the content of the INDEX.HTM as InputStream object * * @return the input stream */ public InputStream getInputStream() { return inputStream; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy