DESKTOP-0GD05B0\Administrator vor 3 Jahren
Ursprung
Commit
e738c77d25

+ 7 - 0
src/main/java/thyyxxk/webserver/controller/PublicController.java

@@ -15,6 +15,7 @@ import thyyxxk.webserver.service.LoginService;
 import thyyxxk.webserver.service.PublicServer;
 import thyyxxk.webserver.utils.ListUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.SnowFlakeId;
 
 import javax.naming.Context;
 import java.lang.reflect.InvocationTargetException;
@@ -74,6 +75,12 @@ public class PublicController {
         return service.maZuiFangShi();
     }
 
+    @PassToken
+    @GetMapping("/getUuid")
+    public ResultVo<String> getUuid() {
+        return ResultVoUtil.success(SnowFlakeId.instance().nextId());
+    }
+
     @GetMapping("/getDate")
     @PassToken
     public ResultVo<Date> getDate() {

+ 15 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/EmrController.java

@@ -2,7 +2,9 @@ package thyyxxk.webserver.controller.zhuyuanyizheng;
 
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataElement;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrPatientData;
 import thyyxxk.webserver.service.zhuyuanyisheng.EmrServer;
 
@@ -45,5 +47,18 @@ public class EmrController {
         return server.queryWhetherThePatientHasASpecifiedMedicalRecord(param);
     }
 
+    @PostMapping("/extractDataElement")
+    public ResultVo<String> extractDataElement(@RequestBody EmrDataElement param) {
+        return server.extractDataElement(param);
+    }
+
+    @PassToken
+    @GetMapping("/hotSearchSorting")
+    public void hotSearchSorting(@RequestParam("userCode") String userCode,
+                                 @RequestParam("code") String code,
+                                 @RequestParam("tableName") String tableName) {
+        server.hotSearchSorting(userCode, code, tableName);
+    }
+
 
 }

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

@@ -1,6 +1,9 @@
 package thyyxxk.webserver.dao.his.zhuyuanyisheng;
 
 import org.apache.ibatis.annotations.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataElement;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataExtract;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrPatientData;
 
 import java.util.List;
@@ -40,7 +43,7 @@ public interface EmrPatientDao {
             "from emr_patient_data\n" +
             "where pat_no = #{patNo}\n" +
             "  and times = #{times}\n" +
-            "  and emr_document_id = #{docmentId0} ")
+            "  and emr_document_id = #{docmentId} ")
     Integer whetherThereIsAMedicalRecord(@Param("patNo") String patNo,
                                          @Param("times") Integer times,
                                          @Param("docmentId") String docmentId);
@@ -77,5 +80,41 @@ public interface EmrPatientDao {
                                                              @Param("times") Integer times,
                                                              @Param("emrCategoryCode") String emrCategoryCode);
 
+    @Select("select *\n" +
+            "from emr_data_extract\n" +
+            "where emr_category_code = #{code} ")
+    EmrDataExtract extractDataSource(String code);
+
+    @Select("select pat_no,times,data_element from emr_data_element where pat_no = #{patNo} and times = #{times}")
+    EmrDataElement obtainPatientSOriginalData(@Param("patNo") String patNo,
+                                              @Param("times") Integer times);
+
+    @Insert("insert into emr_data_element (pat_no, times, data_element)\n" +
+            "values (#{patNo},#{times},#{dataElement});")
+    void insertDataSource(@Param("patNo") String patNo,
+                          @Param("times") Integer times,
+                          @Param("dataElement") String dataElement);
+
+    @Update("update emr_data_element set data_element = #{dataElement} where " +
+            "pat_no = #{patNo} and times = #{times}")
+    void updatePatientDataSource(@Param("patNo") String patNo,
+                                 @Param("times") Integer times,
+                                 @Param("dataElement") String dataElement);
+
+    @Select("select count(1) from hot_search_sorting where user_code = #{userCode} and code = #{code} and table_name = #{tableName}")
+    Integer queryWhetherThereIsHotSearch(@Param("userCode") String userCode,
+                                         @Param("code") String code,
+                                         @Param("tableName") String tableName);
+
+    @Insert("insert into hot_search_sorting (user_code, code, table_name, count) values (#{userCode}, #{code}, #{tableName}, 1)")
+    void hotSearchSorting(@Param("userCode") String userCode,
+                          @Param("code") String code,
+                          @Param("tableName") String tableName);
+
+    @Update("update hot_search_sorting set count = count + 1 where user_code = #{userCode} and code = #{code} and table_name = #{tableName}")
+    void updateHotSearch(@Param("userCode") String userCode,
+                         @Param("code") String code,
+                         @Param("tableName") String tableName);
+
 
 }

