Browse Source

病案首页添加归档申请

lighter 3 years ago
parent
commit
c4d5e62542

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/casefrontsheet/CaseFrontSheetController.java

@@ -95,6 +95,11 @@ public class CaseFrontSheetController {
         return service.saveVerify(param);
     }
 
+    @PostMapping("/signApply")
+    public ResultVo<List<PureCodeName>> signApply(@RequestBody CaseFrontsheetMain sheet) {
+        return service.signApply(sheet);
+    }
+
     @PostMapping("/confirmCopyPrint")
     public ResultVo<String> confirmCopyPrint(@RequestBody OpCaseFrontsheet param) {
         param.setStaffId(TokenUtil.getTokenUserId());

+ 13 - 6
src/main/java/thyyxxk/webserver/dao/his/casefrontsheet/BasSelectOverviewDao.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.dao.his.casefrontsheet;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.casefrontsheet.CaseFrontsheetSurgery;
 import thyyxxk.webserver.entity.casefrontsheet.GetOutSheet;
@@ -12,7 +13,7 @@ import java.util.List;
 @Mapper
 public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery> {
     @Select("select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +
@@ -35,7 +36,7 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
     List<SheetOverview> selectPatientsForBasByBah(GetOutSheet param);
 
     @Select("select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +
@@ -57,8 +58,14 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
             "isnull(a.file_status, 0)>=1 order by a.zk_ward,b.zyys")
     List<SheetOverview> selectPatientsForBasByBah2(GetOutSheet param);
 
+    @Select("select sign_datetime as signDate,bah,times,name,gender as sex, " +
+            "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=apply_staff) " +
+            "from t_frontsheet_sign_apply with(nolock) " +
+            "where bah=#{bah} and status=#{status}")
+    List<SheetOverview> selectSignApply(@Param("bah") String bah, @Param("status") int status);
+
     @Select("select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +
@@ -84,7 +91,7 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
     List<SheetOverview> selectPatientsForBasByWard(GetOutSheet param);
 
     @Select("select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +
@@ -110,7 +117,7 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
     List<SheetOverview> selectPatientsForBasByWard2(GetOutSheet param);
 
     @Select("select " +
-            " signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +
@@ -135,7 +142,7 @@ public interface BasSelectOverviewDao extends BaseMapper<CaseFrontsheetSurgery>
     List<SheetOverview> selectPatientsForBasByFileStatus(GetOutSheet param);
 
     @Select("select " +
-            "signDate=(convert(varchar(10), b.sign_date, 21)), " +
+            "b.sign_date, " +
             "bedNo=rtrim(a.bed_no), " +
             "bah=rtrim(a.inpatient_no), " +
             "times=rtrim(a.admiss_times), " +

+ 14 - 1
src/main/java/thyyxxk/webserver/dao/his/casefrontsheet/CaseFrontSheetDao.java

@@ -511,6 +511,19 @@ public interface CaseFrontSheetDao extends BaseMapper<CaseFrontsheetMain> {
             "#{anaesthesia}, #{anaesthesiaor})")
     void writeNewZySurgeryRecord(CaseFrontsheetSurgery surgery);
 
+    @Select("select status from t_frontsheet_sign_apply where bah=#{bah} and times=#{times} ")
+    Integer getSignApplyStatus(@Param("bah") String bah, @Param("times") int times);
+
+    @Insert("insert into t_frontsheet_sign_apply (bah, times, name, gender, apply_staff) " +
+            "values (#{bah}, #{times}, #{name}, #{gender}, #{staff})")
+    void insertNewSignApply(@Param("bah") String bah, @Param("times") int times,
+                            @Param("name") String name, @Param("gender") String gender,
+                            @Param("staff") String staff);
+
+    @Update("update t_frontsheet_sign_apply set status=1, sign_staff=#{staff}, sign_datetime=getdate() " +
+            "where bah=#{bah} and times=#{times}")
+    void updateSignApply(@Param("bah") String bah, @Param("times") int times, @Param("staff") String staff);
+
     @Update("update zy_actpatient set file_status=#{status} where inpatient_no=#{bah} and " +
             "admiss_times=#{times}")
     void updateZyFileStatus(@Param("status") int status, @Param("bah") String bah, @Param("times") int times);
@@ -722,7 +735,7 @@ public interface CaseFrontSheetDao extends BaseMapper<CaseFrontsheetMain> {
     @Select("select rtrim(zk_ward) as deptCode,isnull(file_status,0) as fileStatus, count(1) as dismissCount " +
             "from zy_inactpatient with(nolock) where dis_date>=#{start} and dis_date<=#{end} group by zk_ward, file_status")
     List<TempDismissCount> selectDismissCount(@Param("start") String start,
-                                          @Param("end") String end);
+                                              @Param("end") String end);
 
     @Select("<script>" +
             "select rtrim(a.inpatient_no) as patNo,a.admiss_times as times, " +

+ 5 - 1
src/main/java/thyyxxk/webserver/entity/casefrontsheet/SheetOverview.java

@@ -1,6 +1,8 @@
 package thyyxxk.webserver.entity.casefrontsheet;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
 
@@ -19,7 +21,9 @@ public class SheetOverview {
     private String deptName;
     private String doctorName;
     private Date disDate;
-    private String signDate;
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date signDate;
     private Integer lateCount;
     private Integer lateDays;
     private Integer lateFlag;

+ 34 - 16
src/main/java/thyyxxk/webserver/service/casefrontsheet/CaseFrontSheetService.java

@@ -158,7 +158,11 @@ public class CaseFrontSheetService {
                 list = basDao.selectPatientsForBasByBah2(param);
             }
             if (list.isEmpty()) {
-                return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有此患者的结算信息,请联系病房核实。");
+                int status = param.getFileStatus() == 0 ? 0 : 1;
+                list = basDao.selectSignApply(param.getBah(), status);
+                if (list.isEmpty()) {
+                    return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有此患者的结算信息或归档申请,请联系病房核实。");
+                }
             }
             if (param.getLateFlag() != 3) {
                 list.removeIf(item -> !item.getLateFlag().equals(param.getLateFlag()));
@@ -290,15 +294,6 @@ public class CaseFrontSheetService {
         }
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    public synchronized ResultVo<List<PureCodeName>> savePatientInfo(OpCaseFrontsheet param) {
-        CaseFrontsheetMain sheet = param.getSheet();
-        final String bah = sheet.getBah();
-        final int times = sheet.getAdmissTimes();
-        dao.writeBaOpLog(param.getOpType(), param.getStaffId(), bah, times);
-        return param.getOpType() == 1 ? saveSheet(sheet) : archiveSheet(sheet);
-    }
-
     private ResultVo<List<PureCodeName>> saveSheet(CaseFrontsheetMain sheet) {
         String bah = sheet.getBah();
         int times = sheet.getAdmissTimes();
@@ -346,10 +341,28 @@ public class CaseFrontSheetService {
         return ResultVoUtil.success();
     }
 
+    public ResultVo<List<PureCodeName>> signApply(CaseFrontsheetMain sheet) {
+        Integer status = dao.getSignApplyStatus(sheet.getBah(), sheet.getAdmissTimes());
+        if (null == status) {
+            List<PureCodeName> message = VerifyCaseFrontSheet.getInstance().printVerify(sheet);
+            if (message.isEmpty()) {
+                dao.insertNewSignApply(sheet.getBah(), sheet.getAdmissTimes(),
+                        sheet.getName(), sheet.getSex(), TokenUtil.getTokenUserId());
+                return ResultVoUtil.success();
+            }
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "校验未通过。", message);
+        }
+        if (status == 0) {
+            return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "此病案已提交过归档申请,请耐心等待病案室签收。");
+        }
+        return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "此病案已签收,无法继续申请。");
+    }
+
     private ResultVo<List<PureCodeName>> archiveSheet(CaseFrontsheetMain sheet) {
-        String bah = sheet.getBah();
-        int times = sheet.getAdmissTimes();
-        if (userDao.getUserRoles(TokenUtil.getTokenUserId()).contains(7)) {
+        String staff = TokenUtil.getTokenUserId();
+        if (userDao.getUserRoles(staff).contains(7)) {
+            String bah = sheet.getBah();
+            int times = sheet.getAdmissTimes();
             if (isLateSubmit(sheet.getDismissDate()) > 8) {
                 sheet.setLateFlag(1);
             } else {
@@ -384,6 +397,7 @@ public class CaseFrontSheetService {
                     basDao.insert(caseFrontsheetSurgery);
                 }
             }
+            dao.updateSignApply(bah, times, staff);
             return ResultVoUtil.success();
         }
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您没有签收首页的权限。");
@@ -514,10 +528,14 @@ public class CaseFrontSheetService {
         if (sheet.getFileStatus() == 2) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "已打印的病案首页无法再次保存!");
         }
-        List<PureCodeName> message = VerifyCaseFrontSheet.getInstance().saveVerify(sheet);
-        log.info("保存前病案逻辑校验, 操作员:{} >>> {}", TokenUtil.getTokenUserId(), message);
+        int optype = info.getOpType();
+        List<PureCodeName> message = optype == 1 ? VerifyCaseFrontSheet.getInstance().saveVerify(sheet) :
+                VerifyCaseFrontSheet.getInstance().printVerify(sheet);
         if (message.isEmpty()) {
-            return savePatientInfo(info);
+            final String bah = sheet.getBah();
+            final int times = sheet.getAdmissTimes();
+            dao.writeBaOpLog(optype, info.getStaffId(), bah, times);
+            return optype == 1 ? saveSheet(sheet) : archiveSheet(sheet);
         } else {
             return ResultVoUtil.fail(ExceptionEnum.INTERNAL_SERVER_ERROR, "校验未通过。", message);
         }

+ 17 - 0
src/main/java/thyyxxk/webserver/service/casefrontsheet/VerifyCaseFrontSheet.java

@@ -90,6 +90,14 @@ public class VerifyCaseFrontSheet {
         if (StringUtil.invalidValue(info.getLivePlace())) {
             array.add(new PureCodeName("livePlace","患者现住址不能为空!"));
         }
+        try {
+            byte[] livePlaceBytes = info.getLivePlace().getBytes("GBK");
+            if (livePlaceBytes.length > 32) {
+                array.add(new PureCodeName("livePlace", "患者现住址不能超过32个字节,当前字节数为" + livePlaceBytes.length + "(1汉字=2字节,1字母或数字=1字节)!"));
+            }
+        } catch (Exception e) {
+            log.error("分析患者现住址长度出现异常", e);
+        }
         if (StringUtil.invalidValue(info.getPhone())) {
             array.add(new PureCodeName("phone","患者电话不能为空!"));
         }
@@ -231,6 +239,15 @@ public class VerifyCaseFrontSheet {
         if (DateUtil.daysBetween(info.getQualityControlDate(), info.getDismissDate()) > 7) {
             array.add(new PureCodeName("qualityControlDate","质控日期不能大于出院7天!"));
         }
+        if (info.getHkPlaceName().length() > 10) {
+            array.add(new PureCodeName("hkPlaceName", "患者户口地址不能超过10个汉字!"));
+        }
+        if (info.getUnitPlace().length() > 16) {
+            array.add(new PureCodeName("unitPlace", "患者单位地址不能超过16个汉字!"));
+        }
+        if (info.getContactAddrName().length() > 16) {
+            array.add(new PureCodeName("contactAddrName", "患者联系人地址不能超过16个汉字!"));
+        }
         if (isNewBorn(info.getHasInfant(), info.getBirthDate())) {
             if (StringUtil.invalidValue(info.getNewBornWeight()) ||
                     StringUtil.invalidValue(info.getNewBornAdmissWeight())) {