Browse Source

患者信息查询

DESKTOP-0GD05B0\Administrator 2 years ago
parent
commit
26efc24dbe

+ 32 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/PatInfoQueryController.java

@@ -0,0 +1,32 @@
+package thyyxxk.webserver.controller.zhuyuanyizheng;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+import thyyxxk.webserver.entity.zhuyuanyisheng.PatInfoQuery.PatInfoQueryParam;
+import thyyxxk.webserver.service.zhuyuanyisheng.PatientInfoQueryService;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/patInfo")
+public class PatInfoQueryController {
+    private final PatientInfoQueryService service;
+
+    @Autowired
+    public PatInfoQueryController(PatientInfoQueryService service) {
+        this.service = service;
+    }
+
+    @GetMapping("/getHospWardAndDept")
+    public ResultVo<List<GetDropdownBox>> getHospWardAndDept() {
+        return service.getHospWardAndDept();
+    }
+
+    @PostMapping("/getPatientInfo")
+    public ResultVo<List<Patient>> getPatientInfo(@RequestBody PatInfoQueryParam param) {
+        return service.getPatientInfo(param);
+    }
+}

+ 53 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/PatientInfoQueryDao.java

@@ -0,0 +1,53 @@
+package thyyxxk.webserver.dao.his.zhuyuanyisheng;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+
+import java.util.List;
+
+@Mapper
+public interface PatientInfoQueryDao {
+
+    @Select("SELECT dept_code    as code, " +
+            "       dept_name    as name, " +
+            "       dept_py_code as py_code, " +
+            "       dept_d_code  as w_code " +
+            "FROM zy_adtward " +
+            "group by dept_code, dept_name, dept_py_code, dept_d_code " +
+            "order by dept_code, dept_name")
+    List<GetDropdownBox> getHospWardAndDept();
+
+
+    @Select("SELECT a.inpatient_no, " +
+            "       a.admiss_times, " +
+            "       a.name, " +
+            "       a.admiss_date, " +
+            "       a.dis_date, " +
+            "       a.admiss_dept, " +
+            "       a.admiss_ward, " +
+            "       a.sex, " +
+            "       a.ward, " +
+            "       a.dept, " +
+            "       a.bed_no, " +
+            "       move_flag, " +
+            "       owe_flag, " +
+            "       admiss_diag_str, " +
+            "       responce_type, " +
+            "       responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," +
+            "       balance, " +
+            "       total_charge, " +
+            "       zk_ward," +
+            "       admissWardName = (select rtrim(name) from zd_unit_code where code = admiss_ward)," +
+            "       zkWardName     = (select rtrim(name) from zd_unit_code where code = zk_ward)," +
+            "       birth_date     = (select birth_date from a_patient_mi c where a.inpatient_no = c.inpatient_no) " +
+            "FROM ${tableName} a " +
+            " ${ew.customSqlSegment} ")
+    List<Patient> getPatInfo(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper,
+                             @Param("tableName") String tableName);
+
+}

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

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
+import thyyxxk.webserver.utils.DateUtil;
 import thyyxxk.webserver.utils.StringUtil;
 
 import java.math.BigDecimal;
@@ -55,6 +56,7 @@ public class Patient {
     private Date admissDate;
     private Date ybRegisterDate;
     private String responceType;
+    private String responceName;
     private Integer dismissOrder;
     private String zkWard;
     private String zkWardName;
@@ -172,6 +174,16 @@ public class Patient {
         }
     }
 
+    public Integer getTempAge() {
+        if (birthDate != null && admissDate != null) {
+            try {
+                return DateUtil.calculateAge(DateUtil.parse(birthDate), admissDate);
+            } catch (Exception ignored) {
+            }
+        }
+        return age;
+    }
+
     public String getPatNo() {
         return StringUtil.isBlank(inpatientNo) ? inpatientNo : inpatientNo.trim();
     }

+ 16 - 0
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/PatInfoQuery/PatInfoQueryParam.java

@@ -0,0 +1,16 @@
+package thyyxxk.webserver.entity.zhuyuanyisheng.PatInfoQuery;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class PatInfoQueryParam {
+    private String patNo;
+    private String name;
+    private Boolean leaveHospital;
+    private List<String> admissionTime;
+    private List<String> dischargeTime;
+    private String dept;
+    private String ward;
+}

+ 64 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/PatientInfoQueryService.java

@@ -0,0 +1,64 @@
+package thyyxxk.webserver.service.zhuyuanyisheng;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.PatientInfoQueryDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
+import thyyxxk.webserver.entity.inpatient.patient.Patient;
+import thyyxxk.webserver.entity.zhuyuanyisheng.PatInfoQuery.PatInfoQueryParam;
+import thyyxxk.webserver.utils.ListUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.util.List;
+
+@Service
+@Slf4j
+public class PatientInfoQueryService {
+
+    private final PatientInfoQueryDao dao;
+
+    @Autowired
+    public PatientInfoQueryService(PatientInfoQueryDao dao) {
+        this.dao = dao;
+    }
+
+    public ResultVo<List<GetDropdownBox>> getHospWardAndDept() {
+        return ResultVoUtil.success(dao.getHospWardAndDept());
+    }
+
+
+    public ResultVo<List<Patient>> getPatientInfo(PatInfoQueryParam param) {
+        log.info("查询患者信息:{}", JSON.toJSONString(param));
+        QueryWrapper<?> qw = new QueryWrapper<>();
+
+        if (StringUtil.notBlank(param.getPatNo())) {
+            qw.eq("inpatient_no", param.getPatNo());
+        }
+        if (StringUtil.notBlank(param.getName())) {
+            qw.like("name", param.getName());
+        }
+        if (ListUtil.notBlank(param.getAdmissionTime())) {
+            qw.ge("admiss_date", param.getAdmissionTime().get(0));
+            qw.le("admiss_date", param.getAdmissionTime().get(1));
+        }
+        if (ListUtil.notBlank(param.getDischargeTime())) {
+            qw.ge("dis_date", param.getAdmissionTime().get(0));
+            qw.le("dis_date", param.getAdmissionTime().get(1));
+        }
+        if (StringUtil.notBlank(param.getDept())) {
+            qw.eq("dept", param.getDept());
+        }
+        if (StringUtil.notBlank(param.getWard())) {
+            qw.eq("ward", param.getWard());
+        }
+        List<Patient> list = dao.getPatInfo(qw, param.getLeaveHospital() ? "zy_inactpatient" : "zy_actpatient");
+        return ResultVoUtil.success(list);
+    }
+
+
+}