Browse Source

病案首页导出

lighter 3 năm trước cách đây
mục cha
commit
6679648475

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>1</version>
+    <version>2</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 44 - 0
src/main/java/thyyxxk/webserver/constants/frntsheet/DismissWay.java

@@ -0,0 +1,44 @@
+package thyyxxk.webserver.constants.frntsheet;
+
+public enum DismissWay {
+    DOCTOR_ORDER_DISMISS("0", "1"),
+
+    DOCTOR_ORDER_TRANSFER("1", "2"),
+
+    DOCTOR_ORDER_LOWER_PLACE("2", "3"),
+
+    NONE_DOCTOR_ORDER("3", "4"),
+
+    DEAD("4", "5"),
+
+    OTHER("5", "9");
+
+
+    private final String hisCode;
+    private final String wjwCode;
+
+    DismissWay(String hisCode, String wjwCode) {
+        this.hisCode = hisCode;
+        this.wjwCode = wjwCode;
+    }
+
+    public String getHisCode() {
+        return hisCode;
+    }
+
+    public String getWjwCode() {
+        return wjwCode;
+    }
+
+    public static String getWjwCodeByHisCode(String hisCode) {
+        if (null == hisCode) {
+            return DOCTOR_ORDER_DISMISS.getWjwCode();
+        }
+        for (DismissWay way : DismissWay.values()) {
+            if (way.getHisCode().equals(hisCode)) {
+                return way.getWjwCode();
+            }
+        }
+        return DOCTOR_ORDER_DISMISS.getWjwCode();
+    }
+}

+ 40 - 0
src/main/java/thyyxxk/webserver/constants/frntsheet/Hbsag.java

@@ -0,0 +1,40 @@
+package thyyxxk.webserver.constants.frntsheet;
+
+public enum Hbsag {
+    NOT_EXAMINED("0", "4"),
+
+    NEGATIVE("1", "1"),
+
+    POSITIVE("2", "2"),
+
+    UNKNOWN("3", "3");
+
+
+    private final String hisCode;
+    private final String wjwCode;
+
+    Hbsag(String hisCode, String wjwCode) {
+        this.hisCode = hisCode;
+        this.wjwCode = wjwCode;
+    }
+
+    public String getHisCode() {
+        return hisCode;
+    }
+
+    public String getWjwCode() {
+        return wjwCode;
+    }
+
+    public static String getWjwCodeByHisCode(String hisCode) {
+        if (null == hisCode) {
+            return NOT_EXAMINED.getWjwCode();
+        }
+        for (Hbsag sag : Hbsag.values()) {
+            if (sag.getHisCode().equals(hisCode)) {
+                return sag.getWjwCode();
+            }
+        }
+        return NOT_EXAMINED.getWjwCode();
+    }
+}

+ 67 - 0
src/main/java/thyyxxk/webserver/constants/frntsheet/Provinces.java

