浏览代码

检验检查后端校验

xiaochan 2 月之前
父节点
当前提交
f5be26994d

+ 4 - 4
src/main/java/thyyxxk/webserver/aop/aspect/CheckClinicalPathwayAop.java

@@ -36,16 +36,16 @@ public class CheckClinicalPathwayAop {
         }
         ClinicalPathwayTemplates clinicalPathwayTemplates = dao.selectById(templateId);
         if (clinicalPathwayTemplates == null) {
-            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板id不存在请刷新页面");
+            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板已经被停用了。");
         }
 
         if (!TokenUtil.getInstance().getTokenUserId().equals(clinicalPathwayTemplates.getCreateCode())) {
             throw new BizException(ExceptionEnum.LOGICAL_ERROR, "改模板不是您创建的无法修改。");
         }
 
-        if (clinicalPathwayTemplates.getPublish()) {
-            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板已经发布无法修改");
-        }
+//        if (clinicalPathwayTemplates.getPublish()) {
+//            throw new BizException(ExceptionEnum.LOGICAL_ERROR, "模板已经发布无法修改");
+//        }
     }
 
 }

+ 15 - 0
src/main/java/thyyxxk/webserver/controller/dictionary/clinicalPathway/ClinicalPathwayController.java

@@ -112,6 +112,21 @@ public class ClinicalPathwayController {
         return ResultVoUtil.success();
     }
 
+
+    @PostMapping("/deleteTemplate")
+    @CheckClinicalPathway
+    @NeedMenu(MenuEnum.clinicalPathway)
+    public ResultVo<String> deleteTemplate(@RequestParam("templateId") String templateId) {
+        ClinicalPathwayTemplates templates = dao.selectById(templateId);
+
+        if (templates == null) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "可能已经被删除了。");
+        }
+
+        dao.deleteTemplate(templates.getId(), TokenUtil.getInstance().getTokenUserId());
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_NOTIFICATION);
+    }
+
     @GetMapping("/addDay")
     @CheckClinicalPathway
     @NeedMenu(MenuEnum.clinicalPathway)

+ 14 - 1
src/main/java/thyyxxk/webserver/dao/his/dictionary/clinicalPathway/ClinicalPathwayDao.java

@@ -3,6 +3,7 @@ package thyyxxk.webserver.dao.his.dictionary.clinicalPathway;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.dictionary.pathwayTemplates.dto.ClinicalPathwayDay;
 import thyyxxk.webserver.entity.dictionary.pathwayTemplates.dto.ClinicalPathwayOrder;
@@ -34,7 +35,7 @@ public interface ClinicalPathwayDao extends BaseMapper<ClinicalPathwayTemplates>
             "       update_code,\n" +
             "       update_name= (select rtrim(name) from a_employee_mi a where a.code = update_code),\n" +
             "       del_flag,is_dir,parent_code,publish,describe \n" +
-            "from clinical_pathway_templates where del_flag <> 1 ${where}")
+            "from clinical_pathway_templates where  1=1 ${where}")
     List<PathwayTemplatesVo> getPathwayTemplates(String where);
 
 
@@ -54,6 +55,18 @@ public interface ClinicalPathwayDao extends BaseMapper<ClinicalPathwayTemplates>
     List<JyJcItemVo> getJcJyItem(String table, Integer type, String key);
 
 
+    @Update("\n" +
+            "UPDATE\n" +
+            "    clinical_pathway_templates \n" +
+            "SET\n" +
+            "    update_time=getdate(),\n" +
+            "    update_code='${userCode}'," +
+            "    del_flag = 1 \n" +
+            "WHERE\n" +
+            "    id='${id}';")
+    void deleteTemplate(String id, String userCode);
+
+
     @Select("select code, name\n" +
             "from jy_zd_sample\n" +
             "where isnull(del_flag, '0') <> '1'")

+ 23 - 10
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/JianYanJianChaDao.java

