LIJU 2 ماه پیش
والد
کامیت
786f63a9dc

+ 5 - 0
src/main/java/cn/hnthyy/thmz/entity/his/yb/SiPatInfo.java

@@ -83,4 +83,9 @@ public class SiPatInfo implements Serializable {
     private BigDecimal quantity;     // 数量
     private BigDecimal unitPrice;    // 单价
     private String confirmName;      // 确认人
+    
+    // 医保相关字段(从yp_zd_dict表关联查询得到)
+    private String medListCodg;      // 医疗目录编码
+    private String rxFlag;           // 处方药标志
+    private String trdnFlag;         // 拆零标志
 } 

+ 8 - 3
src/main/java/cn/hnthyy/thmz/mapper/his/yb/SiPatInfoMapper.java

@@ -73,11 +73,12 @@ public interface SiPatInfoMapper {
      * @return 处方列表
      */
     @Select({
-        "SELECT c.order_no as orderNo, c.charge_date as orderTime, c.receipt_no as receiptNo, c.real_no as realNo, ",
+        "SELECT DISTINCT c.order_no as orderNo, c.charge_date as orderTime, c.receipt_no as receiptNo, c.real_no as realNo, ",
         "c.name as doctorName, c.exec_dept as deptName, ",
-        "ISNULL(c.order_type, '') as orderType, ISNULL(c.unit_price * c.quantity, 0) as totalAmount, ISNULL(c.confirm_flag, 0) as confirmFlag ",
+        "ISNULL(c.order_type, '') as orderType, ISNULL(SUM(c.unit_price * c.quantity), 0) as totalAmount, ISNULL(c.confirm_flag, 0) as confirmFlag ",
         "FROM mz_charge_detail c ",
         "WHERE c.patient_id = #{patientId} AND c.times = #{times} ",
+        "GROUP BY c.order_no, c.charge_date, c.receipt_no, c.real_no, c.name, c.exec_dept, c.order_type, c.confirm_flag ",
         "ORDER BY c.charge_date DESC"
     })
     List<PrescriptionVo> selectPrescriptionsByVisit(@Param("patientId") String patientId, @Param("times") Integer times);
@@ -92,8 +93,12 @@ public interface SiPatInfoMapper {
     @Select({
         "SELECT m.charge_item_code as chargeItemCode, ISNULL(m.drug_name, '') as drugName, ISNULL(m.specification, '') as specification, ",
         "1 as quantity, ISNULL(m.unit_price, 0) as unitPrice, m.drug_trac_codg as drugTracCodg, m.confirm_time as scanTime, ",
-        "ISNULL(m.confirm_name, '') as scanUser, m.order_no as orderNo, m.receipt_no as receiptNo, m.real_no as realNo ",
+        "ISNULL(m.confirm_name, '') as scanUser, m.order_no as orderNo, m.receipt_no as receiptNo, m.real_no as realNo, ",
+        "ISNULL(y.national_code, '') as medListCodg, '0' as rxFlag, '0' as trdnFlag, ",
+        "ISNULL(p.psn_cert_type, '01') as psnCertType, ISNULL(p.certno, '') as certno ",
         "FROM mz_drug_trac_codg m ",
+        "LEFT JOIN yp_zd_dict y ON m.charge_item_code = y.code AND y.serial = '01' ",
+        "LEFT JOIN t_si_pat_info p ON m.patient_id = p.pat_no AND m.times = p.times ",
         "WHERE m.patient_id = #{patientId} AND m.times = #{times} ",
         "AND m.order_no = #{orderNo} ",
         "AND m.drug_trac_codg IS NOT NULL ",

+ 14 - 4
src/main/java/cn/hnthyy/thmz/service/impl/yb/YbParamDetailServiceImpl.java

@@ -131,8 +131,18 @@ public class YbParamDetailServiceImpl implements YbParamDetailService {
         selinfoSold.setSelRetnOpterName("宋荣芝");
         selinfoSold.setPharPracCertNo("HY321322000735");
         selinfoSold.setMdtrtSetlType("2");
-        selinfoSold.setRxFlag("0");
-        selinfoSold.setTrdnFlag("0");
+        
+        // 从药品字典表获取医保相关参数
+        selinfoSold.setMedListCodg(baseInfo.getMedListCodg() != null ? baseInfo.getMedListCodg() : "");
+        selinfoSold.setRxFlag(baseInfo.getRxFlag() != null ? baseInfo.getRxFlag() : "0");
+        selinfoSold.setTrdnFlag(baseInfo.getTrdnFlag() != null ? baseInfo.getTrdnFlag() : "0");
+        
+        // 补充患者相关参数
+        selinfoSold.setPrscDrName(prescription.getDoctorName()); // 开方医师姓名
+        selinfoSold.setPsnCertType(baseInfo.getPsnCertType() != null ? baseInfo.getPsnCertType() : "01"); // 人员证件类型
+        selinfoSold.setCertno(baseInfo.getCertno() != null ? baseInfo.getCertno() : ""); // 证件号码
+        selinfoSold.setPsnNo(visitRecord.getPsnNo()); // 医保人员编号
+        
         drugDetail.setSelinfoSold(selinfoSold);
 
         // 构建追溯码基本信息
@@ -151,8 +161,8 @@ public class YbParamDetailServiceImpl implements YbParamDetailService {
                 tracCodgDetail.setDrugTracCodg(info.getDrugTracCodg());
                 tracCodgDetail.setDrugName(info.getDrugName());
                 tracCodgDetail.setSpecification(info.getSpecification());
-                tracCodgDetail.setScanTime(info.getConfirmTime());
-                tracCodgDetail.setScanUser(info.getConfirmName());
+                tracCodgDetail.setScanTime(info.getConfirmTime() != null ? info.getConfirmTime() : new Date());
+                tracCodgDetail.setScanUser(info.getConfirmName() != null ? info.getConfirmName() : "宋荣芝");
                 // 设置其他追溯码详情信息(从数据库获取)
                 tracCodgDetail.setManufacturer("未知厂家"); // 默认值,实际应从数据库获取
                 tracCodgDetail.setBatchNo("未知批号");     // 默认值,实际应从数据库获取