소스 검색

有的报告会合并,导致医技申请单号变了查不到实际的报告,根据病人的id和申请单日期,医技医嘱编码查询实际报告单

hurugang 2 년 전
부모
커밋
9adf9efa78

+ 2 - 3
src/main/java/cn/hnthyy/thmz/controller/zd/JcJyController.java

@@ -215,9 +215,8 @@ public class JcJyController {
                 resultMap.put("message", "据HIS的检查申请单号查询检查报告失败,暂时没有对应的报告");
                 return resultMap;
             }
-            MzYjReq mzYjReq = mzYjReqService.queryMzYjReqByReqNo(hisReqNo);
-            if (mzYjReq != null && StringUtils.isNotBlank(mzYjReq.getPatientId())) {
-                MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(mzYjReq.getPatientId());
+            if (StringUtils.isNotBlank(patientId)) {
+                MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(patientId);
                 mzPatientMi.setGender(GenderEnum.getGenderByCode(mzPatientMi.getSex()).name);
                 data.put("mzPatientMi", mzPatientMi);
             }

+ 13 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/YjJcRecordMapper.java

@@ -7,6 +7,19 @@ import org.apache.ibatis.annotations.Select;
 import java.util.List;
 
 public interface YjJcRecordMapper {
+
+    /**
+     * 根据检查人id和医嘱编码与日期查询对应的检查报告单
+     * @param jcId
+     * @param orderCode
+     * @param beginTime
+     * @param endTime
+     * @return
+     */
+    @Select("select report_no,his_req_no,* from yj_jc_record WITH(NOLOCK)   where   jc_id=#{jcId}  and order_code=#{orderCode} and input_date >=#{beginTime} and input_date<=#{endTime}")
+    YjJcRecord selectByJcIdAndOrderCodeAndReqDate(@Param("jcId") String jcId,@Param("orderCode") String orderCode, @Param("beginTime") String beginTime, @Param("endTime") String endTime);
+
+
     /**
      * 根据门诊id查询检查ids
      *

+ 3 - 1
src/main/java/cn/hnthyy/thmz/service/his/zd/JcJyItemChargeService.java

@@ -97,8 +97,10 @@ public interface JcJyItemChargeService {
 
     /**
      * 根据his的检查申请单号查询检查报告
-     * @param hisReqNo
+     * @param hisReqNo 门诊医技申请单
+     * @param patientId 门诊id
      * @return
+     * @throws MzException
      */
     Map<String,Object> getYjJcRecordReport(String hisReqNo,String patientId) throws MzException;
 

+ 23 - 3
src/main/java/cn/hnthyy/thmz/service/impl/his/zd/JcJyItemChargeServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.hnthyy.thmz.service.impl.his.zd;
 
+import cn.hnthyy.thmz.Utils.DateUtil;
 import cn.hnthyy.thmz.Utils.SignUtil;
 import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.MzException;
@@ -264,13 +265,32 @@ public class JcJyItemChargeServiceImpl implements JcJyItemChargeService {
             throw new MzException("病人检查ID不存在!");
         }
         List<YjJcRecord> jcRecords = yjJcRecordMapper.selectYjJcRecordByHisReqNo(hisReqNo, jcId);
-        if (jcRecords == null || jcRecords.size() == 0) {
-            throw new MzException("暂时还没有对应的报告单,请稍后重试!");
+        YjJcRecord jcRecord =null;
+        if (jcRecords != null && jcRecords.size() > 0) {
+            //throw new MzException("暂时还没有对应的报告单,请稍后重试!");
+            jcRecord = jcRecords.get(0);
         }
         if (jcRecords.size() > 1) {
             log.error("his申请单号为{}的记录对应的检查单号有多条", hisReqNo);
         }
-        YjJcRecord jcRecord = jcRecords.get(0);
+        //有的报告会合并,导致医技申请单号变了查不到实际的报告,根据病人的id和申请单日期,医技医嘱编码查询实际报告单
+        if (jcRecord == null) {
+            MzYjReq mzYjReq = mzYjReqMapper.selectMzYjReqByReqNo(hisReqNo);
+            if (mzYjReq == null) {
+                throw new MzException("据HIS的检查申请单号查询检查报告失败,没有找到申请单记录");
+            }
+            JcZdItem jcZdItem=jcZdItemMapper.selectJcZdItemByCode(mzYjReq.getOrderCode());
+            if(jcZdItem==null){
+                throw new MzException("据HIS的检查申请单号查询检查报告失败,没有找到对应的医技项目");
+            }
+            if(StringUtils.isBlank(jcZdItem.getZyOrderCode())){
+                throw new MzException("据HIS的检查申请单号查询检查报告失败,没有找到对应的医技项目编码");
+            }
+            String beginTime =DateUtil.fomart(DateUtil.getFirstSecond(mzYjReq.getReqDate()),"yyyy-MM-dd HH:mm:ss");
+            String endTime =DateUtil.fomart(DateUtil.getLastSecond(mzYjReq.getReqDate()),"yyyy-MM-dd HH:mm:ss");
+            jcRecord= yjJcRecordMapper.selectByJcIdAndOrderCodeAndReqDate(jcId,jcZdItem.getZyOrderCode(),beginTime,endTime);
+        }
+        //YjJcRecord jcRecord = jcRecords.get(0);
         if (jcRecord == null || jcRecord.getReportNo() == null || StringUtils.isBlank(jcRecord.getReportNo())) {
             throw new MzException("报告单为空!!");
         }