浏览代码

出院召回

lighter 3 月之前
父节点
当前提交
18459b3bb8

+ 1 - 2
src/main/java/thyyxxk/webserver/config/RestTemplateConfig.java

@@ -13,8 +13,7 @@ public class RestTemplateConfig {
     @Bean
     public RestTemplate restTemplate(RestTemplateBuilder builder) {
         return builder
-                .setConnectTimeout(Duration.ofSeconds(3))
-                .setReadTimeout(Duration.ofSeconds(5))
+                .setConnectTimeout(Duration.ofSeconds(10))
                 .build();
     }
 }

+ 40 - 0
src/main/java/thyyxxk/webserver/controller/inpatient/charge/ForceInAndOutController.java

@@ -0,0 +1,40 @@
+package thyyxxk.webserver.controller.inpatient.charge;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.inpatient.charge.forceinout.PatInquiry;
+import thyyxxk.webserver.entity.inpatient.charge.forceinout.SimplePatient;
+import thyyxxk.webserver.service.inpatient.charge.ForceInAndOutService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/forceInAndOut")
+public class ForceInAndOutController {
+    private final ForceInAndOutService service;
+
+    @Autowired
+    public ForceInAndOutController(ForceInAndOutService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/getActpatient")
+    public ResultVo<List<SimplePatient>> getActpatient(@RequestBody PatInquiry inquiry) {
+        return ResultVoUtil.success(service.getActpatient(inquiry));
+    }
+
+    @PostMapping("/pullBack")
+    public ResultVo<String> pullBack(@RequestBody SimplePatient patient) {
+        return ResultVoUtil.success(service.pullBack(patient));
+    }
+
+    @PostMapping("/kickOut")
+    public ResultVo<String> kickOut(@RequestBody SimplePatient patient) {
+        return null;
+    }
+}

+ 86 - 0
src/main/java/thyyxxk/webserver/dao/his/inpatient/charge/ForceInAndOutDao.java

@@ -0,0 +1,86 @@
+package thyyxxk.webserver.dao.his.inpatient.charge;
+
+import org.apache.ibatis.annotations.*;
+import thyyxxk.webserver.entity.inpatient.charge.forceinout.SimplePatient;
+
+import java.util.List;
+
+@Mapper
+public interface ForceInAndOutDao {
+
+    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,rtrim(name) as name," +
+            "admiss_date as admDate,med_type,dis_date,rtrim(bed_status) as bedStatus," +
+            "rtrim(ward) as ward,rtrim(zk_ward) as dept,rtrim(bed_no) as bedNo " +
+            "from zy_inactpatient where inpatient_no=#{input} or name=#{input} " +
+            "order by inpatient_no,dis_date desc")
+    List<SimplePatient> getZyInactpatient(String input);
+
+    @Select("select rtrim(inpatient_no) as patNo,admiss_times as times,rtrim(name) as name," +
+            "admiss_date as admDate,med_type,dis_date,rtrim(bed_status) as bedStatus," +
+            "rtrim(ward) as ward,rtrim(zk_ward) as dept,rtrim(bed_no) as bedNo " +
+            "from zy_actpatient where inpatient_no=#{input} or name=#{input} ")
+    List<SimplePatient> getZyActpatient(String input);
+
+    /**
+     * 出院召回开始 <<<---
+     * 床位状态:1空闲,2占用
+     */
+    @Select("select count(1) from zy_bed_mi where dept_code=#{ward} " +
+            "and ward_code=#{ward} and bed_no=#{bedNo} and bed_status='1' ")
+    int certainBedFree(SimplePatient patient);
+
+    @Select("select max(rtrim(bed_no)) from zy_bed_mi where dept_code=#{ward} " +
+            "and ward_code=#{ward} and bed_status='1'")
+    String getMaxFreeBedNo(String ward);
+
+    @Update("update zy_inactpatient set bed_no=#{bedNo},dis_ward=null,dis_dept=null," +
+            "bed_status='9' where inpatient_no=#{patNo} and admiss_times=#{times}")
+    void changeBedNoAndBedStatus(SimplePatient patient);
+
+    @Insert("insert into zy_actpatient select * from zy_inactpatient " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} ")
+    void transferZyActpatient(SimplePatient patient);
+
+    @Insert("insert into zy_actpatient select * from zy_inactpatient " +
+            "where inpatient_no>=#{babyNoBegin} and inpatient_no<=#{babyNoEnd} and admiss_times=#{times}")
+    void transferZyActpatientBaby(SimplePatient patient);
+
+    @Update("update zy_bed_mi set bed_status='2',inpatient_no=#{patNo},admiss_times=#{times} " +
+            "where ward_code=#{ward} and dept_code=#{ward} and bed_no=#{bedNo}")
+    void lockZyBedMi(SimplePatient patient);
+
+    @Update("update zy_adt set dis_date=null,orig_ward=null,orig_dept=null,orig_bed=null " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} and trans_times=0")
+    void clearZyAdt(SimplePatient patient);
+
+    @Delete("delete from zy_inactpatient where inpatient_no=#{patNo} and admiss_times=#{times}")
+    void deleteZyInactpatient(SimplePatient patient);
+
+    @Delete("delete from zy_inactpatient where inpatient_no>=#{babyNoBegin} " +
+            "and inpatient_no<=#{babyNoEnd} and admiss_times=#{times}")
+    void deleteZyInactpatientBaby(SimplePatient patient);
+
+    @Insert("insert into yz_act_order select * from yz_inact_order " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times}")
+    void transferYzActOrder(SimplePatient patient);
+
+    @Insert("insert into yz_act_order select *from yz_inact_order " +
+            "where inpatient_no=#{babyNoBegin} and inpatient_no<=#{babyNoEnd} and admiss_times=#{times}")
+    void transferYzActOrderBaby(SimplePatient patient);
+
+    @Delete("delete from yz_inact_order where inpatient_no=#{patNo} and admiss_times=#{times}")
+    void deleteYzActOrder(SimplePatient patient);
+
+    @Delete("delete from yz_inact_order where inpatient_no=#{babyNoBegin} " +
+            "and inpatient_no<=#{babyNoEnd} and admiss_times=#{times}")
+    void deleteYzActOrderBaby(SimplePatient patient);
+    /**
+     * 出院召回结束 --->>>
+     */
+
+    @Insert("insert into zy_work_log(inpatient_no,admiss_times,ledger_sn,op_id,op_date,log_type," +
+            "dept_code,ward_code,name) values " +
+            "(#{patNo},#{times},0,#{staffId},getdate(),#{staffOpType},#{zkWard},#{ward},#{staffName}) ")
+    void insertZyWorkLog(SimplePatient patient);
+
+}

