Explorar el Código

优化电子处方的PDF

lighter hace 1 año
padre
commit
b33072cb67

+ 52 - 7
src/main/java/thyyxxk/simzfeeoprnsystm/service/DigitalReceiptService.java

@@ -19,6 +19,7 @@ import com.itextpdf.text.pdf.*;
 import com.itextpdf.text.pdf.draw.LineSeparator;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.util.Base64;
@@ -183,10 +184,15 @@ public class DigitalReceiptService {
 
         document.add(getPatInfoTable(baseFont, request.getRxMdtrtinfo()));
         LineSeparator line = new LineSeparator(1, 100, BaseColor.BLACK, Element.ALIGN_CENTER, -7);
+        document.add(getStamp());
         document.add(line);
+        document.add(Chunk.NEWLINE);
 
+        document.add(new Phrase("Rp", new Font(baseFont, 16, Font.BOLD)));
         document.add(Chunk.NEWLINE);
+
         document.add(getReceiptTable(baseFont, request.getRxDrugDetailList()));
+        document.add(Chunk.NEWLINE);
         document.add(line);
 
         document.add(Chunk.NEWLINE);
@@ -249,30 +255,46 @@ public class DigitalReceiptService {
         table.setWidthPercentage(100);
         PdfPCell nameCell = new PdfPCell(new Phrase("姓名:" + mdtrt.getPatnName(), smallFont));
         nameCell.setBorder(-1);
+        nameCell.setPaddingTop(6);
         PdfPCell genderCell = new PdfPCell(new Phrase("性别:" + translateGender(mdtrt.getGend()), smallFont));
         genderCell.setBorder(-1);
+        genderCell.setPaddingTop(6);
         PdfPCell ageCell = new PdfPCell(new Phrase("年龄: " + mdtrt.getPatnAge() + "岁",smallFont));
         ageCell.setBorder(-1);
+        ageCell.setPaddingTop(6);
         table.addCell(nameCell);
         table.addCell(genderCell);
         table.addCell(ageCell);
 
         PdfPCell patNoCell = new PdfPCell(new Phrase("门诊号:" + mdtrt.getIptOtpNo(), smallFont));
         patNoCell.setBorder(-1);
+        patNoCell.setPaddingTop(12);
+        patNoCell.setPaddingBottom(6);
         PdfPCell deptCell = new PdfPCell(new Phrase("科别:" + mdtrt.getPrscDeptName(), smallFont));
         deptCell.setBorder(-1);
+        deptCell.setPaddingTop(12);
+        deptCell.setPaddingBottom(6);
         PdfPCell diagCell = new PdfPCell(new Phrase("临床诊断:" + mdtrt.getMaindiagName(),smallFont));
         diagCell.setBorder(-1);
+        diagCell.setPaddingTop(12);
+        diagCell.setPaddingBottom(6);
         table.addCell(patNoCell);
         table.addCell(deptCell);
         table.addCell(diagCell);
 
-        PdfPCell dateCell = new PdfPCell(new Phrase("开具日期:" + DateUtil.formatDatetime(mdtrt.getMdtrtTime()), smallFont));
-        dateCell.setBorder(-1);
         PdfPCell mdtrtIdCell = new PdfPCell(new Phrase("就诊ID:" + mdtrt.getMdtrtId(), smallFont));
         mdtrtIdCell.setBorder(-1);
-        table.addCell(dateCell);
+        mdtrtIdCell.setPaddingTop(12);
+        mdtrtIdCell.setPaddingBottom(6);
+        PdfPCell dateCell = new PdfPCell(new Phrase("开具日期:" + DateUtil.formatDatetime(mdtrt.getMdtrtTime()), smallFont));
+        dateCell.setBorder(-1);
+        dateCell.setPaddingTop(12);
+        dateCell.setPaddingBottom(6);
+        PdfPCell blankCell = new PdfPCell(new Phrase(""));
+        blankCell.setBorder(-1);
         table.addCell(mdtrtIdCell);
+        table.addCell(dateCell);
+        table.addCell(blankCell);
         return table;
     }
 
@@ -291,7 +313,7 @@ public class DigitalReceiptService {
             PdfPCell freqCell = new PdfPCell(new Phrase("用法:" + usedWay, smallFont));
             freqCell.setBorder(-1);
 
-            PdfPCell amountCell = new PdfPCell(new Phrase("×   " + item.getDrugCnt(), smallFont));
+            PdfPCell amountCell = new PdfPCell(new Phrase("×   " + item.getDrugCnt() + item.getDrugTotlcntEmp(), smallFont));
             amountCell.setBorder(-1);
 
             table.addCell(chargeCell);
@@ -302,10 +324,33 @@ public class DigitalReceiptService {
         return table;
     }
 
-    private Phrase getFooter(BaseFont baseFont, RxMdtrtInfo mdtrt) {
+    private PdfPTable getFooter(BaseFont baseFont, RxMdtrtInfo mdtrt) throws Exception {
         Font smallFont = new Font(baseFont, 10, Font.NORMAL);
-        String drInfo = "医师:" + mdtrt.getPrscDrName() + " / " + mdtrt.getDrCode();
-        return new Phrase(drInfo, smallFont);
+        String drInfo = "开方医师:" + mdtrt.getPrscDrName();
+        PdfPTable table = new PdfPTable(2);
+        table.setHorizontalAlignment(Element.ALIGN_LEFT);
+        table.setWidthPercentage(30);
+        PdfPCell nameCell = new PdfPCell(new Phrase(drInfo, smallFont));
+        nameCell.setBorder(-1);
+        PdfPCell signCell = new PdfPCell();
+        signCell.setBorder(-1);
+        signCell.setImage(getDoctorSign());
+        table.addCell(nameCell);
+        table.addCell(signCell);
+        return table;
+    }
+
+    private Image getStamp() throws BadElementException, IOException {
+        Image stamp = Image.getInstance(Global.FILE_PATH + "transparentStamp.png");
+        stamp.scalePercent(40);
+        stamp.setAbsolutePosition(460, 680);
+        return stamp;
+    }
+
+    private Image getDoctorSign() throws BadElementException, IOException {
+        Image stamp = Image.getInstance(Global.FILE_PATH + "doctorSign.png");
+        stamp.scalePercent(35);
+        return stamp;
     }
 
     private String translateGender(String gend) {