@@ -0,0 +1,67 @@
+package thyyxxk.webserver.constants.frntsheet;
+
+public enum Provinces {
+    BEIJING("11", "1"),
+    TIANJIN("12", "2"),
+    HEBEI("13", "3"),
+    SHANXI("14", "4"),
+    INNER_MONGOLIA("15", "5"),
+    LIAONING("21", "6"),
+    JILIN("22", "7"),
+    HEILONGJIANG("23", "8"),
+    SHANGHAI("31", "9"),
+    JIANGSU("32", "10"),
+    ZHEJIANG("33", "11"),
+    ANHUI("34", "12"),
+    FUJIAN("35", "13"),
+    JIANGXI("36", "14"),
+    SHANDONG("37", "15"),
+    HENAN("41", "16"),
+    HUBEI("42", "17"),
+    HUNAN("43", "18"),
+    GUANGDONG("44", "19"),
+    GUANGXI("45", "20"),
+    HAINAN("46", "21"),
+    SICHUAN("51", "22"),
+    CHONGQING("50", "23"),
+    GUIZHOU("52", "24"),
+    YUNNAN("53", "25"),
+    XIZANG("54", "26"),
+    SHANXI2("61", "27"),
+    GANSU("62", "28"),
+    QINGHAI("63", "29"),
+    NINGXIA("64", "30"),
+    XINJIANG("65", "31"),
+    TAIWAN("71", "32"),
+    HONG_KONG("81", "33"),
+    MACAO("82", "34"),
+    FOREIGN("99", "35");
+
+    private final String code;
+    private final String wjwCode;
+
+    Provinces(String code, String wjwCode) {
+        this.code = code;
+        this.wjwCode = wjwCode;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getWjwCode() {
+        return wjwCode;
+    }
+
+    public static String getWjwCodeByHisCode(String hisCode) {
+        if (null == hisCode) {
+            return null;
+        }
+        for (Provinces item : Provinces.values()) {
+            if (item.getCode().equals(hisCode)) {
+                return item.getWjwCode();
+            }
+        }
+        return null;
+    }
+}

+ 34 - 0
src/main/java/thyyxxk/webserver/controller/casefrontsheet/FrontSheetExportController.java

@@ -0,0 +1,34 @@
+package thyyxxk.webserver.controller.casefrontsheet;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetMain;
+import thyyxxk.webserver.service.casefrontsheet.FrontSheetExportService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/frontSheetExport")
+public class FrontSheetExportController {
+    private final FrontSheetExportService service;
+
+    @Autowired
+    public FrontSheetExportController(FrontSheetExportService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/fetchSheets")
+    public ResultVo<List<CaseFrontsheetMain>> fetchSheets(@RequestParam("month") String month) {
+        List<CaseFrontsheetMain> list = service.fetchSheets(month);
+        if (null == list || list.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        return ResultVoUtil.success(list);
+    }
+}

+ 26 - 0
src/main/java/thyyxxk/webserver/dao/his/casefrontsheet/FrontSheetExportDao.java

@@ -0,0 +1,26 @@
+package thyyxxk.webserver.dao.his.casefrontsheet;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetDisdiag;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetMain;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetSurgery;
+
+import java.util.List;
+
+@Mapper
+public interface FrontSheetExportDao {
+
+    @Select("select * from t_case_frontsheet_main where dismiss_date>=#{begin} and dismiss_date<=#{end}")
+    List<CaseFrontsheetMain> fetchSheets(@Param("begin") String begin, @Param("end") String end);
+
+    @Select("select no,code,name,admiss_status,dismiss_status from t_case_frontsheet_disdiag where bah=#{bah} and times=#{times}")
+    List<CaseFrontsheetDisdiag> fetchDiags(@Param("bah") String bah, @Param("times") int times);
+
+    @Select("select no,code,name,date,level,operator,operator_name,assistant_one,assistant_one_name, " +
+            "assistant_two,assistant_two_name,cut=isnull(cut,0),heal=isnull(heal,0),anaesthesiaor,anaesthesiaor_name, " +
+            "anaesthesia=(select wjw_code from zd_anaesthesia where code=anaesthesia) " +
+            "from t_case_frontsheet_surgery where bah=#{bah} and times=#{times}")
+    List<CaseFrontsheetSurgery> fetchSurgeries(@Param("bah") String bah, @Param("times") int times);
+}

+ 11 - 0
src/main/java/thyyxxk/webserver/dao/his/redislike/RedisLikeDao.java

@@ -24,4 +24,15 @@ public interface RedisLikeDao {
     @Select("select name,code='' from t_si_admdvs where code=#{code}")
     PureCodeName selectAdmdvsName(@Param("code") String code);
 
+    @Select("select wjw_code from zd_anaesthesia where code=#{code}")
+    String selectWjwAnaesthesia(@Param("code") String code);
+
+    @Select("select wjw_code from zd_unit_code where code=#{code}")
+    String selectWjwDepartment(@Param("code") String code);
+
+    @Select("select wjw_code from zd_nation_code where code=#{code}")
+    String selectWjwNation(@Param("code") String code);
+
+    @Select("select rtrim(name) from zd_country_code where code=#{code}")
+    String selectCountryName(@Param("code") String code);
 }

+ 6 - 6
src/main/java/thyyxxk/webserver/entity/casefrontsheet/CaseFrontsheetMain.java

@@ -136,7 +136,7 @@ public class CaseFrontsheetMain implements Serializable {
     private String nativePlaceName;
 
     /**
-     * 国家
+     * 民族
      */
     private String nation;
 
@@ -215,11 +215,6 @@ public class CaseFrontsheetMain implements Serializable {
      */
     private String contactRelation;
 
-    /**
-     * 联系人地址编码
-     */
-    private String contactAddr;
-
     /**
      * 联系人地址
      */
@@ -230,6 +225,11 @@ public class CaseFrontsheetMain implements Serializable {
      */
     private String contactPhone;
 
+    /**
+     * 联系人地址编码
+     */
+    private String contactAddr;
+
     /**
      * 入院方式
      */

+ 3 - 0
src/main/java/thyyxxk/webserver/entity/casefrontsheet/CaseFrontsheetSurgery.java

@@ -115,6 +115,9 @@ public class CaseFrontsheetSurgery implements Serializable {
 	@TableField(exist = false)
 	private String cutHeal;
 
+	@TableField(exist = false)
+	private Integer wjwCutHeal;
+
 	public String getCutHeal() {
 		if (StringUtil.isBlank(cutHeal)) {
 			if (getCut() != null && getHeal() != null) {

+ 83 - 0
src/main/java/thyyxxk/webserver/service/casefrontsheet/FrontSheetExportService.java

@@ -0,0 +1,83 @@
+package thyyxxk.webserver.service.casefrontsheet;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.constants.frntsheet.DismissWay;
+import thyyxxk.webserver.constants.frntsheet.Hbsag;
+import thyyxxk.webserver.constants.frntsheet.Provinces;
+import thyyxxk.webserver.dao.his.casefrontsheet.FrontSheetExportDao;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetMain;
+import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetSurgery;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.util.List;
+
+@Service
+public class FrontSheetExportService {
+    private final FrontSheetExportDao dao;
+    private final RedisLikeService redis;
+
+    @Autowired
+    public FrontSheetExportService(FrontSheetExportDao dao, RedisLikeService redis) {
+        this.dao = dao;
+        this.redis = redis;
+    }
+
+    public List<CaseFrontsheetMain> fetchSheets(String month) {
+        String begin = month + "-01 00:00:00.000";
+        String end = DateUtil.getMonthEndtime(month);
+        List<CaseFrontsheetMain> list = dao.fetchSheets(begin, end);
+        list.forEach(item -> {
+            String pmtd = item.getPayMethod();
+            if (StringUtil.invalidValue(pmtd)) {
+                item.setPayMethod("9");
+            } else {
+                int mtd = Integer.parseInt(pmtd);
+                if (mtd < 4) {
+                    if (item.getSocialNo().startsWith("4301")) {
+                        pmtd = pmtd + ".1";
+                    } else {
+                        pmtd = pmtd + ".2";
+                    }
+                    item.setPayMethod(pmtd);
+                }
+            }
+            item.setZyDismissWay(DismissWay.getWjwCodeByHisCode(item.getZyDismissWay()));
+            item.setHbsAg(Hbsag.getWjwCodeByHisCode(item.getHbsAg()));
+            String ntvplc = item.getNativePlace().substring(0, 2);
+            item.setNativePlace(Provinces.getWjwCodeByHisCode(ntvplc));
+            item.setCountry(redis.getCountryName(item.getCountry()));
+            item.setAdmissDeptCode(redis.getWjwDepartment(item.getAdmissDeptCode()));
+            item.setZkWardCode(redis.getWjwDepartment(item.getZkWardCode()));
+            item.setDismissDeptCode(redis.getWjwDepartment(item.getDismissDeptCode()));
+            item.setNation(redis.getWjwNation(item.getNation()));
+            item.setDisdiagList(dao.fetchDiags(item.getBah(), item.getAdmissTimes()));
+            List<CaseFrontsheetSurgery> surgeries = dao.fetchSurgeries(item.getBah(), item.getAdmissTimes());
+            surgeries.forEach(s -> {
+                s.setAnaesthesia(redis.getWjwAnaesthesia(s.getAnaesthesia()));
+                int cut = 0;
+                if (StringUtil.notBlank(s.getCut())) {
+                    cut = Integer.parseInt(s.getCut());
+                }
+                int heal = 0;
+                if (StringUtil.notBlank(s.getHeal())) {
+                    heal = Integer.parseInt(s.getHeal());
+                }
+                if (cut == 0 || heal == 0) {
+                    s.setWjwCutHeal(0);
+                } else {
+                    int wjwCutHeal = (cut - 1) * cut + heal + negationCalculatingResidue(cut);
+                    s.setWjwCutHeal(wjwCutHeal);
+                }
+            });
+            item.setSurgeryList(surgeries);
+        });
+        return list;
+    }
+
+    private int negationCalculatingResidue(int source) {
+        return source % 2 == 0 ? 1 : 0;
+    }
+}

+ 51 - 0
src/main/java/thyyxxk/webserver/service/redislike/RedisLikeService.java

@@ -14,6 +14,10 @@ public class RedisLikeService {
     private final static Map<String, String> deptNameMap = new HashMap<>();
     private final static Map<String, String> deptAndEmployeeName = new HashMap<>();
     private final static Map<String, String> regionMap = new HashMap<>();
+    private final static Map<String, String> wjwAnaesthesiaMap = new HashMap<>();
+    private final static Map<String, String> wjwDepartmentMap = new HashMap<>();
+    private final static Map<String, String> wjwNationMap = new HashMap<>();
+    private final static Map<String, String> countryMap = new HashMap<>();
     private final RedisLikeDao dao;
 
     public RedisLikeService(RedisLikeDao dao) {
@@ -82,4 +86,51 @@ public class RedisLikeService {
         return regionName;
     }
 
+    public String getWjwAnaesthesia(String code) {
+        if (StringUtil.invalidValue(code)) {
+            return null;
+        }
+        String wjwCode = wjwAnaesthesiaMap.get(code);
+        if (null == wjwCode) {
+            wjwCode = dao.selectWjwAnaesthesia(code);
+            wjwAnaesthesiaMap.put(code, wjwCode);
+        }
+        return wjwCode;
+    }
+
+    public String getWjwDepartment(String code) {
+        if (StringUtil.invalidValue(code)) {
+            return null;
+        }
+        String wjwCode = wjwDepartmentMap.get(code);
+        if (null == wjwCode) {
+            wjwCode = dao.selectWjwDepartment(code);
+            wjwDepartmentMap.put(code, wjwCode);
+        }
+        return wjwCode;
+    }
+
+    public String getWjwNation(String code) {
+        if (StringUtil.invalidValue(code)) {
+            return null;
+        }
+        String wjwCode = wjwNationMap.get(code);
+        if (null == wjwCode) {
+            wjwCode = dao.selectWjwNation(code);
+            wjwNationMap.put(code, wjwCode);
+        }
+        return wjwCode;
+    }
+
+    public String getCountryName(String code) {
+        if (StringUtil.invalidValue(code)) {
+            return null;
+        }
+        String name = countryMap.get(code);
+        if (null == name) {
+            name = dao.selectCountryName(code);
+            countryMap.put(code, name);
+        }
+        return name;
+    }
 }