@@ -11,6 +11,7 @@ import org.apache.ibatis.session.ResultHandler;
 import thyyxxk.webserver.entity.casefrontsheet.YshHzRecord;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.*;
+import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.dto.JyJcCheckItemDto;
 import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.vo.ViewInspectionItemDetailsVo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.PatientTemp;
 
@@ -561,14 +562,26 @@ public interface JianYanJianChaDao {
     JSONObject getExamineIllustrate(String orderCode, String tableName);
 
 
-    @Select("select a.report_url,\n" +
-            "       a.patient_uid,\n" +
-            "       b.order_type,examin_eparts\n" +
-            "from t_check_data a,\n" +
-            "     ysh_yj_req b\n" +
-            "where pat_no = #{patNo}\n" +
-            "  and times = #{times}\n" +
-            "  and a.top_req_no = b.req_no\n" +
-            "  and report_url is not null")
-    List<CheckTheCallbacks> getCheckData(String patNo, Integer times);
+    @Select("select a.order_code                  as code," +
+            "       c.name                        as name,\n" +
+            "       cast(rtrim(isnull(nullif(c.del_flag,\n" +
+            "                                ''),\n" +
+            "                         0)) as int)    item_del_flag,\n" +
+            "       cast(rtrim(isnull(nullif(a.del_flag,\n" +
+            "                                ''),\n" +
+            "                         0)) as int) as order_del_flag,\n" +
+            "       e.gender_restriction,\n" +
+            "       e.max_age_restriction,\n" +
+            "       e.min_age_restriction\n" +
+            "from yz_order_item a with (NOLOCK),\n" +
+            "     yz_order_occurence b with (NOLOCK),\n" +
+            "     zd_charge_item c with (NOLOCK),\n" +
+            "     ${tableName} e with (NOLOCK)\n" +
+            "where a.order_code = e.zy_order_code\n" +
+            "  and a.order_code = b.order_code\n" +
+            "  and b.occ_code = c.code\n" +
+            " and  ${ew.sqlSegment};")
+    List<JyJcCheckItemDto> selectJyJcCheckItemDto(@Param("ew") QueryWrapper<?> queryWrapper, String tableName);
+
+
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/ShouShuShenQingDao.java

@@ -269,7 +269,7 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
     @Select("select cast(max(code) as INTEGER) as code from op_zd_part")
     Integer getTheMaximumSurgicalCode();
 
-    @Insert("insert into op_zd_part (code, name, py_code, d_code) " +
+    @Insert("insert into op_zd_part_new(code, name, py_code, d_code) " +
             "values (#{code}, #{name}, #{py}, #{wb})")
     void insertNewSurgicalSite(@Param("code") String code,
                                @Param("name") String name,

+ 25 - 19
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -868,25 +868,31 @@ public interface YiZhuLuRuDao {
             "where rtrim(code) + rtrim(a.serial) + rtrim(group_no) = #{code} ")
     XinZhenYzActOrder drugDataOne(String code, String dept, String supplyCode);
 
-    @Select("select          rtrim(inpatient_no) as inpatient_no, " +
-            "                admiss_times, " +
-            "                rtrim(name)         as name, " +
-            "                rtrim(dept)         as dept_code, " +
-            "                rtrim(zk_ward)      as ward_code, " +
-            "                refer_physician,dept_director, " +
-            "                times_billed, " +
-            "                admiss_date, " +
-            "                small_dept, " +
-            "                bed_no," +
-            "                zk_ward, " +
-            "    ledger_sn = (select max(ledger_sn) " +
-            "                 from zy_ledger_file with (NOLOCK) " +
-            "                 where zy_actpatient.inpatient_no = zy_ledger_file.inpatient_no " +
-            "                   and zy_actpatient.admiss_times = zy_ledger_file.admiss_times)," +
-            "consult_physician,zy_serial_no " +
-            " from zy_actpatient with (NOLOCK) " +
-            "where inpatient_no = #{patNo} " +
-            "  and admiss_times = #{times} ")
+    @Select("select          rtrim(a.inpatient_no)                as inpatient_no,\n" +
+            "                admiss_times,\n" +
+            "                rtrim(a.name)                        as name,\n" +
+            "                rtrim(dept)                          as dept_code,\n" +
+            "                a.sex,\n" +
+            "                birth_date,\n" +
+            "                rtrim(zk_ward)                       as ward_code,\n" +
+            "                refer_physician,\n" +
+            "                dept_director,\n" +
+            "                times_billed,\n" +
+            "                admiss_date,\n" +
+            "                small_dept,\n" +
+            "                bed_no,\n" +
+            "                zk_ward,\n" +
+            "    ledger_sn = (select max(ledger_sn)\n" +
+            "                 from zy_ledger_file with (NOLOCK)\n" +
+            "                 where a.inpatient_no = zy_ledger_file.inpatient_no\n" +
+            "                   and a.admiss_times = zy_ledger_file.admiss_times),\n" +
+            "                consult_physician,\n" +
+            "                zy_serial_no\n" +
+            "from zy_actpatient a with (NOLOCK),\n" +
+            "     a_patient_mi b\n" +
+            "where a.inpatient_no = b.inpatient_no\n" +
+            "  and a.inpatient_no = #{patNo}\n" +
+            "  and admiss_times = #{times}")
     XinZhenYiZhu queryPatientInfo(@Param("patNo") String patNo,
                                   @Param("times") Integer times);
 

+ 7 - 1
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/patientClinicalPathway/ClinicalPathwayPatientDao.java

@@ -45,6 +45,12 @@ public interface ClinicalPathwayPatientDao extends BaseMapper<ClinicalPathwayPat
     List<ClinicalPathwayPatientDayLog> selectExecDay(String patNo, Integer times, String id);
 
 
+    @Select("select sum(execution_day)\n" +
+            "from clinical_pathway_day\n" +
+            "where template_id = '${templateId}'")
+    int execDayByTemplateId(String templateId);
+
+
     @Select("select b.*, c.work_content, c.type\n" +
             "from clinical_pathway_patient_work_log b\n" +
             "         inner join clinical_pathway_work c on (b.content_id = c.id) " +
@@ -54,7 +60,7 @@ public interface ClinicalPathwayPatientDao extends BaseMapper<ClinicalPathwayPat
 
 
     @Select("select                 b.work_content,\n" +
-            "                       b.type as work_type,\n" +
+            "                       b.exec_type as work_type,\n" +
             "                       c.*,\n" +
             "    supply_code_name = case\n" +
             "                           when c.type = 1 then\n" +

+ 14 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/jianyanjiancha/dto/JyJcCheckItemDto.java

@@ -0,0 +1,14 @@
+package thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.dto;
+
+import lombok.Data;
+
+@Data
+public class JyJcCheckItemDto {
+    private String code;
+    private String name;
+    private Boolean itemDelFlag;
+    private Boolean orderDelFlag;
+    private Integer genderRestriction;
+    private Integer maxAgeRestriction;
+    private Integer minAgeRestriction;
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/patientClinicalPathway/req/ExitClinicalPathwayReq.java

@@ -20,7 +20,6 @@ public class ExitClinicalPathwayReq {
     @NotNull(message = "状态不能为空")
     private Integer state;
 
-
     @NotNull(message = "原因不能为空")
     @NotBlank(message = "原因不能为空")
     private String reason;

+ 22 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/yizhuluru/XinZhenYiZhu.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru;
 
+import cn.hutool.core.date.DateUtil;
 import lombok.Data;
 import thyyxxk.webserver.service.PublicServer;
 
@@ -127,6 +128,27 @@ public class XinZhenYiZhu {
      */
     private String seniorDoctor;
 
+    /**
+     * 1-男 2-女
+     */
+    private Integer sex;
+
+    /**
+     * 出生日期
+     */
+    private Date birthDate;
+
+    /**
+     * 年龄
+     */
+    private Integer age;
+
+    public Integer patientAge() {
+        if (birthDate == null) {
+            return 0;
+        }
+        return DateUtil.age(birthDate, admissDate);
+    }
 
     /**
      * 医嘱关联数组

+ 3 - 2
src/main/java/thyyxxk/webserver/service/zhuyuanyiji/ClinicalPathwayPatientService.java

@@ -211,7 +211,7 @@ public class ClinicalPathwayPatientService {
             checkPatientPathway(patNo, times);
         }
 
-        if ((betweenDay + 1) == execDay) {
+        if ((betweenDay + 1) == dao.execDayByTemplateId(patient.getTemplateId())) {
             ClinicalPathwayPatient updateParams = new ClinicalPathwayPatient();
             updateParams.setId(patient.getId());
             updateParams.setState(ClinicalPathwayPatientState.完成.getCode());
@@ -219,6 +219,7 @@ public class ClinicalPathwayPatientService {
             // 完成了临床路径
             return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_NOTIFICATION, "患者完成了全部的路径");
         }
+
         List<TemplateDayVo> templateDay = cache.getTemplateDayNotContent(patient.getTemplateId(), () -> clinicalPathwayService.getTemplateDay(patient.getTemplateId()));
 
         GenerateParams params = new GenerateParams();
@@ -346,7 +347,7 @@ public class ClinicalPathwayPatientService {
         update.setState(req.getState());
         update.setReason(req.getReason());
         // todo 判断是否需要删除当天的数据
-        dao.updateById(patient);
+        dao.updateById(update);
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_NOTIFICATION, "操作成功您现在可以重新入径了。");
     }
 

+ 68 - 6
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/JianYanJianChaShenQingService.java

@@ -19,6 +19,7 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.login.UserInfo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.*;
+import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.dto.JyJcCheckItemDto;
 import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.vo.ViewInspectionItemDetailsVo;
 import thyyxxk.webserver.entity.zhuyuanyisheng.query.ChaXunJianChaHeJianYan;
 import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.PatientTemp;
@@ -367,11 +368,13 @@ public class JianYanJianChaShenQingService {
         }
         XinZhenYiZhu huanZheXinXi = yiZhuLuRuDao.queryPatientInfo(param.getInpatientNo(), param.getAdmissTimes());
         publicServer.huanZheJieSuan(param.getInpatientNo(), param.getAdmissTimes());
-        List<String> xm = new ArrayList<>();
         int index = 1;
         List<String> content = new ArrayList<>();
         StringBuilder cuoWuXinXi = new StringBuilder();
 
+        Set<String> jcCodes = new HashSet<>();
+        Set<String> jyCodes = new HashSet<>();
+
         for (YshYjReq item : param.getList()) {
             if (item.getQuantity() == null) {
                 item.setQuantity(BigDecimal.ONE);
@@ -397,6 +400,7 @@ public class JianYanJianChaShenQingService {
                 cuoWuXinXi.append(baoCunCuoWuXinXi(index, "执行科室不能为空。"));
             }
             if ("3".equals(param.getReqType())) {
+                jcCodes.add(item.getOrderCode());
                 if (StringUtil.isBlank(item.getReqComment())) {
                     cuoWuXinXi.append(baoCunCuoWuXinXi(index, "病室摘要不能为空。"));
                 }
@@ -410,6 +414,7 @@ public class JianYanJianChaShenQingService {
                     cuoWuXinXi.append(baoCunCuoWuXinXi(index, "临床诊断不能为空。"));
                 }
             } else {
+                jyCodes.add(item.getOrderCode());
                 if (StringUtil.isBlank(item.getInspectStuff())) {
                     cuoWuXinXi.append(baoCunCuoWuXinXi(index, "标本不能为空。"));
                 }
@@ -417,7 +422,6 @@ public class JianYanJianChaShenQingService {
             if (cuoWuXinXi.length() > 0) {
                 cuoWuXinXi.append("<br>");
             }
-            xm.add(item.getOrderCode().trim());
             content.add(String.format("%s:<span style='color:#409eff'>【%s】</span><br>" +
                                       "患者姓名:<span style='color:#409eff'>【%s】</span><br>" +
                                       "床位:<span style='color:#409eff'>【%s】</span>",
@@ -426,11 +430,54 @@ public class JianYanJianChaShenQingService {
             index++;
         }
 
-        // 先判断是不是停用了
-        String tingYong = publicServer.xiangMuXianZhi(xm, true);
-        if (StringUtil.notBlank(tingYong)) {
-            throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, tingYong);
+        Map<String, List<JyJcCheckItemDto>> jc = getItemInfo(jcCodes, true);
+        Map<String, List<JyJcCheckItemDto>> jy = getItemInfo(jyCodes, false);
+
+
+        for (int i = 0; i < param.getList().size(); i++) {
+            int finalI = i + 1;
+            YshYjReq item = param.getList().get(i);
+            List<JyJcCheckItemDto> itemInfo;
+            // 检查
+            if ("3".equals(param.getReqType())) {
+                itemInfo = jc.get(item.getOrderCode());
+            } else {
+                // 检验
+                itemInfo = jy.get(item.getOrderCode());
+            }
+
+            if (itemInfo == null || itemInfo.isEmpty()) {
+                cuoWuXinXi.append(baoCunCuoWuXinXi(i, "项目明细为空请刷新页面。"));
+                continue;
+            }
+
+            JyJcCheckItemDto one = itemInfo.get(0);
+
+            if (one.getGenderRestriction() != null && !one.getGenderRestriction().equals(huanZheXinXi.getSex())) {
+                cuoWuXinXi.append(baoCunCuoWuXinXi(finalI, "患者的性别不能开这个项目。"));
+            }
+
+            Integer age = huanZheXinXi.patientAge();
+
+            if (one.getMaxAgeRestriction() != null && one.getMaxAgeRestriction() <= age) {
+                cuoWuXinXi.append(baoCunCuoWuXinXi(finalI, "项目最大年龄限制" + one.getMaxAgeRestriction() + "岁,患者年龄不符合。"));
+            }
+
+            if (one.getMinAgeRestriction() != null && one.getMinAgeRestriction() >= age) {
+                cuoWuXinXi.append(baoCunCuoWuXinXi(finalI, "项目最小年龄限制" + one.getMinAgeRestriction() + "岁,患者年龄不符合。"));
+            }
+
+            if (one.getOrderDelFlag()) {
+                cuoWuXinXi.append(baoCunCuoWuXinXi(finalI, "医嘱已停用"));
+            }
+
+            itemInfo.forEach(value -> {
+                if (value.getItemDelFlag()) {
+                    cuoWuXinXi.append(baoCunCuoWuXinXi(finalI, "项目已停用:【" + value.getName() + "】"));
+                }
+            });
         }
+
         if (StringUtil.notBlank(cuoWuXinXi.toString())) {
             throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, String.valueOf(cuoWuXinXi));
         }
@@ -445,6 +492,21 @@ public class JianYanJianChaShenQingService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_EL_MESSAGE);
     }
 
+    private Map<String, List<JyJcCheckItemDto>> getItemInfo(Set<String> itemCodes, Boolean isCheck) {
+        Map<String, List<JyJcCheckItemDto>> collect = new HashMap<>();
+        if (!itemCodes.isEmpty()) {
+            QueryWrapper<?> qw = new QueryWrapper<>();
+            qw.in("a.order_code", itemCodes);
+            Map<String, List<JyJcCheckItemDto>> info = dao.selectJyJcCheckItemDto(qw, isCheck ? "jc_zd_item" : "jy_zd_item")
+                    .stream()
+                    .collect(
+                            Collectors.groupingBy(JyJcCheckItemDto::getCode)
+                    );
+            collect.putAll(info);
+        }
+        return collect;
+    }
+
     public void insertData(TianJiaJianChaJianYan param, XinZhenYiZhu patInfo, List<String> content) {
         String userCode = TokenUtil.getInstance().getTokenUserId();