Skip to content

Commit

Permalink
[26471] Seitengrösse-Einstellungen für ARTICLE_MEDIC_LABEL (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daksic28 authored and huthomas committed Jul 5, 2024
1 parent c869c6d commit ff9ec74
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
package ch.itmed.fop.printing.xml.documents;

import java.io.InputStream;
import java.util.Optional;

import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import ch.elexis.core.model.IArticle;
import ch.elexis.core.model.IArticleDefaultSignature;
import ch.itmed.fop.printing.preferences.PreferenceConstants;
import ch.itmed.fop.printing.xml.elements.ArticlesElement;
import ch.itmed.fop.printing.xml.elements.MandatorElement;
Expand Down Expand Up @@ -55,9 +58,16 @@ public static InputStream create(boolean includeMedication) throws Exception {

public static InputStream create(IArticle article) throws Exception {
Document doc = DomDocument.newDocument();

Optional<IArticleDefaultSignature> signatureOpt = ArticlesElement.getDefaultSignature(article);
Element page = PageProperties.setProperties(doc, PreferenceConstants.ARTICLE_LABEL);
PageProperties.setCurrentDate(page);
if (signatureOpt.isPresent()) {
IArticleDefaultSignature signature = signatureOpt.get();
String dosageInstructions = signature.getComment();
if (StringUtils.isNotBlank(dosageInstructions)) {
page = PageProperties.setProperties(doc, PreferenceConstants.ARTICLE_MEDIC_LABEL);
PageProperties.setCurrentDate(page);
}
}
doc.appendChild(page);
Element patient = PatientElement.create(doc, false);
page.appendChild(patient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

Expand Down Expand Up @@ -57,11 +58,11 @@ private static Element createArticleElement(Document doc, IArticle article) {
appendChildWithText(doc, articleElement, "Name", articleData.getName()); //$NON-NLS-1$
appendChildWithText(doc, articleElement, "Price", articleData.getPrice()); //$NON-NLS-1$
appendChildWithText(doc, articleElement, "DeliveryDate", articleData.getDeliveryDate()); //$NON-NLS-1$
Optional<IArticleDefaultSignature> signatureOpt = MedicationServiceHolder.get().getDefaultSignature(article);
Optional<IArticleDefaultSignature> signatureOpt = getDefaultSignature(article);
if (signatureOpt.isPresent()) {
IArticleDefaultSignature signature = signatureOpt.get();
String dosageInstructions = signature.getComment();
if (dosageInstructions != null && !dosageInstructions.isEmpty()) {
if (StringUtils.isNotBlank(dosageInstructions)) {
appendChildWithText(doc, articleElement, "DosageInstructions", dosageInstructions); //$NON-NLS-1$
appendDoseTable(doc, articleElement, signature);
}
Expand Down Expand Up @@ -97,4 +98,8 @@ private static boolean isMedication(ArticleData ad, ConsultationData cd) {
}
return false;
}

public static Optional<IArticleDefaultSignature> getDefaultSignature(IArticle article) {
return MedicationServiceHolder.get().getDefaultSignature(article);
}
}

0 comments on commit ff9ec74

Please sign in to comment.