+ 14 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/charge/forceinout/PatInquiry.java

@@ -0,0 +1,14 @@
+package thyyxxk.webserver.entity.inpatient.charge.forceinout;
+
+import lombok.Data;
+
+@Data
+public class PatInquiry {
+    private PatStatus patStatus;
+    private String userInput;
+
+    public static enum PatStatus {
+        IN_HOSPITAL,
+        OUT_HOSPITAL;
+    }
+}

+ 34 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/charge/forceinout/SimplePatient.java

@@ -0,0 +1,34 @@
+package thyyxxk.webserver.entity.inpatient.charge.forceinout;
+
+import lombok.Data;
+
+@Data
+public class SimplePatient {
+    private String patNo;
+    private Integer times;
+    private String name;
+    private String admDate;
+    private String disDate;
+    private String bedStatus;
+    private String ward;
+    private String wardName;
+    private String dept;
+    private String deptName;
+    private String bedNo;
+    private String medType;
+    private String medTypeName;
+    private String staffId;
+    private String staffName;
+    private String staffOpType;
+
+    private String babyNoBegin;
+    private String babyNoEnd;
+
+    public String getBabyNoBegin() {
+        return babyNoBegin + "$1";
+    }
+
+    public String getBabyNoEnd() {
+        return babyNoEnd + "$6";
+    }
+}

+ 0 - 2
src/main/java/thyyxxk/webserver/service/examinations/InspectionsService.java

@@ -2,8 +2,6 @@ package thyyxxk.webserver.service.examinations;
 
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpMethod;

+ 83 - 0
src/main/java/thyyxxk/webserver/service/inpatient/charge/ForceInAndOutService.java

@@ -0,0 +1,83 @@
+package thyyxxk.webserver.service.inpatient.charge;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.sidicts.MedType;
+import thyyxxk.webserver.dao.his.inpatient.charge.ForceInAndOutDao;
+import thyyxxk.webserver.entity.inpatient.charge.forceinout.PatInquiry;
+import thyyxxk.webserver.entity.inpatient.charge.forceinout.SimplePatient;
+import thyyxxk.webserver.entity.login.UserInfo;
+import thyyxxk.webserver.service.hutoolcache.DeptCache;
+import thyyxxk.webserver.service.hutoolcache.UserCache;
+
+import java.util.List;
+
+@Service
+public class ForceInAndOutService {
+    private final ForceInAndOutDao dao;
+    private final DeptCache deptCache;
+    private final UserCache userCache;
+
+    @Autowired
+    public ForceInAndOutService(ForceInAndOutDao dao, DeptCache deptCache, UserCache userCache) {
+        this.dao = dao;
+        this.deptCache = deptCache;
+        this.userCache = userCache;
+    }
+
+    public List<SimplePatient> getActpatient(PatInquiry inquiry) {
+        List<SimplePatient> list;
+        if (inquiry.getPatStatus() == PatInquiry.PatStatus.IN_HOSPITAL) {
+            list = dao.getZyActpatient(inquiry.getUserInput());
+        } else {
+            list = dao.getZyInactpatient(inquiry.getUserInput());
+        }
+        list.forEach(item -> {
+            item.setWardName(deptCache.getDeptName(item.getWard()));
+            item.setDeptName(deptCache.getDeptName(item.getDept()));
+            item.setMedTypeName(MedType.getName(item.getMedType()));
+        });
+        return list;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public String pullBack(SimplePatient patient) {
+        int bedFree = dao.certainBedFree(patient);
+        if (bedFree == 0) {
+            String maxFreeBedNo = dao.getMaxFreeBedNo(patient.getWard());
+            if (StrUtil.isBlank(maxFreeBedNo)) {
+                throw new BizException(ExceptionEnum.LOGICAL_ERROR, "病房已无空闲床位,无法进行召回操作!");
+            }
+            patient.setBedNo(maxFreeBedNo);
+        }
+
+        UserInfo user = userCache.getUserInfoByToken();
+        patient.setStaffId(user.getCode());
+        patient.setStaffName(user.getName());
+        patient.setStaffOpType("5");
+
+        dao.changeBedNoAndBedStatus(patient);
+        dao.transferZyActpatient(patient);
+        dao.transferZyActpatientBaby(patient);
+        dao.lockZyBedMi(patient);
+        dao.clearZyAdt(patient);
+        dao.deleteZyInactpatient(patient);
+        dao.deleteZyInactpatientBaby(patient);
+        dao.transferYzActOrder(patient);
+        dao.transferYzActOrderBaby(patient);
+        dao.deleteYzActOrder(patient);
+        dao.deleteYzActOrderBaby(patient);
+        dao.insertZyWorkLog(patient);
+
+        return "患者召回成功。";
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public String kickOut(SimplePatient patient) {
+        return null;
+    }
+}