123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540 |
- package thyyxxk.simzfeeoprnsystm.service;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.itextpdf.text.Font;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.web.client.RestTemplate;
- import thyyxxk.simzfeeoprnsystm.config.MedinsurConfig;
- import thyyxxk.simzfeeoprnsystm.dao.RxDao;
- import thyyxxk.simzfeeoprnsystm.dicts.SiFunction;
- import thyyxxk.simzfeeoprnsystm.pojo.CodeName;
- import thyyxxk.simzfeeoprnsystm.pojo.ResultVo;
- import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.*;
- import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.request.*;
- import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.response.RxMedicine;
- import thyyxxk.simzfeeoprnsystm.utils.*;
- import thyyxxk.simzfeeoprnsystm.utils.rxsign.HseEncAndDecUtil;
- import com.itextpdf.text.*;
- 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.*;
- import java.util.List;
- @Slf4j
- @Service
- public class DigitalReceiptService {
- private final ExecService exec;
- private final RxDao rxDao;
- private final RestTemplate template;
- private final MedinsurConfig cfg;
- // 处方流转正式地址
- // private final static String cflzUrl = "http://130.150.161.72:8079/cflz";
- // private final static String ypcxUrl = "http://130.150.161.72:8079/cflzYpCx";
- // private final static String drCxUrl = "http://130.150.161.72:8079/drCx";
- // 处方流转测试地址
- private final static String cflzUrl = "http://130.150.161.72:8079/testCflz";
- private final static String ypcxUrl = "http://130.150.161.72:8079/testCflzYpCx";
- private final static String drcxUrl = "http://130.150.161.72:8079/testDrCx";
- @Autowired
- public DigitalReceiptService(ExecService exec, RxDao rxDao, RestTemplate template, MedinsurConfig cfg) {
- this.exec = exec;
- this.rxDao = rxDao;
- this.template = template;
- this.cfg = cfg;
- }
- public ResultVo<JSONObject> drInquiry() throws Exception {
- JSONObject data = new JSONObject();
- data.put("fixmedinsCode", cfg.getHospId());
- data.put("mdtrtareaAdmvs", cfg.getHospArea());
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- log.info("查询定点医师信息明文:{}", data);
- JSONObject result = template.postForObject(drcxUrl, input, JSONObject.class);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- return ResultVoUtil.success(decryptResult);
- }
- public ResultVo<JSONObject> medicineInquiry(MedicineInquiry inquiry) throws Exception {
- if (inquiry.needSaving()) {
- if (inquiry.getPageNum() == 1) {
- rxDao.truncateTable();
- } else {
- rxDao.deleteByPageNo(inquiry.getPageNum());
- }
- }
- return executeQuery(inquiry);
- }
- private ResultVo<JSONObject> executeQuery(MedicineInquiry inquiry) throws Exception {
- String dataRef = JSONObject.toJSONString(inquiry);
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("电子处方药品查询页码:{}", inquiry.getPageNum());
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(ypcxUrl, input, JSONObject.class);
- log.info("电子处方药品查询结果:{}", result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- Integer size = decryptResult.getInteger("size");
- if (null == size || 0 == size) {
- decryptResult.put("size", 0);
- }
- if (inquiry.needSaving()) {
- JSONArray list = decryptResult.getJSONArray("list");
- try {
- batchInsert(list, inquiry.getPageNum());
- } catch (Exception e) {
- log.info(list.toJSONString());
- throw new Exception(e);
- }
- if (!inquiry.onlyCurrentPage()) {
- Integer nextPage = decryptResult.getInteger("nextPage");
- if (null != nextPage && nextPage > inquiry.getPageNum()) {
- inquiry.setPageNum(nextPage);
- executeQuery(inquiry);
- }
- }
- decryptResult.remove("list");
- }
- return ResultVoUtil.success(decryptResult);
- }
- private void batchInsert(JSONArray array, int pageNo) {
- if (null == array || array.isEmpty()) {
- return;
- }
- List<RxMedicine> list = new ArrayList<>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject item = array.getJSONObject(i);
- RxMedicine medicine = JSONObject.parseObject(item.toJSONString(), RxMedicine.class);
- medicine.setId(UUID.randomUUID().toString().replaceAll("-", ""));
- medicine.setPyCode(PingYinUtil.getPinYinHeadChar(medicine.getRegName()));
- medicine.setPageNo(pageNo);
- list.add(medicine);
- if (list.size() == 50) {
- rxDao.batchInsertRxMedicine(list);
- list.clear();
- }
- }
- if (!list.isEmpty()) {
- rxDao.batchInsertRxMedicine(list);
- }
- }
- public ResultVo<JSONObject> rxPreCheck(RxPreCheckRequest request) throws Exception {
- CodeName phar = rxDao.getDocYbCode(request.getStaffId());
- if (null == phar || StringUtil.isBlank(phar.getYbCode())) {
- return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "审方药师医保编码不能为空。");
- }
- request.getRxMdtrtinfo().setPrscDrCertType("01");
- request.getRxMdtrtinfo().setPrscDrCertno("320823197007280258");
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxPreCheck(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- String rxdrugdetailRef = JSONArray.toJSONStringWithDateFormat(request.getRxDrugDetailList(), "yyyy-MM-dd HH:mm:ss");
- data.put("rxdrugdetail", JSONArray.parseArray(rxdrugdetailRef));
- String mdtrtinfoRef = JSONObject.toJSONStringWithDateFormat(request.getRxMdtrtinfo(), "yyyy-MM-dd HH:mm:ss");
- data.put("mdtrtinfo", JSONObject.parseObject(mdtrtinfoRef));
- String diseinfoRef = JSONArray.toJSONStringWithDateFormat(request.getRxDiseInfoList(), "yyyy-MM-dd HH:mm:ss");
- data.put("diseinfo", JSONArray.parseArray(diseinfoRef));
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/uploadChk", input, JSONObject.class);
- log.info("电子处方上传预核验:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- RxUpload rxUpload = new RxUpload();
- rxUpload.setHiRxno(decryptResult.getString("hiRxno"));
- rxUpload.setRxTraceCode(decryptResult.getString("rxTraceCode"));
- rxUpload.setHospRxno(request.getHospRxno());
- rxUpload.setMdtrtId(request.getRxMdtrtinfo().getMdtrtId());
- rxUpload.setPatnName(request.getRxMdtrtinfo().getPatnName());
- rxUpload.setPsnCertType(request.getRxMdtrtinfo().getPsnCertType());
- rxUpload.setCertno(request.getRxMdtrtinfo().getCertno());
- rxUpload.setDrCode(request.getRxMdtrtinfo().getDrCode());
- rxUpload.setPrscDrName(request.getRxMdtrtinfo().getPrscDrName());
- rxUpload.setPharDeptCode(request.getRxMdtrtinfo().getPrscDeptCode());
- rxUpload.setPharDeptName(request.getRxMdtrtinfo().getPrscDeptName());
- rxUpload.setPharCode(phar.getYbCode());
- rxUpload.setPharName(phar.getName());
- rxUpload.setRxFile(createRxPdf(request));
- rxUpload.setPharChkTime(new Date());
- int d = rxDao.deleteOldRxPreCheck(request.getHospRxno());
- int i = rxDao.insertRxPrecheck(rxUpload);
- log.info("电子处方预核验入库:删除:{},新增:{}", d, i);
- deleteRxPdfFile(request);
- return ResultVoUtil.success(decryptResult);
- }
- public ResultVo<JSONObject> rxSign(RxSignRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxSign(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/rxFixmedinsSign", input, JSONObject.class);
- log.info("电子处方医保电子签名:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- String signDigest = decryptResult.getString("signDigest");
- String rxFile = decryptResult.getString("rxFile");
- rxDao.updateSignDigest(request.getHospRxno(), signDigest, rxFile);
- return ResultVoUtil.success(decryptResult);
- }
- public ResultVo<JSONObject> rxUpload(RxUploadRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxUpload(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/rxFileUpld", input, JSONObject.class);
- log.info("电子处方上传:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- String hiRxno = decryptResult.getString("hiRxno");
- rxDao.updateRxState(hiRxno, RxState.UPLOADED);
- return ResultVoUtil.success(decryptResult);
- }
- public ResultVo<JSONObject> rxRevoke(RxRevokeRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxRevoke(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/rxUndo", input, JSONObject.class);
- log.info("电子处方撤销:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
- String hiRxno = decryptResult.getString("hiRxno");
- rxDao.updateRxState(hiRxno, RxState.REVOKED);
- return ResultVoUtil.success(decryptResult);
- }
- public ResultVo<JSONObject> rxInfoQuery(RxInfoQueryRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxInfoQuery(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/hospRxDetlQuery", input, JSONObject.class);
- log.info("电子处方信息查询:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- return ResultVoUtil.success(HseEncAndDecUtil.decryptMsg(result));
- }
- public ResultVo<JSONObject> rxAuditingQuery(RxAuditingQueryRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxAuditingQuery(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/rxChkInfoQuery", input, JSONObject.class);
- log.info("电子处方审核结果查询:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- return ResultVoUtil.success(HseEncAndDecUtil.decryptMsg(result));
- }
- public ResultVo<JSONObject> rxSetlQuery(RxSetlQueryRequest request) throws Exception {
- String dataRef = JSONObject.toJSONStringWithDateFormat(request.getRxSetlQuery(), "yyyy-MM-dd HH:mm:ss");
- JSONObject data = JSONObject.parseObject(dataRef);
- log.info("明文:{}", data);
- JSONObject input = HseEncAndDecUtil.encryptMsg(data);
- JSONObject result = template.postForObject(cflzUrl + "/rxSetlInfoQuery", input, JSONObject.class);
- log.info("电子处方取药结果查询:\n参数:{},\n结果:{}", input, result);
- if (null == result) {
- return ResultVoUtil.fail(ExceptionEnum.NETWORK_ERROR);
- }
- Integer code = result.getInteger("code");
- if (null == code || code != 0){
- return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
- }
- return ResultVoUtil.success(HseEncAndDecUtil.decryptMsg(result));
- }
- public String createRxPdf(RxPreCheckRequest request) throws Exception {
- String pdfFilePath = Global.FILE_PATH + request.getHospRxno() + ".pdf";
- File pdfFile = new File(pdfFilePath);
- if (pdfFile.exists()) {
- pdfFile.delete();
- }
- OutputStream outputStream = Files.newOutputStream(pdfFile.toPath());
- Document document = getDocument();
- PdfWriter pdfWriter = PdfWriter.getInstance(document, outputStream);
- document.open();
- BaseFont baseFont = BaseFont.createFont("STSong-Light","UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
- Font font = new Font(baseFont, 14, Font.BOLD);
- document.add(getTitleParagraph(font));
- 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);
- document.add(getFooter(baseFont, request));
- pdfWriter.setPageEvent(new PdfPageEventHelper() {
- @Override
- public void onStartPage(PdfWriter writer, Document document) {
- PdfContentByte pdfContentByte = writer.getDirectContent();
- pdfContentByte.saveState();
- pdfContentByte.beginText();
- pdfContentByte.setFontAndSize(baseFont, 10);
- float y = document.top(-20);
- pdfContentByte.showTextAligned(PdfContentByte.ALIGN_LEFT, "H-Left", document.left(), y, 0);
- pdfContentByte.showTextAligned(PdfContentByte.ALIGN_CENTER, "第" + writer.getPageNumber() + "页",
- (document.right() + document.left()) / 2, y, 0);
- pdfContentByte.showTextAligned(PdfContentByte.ALIGN_RIGHT, "H-Right", document.right(), y, 0);
- pdfContentByte.endText();
- LineSeparator line = new LineSeparator(1, 100, BaseColor.BLACK, Element.ALIGN_CENTER, 10);
- try {
- document.add(line);
- } catch (DocumentException e) {
- throw new RuntimeException(e);
- }
- pdfContentByte.restoreState();
- }
- });
- document.close();
- outputStream.close();
- byte[] pdfBytes = java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(pdfFilePath));
- return Base64.getEncoder().encodeToString(pdfBytes);
- }
- private Document getDocument() {
- Document document = new Document(PageSize.A4);
- document.addAuthor("沭阳铭和医院");
- document.addCreationDate();
- document.addSubject("处方笺");
- return document;
- }
- private Paragraph getTitleParagraph(Font font) {
- Paragraph titleParagraph = new Paragraph();
- Chunk titleChunkLine = new Chunk("沭 阳 铭 和 医 院 外 配 药 品 处 方 笺");
- titleChunkLine.setFont(font);
- titleChunkLine.setTextRise(30);
- titleParagraph.add(titleChunkLine);
- titleParagraph.setAlignment(Element.ALIGN_CENTER);
- LineSeparator line = new LineSeparator(1, 100, BaseColor.BLACK, Element.ALIGN_CENTER, 5);
- titleParagraph.add(line);
- return titleParagraph;
- }
- private PdfPTable getPatInfoTable(BaseFont baseFont, RxMdtrtInfo mdtrt) {
- Font smallFont = new Font(baseFont, 10, Font.NORMAL);
- PdfPTable table = new PdfPTable(3);
- 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 mdtrtIdCell = new PdfPCell(new Phrase("就诊ID:" + mdtrt.getMdtrtId(), smallFont));
- mdtrtIdCell.setBorder(-1);
- 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;
- }
- private PdfPTable getReceiptTable(BaseFont baseFont, List<RxDrugDetail> drugList) {
- Font smallFont = new Font(baseFont, 9, Font.NORMAL);
- PdfPTable table = new PdfPTable(4);
- table.setWidthPercentage(100);
- for (RxDrugDetail item : drugList) {
- String drugName = item.getDrugGenname() + "(" + item.getDrugSpec() + ")";
- PdfPCell drugNameCell = new PdfPCell(new Phrase(drugName, smallFont));
- drugNameCell.setBorder(-1);
- String usedWay = "用法:" + item.getMedcWayDscr() + "(" + item.getSinDoscnt() + item.getSinDosunt() + "/次)" ;
- PdfPCell usedWayCell = new PdfPCell(new Phrase(usedWay, smallFont));
- usedWayCell.setBorder(-1);
- String freq = "频率:" + item.getUsedFrquName();
- PdfPCell freqCell = new PdfPCell(new Phrase(freq, smallFont));
- freqCell.setBorder(-1);
- PdfPCell amountCell = new PdfPCell(new Phrase("× " + item.getDrugCnt() + item.getDrugDosunt(), smallFont));
- amountCell.setBorder(-1);
- table.addCell(drugNameCell);
- table.addCell(usedWayCell);
- table.addCell(freqCell);
- table.addCell(amountCell);
- }
- return table;
- }
- private PdfPTable getFooter(BaseFont baseFont, RxPreCheckRequest request) throws Exception {
- RxMdtrtInfo mdtrt = request.getRxMdtrtinfo();
- Font smallFont = new Font(baseFont, 10, Font.NORMAL);
- PdfPTable table = new PdfPTable(5);
- table.setHorizontalAlignment(Element.ALIGN_LEFT);
- table.setWidthPercentage(80);
- PdfPCell drNameCell = new PdfPCell(new Phrase("开方医师:", smallFont));
- drNameCell.setBorder(-1);
- String hisCode = rxDao.getDoctorHisCode(mdtrt.getDrCode());
- PdfPCell drSignCell = new PdfPCell();
- drSignCell.setBorder(-1);
- drSignCell.setImage(getDoctorSign(hisCode));
- PdfPCell blankCell = new PdfPCell(new Phrase(""));
- blankCell.setBorder(-1);
- PdfPCell phNameCell = new PdfPCell(new Phrase("审方药师:", smallFont));
- phNameCell.setBorder(-1);
- PdfPCell phSignCell = new PdfPCell();
- phSignCell.setBorder(-1);
- phSignCell.setImage(getDoctorSign(request.getStaffId()));
- table.addCell(drNameCell);
- table.addCell(drSignCell);
- table.addCell(blankCell);
- table.addCell(phNameCell);
- table.addCell(phSignCell);
- return table;
- }
- private Image getStamp() throws BadElementException, IOException {
- Image stamp = Image.getInstance("http://localhost:1100/stamp.png");
- stamp.scalePercent(50);
- int absoluteY = new Random().nextInt(20) + 630;
- stamp.setAbsolutePosition(460, absoluteY);
- return stamp;
- }
- private Image getDoctorSign(String hisCode) {
- return TryUtil.ignoreErr(() -> {
- Image signature = Image.getInstance("http://130.150.161.72:8080/doctorSignatureImage/" + hisCode + ".png");
- signature.scalePercent(35);
- return signature;
- });
- }
- private String translateGender(String gend) {
- gend = StringUtil.isBlank(gend) ? "9" : gend;
- switch (gend) {
- case "1":
- return "男";
- case "2":
- return "女";
- default:
- return "未知";
- }
- }
- private void deleteRxPdfFile(RxPreCheckRequest request) {
- String pdfFilePath = Global.FILE_PATH + request.getHospRxno() + ".pdf";
- File pdfFile = new File(pdfFilePath);
- if (pdfFile.exists()) {
- pdfFile.delete();
- }
- }
- }
|