Browse Source

检查部位字典维护

lighter 4 months ago
parent
commit
b277b501a1

+ 122 - 0
src/main/java/thyyxxk/webserver/controller/dictionary/JcPartMaintainController.java

@@ -0,0 +1,122 @@
+package thyyxxk.webserver.controller.dictionary;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.dictionary.JcPartMaintainDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.JcZdClass;
+import thyyxxk.webserver.service.PublicServer;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@RestController
+@RequestMapping("/jcPartMaintain")
+public class JcPartMaintainController {
+    private final JcPartMaintainDao dao;
+    private final PublicServer publicServer;
+
+    @Autowired
+    public JcPartMaintainController(JcPartMaintainDao dao, PublicServer publicServer) {
+        this.dao = dao;
+        this.publicServer = publicServer;
+    }
+
+    @Data
+    public static class JcPart {
+        String code;
+        String name;
+        String pyCode;
+        String delFlag;
+        String parentCode;
+        String parentName;
+
+        public String getPyCode() {
+            return null == pyCode ? "" : pyCode;
+        }
+
+        public String getDelFlag() {
+            return StringUtil.isBlank(delFlag) ? "0" : delFlag;
+        }
+    }
+
+    @Data
+    public static class JcPartAndJcClass {
+        List<JcPart> jcPartList;
+        List<JcZdClass> jcClassList;
+    }
+
+    @GetMapping("/getAllJcPart")
+    public ResultVo<JcPartAndJcClass> getAllJcPart() {
+        JcPartAndJcClass jcPartAndJcClass = new JcPartAndJcClass();
+        jcPartAndJcClass.setJcPartList(dao.getAllJcPart());
+        jcPartAndJcClass.setJcClassList(dao.getAllJcZdClass());
+        return ResultVoUtil.success(jcPartAndJcClass);
+    }
+
+    @PostMapping("/insertNewPart")
+    public ResultVo<List<JcPart>> insertNewPart(@RequestBody JcPart jcPart) {
+        int sameCount = StringUtil.isBlank(jcPart.getParentCode()) ?
+                dao.getSameName(jcPart) : dao.getSameNameAndParent(jcPart);
+        if (sameCount > 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR,
+                    "已有名称和检查类别相同的部位存在,请勿重复添加。");
+        }
+        jcPart.setCode(generateJcPartCode(jcPart.getParentCode()));
+        dao.insertNewPart(jcPart);
+        return ResultVoUtil.success(dao.getAllJcPart());
+    }
+
+    @PostMapping("/updatePart")
+    public ResultVo<List<JcPart>> updatePart(@RequestBody JcPart jcPart) {
+        dao.updatePart(jcPart);
+        return ResultVoUtil.success(dao.getAllJcPart());
+    }
+
+    private String generateJcPartCode(String parentCode) {
+        String prefix = getPrefix(parentCode);
+        if (null == prefix) {
+            String maxCode = dao.getMaxNumericCode();
+            if (StringUtil.isBlank(maxCode)) {
+                return "0001";
+            }
+            BigDecimal code = new BigDecimal(maxCode).add(BigDecimal.ONE);
+            return publicServer.fmtNoWithLead0(code, 4);
+        }
+        String maxCode = dao.getMaxLetterCode(prefix);
+        if (StringUtil.isBlank(maxCode)) {
+            return prefix + "01";
+        }
+        maxCode = maxCode.substring(2);
+        BigDecimal code = new BigDecimal(maxCode).add(BigDecimal.ONE);
+        return prefix + publicServer.fmtNoWithLead0(code, 2);
+    }
+
+    private String getPrefix(String code) {
+        if (StringUtil.isBlank(code)) {
+            return null;
+        }
+        switch (code) {
+            case "01":
+                return "BC";
+            case "07":
+                return "DR";
+            case "08":
+                return "CT";
+            case "26":
+                return "MR";
+            case "27":
+                return "EC";
+            case "41":
+                return "TC";
+            case "51":
+                return "US";
+            default:
+                return null;
+        }
+    }
+}

+ 43 - 0
src/main/java/thyyxxk/webserver/dao/his/dictionary/JcPartMaintainDao.java

