Skip to content

Commit

Permalink
[26103] always produce xml with print at intermediate false for pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
huthomas committed Jan 30, 2024
1 parent 760e50a commit 62633ba
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bundles/ch.elexis.pdfBills/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ Require-Bundle: ch.elexis.core.data;bundle-version="3.9.0",
ch.elexis.base.ch.arzttarife;bundle-version="3.9.0",
ch.elexis.ebanking.qr;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Import-Package: ch.elexis.base.ch.ebanking.esr,
Import-Package: at.medevit.elexis.tarmed.model,
ch.elexis.base.ch.ebanking.esr,
ch.elexis.core.mail,
ch.fd.invoice450.request,
org.apache.commons.io,
org.apache.commons.lang3;version="3.1.0",
org.jdom2;version="2.0.6",
org.jdom2.input;version="2.0.6",
org.jdom2.output;version="2.0.6"
Service-Component: OSGI-INF/ch.elexis.pdfBills.MailClientHolder.xml
Export-Package: ch.elexis.pdfBills,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public void run(final IProgressMonitor monitor) {

XMLExporter ex = new XMLExporter();
Document dRn = ex.doExport(rn, null, type, true);
dRn = TarmedXmlUtil.setPrintAtIntermediate(dRn, false);
monitor.worked(1);
if (invoice.getState() == InvoiceState.DEFECTIVE) {
errors++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public void run(final IProgressMonitor monitor) {
XMLExporter ex = new XMLExporter();
ex.setEsrType(EsrType.esr9);
Document dRn = ex.doExport(rn, null, type, true);
dRn = TarmedXmlUtil.setPrintAtIntermediate(dRn, false);
monitor.worked(1);
if (invoice.getState() == InvoiceState.DEFECTIVE) {
errors++;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package ch.elexis.pdfBills;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringReader;

import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.slf4j.LoggerFactory;

import at.medevit.elexis.tarmed.model.TarmedJaxbUtil;

public class TarmedXmlUtil {

/**
* Modify the print at intermediate attribute of the tarmed xml {@link Document}
* and return a modified {@link Document} object.
*
* @param document
* @param value
* @return
*/
public static Document setPrintAtIntermediate(Document document, boolean value) {
String version = TarmedJaxbUtil.getXMLVersion(document);
if ("4.5".equals(version)) {
ch.fd.invoice450.request.RequestType invoiceRequest = TarmedJaxbUtil.unmarshalInvoiceRequest450(document);
setPrintAtIntermediate(invoiceRequest, value);

ByteArrayOutputStream xmlOutput = new ByteArrayOutputStream();
if (TarmedJaxbUtil.marshallInvoiceRequest(invoiceRequest, xmlOutput)) {
SAXBuilder builder = new SAXBuilder();
try {
return builder.build(new StringReader(xmlOutput.toString()));
} catch (IOException | JDOMException e) {
LoggerFactory.getLogger(TarmedXmlUtil.class).error("Error loading existing xml document", e);
}
}
} else {
LoggerFactory.getLogger(TarmedXmlUtil.class)
.error("Could not modify xml document with version [" + version + "]");
}
return document;
}

private static void setPrintAtIntermediate(ch.fd.invoice450.request.RequestType invoiceRequest, boolean value) {
if (invoiceRequest != null && invoiceRequest.getProcessing() != null) {
invoiceRequest.getProcessing().setPrintAtIntermediate(value);
}
}
}

0 comments on commit 62633ba

Please sign in to comment.