ソースを参照

患者危急值

DESKTOP-0GD05B0\Administrator 2 年 前
コミット
cfec018503

+ 5 - 5
src/main/java/thyyxxk/webserver/constants/Message.java

@@ -18,15 +18,15 @@ public enum Message {
      * 系统消息
      */
     SYSTEM_NOTIFICATION("systemNotification"),
-
     SERVER_UPDATE_MESSAGE("serverUpdateMessage"),
-
     SYSTEM_ANNOUNCEMENT("systemAnnouncement"),
-
     SCROLLING_MESSAGES("scrollingMessages"),
-
     UPDATED_ORDER("updatedOrder"),
-    AVATAR_NOTIFICATION("avatarNotification");
+    AVATAR_NOTIFICATION("avatarNotification"),
+    /**
+     * 患者危急值
+     */
+    critical_value("criticalValue");
 
     private final String name;
 

+ 33 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/AcceptPatientCriticalValuesControllre.java

@@ -0,0 +1,33 @@
+package thyyxxk.webserver.controller.zhuyuanyizheng;
+
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+import thyyxxk.webserver.service.zhuyuanyisheng.PatientCriticalValuesServer;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/criticalValue")
+public class AcceptPatientCriticalValuesControllre {
+
+    private final PatientCriticalValuesServer server;
+
+    public AcceptPatientCriticalValuesControllre(PatientCriticalValuesServer server) {
+        this.server = server;
+    }
+
+    @GetMapping("/pushMessage")
+    @PassToken
+    public ResultVo<String> acceptCriticalValues(@RequestParam("message") String message) {
+        return server.acceptCriticalValues(message);
+    }
+
+    @GetMapping("/getCriticalValuePatientList")
+    public ResultVo<List<JSONObject>> getCriticalValuePatientList(@RequestParam("patNo") String patNo) {
+        return server.getCriticalValuePatientList(patNo);
+    }
+
+}

+ 45 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/PatientCriticalValuesDao.java

@@ -0,0 +1,45 @@
+package thyyxxk.webserver.dao.his.zhuyuanyisheng;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import org.apache.ibatis.annotations.Insert;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+
+import java.util.List;
+
+public interface PatientCriticalValuesDao {
+
+    @Select("select inpatient_no, admiss_times, zk_ward as deptCode, rtrim(name) as name, bed_no " +
+            "from zy_actpatient " +
+            "where inpatient_no = #{patNo} ")
+    Patient selectPatientInfoByPatNo(String patNo);
+
+    @Insert("insert t_patient_critical_value (pat_no, times, message) " +
+            "values (#{patNo}, #{times}, #{message} )")
+    void insertAMessage(String patNo,
+                        Integer times,
+                        String message);
+
+    @Select("select code " +
+            "from a_employee_mi " +
+            "where dept_code = #{deptCode} " +
+            "  and isnull(del_flag, 0) = 0")
+    List<String> selectDoctorByDept(String deptCode);
+
+
+    @Select("select rtrim(inpatient_no) + '_' + cast(admiss_times as varchar(3)) as patNo, " +
+            "       rtrim(name)                                                  as name, " +
+            "       rtrim(bed_no)                                                as bedNo, " +
+            "       a.message " +
+            "from t_patient_critical_value a " +
+            "         left join " +
+            "     zy_actpatient b on (a.pat_no = b.inpatient_no " +
+            "         and a.times = b.admiss_times) " +
+            " ${ew.customSqlSegment} ")
+    List<JSONObject> selectCriticalValuePatientList(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
+
+
+}

+ 2 - 4
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/YiZhuLuRuDao.java

@@ -925,7 +925,6 @@ public interface YiZhuLuRuDao {
             "</script>")
     List<XinZhenYzActOrder> huoQuXiangMuXinXi(Set<String> code);
 
-
     @Select("select          rtrim(inpatient_no) as inpatient_no, " +
             "                admiss_times, " +
             "                rtrim(name)         as name, " +
@@ -947,7 +946,6 @@ public interface YiZhuLuRuDao {
     XinZhenYiZhu queryPatientInfo(@Param("patNo") String patNo,
                                   @Param("times") Integer times);
 
-
     @Insert("<script>" +
             "INSERT INTO yz_act_order (order_code, order_name, frequ_code, instruction, discription, infant_flag, order_time, " +
             "    /*录入人*/physician, start_time, drug_specification, drug_quan, supply_code, act_order_no, inpatient_no, " +
@@ -1597,7 +1595,7 @@ public interface YiZhuLuRuDao {
             "                           submit_name, submit_flag, " +
             "                           page_class, page_name, " +
             "                           start_date, end_date, group_no) " +
-            "values (#{pageNo}, #{patInfo.deptCode}, #{patInfo.wardCode}, getdate()," +
+            "values (#{pageNo}, #{patInfo.wardCode}, #{patInfo.deptCode}, getdate()," +
             " #{userCode}, 1, 1, '出院带药', getdate(), getdate(), #{groupNo})")
     void summarySheetOfDrugs(Integer pageNo, XinZhenYiZhu patInfo, String userCode, String groupNo);
 
@@ -1610,7 +1608,7 @@ public interface YiZhuLuRuDao {
             " group_no, doctor_name, page_class) " +
             "values " +
             "<foreach collection='list' item='item' separator=','>" +
-            "(#{patInfo.inpatientNo},#{patInfo.admissTimes},#{patInfo.name},#{patInfo.bedNo},#{patInfo.deptCode},#{patInfo.wardCode},#{item.orderCode}," +
+            "(#{patInfo.inpatientNo},#{patInfo.admissTimes},#{patInfo.name},#{patInfo.bedNo},#{patInfo.wardCode},#{patInfo.deptCode},#{item.orderCode}," +
             "#{item.drugQuan},(select pack_retprice from yp_zd_dict where code = '${item.orderCode}' and serial = '${item.serial}'),getdate()," +
             "#{patInfo.infantFlag},#{userCode}," +
             "'a','1',#{item.drugFlag},'0',getdate(),#{item.actOrderNo},#{pageNo},'0',#{item.serial},#{groupNo},#{userCode},'1')" +

+ 1 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/patient/Patient.java

@@ -51,6 +51,7 @@ public class Patient {
     private String admissDept;
     private String smallDept;
     private String smallDeptName;
+    private String deptCode;
     private Date admissDate;
     private Date ybRegisterDate;
     private String responceType;

+ 74 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/PatientCriticalValuesServer.java

@@ -0,0 +1,74 @@
+package thyyxxk.webserver.service.zhuyuanyisheng;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.Message;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.PatientCriticalValuesDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.ListUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.SocketMsg;
+import thyyxxk.webserver.utils.StringUtil;
+import thyyxxk.webserver.websocket.WebSocketServer;
+
+import java.util.List;
+
+@Service
+@Slf4j
+public class PatientCriticalValuesServer {
+
+    private final PatientCriticalValuesDao dao;
+    private final RedisLikeService redisLikeService;
+
+    public PatientCriticalValuesServer(PatientCriticalValuesDao dao, RedisLikeService redisLikeService) {
+        this.dao = dao;
+        this.redisLikeService = redisLikeService;
+    }
+
+    public ResultVo<String> acceptCriticalValues(String message) {
+        log.info("数据:{}", message);
+        if (StringUtil.isBlank(message)) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "消息体为空。");
+        }
+        String patNo = message.substring(message.indexOf("住院号") + 4, message.indexOf(",姓名"));
+        Patient p = dao.selectPatientInfoByPatNo(patNo);
+        if (p == null) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "未查询到该住院患者信息。");
+        }
+        dao.insertAMessage(patNo, p.getAdmissTimes(), message);
+        List<String> codeList = dao.selectDoctorByDept(p.getDeptCode());
+
+        JSONObject js = new JSONObject();
+        js.put("message", message);
+
+        codeList.forEach(item -> {
+            WebSocketServer.sendMessageByUserCode(item, SocketMsg.socketVo(Message.critical_value, js));
+        });
+
+        log.info("住院号:{}", patNo);
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<List<JSONObject>> getCriticalValuePatientList(String patNo) {
+        QueryWrapper<?> qw = new QueryWrapper<>();
+        UserInfo u = redisLikeService.getUserInfoByToken();
+        if (StringUtil.isBlank(patNo)) {
+            qw.eq("b.zk_ward", u.getDeptCode());
+        } else {
+            qw.eq("a.pat_no", patNo);
+        }
+        List<JSONObject> patientList = dao.selectCriticalValuePatientList(qw);
+        if (patientList == null) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
+        }
+        return ResultVoUtil.success(patientList);
+    }
+
+
+}