@@ -0,0 +1,43 @@
+package thyyxxk.webserver.dao.his.dictionary;
+
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import thyyxxk.webserver.controller.dictionary.JcPartMaintainController;
+import thyyxxk.webserver.entity.zhuyuanyisheng.jianyanjiancha.JcZdClass;
+
+import java.util.List;
+
+@Mapper
+public interface JcPartMaintainDao {
+
+    @Select("select a.code,a.name,a.py_code,a.del_flag,a.parent_code,b.name as parentName " +
+            "from ysh_zd_part_code a left join jc_zd_class b on b.code=a.parent_code")
+    List<JcPartMaintainController.JcPart> getAllJcPart();
+
+    @Select("select * from jc_zd_class")
+    List<JcZdClass> getAllJcZdClass();
+
+    @Select("select count(1) from ysh_zd_part_code where name=#{name} ")
+    int getSameName(JcPartMaintainController.JcPart jcPart);
+
+    @Select("select count(1) from ysh_zd_part_code where name=#{name} and parent_code=#{parentCode}")
+    int getSameNameAndParent(JcPartMaintainController.JcPart jcPart);
+
+    @Insert("insert into ysh_zd_part_code (code,name,py_code,del_flag,parent_code) " +
+            "values (#{code},#{name},#{pyCode},#{delFlag},#{parentCode})")
+    void insertNewPart(JcPartMaintainController.JcPart jcPart);
+
+    @Update("update ysh_zd_part_code set name=#{name},py_code=#{pyCode}, " +
+            "del_flag=#{delFlag},parent_code=#{parentCode} where code=#{code}")
+    void updatePart(JcPartMaintainController.JcPart jcPart);
+
+    @Select("select max(cast(code as int)) from " +
+            "(SELECT ISNUMERIC(code) as f,code FROM ysh_zd_part_code) t " +
+            "where t.f = 1")
+    String getMaxNumericCode();
+
+    @Select("select max(code) from ysh_zd_part_code where code like #{prefix} + '%'")
+    String getMaxLetterCode(String prefix);
+}

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

@@ -28,7 +28,6 @@ import java.util.Map;
 @Mapper
 public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
 
-
     @Select("<script>" +
             "select op_type_name = (select name from zd_operation_type where code = op_type), " +
             "       rtrim(code) as code," +
@@ -60,7 +59,6 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
                                                @Param("times") Integer times,
                                                @Param("name") String name);
 
-
     @Select("select count(1) from op_record where inpatient_no = #{patNo} and admiss_times = #{times} and status <> 'd' and urgent_clinic_flag = '0' ")
     int currentPatientOpCount(String patNo, Integer times);
 
@@ -77,7 +75,6 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
             "order by a.name")
     List<GetDropdownBox> shouShuShenQingCeBianLan();
 
-
     @Select("select a.record_id /*申请单号*/," +
             "       a.op_name," +
             "       a.urgent_clinic_flag," +
@@ -116,12 +113,10 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
                            @Param("times") Integer times,
                            @Param("recordId") Integer recordId);
 
-
     @Select("select req_no, code, name, type, sort " +
             "from t_req_surgical_diag where req_no = #{recordId}")
     List<TReqSurgicalDiag> selectReqSurgicalDiagByReqNo(@Param("recordId") Integer recordId);
 
-
     @Select("select refer_physician_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = refer_physician) /*住院医生*/, " +
             "       dept_director_name   = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = dept_director) /*科主任*/, " +
             "       sex, " +
@@ -134,7 +129,6 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
     OpRecord daYingHuanZheXinXi(@Param("patNo") String patNo,
                                 @Param("times") Integer times);
 
-
     @Select("<script>" +
             "SELECT rtrim(order_code) as opCode, " +
             "       rtrim(order_name) as opName, " +
@@ -262,10 +256,10 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
     @Update("update op_record set status = 'd' where record_id = #{id}")
     void genXingShanChuBiaoZhi(Integer id);
 
-    @Select("select count(1) from op_zd_part where name = #{name} and del_flag = 0")
+    @Select("select count(1) from op_zd_part_new where name = #{name} and del_flag = 0")
     Boolean repeatPartName(String name);
 
-    @Select("select cast(max(code) as INTEGER) as code from op_zd_part")
+    @Select("select cast(max(code) as INTEGER) as code from op_zd_part_new")
     Integer getTheMaximumSurgicalCode();
 
     @Insert("insert into op_zd_part_new(code, name, py_code, d_code) " +
@@ -275,10 +269,9 @@ public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
                                @Param("py") String py,
                                @Param("wb") String wb);
 
-    @Update("update op_zd_part set del_flag = 1 where code = #{code}")
+    @Update("update op_zd_part_new set del_flag = 1 where code = #{code}")
     void removeSurgicalSite(String code);
 
-
     @Select("select op_name,\n" +
             "       op_datetime,\n" +
             "       status,\n" +