Browse Source

优化电子处方

lighter 7 months ago
parent
commit
e057bca4b7

+ 16 - 5
src/main/java/thyyxxk/simzfeeoprnsystm/dao/RxDao.java

@@ -1,6 +1,7 @@
 package thyyxxk.simzfeeoprnsystm.dao;
 
 import org.apache.ibatis.annotations.*;
+import thyyxxk.simzfeeoprnsystm.pojo.CodeName;
 import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.RxState;
 import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.RxUpload;
 import thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt.response.RxMedicine;
@@ -10,13 +11,23 @@ import java.util.List;
 @Mapper
 public interface RxDao {
 
-    @Insert("delete from t_rx_precheck where hosp_rxno=#{hospRxno};" +
-            "insert into t_rx_precheck (hosp_rxno,hi_rxno,rx_trace_code,mdtrt_id," +
-            "patn_name,psn_cert_type,certno,dr_code,prsc_dr_name,original_rx_file) " +
+    @Select("select rtrim(code) from a_employee_mi where yb_code=#{ybCode}")
+    String getDoctorHisCode(String ybCode);
+
+    @Select("select rtrim(yb_code) as ybCode,rtrim(name) as name from a_employee_mi where code=#{code}")
+    CodeName getDocYbCode(String code);
+
+    @Delete("delete from t_rx_precheck where hosp_rxno=#{hospRxno};")
+    int deleteOldRxPreCheck(String hospRxno);
+
+    @Insert("insert into t_rx_precheck (hosp_rxno,hi_rxno,rx_trace_code,mdtrt_id," +
+            "patn_name,psn_cert_type,certno,dr_code,prsc_dr_name,phar_dept_code," +
+            "phar_dept_name,phar_code,phar_name,phar_chk_time,original_rx_file) " +
             "values (#{hospRxno},#{hiRxno},#{rxTraceCode}," +
             "#{mdtrtId},#{patnName},#{psnCertType},#{certno}," +
-            "#{drCode},#{prscDrName},#{rxFile})")
-    void insertRxPrecheck(RxUpload obj);
+            "#{drCode},#{prscDrName},#{pharDeptCode},#{pharDeptName}," +
+            "#{pharCode},#{pharName},#{pharChkTime},#{rxFile})")
+    int insertRxPrecheck(RxUpload obj);
 
     @Update("update t_rx_precheck set original_rx_file = #{rxFile} where hosp_rxno=#{hospRxno} ;")
     void test(RxUpload obj);

+ 17 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/dao/SiMzDao.java

@@ -23,6 +23,9 @@ public interface SiMzDao {
     @Update("update t_si_pat_info set mdtrt_id=#{nullCtnt}, setl_id=#{nullCtnt} where pat_no=#{patientId} and times=#{times} ")
     void clearMdtrtIdForMz(String patientId, int times, String nullCtnt);
 
+    @Select("select mdtrt_id from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
+    String getMdtrtId(String patNo, int times);
+
     @Select("select a.psn_no, mdtrtCertType='02',b.visit_date as begntime, " +
             "a.certno as mdtrtCertNo,a.psn_cert_type,a.certno,a.psn_name, " +
             "rtrim(b.visit_dept_code) as deptCode,a.mdtrt_id, " +
@@ -34,6 +37,16 @@ public interface SiMzDao {
             "from t_si_pat_info a, mz_visit_table b where a.pat_no=#{patNo} and a.times=#{times} " +
             "and a.pat_no=b.patient_id and a.times=b.times")
     Regstrtn selectRegstrtn(String patNo, int times);
+    
+    @Select("select psn_no, mdtrtCertType='02', " +
+            "certno as mdtrtCertNo,psn_cert_type,certno,psn_name,mdtrt_id, " +
+            "atddrNo=(select rtrim(yb_code) from a_employee_mi where code=#{doctorCode}), " +
+            "drName=(select rtrim(name) from a_employee_mi where code=#{doctorCode}), " +
+            "caty=(select si_caty from zd_unit_code where code=#{deptCode}), " +
+            "deptName=(select z.name from t_yb_dept z where z.code= " +
+            "(select t.si_caty from zd_unit_code t where t.code=#{deptCode})) " +
+            "from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
+    Regstrtn selectRegstrtn2(MzPatientInfo params);
 
     @Select("select times from mz_patient_mi where patient_id=#{patientId} ")
     Integer selectMaxTimes(String patientId);
@@ -91,6 +104,10 @@ public interface SiMzDao {
             "from mz_visit_table where patient_id=#{patNo} and times=#{times}")
     Diagnoses selectDiseinfo(String patNo, int times);
 
+    @Select("select rtrim(yb_code) as code, rtrim(name) as name " +
+            "from a_employee_mi where code=#{code}")
+    CodeName getDorCodeAndName(String code);
+
     @Update("update t_si_pat_info set dise_code=#{code},dise_name=#{name} where pat_no=#{patNo} and times=#{times}")
     void updatePatDiseinfo(String patNo, int times, String code, String name);
 

+ 1 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/CodeName.java

@@ -7,6 +7,7 @@ public class CodeName {
     private String code;
     private String codeRs;
     private String name;
+    private String ybCode;
 
     public String getStaff() {
         return "【工号:" + codeRs + ",姓名:" + name + "】";

+ 8 - 2
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/DirectionRegParam.java

@@ -3,6 +3,8 @@ package thyyxxk.simzfeeoprnsystm.pojo;
 import lombok.Data;
 import thyyxxk.simzfeeoprnsystm.utils.StringUtil;
 
+import java.util.Date;
+
 @Data
 public class DirectionRegParam {
     private String staffId;
@@ -10,11 +12,15 @@ public class DirectionRegParam {
     private Integer times;
 
     private String medType;
-    // 慢特病病种编码
     private String opspDiseCode;
-    // 慢特病病种名称
     private String opspDiseName;
 
+    private Date visitDate;
+    private String visitDeptCode;
+    private String doctorCode;
+    private String icdCodeNew;
+    private String icdTextNew;
+
     private Integer acctUsedFlag;
     // 读卡类型:01-电子凭证,02-身份证,03-社保卡
     private String readCardType;

+ 2 - 0
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/MzPatientInfo.java

@@ -35,6 +35,8 @@ public class MzPatientInfo {
     private String deptClass;
     private String icdCode;
     private String icdText;
+    private String icdCodeNew;
+    private String icdTextNew;
     private Integer needSaving;
     private Integer saved;
     private Boolean revokeRegistration;

+ 23 - 22
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/SiSetlinfo.java

@@ -7,6 +7,7 @@ import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -81,7 +82,7 @@ public class SiSetlinfo implements Serializable {
 	/**
 	 * 年龄
 	 */
-	private Double age;
+	private BigDecimal age;
 
 	/**
 	 * 险种类型
@@ -116,107 +117,107 @@ public class SiSetlinfo implements Serializable {
 	/**
 	 * 医疗费总额
 	 */
-	private Double medfeeSumamt;
+	private BigDecimal medfeeSumamt;
 
 	/**
 	 * 全自费金额
 	 */
-	private Double fulamtOwnpayAmt;
+	private BigDecimal fulamtOwnpayAmt;
 
 	/**
 	 * 超限价自费费用
 	 */
-	private Double overlmtSelfpay;
+	private BigDecimal overlmtSelfpay;
 
 	/**
 	 * 先行自付金额
 	 */
-	private Double preselfpayAmt;
+	private BigDecimal preselfpayAmt;
 
 	/**
 	 * 符合政策范围金额
 	 */
-	private Double inscpScpAmt;
+	private BigDecimal inscpScpAmt;
 
 	/**
 	 * 实际支付起付线
 	 */
-	private Double actPayDedc;
+	private BigDecimal actPayDedc;
 
 	/**
 	 * 基本医疗保险统筹基金支出
 	 */
-	private Double hifpPay;
+	private BigDecimal hifpPay;
 
 	/**
 	 * 基本医疗保险统筹基金支付比例
 	 */
-	private Double poolPropSelfpay;
+	private BigDecimal poolPropSelfpay;
 
 	/**
 	 * 公务员医疗补助资金支出
 	 */
-	private Double cvlservPay;
+	private BigDecimal cvlservPay;
 
 	/**
 	 * 企业补充医疗保险基金支出
 	 */
-	private Double hifesPay;
+	private BigDecimal hifesPay;
 
 	/**
 	 * 居民大病保险资金支出
 	 */
-	private Double hifmiPay;
+	private BigDecimal hifmiPay;
 
 	/**
 	 * 职工大额医疗费用补助基金支出
 	 */
-	private Double hifobPay;
+	private BigDecimal hifobPay;
 
 	/**
 	 * 医疗救助基金支出
 	 */
-	private Double mafPay;
+	private BigDecimal mafPay;
 
 	/**
 	 * 医院负担金额
 	 */
-	private Double hospPartAmt;
+	private BigDecimal hospPartAmt;
 
 	/**
 	 * 其他支出
 	 */
-	private Double othPay;
+	private BigDecimal othPay;
 
 	/**
 	 * 基金支付总额
 	 */
-	private Double fundPaySumamt;
+	private BigDecimal fundPaySumamt;
 
 	/**
 	 * 个人负担总金额
 	 */
-	private Double psnPartAmt;
+	private BigDecimal psnPartAmt;
 
 	/**
 	 * 个人账户支出
 	 */
-	private Double acctPay;
+	private BigDecimal acctPay;
 
 	/**
 	 * 个人现金支出
 	 */
-	private Double psnCashPay;
+	private BigDecimal psnCashPay;
 
 	/**
 	 * 余额
 	 */
-	private Double balc;
+	private BigDecimal balc;
 
 	/**
 	 * 个人账户共济支付金额
 	 */
-	private Double acctMulaidPay;
+	private BigDecimal acctMulaidPay;
 
 	/**
 	 * 医药机构结算ID

+ 2 - 1
src/main/java/thyyxxk/simzfeeoprnsystm/pojo/digitalreceipt/RxState.java

@@ -1,7 +1,8 @@
 package thyyxxk.simzfeeoprnsystm.pojo.digitalreceipt;
 
 public enum RxState {
-    UNSIGNED,
+    NEW_RECEIPT,
+    PRE_CHECKED,
     SIGNED,
     UPLOADED,
     REVOKED,

+ 30 - 19
src/main/java/thyyxxk/simzfeeoprnsystm/service/DigitalReceiptService.java

@@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 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.*;
@@ -23,10 +24,8 @@ import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.Base64;
+import java.util.*;
 import java.util.List;
-import java.util.UUID;
 
 @Slf4j
 @Service
@@ -126,6 +125,8 @@ public class DigitalReceiptService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, result.getString("message"));
         }
 
+        CodeName phar = rxDao.getDocYbCode(request.getStaffId());
+
         JSONObject decryptResult = HseEncAndDecUtil.decryptMsg(result);
         RxUpload rxUpload = new RxUpload();
         rxUpload.setHiRxno(decryptResult.getString("hiRxno"));
@@ -137,8 +138,15 @@ public class DigitalReceiptService {
         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));
-        rxDao.insertRxPrecheck(rxUpload);
+        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);
     }
@@ -237,7 +245,7 @@ public class DigitalReceiptService {
         return ResultVoUtil.success(HseEncAndDecUtil.decryptMsg(result));
     }
 
-    private String createRxPdf(RxPreCheckRequest request) throws Exception {
+    public String createRxPdf(RxPreCheckRequest request) throws Exception {
         String pdfFilePath = Global.FILE_PATH + request.getHospRxno() + ".pdf";
         File pdfFile = new File(pdfFilePath);
         if (pdfFile.exists()) {
@@ -369,26 +377,29 @@ public class DigitalReceiptService {
     }
 
     private PdfPTable getReceiptTable(BaseFont baseFont, List<RxDrugDetail> drugList) {
-        Font smallFont = new Font(baseFont, 10, Font.NORMAL);
-        PdfPTable table = new PdfPTable(3);
+        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 chargeCell = new PdfPCell(new Phrase(drugName, smallFont));
-            chargeCell.setBorder(-1);
+            PdfPCell drugNameCell = new PdfPCell(new Phrase(drugName, smallFont));
+            drugNameCell.setBorder(-1);
 
-            String usedWay = item.getSinDoscnt() + item.getSinDosunt() + "/次 +    " +
-                    item.getUsedFrquName() + "    " + item.getMedcWayDscr();
+            String usedWay = "用法:" + item.getMedcWayDscr() + "(" + item.getSinDoscnt() + item.getSinDosunt() + "/次)" ;
+            PdfPCell usedWayCell = new PdfPCell(new Phrase(usedWay, smallFont));
+            usedWayCell.setBorder(-1);
 
-            PdfPCell freqCell = new PdfPCell(new Phrase("用法:" + usedWay, smallFont));
+            String freq = "频率:" + item.getUsedFrquName();
+            PdfPCell freqCell = new PdfPCell(new Phrase(freq, smallFont));
             freqCell.setBorder(-1);
 
-            PdfPCell amountCell = new PdfPCell(new Phrase("×   " + item.getDrugCnt() + item.getDrugTotlcntEmp(), smallFont));
+            PdfPCell amountCell = new PdfPCell(new Phrase("×   " + item.getDrugCnt() + item.getDrugDosunt(), smallFont));
             amountCell.setBorder(-1);
 
-            table.addCell(chargeCell);
+            table.addCell(drugNameCell);
+            table.addCell(usedWayCell);
             table.addCell(freqCell);
             table.addCell(amountCell);
         }
@@ -398,15 +409,14 @@ public class DigitalReceiptService {
 
     private PdfPTable getFooter(BaseFont baseFont, RxMdtrtInfo mdtrt) throws Exception {
         Font smallFont = new Font(baseFont, 10, Font.NORMAL);
-        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));
+        PdfPCell nameCell = new PdfPCell(new Phrase("开方医师:", smallFont));
         nameCell.setBorder(-1);
         PdfPCell signCell = new PdfPCell();
         signCell.setBorder(-1);
-        signCell.setImage(getDoctorSign());
+        signCell.setImage(getDoctorSign(mdtrt.getDrCode()));
         table.addCell(nameCell);
         table.addCell(signCell);
         return table;
@@ -419,8 +429,9 @@ public class DigitalReceiptService {
         return stamp;
     }
 
-    private Image getDoctorSign() throws BadElementException, IOException {
-        Image stamp = Image.getInstance("http://webhis.thyy.cn:8080/doctorSignatureImage/02521.png");
+    private Image getDoctorSign(String ybCode) throws BadElementException, IOException {
+        String hisCode = rxDao.getDoctorHisCode(ybCode);
+        Image stamp = Image.getInstance("http://webhis.thyy.cn:8080/doctorSignatureImage/" + hisCode + ".png");
         stamp.scalePercent(35);
         return stamp;
     }

+ 1 - 7
src/main/resources/application-dev.yml

@@ -13,7 +13,7 @@ spring:
     cache: false
   datasource:
     dynamic:
-      primary: dev
+      primary: his
       strict: false
       datasource:
         his:
@@ -22,12 +22,6 @@ spring:
           password:
           type: "com.zaxxer.hikari.HikariDataSource"
           driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
-        dev:
-          url: "jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb"
-          username: "sa"
-          password:
-          type: "com.zaxxer.hikari.HikariDataSource"
-          driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
         thmz:
           url: "jdbc:mariadb://172.16.32.160:3306/thyy_mz_system?useUnicode=true&characterEncoding=utf-8"
           username: "root"