+ 33 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/emr/EmrDataElement.java

@@ -0,0 +1,33 @@
+package thyyxxk.webserver.entity.zhuyuanyisheng.emr;
+
+import lombok.Data;
+
+/**
+ * @author xc
+ * @date 2022-11-08 09:22:51
+ */
+@Data
+public class EmrDataElement {
+
+    /**
+     * 住院号
+     */
+    private String patNo;
+
+    /**
+     * 住院次数
+     */
+    private Integer times;
+
+    /**
+     * 数据元
+     */
+    private String dataElement;
+
+    /**
+     * 病历编码
+     */
+    private String categoryCode;
+
+
+}

+ 23 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/emr/EmrDataExtract.java

@@ -0,0 +1,23 @@
+package thyyxxk.webserver.entity.zhuyuanyisheng.emr;
+
+
+import lombok.Data;
+
+/**
+ * @author xc
+ * @date 2022-11-08 02:36:35
+ */
+@Data
+public class EmrDataExtract {
+
+    /**
+     * 电子病历编码
+     */
+    private String emrCategoryCode;
+
+    /**
+     * 需要提取的数据元
+     */
+    private String dataExtract;
+
+}

+ 19 - 2
src/main/java/thyyxxk/webserver/service/dictionary/EmrDataMaintenanceServer.java

@@ -7,7 +7,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.dictionary.EmrDataMaintenanceDao;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.EmrPatientDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataElement;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataMaintenance;
 import thyyxxk.webserver.utils.*;
 
