[update] Enhance CheckUpPage by integrating ultrasound result printing functionality. Implement image selection for printing, including validation for selected images, and improve user feedback with warning messages. Update medical invoice format with new patient and service details.

This commit is contained in:
Lê Thành Đạt committed 2025-07-01 02:10:23 +07:00
1 parent f97578ad6b
commit 57a19bcbf7
10 files changed
+1713 -6

No files matched your search

+14
View File
@@ -1,6 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "test_print",
"request": "launch",
"mainClass": "BsK.client.ui.component.CheckUpPage.PrintDialog.print_forms.test_print",
"projectName": "ldS_BsK"
},
{
"type": "java",
"name": "test_print",
"request": "launch",
"mainClass": "test_print",
"projectName": "ldS_BsK"
},
{
"type": "java",
"name": "Client",
Binary file not shown.
+21
View File
@@ -246,5 +246,26 @@
<artifactId>opencv-platform</artifactId>
<version>4.9.0-1.5.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>7.0.3</version>
</dependency>
<!-- Barcode4J for JasperReports -->
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j</artifactId>
<version>2.1</version>
</dependency>
<!-- JasperReports Barcode4J Extension -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-barcode4j</artifactId>
<version>7.0.3</version>
</dependency>
</dependencies>
</project>
@@ -7,6 +7,7 @@ import BsK.client.ui.component.CheckUpPage.AddDialog.AddDialog;
import BsK.client.ui.component.CheckUpPage.HistoryViewDialog.HistoryViewDialog;
import BsK.client.ui.component.CheckUpPage.MedicineDialog.MedicineDialog;
import BsK.client.ui.component.CheckUpPage.PrintDialog.MedicineInvoice;
import BsK.client.ui.component.CheckUpPage.PrintDialog.UltrasoundResult;
import BsK.client.ui.component.CheckUpPage.ServiceDialog.ServiceDialog;
import BsK.client.ui.component.CheckUpPage.TemplateDialog.TemplateDialog;
import BsK.client.ui.component.MainFrame;
@@ -87,6 +88,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import javax.swing.JFrame;
import javax.swing.JTextPane;
import javax.swing.JToolBar;
@@ -167,6 +169,8 @@ public class CheckUpPage extends JPanel {
private JLabel overallTotalCostLabel;
private static final DecimalFormat df = new DecimalFormat("#,##0");
private List<File> selectedImagesForPrint = new ArrayList<>();
// New member variables for Supersonic View
private JPanel supersonicViewPanelGlobal;
private JPanel imageGalleryPanel; // Displays thumbnails
@@ -1328,7 +1332,35 @@ public class CheckUpPage extends JPanel {
medicineInvoice.createDialog(mainFrame);
break;
case "ultrasound":
// No dialog needed for now
if (selectedImagesForPrint.isEmpty()) {
JOptionPane.showMessageDialog(this,
"Vui lòng chọn ít nhất một hình ảnh để in kết quả.",
"Chưa chọn ảnh", JOptionPane.WARNING_MESSAGE);
return;
}
if (photoNum != 0 && selectedImagesForPrint.size() > photoNum) {
JOptionPane.showMessageDialog(this,
"Số lượng ảnh đã chọn (" + selectedImagesForPrint.size() + ") nhiều hơn số lượng cho phép trong mẫu (" + photoNum + ").",
"Quá nhiều ảnh", JOptionPane.WARNING_MESSAGE);
return;
}
UltrasoundResult ultrasoundDialog = new UltrasoundResult(
checkupIdField.getText(),
customerLastNameField.getText() + " " + customerFirstNameField.getText(),
dobPicker.getJFormattedTextField().getText(),
(String) genderComboBox.getSelectedItem(),
customerAddressField.getText() + ", " + (wardComboBox.getSelectedItem() != null ? wardComboBox.getSelectedItem().toString() : "") + ", " + (districtComboBox.getSelectedItem() != null ? districtComboBox.getSelectedItem().toString() : "") + ", " + (provinceComboBox.getSelectedItem() != null ? provinceComboBox.getSelectedItem().toString() : ""),
(String) doctorComboBox.getSelectedItem(),
datePicker.getJFormattedTextField().getText(),
getRtfContentAsString(),
conclusionField.getText(),
suggestionField.getText(),
selectedImagesForPrint,
printType,
templateTitle
);
ultrasoundDialog.createDialog(mainFrame);
break;
}
}
@@ -1420,6 +1452,8 @@ public class CheckUpPage extends JPanel {
imageRefreshTimer.stop();
}
selectedImagesForPrint.clear();
// Only stop recording if it's active, don't cleanup webcam
if (isRecording) {
stopRecording();
@@ -2469,14 +2503,50 @@ public class CheckUpPage extends JPanel {
Image scaledImage = image.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH);
JLabel imageLabel = new JLabel(new ImageIcon(scaledImage));
imageLabel.setToolTipText(file.getName() + " (" + originalWidth + "x" + originalHeight + ")");
imageLabel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
// Set fixed size for the label to ensure FlowLayout behaves
imageLabel.setPreferredSize(new Dimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT));
imageLabel.setToolTipText(file.getName());
// These are important to center the image if it's smaller than the thumbnail bounds
imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
imageLabel.setVerticalAlignment(SwingConstants.CENTER);
imageGalleryPanel.add(imageLabel);
JCheckBox selectCheckBox = new JCheckBox(""); // "box only"
selectCheckBox.setToolTipText("Chọn để in");
selectCheckBox.setOpaque(false); // Make it transparent to see the image behind
// Check if the file is already in the list to maintain state on refresh
if (selectedImagesForPrint.contains(file)) {
selectCheckBox.setSelected(true);
}
final File imageFile = file;
selectCheckBox.addActionListener(e -> {
if (selectCheckBox.isSelected()) {
if (!selectedImagesForPrint.contains(imageFile)) {
selectedImagesForPrint.add(imageFile);
}
} else {
selectedImagesForPrint.remove(imageFile);
}
if (log.isInfoEnabled()) {
log.info("Selected images for printing: {}", selectedImagesForPrint.stream().map(File::getName).collect(Collectors.toList()));
}
});
// Use a JLayeredPane to overlay checkbox on the image
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(new Dimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT));
layeredPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
// The label will fill the entire pane
imageLabel.setBounds(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT);
// Position the checkbox at the top-right corner
int checkboxSize = 20;
selectCheckBox.setBounds(THUMBNAIL_WIDTH - checkboxSize - 2, 2, checkboxSize, checkboxSize); // 2px padding
layeredPane.add(imageLabel, JLayeredPane.DEFAULT_LAYER);
layeredPane.add(selectCheckBox, JLayeredPane.PALETTE_LAYER); // PALETTE_LAYER is on top of DEFAULT_LAYER
imageGalleryPanel.add(layeredPane);
} catch (Exception ex) {
log.error("Error loading image thumbnail: {}", file.getAbsolutePath(), ex);
JLabel errorLabel = new JLabel("<html><center>Lỗi ảnh<br>" + file.getName().substring(0, Math.min(file.getName().length(),10)) + "...</center></html>");
@@ -0,0 +1,568 @@
package BsK.client.ui.component.CheckUpPage.PrintDialog;
import BsK.client.LocalStorage;
import com.itextpdf.io.font.constants.StandardFonts;
import com.itextpdf.io.image.ImageDataFactory;
import com.itextpdf.kernel.colors.ColorConstants;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.PageSize;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.borders.Border;
import com.itextpdf.layout.borders.SolidBorder;
import com.itextpdf.layout.element.Cell;
import com.itextpdf.layout.element.Image;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.element.Text;
import com.itextpdf.layout.property.HorizontalAlignment;
import com.itextpdf.layout.property.TextAlignment;
import com.itextpdf.layout.property.UnitValue;
import com.itextpdf.layout.property.VerticalAlignment;
import com.itextpdf.layout.element.AreaBreak;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.text.rtf.RTFEditorKit;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.*;
import java.util.List;
@Slf4j
public class UltrasoundResult {
private JDialog dialog;
private final String checkupId;
private final String patientName;
private final String patientDOB;
private final String patientGender;
private final String patientAddress;
private final String doctorName;
private final String checkupDate;
private final String rtfContent;
private final String conclusion;
private final String suggestion;
private final List<File> selectedImages;
private final String printType; // "ngang" or "dọc"
private final String templateTitle;
private static final String PDF_PATH = "ultrasound_result.pdf";
public UltrasoundResult(String checkupId, String patientName, String patientDOB, String patientGender,
String patientAddress, String doctorName, String checkupDate,
String rtfContent, String conclusion, String suggestion,
List<File> selectedImages, String printType, String templateTitle) {
this.checkupId = checkupId;
this.patientName = patientName;
this.patientDOB = patientDOB;
this.patientGender = patientGender;
this.patientAddress = patientAddress;
this.doctorName = doctorName;
this.checkupDate = checkupDate;
this.rtfContent = rtfContent;
this.conclusion = conclusion;
this.suggestion = suggestion;
this.selectedImages = selectedImages;
this.printType = printType;
this.templateTitle = templateTitle;
}
public void createDialog(JFrame parent) {
dialog = new JDialog(parent, "Kết quả siêu âm", true);
dialog.setSize(800, 700);
dialog.setResizable(true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setLayout(new BorderLayout());
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowIconified(WindowEvent e) {
if (parent != null) parent.setState(Frame.ICONIFIED);
}
@Override
public void windowDeiconified(WindowEvent e) {
if (parent != null && parent.getState() == Frame.ICONIFIED) parent.setState(Frame.NORMAL);
}
});
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
JButton saveButton = new JButton("Lưu PDF");
JButton printButton = new JButton("In PDF");
buttonPanel.add(saveButton);
buttonPanel.add(printButton);
JPanel pdfViewer = new JPanel();
JScrollPane scrollPane = new JScrollPane(pdfViewer);
dialog.add(scrollPane, BorderLayout.CENTER);
dialog.add(buttonPanel, BorderLayout.SOUTH);
try {
generatePdf(PDF_PATH);
displayPdfInLabel(PDF_PATH, pdfViewer);
} catch (Exception e) {
log.error("Error generating ultrasound PDF", e);
JOptionPane.showMessageDialog(dialog, "Lỗi khi tạo PDF: " + e.getMessage(), "Lỗi", JOptionPane.ERROR_MESSAGE);
}
saveButton.addActionListener(e -> savePdf());
printButton.addActionListener(e -> printPdf());
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
}
private void generatePdf(String pdfPath) throws Exception {
PdfWriter writer = new PdfWriter(pdfPath);
PdfDocument pdfDoc = new PdfDocument(writer);
Document document;
boolean isLandscape = "ngang".equalsIgnoreCase(this.printType);
if (isLandscape) {
document = new Document(pdfDoc, PageSize.A4.rotate());
} else {
document = new Document(pdfDoc, PageSize.A4);
}
document.setMargins(20, 20, 20, 20);
String boldFontPath = "src/main/java/BsK/client/ui/assets/font/SVN-Arial Bold.ttf";
PdfFont boldFont = PdfFontFactory.createFont(boldFontPath, "Identity-H", true);
String fontPath = "src/main/java/BsK/client/ui/assets/font/SVN-Arial Regular.ttf";
PdfFont font = PdfFontFactory.createFont(fontPath, "Identity-H", true);
String title = templateTitle != null ? templateTitle.toUpperCase() : "KẾT QUẢ SIÊU ÂM";
if (isLandscape) {
generateLandscapeLayout(document, boldFont, font, title);
} else {
addHeader(document, boldFont, font);
document.add(new Paragraph(title)
.setFont(boldFont).setFontSize(14)
.setTextAlignment(TextAlignment.CENTER)
.setMarginBottom(5));
generatePortraitLayout(document, boldFont, font);
}
document.close();
}
private Cell createHeaderBlock(PdfFont boldFont, PdfFont font) {
Cell headerContainer = new Cell().setBorder(Border.NO_BORDER).setPadding(0);
Table headerTable = new Table(UnitValue.createPercentArray(new float[]{0.3f, 0.7f}))
.setWidth(UnitValue.createPercentValue(100))
.setBorder(Border.NO_BORDER)
.setMarginBottom(2);
try {
String logoPath = "src/main/java/BsK/client/ui/assets/icon/clinic_logo.png";
Image logo = new Image(ImageDataFactory.create(logoPath)).scaleToFit(50, 50);
headerTable.addCell(new Cell().add(logo).setBorder(Border.NO_BORDER).setVerticalAlignment(VerticalAlignment.MIDDLE));
} catch (Exception e) {
headerTable.addCell(new Cell().setBorder(Border.NO_BORDER));
log.warn("Clinic logo not found", e);
}
Paragraph clinicInfo = new Paragraph()
.add(new Text(LocalStorage.ClinicName + "\n").setFont(boldFont).setFontSize(10))
.add(new Text("Địa chỉ: " + LocalStorage.ClinicAddress + "\n").setFontSize(8))
.add(new Text("Điện thoại: " + LocalStorage.ClinicPhone).setFontSize(8))
.setFont(font);
headerTable.addCell(new Cell().add(clinicInfo).setBorder(Border.NO_BORDER).setVerticalAlignment(VerticalAlignment.MIDDLE));
headerContainer.add(headerTable);
return headerContainer;
}
private void generateLandscapeLayout(Document document, PdfFont boldFont, PdfFont font, String title) throws Exception {
Table titleTable = new Table(UnitValue.createPercentArray(new float[]{1, 1}))
.setWidth(UnitValue.createPercentValue(100))
.setMarginBottom(2);
Paragraph titleParagraph = new Paragraph(title)
.setFont(boldFont).setFontSize(14)
.setTextAlignment(TextAlignment.CENTER)
.setMarginBottom(2);
Table mainTable = new Table(UnitValue.createPercentArray(new float[]{1.2f, 0.8f}))
.setWidth(UnitValue.createPercentValue(100))
.setMarginTop(0);
Cell leftCell = new Cell().setBorder(Border.NO_BORDER).setPadding(1).setVerticalAlignment(VerticalAlignment.TOP);
leftCell.add(createHeaderBlock(boldFont, font));
leftCell.add(new Paragraph(title)
.setFont(boldFont).setFontSize(14)
.setTextAlignment(TextAlignment.CENTER)
.setMarginBottom(2));
addPatientInfo(leftCell, boldFont, font, 8);
leftCell.add(new Paragraph("NỘI DUNG").setFont(boldFont).setFontSize(10).setMarginTop(2)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
Image rtfImage = createRtfImage(this.rtfContent, PageSize.A4.rotate().getWidth() * 0.58f);
if (rtfImage != null) {
// Set maximum height to prevent page overflow - ensure single page layout
rtfImage.setMaxHeight(320); // Fixed max height to ensure single page
rtfImage.setAutoScale(false);
leftCell.add(rtfImage);
}
// Add conclusion and suggestion to left column
leftCell.add(new Paragraph("KẾT LUẬN").setFont(boldFont).setFontSize(10).setMarginTop(3)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
leftCell.add(new Paragraph(this.conclusion).setFont(font).setFontSize(8));
leftCell.add(new Paragraph("ĐỀ NGHỊ").setFont(boldFont).setFontSize(10).setMarginTop(2)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
leftCell.add(new Paragraph(this.suggestion).setFont(font).setFontSize(8));
Cell rightCell = new Cell().setBorder(Border.NO_BORDER).setPadding(1).setVerticalAlignment(VerticalAlignment.TOP);
rightCell.add(new Paragraph("HÌNH ẢNH SIÊU ÂM").setFont(boldFont).setFontSize(10)
.setTextAlignment(TextAlignment.LEFT).setUnderline().setMarginBottom(1));
Table imageTable = createImageTable(selectedImages);
rightCell.add(imageTable);
rightCell.add(createSignatureBlock(font, boldFont));
mainTable.addCell(leftCell);
mainTable.addCell(rightCell);
document.add(mainTable);
}
private void generatePortraitLayout(Document document, PdfFont boldFont, PdfFont font) throws Exception {
boolean multiPage = selectedImages.size() > 4;
addPatientInfo(document, boldFont, font, 8);
if (multiPage) {
Table contentTable = new Table(1).setWidth(UnitValue.createPercentValue(100));
Cell contentCell = new Cell().setBorder(Border.NO_BORDER).setPadding(0);
contentCell.add(new Paragraph("NỘI DUNG").setFont(boldFont).setFontSize(10).setMarginTop(5)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
Image rtfImage = createRtfImage(this.rtfContent, PageSize.A4.getWidth() - 60);
if (rtfImage != null) {
contentCell.add(rtfImage);
}
contentCell.add(new Paragraph("KẾT LUẬN").setFont(boldFont).setFontSize(10).setMarginTop(5)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
contentCell.add(new Paragraph(this.conclusion).setFont(font).setFontSize(8));
contentCell.add(new Paragraph("ĐỀ NGHỊ").setFont(boldFont).setFontSize(10).setMarginTop(5)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
contentCell.add(new Paragraph(this.suggestion).setFont(font).setFontSize(8));
contentTable.addCell(contentCell);
document.add(contentTable);
addSignature(document, font, boldFont);
document.add(new AreaBreak());
addHeader(document, boldFont, font);
document.add(new Paragraph("HÌNH ẢNH SIÊU ÂM (tt)").setFont(boldFont).setFontSize(10)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
Table imageTable = createImageTable(selectedImages);
document.add(imageTable);
} else {
Table mainTable = new Table(UnitValue.createPercentArray(new float[]{1.2f, 0.8f}))
.setWidth(UnitValue.createPercentValue(100))
.setMarginTop(5);
Cell leftCell = new Cell().setBorder(Border.NO_BORDER).setPaddingRight(5);
leftCell.add(new Paragraph("NỘI DUNG").setFont(boldFont).setFontSize(10)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
Image rtfImage = createRtfImage(this.rtfContent, PageSize.A4.getWidth() * 0.55f - 40);
if (rtfImage != null) {
leftCell.add(rtfImage);
}
Cell rightCell = new Cell().setBorder(Border.NO_BORDER);
rightCell.add(new Paragraph("HÌNH ẢNH").setFont(boldFont).setFontSize(10)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
Table imageTable = createImageTable(selectedImages);
rightCell.add(imageTable);
mainTable.addCell(leftCell);
mainTable.addCell(rightCell);
document.add(mainTable);
document.add(new Paragraph("KẾT LUẬN").setFont(boldFont).setFontSize(10).setMarginTop(5)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
document.add(new Paragraph(this.conclusion).setFont(font).setFontSize(8));
document.add(new Paragraph("ĐỀ NGHỊ").setFont(boldFont).setFontSize(10).setMarginTop(5)
.setTextAlignment(TextAlignment.LEFT).setUnderline());
document.add(new Paragraph(this.suggestion).setFont(font).setFontSize(8));
addSignature(document, font, boldFont);
}
}
private Table createImageTable(List<File> images) throws IOException {
int numImages = images.size();
int numCols = numImages == 1 ? 1 : 2;
Table imageTable = new Table(numCols)
.useAllAvailableWidth()
.setMarginTop(1).setMarginBottom(1);
for(File imgFile : images) {
Image img = new Image(ImageDataFactory.create(imgFile.getAbsolutePath()));
img.setAutoScale(true);
img.setMaxWidth(110f);
img.setMaxHeight(85f);
Cell imgCell = new Cell()
.add(img)
.setBorder(new SolidBorder(ColorConstants.GRAY, 0.5f))
.setPadding(1)
.setHorizontalAlignment(HorizontalAlignment.CENTER)
.setVerticalAlignment(VerticalAlignment.MIDDLE);
imageTable.addCell(imgCell);
}
int remainder = numImages % numCols;
if (remainder != 0 && numImages > 1) {
imageTable.addCell(new Cell().setBorder(Border.NO_BORDER));
}
return imageTable;
}
private Image createRtfImage(String rtf, float availableWidth) {
if (rtf == null || rtf.trim().isEmpty()) {
return null;
}
try {
JTextPane pane = new JTextPane();
pane.setEditorKit(new RTFEditorKit());
pane.setBackground(Color.WHITE);
pane.setOpaque(true);
pane.read(new ByteArrayInputStream(rtf.getBytes("ISO-8859-1")), null);
pane.setSize(new Dimension((int) availableWidth, Integer.MAX_VALUE));
Dimension prefSize = pane.getPreferredSize();
pane.setSize(prefSize);
int renderDPI = 240; // Further reduced DPI to make text appear even smaller
float scale = renderDPI / 72f;
int imgWidth = (int) (prefSize.width * scale);
int imgHeight = (int) (prefSize.height * scale);
if (imgWidth <= 0 || imgHeight <= 0) {
log.warn("Invalid image dimensions for RTF rendering: {}x{}", imgWidth, imgHeight);
return null;
}
BufferedImage img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = img.createGraphics();
g2d.scale(scale, scale);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
pane.paint(g2d);
g2d.dispose();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(img, "png", baos);
Image itextImage = new Image(ImageDataFactory.create(baos.toByteArray()));
// Set width directly. The reduced DPI has already made the content smaller.
itextImage.setWidth(UnitValue.createPointValue(prefSize.width));
return itextImage;
} catch (Exception e) {
log.error("Failed to convert RTF to Image", e);
return null;
}
}
private void addHeader(Document document, PdfFont boldFont, PdfFont font) {
Table headerTable = new Table(UnitValue.createPercentArray(new float[]{1.2f, 3.8f, 2f}))
.setWidth(UnitValue.createPercentValue(100))
.setBorder(Border.NO_BORDER)
.setMarginBottom(5);
try {
String logoPath = "src/main/java/BsK/client/ui/assets/icon/clinic_logo.png";
Image logo = new Image(ImageDataFactory.create(logoPath)).scaleToFit(50, 50);
headerTable.addCell(new Cell().add(logo).setBorder(Border.NO_BORDER).setVerticalAlignment(VerticalAlignment.MIDDLE));
} catch (Exception e) {
headerTable.addCell(new Cell().setBorder(Border.NO_BORDER));
log.warn("Clinic logo not found", e);
}
Paragraph clinicInfo = new Paragraph()
.add(new Text(LocalStorage.ClinicName + "\n").setFont(boldFont).setFontSize(10))
.add(new Text("Địa chỉ: " + LocalStorage.ClinicAddress + "\n").setFontSize(8))
.add(new Text("Điện thoại: " + LocalStorage.ClinicPhone).setFontSize(8))
.setFont(font);
headerTable.addCell(new Cell().add(clinicInfo).setBorder(Border.NO_BORDER).setVerticalAlignment(VerticalAlignment.MIDDLE));
headerTable.addCell(new Cell().setBorder(Border.NO_BORDER));
document.add(headerTable);
}
private void addPatientInfo(Object container, PdfFont boldFont, PdfFont font, int fontSize) {
Table table = new Table(UnitValue.createPercentArray(new float[]{1,1}))
.setWidth(UnitValue.createPercentValue(100))
.setFontSize(fontSize).setFont(font)
.setBorder(new SolidBorder(ColorConstants.GRAY, 0.5f))
.setMarginBottom(1); // Reduced margin for compactness
Cell left = new Cell().setBorder(Border.NO_BORDER).setPadding(1);
left.add(new Paragraph().add(new Text("Họ tên: ").setFont(boldFont)).add(patientName));
left.add(new Paragraph().add(new Text("Năm sinh: ").setFont(boldFont)).add(patientDOB));
left.add(new Paragraph().add(new Text("Giới tính: ").setFont(boldFont)).add(patientGender));
Cell right = new Cell().setBorder(Border.NO_BORDER).setPadding(1);
right.add(new Paragraph().add(new Text("Địa chỉ: ").setFont(boldFont)).add(patientAddress));
right.add(new Paragraph().add(new Text("Ngày khám: ").setFont(boldFont)).add(checkupDate));
right.add(new Paragraph().add(new Text("Mã khám: ").setFont(boldFont)).add(checkupId));
table.addCell(left);
table.addCell(right);
if (container instanceof Document) {
((Document) container).add(table);
} else if (container instanceof Cell) {
((Cell) container).add(table);
}
}
private void addSignature(Document document, PdfFont font, PdfFont boldFont) {
Table signatureTable = new Table(UnitValue.createPercentArray(new float[]{1, 1}))
.setWidth(UnitValue.createPercentValue(100))
.setMarginTop(5);
signatureTable.addCell(new Cell().setBorder(Border.NO_BORDER)); // empty cell for alignment
Paragraph signParagraph = new Paragraph()
.add("Ngày " + checkupDate.substring(0,2) + " tháng " + checkupDate.substring(3,5) + " năm " + checkupDate.substring(6) + "\n")
.add(new Text("BÁC SĨ ĐIỀU TRỊ\n").setFont(boldFont))
.add(new Text("(Ký và ghi rõ họ tên)\n\n").setFontSize(9).setItalic()) // Reduced newlines for signature space
.add(doctorName)
.setTextAlignment(TextAlignment.CENTER)
.setFont(font).setFontSize(10);
signatureTable.addCell(new Cell().add(signParagraph).setBorder(Border.NO_BORDER));
document.add(signatureTable);
}
private void displayPdfInLabel(String pdfPath, JPanel pdfPanel) {
pdfPanel.removeAll();
pdfPanel.setLayout(new BoxLayout(pdfPanel, BoxLayout.Y_AXIS));
try (PDDocument document = PDDocument.load(new File(pdfPath))) {
PDFRenderer pdfRenderer = new PDFRenderer(document);
float scale = 0.6f;
for (int i = 0; i < document.getNumberOfPages(); i++) {
BufferedImage image = pdfRenderer.renderImageWithDPI(i, 120);
int newWidth = (int) (image.getWidth() * scale);
int newHeight = (int) (image.getHeight() * scale);
ImageIcon icon = new ImageIcon(image.getScaledInstance(newWidth, newHeight, java.awt.Image.SCALE_SMOOTH));
JLabel pageLabel = new JLabel(icon);
pageLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
pageLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
pdfPanel.add(pageLabel);
}
} catch (IOException e) {
log.error("Error displaying PDF", e);
pdfPanel.add(new JLabel("Lỗi khi hiển thị PDF: " + e.getMessage()));
}
pdfPanel.revalidate();
pdfPanel.repaint();
}
private void savePdf() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Lưu file PDF");
fileChooser.setSelectedFile(new File("ultrasound_" + checkupId + ".pdf"));
int userSelection = fileChooser.showSaveDialog(dialog);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = fileChooser.getSelectedFile();
try {
generatePdf(fileToSave.getAbsolutePath());
JOptionPane.showMessageDialog(dialog, "PDF đã được lưu: " + fileToSave.getAbsolutePath());
} catch (Exception ex) {
log.error("Error saving PDF", ex);
JOptionPane.showMessageDialog(dialog, "Lỗi khi lưu PDF: " + ex.getMessage(), "Lỗi", JOptionPane.ERROR_MESSAGE);
}
}
}
private void printPdf() {
File pdfFile = new File(PDF_PATH);
try (PDDocument document = PDDocument.load(pdfFile)) {
PrinterJob printerJob = PrinterJob.getPrinterJob();
printerJob.setJobName("In kết quả siêu âm - " + patientName);
if (printerJob.printDialog()) {
printerJob.setPrintable(new Printable() {
@Override
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex >= document.getNumberOfPages()) {
return NO_SUCH_PAGE;
}
try {
PDFRenderer pdfRenderer = new PDFRenderer(document);
BufferedImage pageImage = pdfRenderer.renderImageWithDPI(pageIndex, 300);
Graphics2D g2d = (Graphics2D) graphics;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
double scale = Math.min(pageFormat.getImageableWidth() / pageImage.getWidth(), pageFormat.getImageableHeight() / pageImage.getHeight());
g2d.drawImage(pageImage, 0, 0, (int) (pageImage.getWidth() * scale), (int) (pageImage.getHeight() * scale), null);
return PAGE_EXISTS;
} catch (IOException e) {
log.error("Error rendering page for printing", e);
throw new PrinterException(e.getMessage());
}
}
});
printerJob.print();
}
} catch (Exception e) {
log.error("Error printing PDF", e);
JOptionPane.showMessageDialog(dialog, "Lỗi khi in PDF: " + e.getMessage(), "Lỗi", JOptionPane.ERROR_MESSAGE);
}
}
private Table createSignatureBlock(PdfFont font, PdfFont boldFont) {
Table signatureTable = new Table(UnitValue.createPercentArray(new float[]{1, 1}))
.setWidth(UnitValue.createPercentValue(100))
.setMarginTop(2); // Reduced margin for compactness
signatureTable.addCell(new Cell().setBorder(Border.NO_BORDER)); // empty cell for alignment
Paragraph signParagraph = new Paragraph()
.add("Ngày " + checkupDate.substring(0,2) + " tháng " + checkupDate.substring(3,5) + " năm " + checkupDate.substring(6) + "\n")
.add(new Text("BÁC SĨ ĐIỀU TRỊ\n").setFont(boldFont))
.add(new Text("(Ký và ghi rõ họ tên)\n\n").setFontSize(9).setItalic()) // Reduced newlines for signature space
.add(doctorName)
.setTextAlignment(TextAlignment.CENTER)
.setFont(font).setFontSize(10);
signatureTable.addCell(new Cell().add(signParagraph).setBorder(Border.NO_BORDER));
return signatureTable;
}
}
@@ -0,0 +1,86 @@
package BsK.client.ui.component.CheckUpPage.PrintDialog.print_forms;
/**
* Represents a single item on the invoice, which can be a medicine, a service, or a supplement.
* This class matches the fields defined in the 'med_pre' dataset in the JRXML.
*/
public class InvoiceItem {
// --- Common Fields ---
private String type; // "MED", "SER", "SUP"
// --- Medicine Fields ---
private String medName;
private String dosage;
private Integer amount;
private Double unitPrice;
private String medNote;
// --- Service Fields ---
private String serName;
private String serNote;
private Double serUnitPrice;
private Integer serAmount;
// --- Supplement Fields ---
private String supName;
private String supNote;
private String supDosage;
private Integer supAmount;
private Double supUnitPrice;
// Private constructor to be used by factory methods
private InvoiceItem() {}
// --- Factory Methods ---
public static InvoiceItem createMedicine(String medName, String dosage, Integer amount, Double unitPrice, String medNote) {
InvoiceItem item = new InvoiceItem();
item.type = "MED";
item.medName = medName;
item.dosage = dosage;
item.amount = amount;
item.unitPrice = unitPrice;
item.medNote = medNote;
return item;
}
public static InvoiceItem createService(String serName, String serNote, Integer serAmount, Double serUnitPrice) {
InvoiceItem item = new InvoiceItem();
item.type = "SER";
item.serName = serName;
item.serNote = serNote;
item.serAmount = serAmount;
item.serUnitPrice = serUnitPrice;
return item;
}
public static InvoiceItem createSupplement(String supName, String supNote, String supDosage, Integer supAmount, Double supUnitPrice) {
InvoiceItem item = new InvoiceItem();
item.type = "SUP";
item.supName = supName;
item.supNote = supNote;
item.supDosage = supDosage;
item.supAmount = supAmount;
item.supUnitPrice = supUnitPrice;
return item;
}
// --- Getters ---
public String getType() { return type; }
public String getMedName() { return medName; }
public String getDosage() { return dosage; }
public Integer getAmount() { return amount; }
public Double getUnitPrice() { return unitPrice; }
public String getMedNote() { return medNote; }
public String getSerName() { return serName; }
public String getSerNote() { return serNote; }
public Double getSerUnitPrice() { return serUnitPrice; }
public Integer getSerAmount() { return serAmount; }
public String getSupName() { return supName; }
public String getSupNote() { return supNote; }
public String getSupDosage() { return supDosage; }
public Integer getSupAmount() { return supAmount; }
public Double getSupUnitPrice() { return supUnitPrice; }
}
@@ -0,0 +1,854 @@
<!-- Created with Jaspersoft Studio version 7.0.3.final using JasperReports Library version 7.0.3-41034ca841d452f3305ba55b9042260aaa1ab5dd -->
<jasperReport name="medserinvoice" language="java" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="89e1c712-fb3e-4ad3-bd4e-06dc0bfbbca4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
<box>
<pen lineWidth="0.5" lineColor="#000000"/>
<topPen lineWidth="0.5" lineColor="#000000"/>
<leftPen lineWidth="0.5" lineColor="#000000"/>
<bottomPen lineWidth="0.5" lineColor="#000000"/>
<rightPen lineWidth="0.5" lineColor="#000000"/>
</box>
</style>
<style name="Table_TD" mode="Transparent" backcolor="#FF0905"/>
<dataset name="med_pre" uuid="004d49d7-270e-4e3d-b2da-0d89ba43174a">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
<query language="sql"><![CDATA[]]></query>
<field name="medName" class="java.lang.String"/>
<field name="dosage" class="java.lang.String"/>
<field name="amount" class="java.lang.Integer"/>
<field name="unitPrice" class="java.lang.Double"/>
<field name="medNote" class="java.lang.String"/>
<field name="serName" class="java.lang.String"/>
<field name="serNote" class="java.lang.String"/>
<field name="serUnitPrice" class="java.lang.Double"/>
<field name="serAmount" class="java.lang.Integer"/>
<field name="supName" class="java.lang.String"/>
<field name="supNote" class="java.lang.String"/>
<field name="supDosage" class="java.lang.String"/>
<field name="supAmount" class="java.lang.Integer"/>
<field name="supUnitPrice" class="java.lang.Double"/>
<variable name="medRowTotal" class="java.math.BigDecimal">
<expression><![CDATA[new java.math.BigDecimal($F{unitPrice}).multiply(new java.math.BigDecimal($F{amount}))]]></expression>
</variable>
<variable name="medTotal" calculation="Sum" class="java.math.BigDecimal">
<expression><![CDATA[$V{medRowTotal}]]></expression>
</variable>
<variable name="serRowTotal" class="java.math.BigDecimal">
<expression><![CDATA[new java.math.BigDecimal($F{serUnitPrice}).multiply(new java.math.BigDecimal($F{serAmount}))]]></expression>
</variable>
<variable name="serTotal" calculation="Sum" class="java.math.BigDecimal">
<expression><![CDATA[$V{serRowTotal}]]></expression>
</variable>
<variable name="supRowTotal" class="java.math.BigDecimal">
<expression><![CDATA[new java.math.BigDecimal($F{supUnitPrice}).multiply(new java.math.BigDecimal($F{supAmount}))]]></expression>
</variable>
<variable name="supTotal" calculation="Sum" class="java.math.BigDecimal">
<expression><![CDATA[$V{supRowTotal}]]></expression>
</variable>
</dataset>
<parameter name="medicineDS" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="serviceDS" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="supplementDS" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
<parameter name="name" class="java.lang.String"/>
<parameter name="clinicName" class="java.lang.String"/>
<parameter name="clinicPhone" class="java.lang.String"/>
<parameter name="patientName" class="java.lang.String"/>
<parameter name="patientDOB" class="java.lang.String"/>
<parameter name="clinicAddress" class="java.lang.String"/>
<parameter name="logoImage" class="java.lang.String"/>
<parameter name="barcodeNumber" class="java.lang.String"/>
<query language="sql"><![CDATA[]]></query>
<variable name="MedicineGrandTotal" calculation="System" class="java.math.BigDecimal">
<initialValueExpression><![CDATA[new java.math.BigDecimal(0)]]></initialValueExpression>
</variable>
<variable name="SupplementGrandTotal" calculation="System" class="java.math.BigDecimal">
<initialValueExpression><![CDATA[new java.math.BigDecimal(0)]]></initialValueExpression>
</variable>
<variable name="ServiceGrandTotal" calculation="System" class="java.math.BigDecimal">
<initialValueExpression><![CDATA[new java.math.BigDecimal(0)]]></initialValueExpression>
</variable>
<background splitType="Stretch"/>
<title height="83" splitType="Stretch">
<element kind="image" uuid="c596ac6f-18d9-4cfe-a74e-58b1f7d11ecc" x="-10" y="-4" width="90" height="83">
<expression><![CDATA[$P{logoImage}]]></expression>
</element>
<element kind="textField" uuid="48bf4793-8d8d-427d-b739-8f34f051192f" x="80" y="-4" width="350" height="25" fontName="Arial" fontSize="18.0" bold="true">
<expression><![CDATA["PHÒNG KHÁM " + $P{clinicName}]]></expression>
</element>
<element kind="staticText" uuid="d8e95ce7-3ac0-44a7-ac8f-65821b7f373c" x="80" y="20" width="150" height="15" fontName="Arial" fontSize="12.0" bold="true" hTextAlign="Left">
<text><![CDATA[Địa chỉ: ]]></text>
</element>
<element kind="textField" uuid="9883203e-fd4b-4110-a4b9-2c8c257ce5fa" x="126" y="20" width="426" height="15" fontName="Arial" fontSize="12.0">
<expression><![CDATA[$P{clinicAddress}]]></expression>
</element>
<element kind="staticText" uuid="f00706ca-903c-4089-b3a1-33be68f6112b" x="80" y="35" width="150" height="15" fontName="Arial" fontSize="12.0" bold="true" hTextAlign="Left">
<text><![CDATA[SĐT:]]></text>
</element>
<element kind="textField" uuid="2af00e22-702e-42cb-a6fb-19d401a58170" x="110" y="35" width="442" height="15" fontName="Arial" fontSize="12.0">
<expression><![CDATA[$P{clinicPhone}]]></expression>
</element>
<element kind="component" uuid="35037abf-0984-4b9e-8a05-f8fae38d7dcc" x="430" y="20" width="79" height="48">
<component kind="barcode4j:Code128">
<codeExpression><![CDATA[$P{barcodeNumber}]]></codeExpression>
</component>
</element>
<element kind="staticText" uuid="aef24b29-b2af-4cdb-b230-d2acd3ce2892" x="430" y="7" width="80" height="25" fontName="Arial" fontSize="10.0" bold="false" hTextAlign="Center">
<text><![CDATA[Mã khám bệnh]]></text>
</element>
<element kind="staticText" uuid="de38fb46-49af-4f48-8c33-f97680bcc7fa" x="192" y="54" width="180" height="25" fontName="Arial" fontSize="18.0" bold="true" hTextAlign="Center">
<text><![CDATA[TOA THUỐC]]></text>
</element>
</title>
<pageHeader height="87" splitType="Stretch">
<element kind="staticText" uuid="68240a36-0b2b-4bc9-aee9-ab6c4ec19f7c" x="0" y="1" width="50" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Họ và tên:]]></text>
</element>
<element kind="staticText" uuid="fbfab342-b9df-417d-8341-38a547f80561" x="0" y="16" width="80" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Ngày sinh:]]></text>
</element>
<element kind="staticText" uuid="5902f022-60d4-4924-88bb-c3f5bc010212" x="0" y="31" width="80" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Giới tính:]]></text>
</element>
<element kind="staticText" uuid="7c27a754-d81f-4411-be00-7ee575cc12e8" x="0" y="46" width="80" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Địa chỉ:]]></text>
</element>
<element kind="staticText" uuid="089f23f2-b1f5-4102-89a4-b11bfa1ff468" x="320" y="1" width="50" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Bác sĩ:]]></text>
</element>
<element kind="staticText" uuid="f6b2d15b-04a1-44ed-b72e-bd9e364ed248" x="320" y="16" width="50" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Ngày lập:]]></text>
</element>
<element kind="staticText" uuid="d46aeb12-c383-4e77-aa97-3b9ba5893378" x="320" y="31" width="50" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Ngày lập:]]></text>
</element>
<element kind="staticText" uuid="7b2f5efd-dda7-4233-8f6d-e54a425f6ef6" x="0" y="61" width="80" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Chuẩn đoán:]]></text>
</element>
<element kind="staticText" uuid="23013729-cb89-46b8-b956-7be6bfd2a010" x="320" y="46" width="80" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Ghi chú:]]></text>
</element>
<element kind="textField" uuid="7e27e979-69d3-475c-ad48-5b71030a6eae" x="70" y="1" width="210" height="15" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="ff99dc8c-8477-49d7-8206-344463437478" x="70" y="16" width="210" height="15" fontName="Arial">
<expression><![CDATA[$P{patientDOB}]]></expression>
</element>
<element kind="textField" uuid="19536fc9-be78-46dc-8891-a7c1e6108498" x="70" y="31" width="210" height="15" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="a942834e-78fb-4975-ba71-331948e92d65" x="70" y="46" width="210" height="30" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="4154fffa-29ed-4d89-ba1f-4bb490626135" x="370" y="1" width="176" height="15" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="2c951dbb-1809-4aef-b3f9-1325579449b7" x="370" y="16" width="176" height="15" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="b6ae33b9-8062-4448-806d-aaf41dd92fc1" x="370" y="31" width="176" height="15" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="85f77798-f7e7-4bb0-b32f-d0cba62f3664" x="70" y="61" width="250" height="26" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="3d2ad8af-d76e-4191-8c49-38535da8bda1" x="370" y="46" width="182" height="40" fontName="Arial">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
</pageHeader>
<detail>
<band height="276" splitType="Stretch">
<element kind="component" uuid="c0ec0570-9841-4438-a387-2e29436a01e7" x="8" y="18" width="539" height="65">
<component kind="table">
<datasetRun uuid="ee5be970-758d-4ae3-91fa-3b3a0a5fd160" subDataset="med_pre">
<dataSourceExpression><![CDATA[$P{medicineDS}]]></dataSourceExpression>
<returnValue toVariable="MedicineGrandTotal" fromVariable="medTotal"/>
</datasetRun>
<column kind="single" uuid="249a6076-168a-4d8c-ba6c-92ca1d870834" width="160">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="9b6682e0-0e7a-48be-baa3-932a54d0c959" x="0" y="0" width="160" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Tên thuốc]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="bc690d0f-bc31-4bcc-a134-ff5deb5be586" x="0" y="0" width="160" height="15" fontName="Arial" fontSize="8.0" hTextAlign="Left" vTextAlign="Top">
<expression><![CDATA[$F{medName}]]></expression>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="9b848a7f-a2e8-4360-9e6c-b5fde8d00361" x="0" y="15" width="160" height="15" fontName="Arial" fontSize="8.0" italic="true">
<expression><![CDATA["Ghi chú: " + $F{medNote}]]></expression>
<box leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
</column>
<column kind="single" uuid="f60271bc-52a8-4c6d-b0c7-6f8f4992eb76" width="90">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="0e5182ab-966b-4402-a5c3-a3b2eb23259e" x="0" y="0" width="90" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Liều dùng]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="797d2d36-5447-4ad1-be15-79b697389206" x="0" y="0" width="90" height="30" fontName="Arial" fontSize="8.0" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{dosage}]]></expression>
<box topPadding="3" leftPadding="3">
<pen lineWidth="1.0"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
</column>
<column kind="single" uuid="dd7c9141-b6c3-4471-916b-43e980f65a47" width="80">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="ae479f63-bbbf-4271-85e3-59bf587e90b6" x="0" y="0" width="80" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[SL]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="f200da37-dcd6-40f6-aa63-558a6f9ace69" x="0" y="0" width="80" height="30" fontName="Arial" fontSize="8.0" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{amount}]]></expression>
<box topPadding="3" leftPadding="3" bottomPadding="0" rightPadding="0">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
</column>
<column kind="single" uuid="d0909427-1340-4ba9-950e-ba0fdedd2638" width="99">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="72a37327-ff08-4bf2-98d7-224713fb08e1" x="0" y="0" width="99" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Đơn giá (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="staticText" uuid="c9e64949-22e1-4894-b6c2-4547444cea01" x="0" y="0" width="99" height="30" fontName="Arial" fontSize="12.0" bold="true" hTextAlign="Left" vTextAlign="Top">
<text><![CDATA[Tổng tiền thuốc:]]></text>
<box topPadding="3" leftPadding="3"/>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="3b16ef7d-483a-4149-88d3-c0b8b0e35dde" x="0" y="0" width="99" height="30" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$F{unitPrice}]]></expression>
<box topPadding="3" leftPadding="3" rightPadding="3">
<pen lineWidth="1.0"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
</column>
<column kind="single" uuid="aeb60052-ca3b-42d2-937e-3a40af79b35c" width="110">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="ec36d49b-ab0f-4e85-a43f-ad8b5715edb7" x="0" y="0" width="110" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Thành tiền (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="textField" uuid="c4a50fa9-96a2-498f-8df1-211aa2ad308b" x="0" y="0" width="110" height="30" pattern="#,##0" bold="true" hTextAlign="Right" vTextAlign="Top">
<expression><![CDATA[$V{medTotal}]]></expression>
<box topPadding="3" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="02937f0a-f5d4-4549-a3ac-75615083057e" x="0" y="0" width="110" height="30" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$V{medRowTotal}]]></expression>
<box topPadding="3" leftPadding="0" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
</column>
</component>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</element>
<element kind="staticText" uuid="9117208f-15de-4a22-8c8a-a994a0c99777" x="232" y="0" width="100" height="18" fontSize="14.0" bold="true" hTextAlign="Center">
<text><![CDATA[THUỐC]]></text>
</element>
<element kind="component" uuid="68c80e54-2998-4cf3-91c0-42fde9130772" positionType="Float" x="8" y="101" width="539" height="69">
<component kind="table">
<datasetRun uuid="24cf5328-ecae-4c68-8955-73475b8823b4" subDataset="med_pre">
<dataSourceExpression><![CDATA[$P{serviceDS}]]></dataSourceExpression>
<returnValue toVariable="ServiceGrandTotal" fromVariable="serTotal"/>
</datasetRun>
<column kind="single" uuid="9be00b0a-9844-4037-a53e-be1970a83d48" width="240">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="f3bfa0e9-452f-417c-a96b-a36de1d89c60" x="0" y="0" width="240" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Tên dịch vụ]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="29" style="Table_TD">
<element kind="textField" uuid="a16334e1-e3e0-4c20-a22d-7ce6a546edc8" x="0" y="0" width="240" height="15" fontName="Arial" fontSize="8.0" hTextAlign="Left" vTextAlign="Top">
<expression><![CDATA[$F{serName}]]></expression>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="48a3aa97-2f44-433e-a5b3-28fbcc0b0877" x="0" y="15" width="240" height="14" fontName="Arial" fontSize="8.0" italic="true">
<expression><![CDATA["Ghi chú: " + $F{serNote}]]></expression>
<box leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
</column>
<column kind="single" uuid="5d4cb5ab-0637-4bc5-9aa4-51d8748d93a3" width="90">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="7d80482e-8a8d-4afe-9024-2ebddcd229ba" x="0" y="0" width="90" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[SL]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="29" style="Table_TD">
<element kind="textField" uuid="48ad7d8f-6a79-4804-9f36-9f5c8b6ce888" x="0" y="0" width="90" height="29" fontName="Arial" fontSize="8.0" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{serAmount}]]></expression>
<box topPadding="3" leftPadding="3" bottomPadding="0" rightPadding="0">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
</column>
<column kind="single" uuid="3327181e-4f64-4d63-82ff-0ed2b59480cc" width="109">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="37981f61-4b25-40b0-8a0c-41bcc6ed32fa" x="0" y="0" width="109" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Đơn giá (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="staticText" uuid="3b9fa332-aed6-4fa5-936b-8de4b1e1bae0" x="0" y="0" width="109" height="30" fontName="Arial" fontSize="12.0" bold="true" hTextAlign="Left" vTextAlign="Top">
<text><![CDATA[Tổng tiền dịch vụ:]]></text>
<box topPadding="3" leftPadding="3"/>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="29" style="Table_TD">
<element kind="textField" uuid="6bf24316-39cd-4805-8548-52ea9d23818e" x="0" y="0" width="109" height="29" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$F{serUnitPrice}]]></expression>
<box topPadding="3" leftPadding="3" rightPadding="3">
<pen lineWidth="1.0"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
</column>
<column kind="single" uuid="5aca36b8-4305-428a-9311-4223d48dc96b" width="100">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="51fe5f04-3e6f-4f9c-bfbe-c9aa31e5266d" x="0" y="0" width="100" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Thành tiền (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="textField" uuid="a0606f4b-6dad-47cd-b470-f401e298612e" x="0" y="0" width="100" height="30" pattern="#,##0" bold="true" hTextAlign="Right" vTextAlign="Top">
<expression><![CDATA[$V{serTotal}]]></expression>
<box topPadding="3" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="29" style="Table_TD">
<element kind="textField" uuid="035cfa1b-9187-4bfe-8fa1-1d149d789768" x="0" y="0" width="100" height="29" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$V{serRowTotal}]]></expression>
<box topPadding="3" leftPadding="0" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
</column>
</component>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</element>
<element kind="staticText" uuid="5a4c9016-75d9-4a19-aa4d-7af0a0d88dbc" positionType="Float" x="232" y="83" width="100" height="18" fontSize="14.0" bold="true" hTextAlign="Center">
<text><![CDATA[DỊCH VỤ]]></text>
</element>
<element kind="staticText" uuid="6d6dde35-8321-4fa0-9c3c-d958b1746883" positionType="Float" x="202" y="170" width="161" height="19" fontSize="14.0" bold="true" hTextAlign="Center">
<text><![CDATA[THỰC PHẨM BỔ SUNG]]></text>
</element>
<element kind="component" uuid="1e772fe4-c438-49a7-9c8d-80acc5179879" positionType="Float" x="8" y="189" width="539" height="79">
<component kind="table">
<datasetRun uuid="b5f5d7d0-20c6-4715-940e-fc9269e059c4" subDataset="med_pre">
<dataSourceExpression><![CDATA[$P{supplementDS}]]></dataSourceExpression>
<returnValue toVariable="SupplementGrandTotal" fromVariable="supTotal"/>
</datasetRun>
<column kind="single" uuid="c56e4696-b21a-4640-a3ca-b528622c7c86" width="160">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="5ac78482-8ead-4d65-8232-92426efbcb34" stretchType="NoStretch" x="0" y="0" width="160" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Tên sản phẩm]]></text>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="d5ea8862-e0b9-46d9-a53c-c10aca930651" x="0" y="0" width="160" height="15" fontName="Arial" fontSize="8.0" hTextAlign="Left" vTextAlign="Top">
<expression><![CDATA[$F{supName}]]></expression>
<box topPadding="3" leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<element kind="textField" uuid="5bf931d8-5fc9-4ad0-9a88-ce5fb7874edd" x="0" y="15" width="160" height="15" fontName="Arial" fontSize="8.0" italic="true">
<expression><![CDATA["Ghi chú: " + $F{supNote}]]></expression>
<box leftPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
</column>
<column kind="single" uuid="ed772a4b-c595-416c-89c4-adc8f03f8bbb" width="90">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="931a3eba-7d94-4d55-9584-ef03aef45f85" x="0" y="0" width="90" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Liều dùng]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="76c3a08d-98e3-44ad-8422-24a953ce06d6" x="0" y="0" width="90" height="30" fontName="Arial" fontSize="8.0" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{supDosage}]]></expression>
<box topPadding="3" leftPadding="3">
<pen lineWidth="1.0"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
</column>
<column kind="single" uuid="896672c4-8128-4e60-b52a-4469dff9bc37" width="80">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="dec34657-b22a-42b0-b8f6-54c2d0b557b7" x="0" y="0" width="80" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[SL]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="b0d84fb4-a5d8-4b2d-89c0-f082afe51ef3" x="0" y="0" width="80" height="30" fontName="Arial" fontSize="8.0" hTextAlign="Center" vTextAlign="Middle">
<expression><![CDATA[$F{supAmount}]]></expression>
<box topPadding="3" leftPadding="3" bottomPadding="0" rightPadding="0">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
</column>
<column kind="single" uuid="b39552ea-7133-415f-9651-ab70891e8c3b" width="99">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="6ccc7d95-8eb4-45dd-990a-405dbdd76460" x="0" y="0" width="99" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Đơn giá (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="staticText" uuid="9507b170-f15d-4fc1-92d0-afdff63314dc" x="0" y="0" width="99" height="30" fontName="Arial" fontSize="12.0" bold="true" hTextAlign="Left" vTextAlign="Top">
<text><![CDATA[Tổng tiền thuốc:]]></text>
<box topPadding="3" leftPadding="3"/>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="b2a7a96b-2dfa-4e45-80fb-a539e558c7f7" x="0" y="0" width="99" height="30" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$F{supUnitPrice}]]></expression>
<box topPadding="3" leftPadding="3" rightPadding="3">
<pen lineWidth="1.0"/>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
</column>
<column kind="single" uuid="37250740-3d62-4dc1-800d-eb943da0388e" width="110">
<columnHeader height="20" rowSpan="1" style="Table_CH">
<element kind="staticText" uuid="5c61209b-8409-4ba2-979e-f52e49eb0b00" x="0" y="0" width="110" height="20" fontName="Arial" hTextAlign="Center" vTextAlign="Middle">
<text><![CDATA[Thành tiền (VND)]]></text>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
</columnHeader>
<columnFooter height="30" rowSpan="1">
<element kind="textField" uuid="f0e1b6cf-c081-4483-ab9c-a9112960858d" x="0" y="0" width="110" height="30" pattern="#,##0" bold="true" hTextAlign="Right" vTextAlign="Top">
<expression><![CDATA[$V{supTotal}]]></expression>
<box topPadding="3" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</columnFooter>
<detailCell height="30" style="Table_TD">
<element kind="textField" uuid="b46cdc11-d0af-4436-a554-b9c38613f07a" x="0" y="0" width="110" height="30" fontName="Arial" fontSize="8.0" pattern="#,##0" hTextAlign="Right" vTextAlign="Middle">
<expression><![CDATA[$V{supRowTotal}]]></expression>
<box topPadding="3" leftPadding="0" rightPadding="3">
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</element>
<box style="Table_TD">
<topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
<rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
</detailCell>
<property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
</column>
</component>
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
<property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
<property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
<property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
</element>
</band>
</detail>
<pageFooter height="29" splitType="Stretch">
<element kind="textField" uuid="6bf56eff-9df3-4dbc-a46f-ed2169078f76" x="300" y="6" width="252" height="19" pattern="MMMMM dd, yyyy" hTextAlign="Right" vTextAlign="Bottom">
<expression><![CDATA[new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm").format(new java.util.Date()) + " | Trang " + $V{PAGE_NUMBER}]]></expression>
</element>
</pageFooter>
<summary height="149" splitType="Stretch">
<element kind="staticText" uuid="f6d652a5-b593-4ee5-96a2-a4886beb7483" x="240" y="15" width="280" height="30" fontName="Arial" fontSize="16.0" bold="true">
<text><![CDATA[Tổng cộng thanh toán:]]></text>
</element>
<element kind="textField" uuid="f53358c4-1118-484a-968d-cf3fa2f55f3c" x="446" y="15" width="100" height="30" fontName="Arial" fontSize="16.0" evaluationTime="Report" pattern="#,##0" bold="true" hTextAlign="Right">
<expression><![CDATA[$V{MedicineGrandTotal}.add($V{ServiceGrandTotal}).add($V{SupplementGrandTotal})]]></expression>
</element>
<element kind="line" uuid="cc682c03-bd3f-480a-a69c-a7c56e855a7d" x="110" y="6" width="450" height="1">
<pen lineWidth="1.0"/>
</element>
<element kind="staticText" uuid="4884d0d3-eb98-4fd9-865c-a0d39f14ddce" x="376" y="37" width="70" height="15" fontName="Arial" fontSize="10.0" bold="true" hTextAlign="Left">
<text><![CDATA[Bác sĩ ghi toa:]]></text>
</element>
<element kind="textField" uuid="7430fd89-6565-41e6-a25a-619a9ab8f788" x="323" y="116" width="176" height="15" fontName="Arial" hTextAlign="Center">
<expression><![CDATA[$P{patientName}]]></expression>
</element>
<element kind="textField" uuid="0324ca00-fa26-42c4-a87b-4bac3fa6db7c" x="285" y="127" width="252" height="19" pattern="MMMMM dd, yyyy" hTextAlign="Center" vTextAlign="Bottom">
<expression><![CDATA[new java.text.SimpleDateFormat("'Đức Hoà, ngày ' dd ' tháng ' MM ' năm ' yyyy", new java.util.Locale("vi", "VN")).format(new java.util.Date())]]></expression>
</element>
</summary>
</jasperReport>
@@ -0,0 +1,94 @@
package BsK.client.ui.component.CheckUpPage.PrintDialog.print_forms;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JRParameter;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.File;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Locale;
import java.util.stream.Collectors;
public class test_print {
public static void main(String[] args) {
try {
// 1. Create a master list with all item types
List<InvoiceItem> allItems = new ArrayList<>();
// Medicines
allItems.add(InvoiceItem.createMedicine("Paracetamol", "2 viên/lần, 3 lần/ngày", 10, 10000.0, "Uống sau ăn"));
allItems.add(InvoiceItem.createMedicine("Amoxicillin", "1 viên/lần, 2 lần/ngày", 20, 5000.0, "Uống trước ăn 30 phút"));
// Services
allItems.add(InvoiceItem.createService("Khám tổng quát", "Kiểm tra sức khoẻ định kỳ", 1, 200000.0));
allItems.add(InvoiceItem.createService("Siêu âm ổ bụng", "", 1, 150000.0));
// Supplements
allItems.add(InvoiceItem.createSupplement("Vitamin C", "Uống sau ăn sáng", "1 viên/lần, 1 lần/ngày", 30, 2000.0));
allItems.add(InvoiceItem.createSupplement("Vitamin C", "Uống sau ăn sáng", "1 viên/lần, 1 lần/ngày", 30, 2000.0));
// 2. Filter the master list into separate lists for each type
List<InvoiceItem> medicines = allItems.stream().filter(item -> "MED".equals(item.getType())).collect(Collectors.toList());
List<InvoiceItem> services = allItems.stream().filter(item -> "SER".equals(item.getType())).collect(Collectors.toList());
List<InvoiceItem> supplements = allItems.stream().filter(item -> "SUP".equals(item.getType())).collect(Collectors.toList());
// 3. Create a JRBeanCollectionDataSource for each list
JRBeanCollectionDataSource medicineDS = new JRBeanCollectionDataSource(medicines);
JRBeanCollectionDataSource serviceDS = new JRBeanCollectionDataSource(services);
JRBeanCollectionDataSource supplementDS = new JRBeanCollectionDataSource(supplements);
// 4. Put the data sources into the parameters map
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("medicineDS", medicineDS);
parameters.put("serviceDS", serviceDS);
parameters.put("supplementDS", supplementDS);
// Set locale to Vietnamese for number formatting
parameters.put(JRParameter.REPORT_LOCALE, new Locale("vi", "VN"));
// Sample data parameters
parameters.put("name", "John Doe");
parameters.put("clinicName", " BSK CLINIC");
parameters.put("clinicPhone", "0123-456-789");
parameters.put("patientName", "Nguyen Van A");
parameters.put("clinicAddress", "123 Main Street, City, Country");
// Add logo image path
String logoPath = System.getProperty("user.dir") + "/src/main/java/BsK/client/ui/assets/icon/logo.jpg";
parameters.put("logoImage", logoPath);
// Add barcode number
parameters.put("barcodeNumber", "2024001234");
// Use relative path for jrxml file
String jrxmlPath = System.getProperty("user.dir") + "/src/main/java/BsK/client/ui/component/CheckUpPage/PrintDialog/print_forms/medserinvoice.jrxml";
InputStream inputStream = new FileInputStream(new File(jrxmlPath));
JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JREmptyDataSource());
// view the report
JasperViewer.viewReport(jasperPrint);
//JasperExportManager.exportReportToPdfFile(jasperPrint, "D:\\Github Clones\\BSK-All-in-One-Clinic-Management-System\\src\\main\\resources\\print_forms\\medserinvoice.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Binary file not shown.
Binary file not shown.