@@ -22,8 +24,11 @@ public class EmrDataMaintenanceServer {
 
     private final EmrDataMaintenanceDao dao;
 
-    public EmrDataMaintenanceServer(EmrDataMaintenanceDao dao) {
+    private final EmrPatientDao emrPatientDao;
+
+    public EmrDataMaintenanceServer(EmrDataMaintenanceDao dao, EmrPatientDao emrPatientDao) {
         this.dao = dao;
+        this.emrPatientDao = emrPatientDao;
     }
 
     private static String keyParameterSubstitution(String sqlSentence, String patNo, Integer times) {
@@ -133,7 +138,14 @@ public class EmrDataMaintenanceServer {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
-
+    /**
+     * 获取患者的数据元
+     *
+     * @param patNo 住院号
+     * @param times 住院次数
+     * @return 返回数据元
+     * @throws Exception 错误
+     */
     public ResultVo<JSONObject> getEmrInpatientData(String patNo, Integer times) throws Exception {
         List<EmrDataMaintenance> emrData = dao.getEmrInpatientData();
         JSONObject obj = new JSONObject();
@@ -147,6 +159,11 @@ public class EmrDataMaintenanceServer {
                 }
             }
         }
+
+        EmrDataElement emrDataElement = emrPatientDao.obtainPatientSOriginalData(patNo, times);
+        if (emrDataElement != null) {
+            obj.putAll(JSONObject.parseObject(emrDataElement.getDataElement()));
+        }
         return ResultVoUtil.success(obj);
     }
 

+ 1 - 1
src/main/java/thyyxxk/webserver/service/heliyongyao/RationalUseServer.java

@@ -97,7 +97,7 @@ public class RationalUseServer {
         String baseXml = "<base_xml>" +
                 "<source>HIS</source>" +
                 "<hosp_code>H43010500370</hosp_code>" +
-                "<hosp_name>湖南泰和医院</hosp_name>" +
+                "<hosp_name>长沙泰和医院</hosp_name>" +
                 "<dept_code>" + nullToBlank(yiShenXinXi.get("dept_code")) + "</dept_code>" +
                 "<dept_name>" + nullToBlank(yiShenXinXi.get("dept_name")) + "</dept_name>" +
                 "<doct>" +

+ 2 - 0
src/main/java/thyyxxk/webserver/service/medicalinsurance/SetlListUpldService.java

@@ -1293,4 +1293,6 @@ public class SetlListUpldService {
         ExcelUtil.exportExcel(response, title, content);
     }
 
+
+
 }

+ 48 - 3
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/EmrServer.java

@@ -1,15 +1,22 @@
 package thyyxxk.webserver.service.zhuyuanyisheng;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.dynamic.datasource.annotation.DS;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.zhuyuanyisheng.EmrPatientDao;
 import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataElement;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrDataExtract;
 import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrPatientData;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -75,10 +82,10 @@ public class EmrServer {
     public ResultVo<String> insertEmrData(EmrPatientData param) {
         param.setCreateId(TokenUtil.getTokenUserId());
         if (dao.whetherThereIsAMedicalRecord(param.getPatNo(), param.getTimes(), param.getEmrDocumentId()).equals(1)) {
-            dao.emrInsertForTheFirstTime(param);
+            dao.updateCreatedTemplate(param);
             return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "保存成功,已覆盖原数据。");
         } else {
-            dao.updateCreatedTemplate(param);
+            dao.emrInsertForTheFirstTime(param);
             return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "保存到本院成功");
         }
     }
@@ -105,9 +112,47 @@ public class EmrServer {
         return ResultVoUtil.success(dao.queryWhetherThePatientHasASpecifiedMedicalRecord(param.getPatNo(), param.getTimes(), param.getEmrCategoryCode()) == 1);
     }
 
-    public ResultVo<String> extractDataElement() {
+    public ResultVo<String> extractDataElement(EmrDataElement param) {
+        EmrDataExtract 需要提取的数据源 = dao.extractDataSource(param.getCategoryCode());
+        if (需要提取的数据源 == null) {
+            return ResultVoUtil.success();
+        }
+        List<String> strings = JSON.parseArray(需要提取的数据源.getDataExtract(), String.class);
+        JSONObject elementData = JSONObject.parseObject(param.getDataElement());
+        Map<String, Object> extractedData = new HashMap<>(strings.size());
+        for (String el : strings) {
+            if (elementData.containsKey(el)) {
+                JSONObject item = (JSONObject) elementData.get(el);
+                Object value = item.get("value");
+                if (value != null) {
+                    extractedData.put(el, value);
+                }
+            }
+        }
+        EmrDataElement emrDataElement = dao.obtainPatientSOriginalData(param.getPatNo(), param.getTimes());
+        if (emrDataElement == null) {
+            log.info("提取到的数据:{}", JSON.toJSONString(extractedData));
+            dao.insertDataSource(param.getPatNo(), param.getTimes(), JSON.toJSONString(extractedData));
+        } else {
+            JSONObject jsonObject = JSONObject.parseObject(emrDataElement.getDataElement());
+            jsonObject.putAll(extractedData);
+            dao.updatePatientDataSource(param.getPatNo(), param.getTimes(), JSON.toJSONString(jsonObject));
+            log.info("患者原来的数据:{}", jsonObject);
+        }
+
         return ResultVoUtil.success();
     }
 
+    @DS("his")
+    public void hotSearchSorting(String userCode, String code, String tableName) {
+        boolean insert = dao.queryWhetherThereIsHotSearch(userCode, code, tableName) == 0;
+        if (insert) {
+            dao.hotSearchSorting(userCode, code, tableName);
+        } else {
+            dao.updateHotSearch(userCode, code, tableName);
+        }
+        log.info("医生编码:{},搜索关键字:{},表名:{}", userCode, code, tableName);
+    }
+
 
 }

+ 111 - 0
src/main/java/thyyxxk/webserver/utils/DesEncryption.java

@@ -0,0 +1,111 @@
+package thyyxxk.webserver.utils;
+
+import java.security.Key;
+import java.security.SecureRandom;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+
+import com.alibaba.fastjson.JSONObject;
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+
+
+public class DesEncryption {
+
+    public static void main(String[] args) {
+        JSONObject a = new JSONObject();
+        a.put("patNo", "0215415");
+        a.put("times", 1);
+        a.put("date", "2011-12-12 12:23:00");
+
+        System.out.print("加密前");
+        System.out.println(a);
+
+        String jiami = DesEncryption.getEncryptString(a.toJSONString());
+        String jiemi = DesEncryption.getDecryptString(jiami);
+
+        // 53mbVtLVP4Lk08kgImqd4iP+HqaMwAyt0V5BTEHknipma/H7SI5NasTJGMrHUwXiBZwvewwj575wuYZVp3PvcQ==
+
+        System.out.print("加密中");
+        System.out.println(jiami);
+
+        System.out.print("解密");
+        System.out.println(jiemi);
+    }
+
+    private static Key key;
+
+    private static String KEY_STR = "myKey";
+    private static String CHARSETNAME = "UTF-8";
+    private static String ALGORITHM = "DES";
+
+    static {
+        try {
+            //生成DES算法对象
+            KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM);
+            //运用SHA1安全策略
+            SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
+            //设置上密钥种子
+            secureRandom.setSeed(KEY_STR.getBytes());
+            //初始化基于SHA1的算法对象
+            generator.init(secureRandom);
+            //生成密钥对象
+            key = generator.generateKey();
+            generator = null;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /***
+     * 获取加密的信息
+     * @param str
+     * @return
+     */
+    public static String getEncryptString(String str) {
+        //基于BASE64编码,接收byte[]并转换成String
+        BASE64Encoder encoder = new BASE64Encoder();
+        try {
+            //按utf8编码
+            byte[] bytes = str.getBytes(CHARSETNAME);
+            //获取加密对象
+            Cipher cipher = Cipher.getInstance(ALGORITHM);
+            //初始化密码信息
+            cipher.init(Cipher.ENCRYPT_MODE, key);
+            //加密
+            byte[] doFinal = cipher.doFinal(bytes);
+            //byte[]to encode好的String 并返回
+            return encoder.encode(doFinal);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /***
+     * 获取解密之后的信息
+     * @param str
+     * @return
+     */
+    public static String getDecryptString(String str) {
+        BASE64Decoder decoder = new BASE64Decoder();
+        try {
+            //将字符串decode成byte[]
+            byte[] bytes = decoder.decodeBuffer(str);
+            //获取解密对象
+            Cipher cipher = Cipher.getInstance(ALGORITHM);
+            //初始化解密信息
+            cipher.init(Cipher.DECRYPT_MODE, key);
+            //解密
+            byte[] doFial = cipher.doFinal(bytes);
+
+            return new String(doFial, CHARSETNAME);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

+ 1 - 0
src/main/java/thyyxxk/webserver/utils/SnowFlakeId.java

@@ -15,6 +15,7 @@ public class SnowFlakeId {
     private long sequence;
     //上次时间戳,初始值为负数
     private long lastTimestamp = -1L;
+
     private SnowFlakeId(long workerId, long datacenterId, long sequence) {
         //最大值
         long maxWorkerId = ~(-1L << workerIdBits);