Browse Source

恢复文件

xiaochan 1 year ago
parent
commit
7b7e00017a

+ 120 - 0
src/main/java/thyyxxk/webserver/controller/zhuyuanyizheng/emr/EmrControlRuleController.java

@@ -0,0 +1,120 @@
+package thyyxxk.webserver.controller.zhuyuanyizheng.emr;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.web.bind.annotation.*;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrAuditDetail;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrLimitUnlock;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.*;
+import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrControlRuleSever;
+import thyyxxk.webserver.service.zhuyuanyisheng.emr.EmrControlRuleSeverV2;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Administrator
+ */
+@RestController
+@RequestMapping("/emrControlRule")
+public class EmrControlRuleController {
+    private final EmrControlRuleSever server;
+
+    private final EmrControlRuleSeverV2 serverv2;
+
+    public EmrControlRuleController(EmrControlRuleSever server, EmrControlRuleSeverV2 serverv2) {
+        this.server = server;
+        this.serverv2 = serverv2;
+    }
+
+    @GetMapping("/getAvailableObjects")
+    public ResultVo<List<Map<String, Object>>> getAvailableObjects() {
+        return server.getAvailableObjects();
+    }
+
+    @GetMapping("/specifyAdmissionQualityControl")
+    public ResultVo<JSONObject> specifyAdmissionQualityControl(@RequestParam("start") String start,
+                                                               @RequestParam("end") String end) {
+        return serverv2.specifyAdmissionQualityControl(start, end);
+    }
+
+    @GetMapping("/myPatientQualityControl")
+    public ResultVo<List<EmrAuditDetail>> myPatientQualityControl() {
+        return serverv2.myPatientQualityControl();
+    }
+
+
+    @GetMapping("/getRuleList")
+    public ResultVo<List<EmrRule>> getRuleList() {
+        return ResultVoUtil.success(server.getRuleList());
+    }
+
+    @GetMapping("/switchQualityControl")
+    public ResultVo<String> switchQualityControl(@RequestParam("id") String id,
+                                                 @RequestParam("offOn") Integer offOn) {
+        return server.switchQualityControl(id, offOn);
+    }
+
+    @GetMapping("/deleteRuleById")
+    public ResultVo<String> deleteRuleById(@RequestParam("id") String id) {
+        return server.deleteRuleById(id);
+    }
+
+    @GetMapping("/modifyTheAdmissionQualityControlTime")
+    public ResultVo<String> modifyTheAdmissionQualityControlTime(@RequestParam("date") String date) {
+        return server.modifyTheAdmissionQualityControlTime(date);
+    }
+
+    @GetMapping("/getAdmissDate")
+    public ResultVo<String> getAdmissDate() {
+        return server.getAdmissDate();
+    }
+
+    @GetMapping("/createRestrictions")
+    public ResultVo<EmrRuleVerify> createRestrictions(@RequestParam("code") String code,
+                                                      @RequestParam("id") String id,
+                                                      @RequestParam("patNo") String patNo) {
+        String[] strings = patNo.split("_");
+        return server.createRestrictions(code, strings[0], Integer.valueOf(strings[1]), Integer.valueOf(strings[2]), id);
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////
+    @PostMapping("/requestToUnlockMedicalRecords")
+    public ResultVo<String> requestToUnlockMedicalRecords(@RequestBody EmrLimitUnlock param) {
+        return server.requestToUnlockMedicalRecords(param);
+    }
+
+    @PostMapping("/getApplicationData")
+    public ResultVo<IPage<EmrLimitUnlock>> getApplicationData(@RequestBody SelectUnlockParam param) {
+        return server.getApplicationData(param);
+    }
+
+    @PostMapping("/exportExcelUnlock")
+    @PassToken
+    public void exportExcelUnlock(HttpServletResponse response, @RequestBody SelectUnlockParam param) {
+        server.exportExcelUnlock(response, param);
+    }
+
+    @PostMapping("/reviewMedicalRecordsToUnlock")
+    public ResultVo<String> reviewMedicalRecordsToUnlock(@RequestBody EmrLimitUnlock param) {
+        return server.reviewMedicalRecordsToUnlock(param);
+    }
+
+    @GetMapping("/getMyUnlockByPatNo")
+    @PassToken
+    public ResultVo<EmrLimitUnlock> getMyUnlockByPatNo(@RequestParam("patNo") String patNo,
+                                                       @RequestParam("times") Integer times) {
+        return server.getMyUnlockByPatNo(patNo, times);
+    }
+
+
+    @PostMapping("/terminalPatients")
+    public ResultVo<List<QualityControlAnalysisOfMedicalRecords>> terminalPatients(@RequestBody FinalQuery param) {
+        return serverv2.terminalPatients(param);
+    }
+
+}

+ 341 - 0
src/main/java/thyyxxk/webserver/dao/his/zhuyuanyisheng/emr/EmrControlDao.java

@@ -0,0 +1,341 @@
+package thyyxxk.webserver.dao.his.zhuyuanyisheng.emr;
+
+
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.*;
+import org.apache.poi.ss.formula.functions.Count;
+import thyyxxk.webserver.constants.sidicts.ListType;
+import thyyxxk.webserver.entity.fluorescenceTest.FluorescenceSpecimenResult;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrLimitUnlock;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrProgressNote;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+public interface EmrControlDao {
+
+    @Select("select count(1) " +
+            "from emr_control_temp_code a, " +
+            "     emr_control_rule b " +
+            "where a.rule_id = b.id " +
+            "  and code = #{code} " +
+            "  and b.type = #{type} ")
+    int getEmrRuleCount(String code, int type);
+
+    @Insert("insert into emr_control_temp_code (code, rule_id) values (#{code},#{id})")
+    void insertControlRule(@Param("id") String id, @Param("code") String code);
+
+
+    @Insert("insert into emr_control_rule (id, type, off_or_on_rule,prompt_statement,name,sql,prescription,superior_doctor_time) " +
+            "values (#{id},#{param.type},#{param.offOrOnRule},#{param.promptStatement},#{param.name}," +
+            "#{param.sql},#{param.prescription},#{param.superiorDoctorTime})")
+    void insertRule(@Param("id") String id, @Param("param") RuleAdd param);
+
+    @Select("select name, id, group_name,sql_sentence " +
+            "from emr_data_maintenance " +
+            "where data_type = 3")
+    List<Map<String, Object>> getAvailableObjects();
+
+    @Select("select sql_sentence " +
+            " from emr_data_maintenance " +
+            " where id = 7")
+    String selectedSpecifyTheTimeOfAdmissionSql();
+
+    @Select("select rtrim(inpatient_no)                                                  as inpatient_no, " +
+            "       admiss_times, " +
+            "       (select rtrim(name) from zd_unit_code where code = zk_ward)          as deptName, " +
+            "       (select rtrim(name) from a_employee_mi where code = refer_physician) as tubeBedDoctorName, " +
+            "       admiss_date," +
+            "       rtrim(name) as name " +
+            "from zy_actpatient " +
+            "where ${condition} ")
+    List<QualityControlAnalysisOfMedicalRecords> selectedPatientsAdmittedAtTheSpecifiedTime(String condition);
+
+
+    @Select("select id, " +
+            "       type, " +
+            "       off_or_on_rule, " +
+            "       prompt_statement, " +
+            "       name, " +
+            "       sql, " +
+            "       prescription," +
+            "       superior_doctor_time " +
+            "from emr_control_rule ")
+    List<EmrRule> selectRules();
+
+    @Select("select id, " +
+            "       type, " +
+            "       off_or_on_rule, " +
+            "       prompt_statement, " +
+            "       name, " +
+            "       sql, " +
+            "       prescription " +
+            "from emr_control_rule " +
+            "where off_or_on_rule = 1")
+    List<EmrRule> selectRulesOpen();
+
+    @Select("select code " +
+            "from emr_control_temp_code " +
+            "where rule_id = #{id} ")
+    List<String> selectedEmrCode(String id);
+
+    @Select("${sql}")
+    Map<String, Object> executeSql(String sql);
+
+    @Select("${sql}")
+    Date executeSqlDate(String sql);
+
+    @Select("${sql}")
+    List<Date> executeSqlList(String sql);
+
+    /**
+     * 医嘱下达后是否创建了指定的片段
+     *
+     * @return
+     */
+    @Select("select count(1) from emr_progress_note where document_id = #{id} and creation_time > #{start} and creation_time <= #{end} ")
+    Integer theDoctorOrdersWhetherToCreateFragments(Integer id, Date start, Date end);
+
+    @Select("select id, " +
+            "       document_id, " +
+            "       name, " +
+            "       create_id, " +
+            "       creation_time, " +
+            "       refer_physician, " +
+            "       consult_physician, " +
+            "       dept_director " +
+            "from emr_progress_note " +
+            "where document_id = (select top 1 id " +
+            "                     from emr_patient_data " +
+            "                     where pat_no = #{patNo} " +
+            "                       and times = #{times} " +
+            "                       and del_flag = 0 " +
+            "                       and emr_category_code = 'shoucibingchengjilu')" +
+            " order by creation_time ")
+    List<EmrProgressNote> fragmentInterval(String patNo, Integer times);
+
+    @Select("select top 1 order_time " +
+            "from yz_act_order " +
+            "where inpatient_no = #{patNo} " +
+            "  and admiss_times = #{times} " +
+            "  and status_flag in ('3', '4') " +
+            "  and order_code in (select order_code from yz_zd_order_item_confirm where item_name = N'${name}')")
+    Date whetherThereIsASeriousIllnessDoctorSOrder(String patNo, Integer times, String name);
+
+
+    @Select("<script>" +
+            "select count(1) " +
+            "from emr_patient_data " +
+            "where pat_no = #{patNo} " +
+            "  and times = #{times} " +
+            "  and create_date &gt;= #{date} " +
+            "  and emr_category_code in " +
+            "<foreach collection='codeList' item='item'  open='(' close=')' separator=','>" +
+            "#{item}" +
+            "</foreach>" +
+            "</script>")
+    int determineWhetherTheDataWasCreated(String patNo,
+                                          Integer times,
+                                          Date date,
+                                          List<String> codeList);
+
+    @Select("select rtrim(code_rs) " +
+            "from dj_user_role a, " +
+            "     a_employee_mi b " +
+            "where role_id = 38 " +
+            "  and a.user_code = b.code " +
+            "  and isnull(b.del_flag, 0) = 0")
+    List<String> peopleWhoGetMedicalDepartment();
+
+    @Update("update emr_control_rule set off_or_on_rule = #{offOn} where id = #{id} ")
+    int switchQualityControl(String id, Integer offOn);
+
+    @Delete("delete emr_control_rule where id = #{id};" +
+            "delete emr_control_temp_code where rule_id = #{id} ")
+    void deleteRuleById(String id);
+
+    @Select("select code from emr_control_temp_code where rule_id = #{id}")
+    List<String> selectEmrCodeByRuleId(String id);
+
+    @Update("update emr_data_maintenance " +
+            "set sql_sentence = #{date} " +
+            "where id = 7")
+    void setTheTime(String date);
+
+
+    @Select("select sql_sentence " +
+            "from emr_data_maintenance where id = 7 ")
+    String getAdmissDate();
+
+
+    @Select("select id, " +
+            "       type, " +
+            "       off_or_on_rule, " +
+            "       prompt_statement, " +
+            "       name, " +
+            "       sql, " +
+            "       prescription, " +
+            "       superior_doctor_time, " +
+            "       code, " +
+            "       rule_id " +
+            "from emr_control_rule a, " +
+            "     emr_control_temp_code b " +
+            "where a.id = b.rule_id " +
+            "  and b.code = #{code}" +
+            "  and off_or_on_rule = 1 ")
+    List<EmrRule> selectRuleByEmrCode(String code);
+
+    @Insert("insert into emr_rule_unlock (pat_no, times, emr_id, code, " +
+            "date,input_id,input_remark,emr_name) " +
+            " values " +
+            " (#{patNo},#{times},#{id},#{code},#{date},#{inputId},#{remarks},#{name})")
+    void insertRemoveRestrictions(RemoveRestrictions data);
+
+    @Select("select top 1 id, " +
+            "       pat_no, " +
+            "       times, " +
+            "       emr_id, " +
+            "       code, " +
+            "       date, " +
+            "       input_id, " +
+            "       input_remark, " +
+            "       reviewed_by, " +
+            "       review_notes, " +
+            "       flag " +
+            "from emr_rule_unlock " +
+            "where pat_no = #{patNo} " +
+            "  and times = #{times} " +
+            "  and ${sql} " +
+            "  and date >= convert(varchar(10), getdate(), 120)" +
+            "  and flag = 1" +
+            "  and input_id = #{inputId} " +
+            "order by date desc ")
+    EmrRuleUnlock selectRemoveRestrictions(String patNo,
+                                           Integer times,
+                                           String sql,
+                                           String inputId);
+
+
+    @Select("select id, " +
+            "       pat_no, " +
+            "       times, " +
+            "       emr_id, " +
+            "       code, " +
+            "       date, " +
+            "       input_id, " +
+            "       input_name    = (select rtrim(name) from a_employee_mi where input_id = code), " +
+            "       input_remark, " +
+            "       reviewed_by, " +
+            "       reviewed_name = (select rtrim(name) from a_employee_mi where reviewed_by = code), " +
+            "       review_notes, " +
+            "       flag," +
+            "       emr_name," +
+            "       input_date," +
+            "       review_time " +
+            "from emr_rule_unlock ${ew.customSqlSegment} ")
+    List<EmrRuleUnlock> selectRuleUnlock(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
+
+    @Select("select count(1) " +
+            "from emr_rule_unlock " +
+            "where id = #{id} " +
+            "  and flag = 0 ")
+    int selectRuleUnlockById(Integer id);
+
+    @Update(" update emr_rule_unlock " +
+            " set " +
+            " flag = #{flag}," +
+            " reviewed_by = #{reviewedBy}," +
+            " review_notes = #{reviewNotes}," +
+            " review_time = getdate() " +
+            " where id = #{id}")
+    void updateUnlockById(EmrRuleUnlock param);
+
+    @Update("update emr_limit_unlock " +
+            "set state = 3 " +
+            "where pat_no = #{param.patNo} " +
+            "  and times = #{param.times} " +
+            "  and applicant = #{param.applicant} " +
+            "  and effective_time >= getdate()")
+    int updateUnlockOld(@Param("param") EmrLimitUnlock param);
+
+    @Insert("insert into emr_limit_unlock (pat_no, times, unlock_json, applicant, application_time, request_remarks, " +
+            "                              effective_time, state) " +
+            "values (#{param.patNo}, #{param.times},#{param.unlockJson},#{param.applicant},getdate(), #{param.requestRemarks}," +
+            "#{param.effectiveTime},0)")
+    int applicationUnlock(@Param("param") EmrLimitUnlock param);
+
+    @Select("select id, " +
+            "       pat_no, " +
+            "       times, " +
+            "       unlock_json, " +
+            "       applicant," +
+            "applicantName =    (select rtrim(name) from a_employee_mi where code = applicant), " +
+            "       application_time, " +
+            "       request_remarks, " +
+            "       approve," +
+            "approveName   =    (select rtrim(name) from a_employee_mi where code = approve), " +
+            "       review_time, " +
+            "       review_notes, " +
+            "       effective_time, " +
+            "       state " +
+            "from emr_limit_unlock " +
+            "${ew.customSqlSegment}")
+    IPage<EmrLimitUnlock> selectUnlock(IPage<EmrLimitUnlock> page,
+                                       @Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
+
+    @Select("select id, " +
+            "       pat_no, " +
+            "       times, " +
+            "       unlock_json, " +
+            "       applicant," +
+            "applicantName =    (select rtrim(name) from a_employee_mi where code = applicant), " +
+            "       application_time, " +
+            "       request_remarks, " +
+            "       approve," +
+            "approveName   =    (select rtrim(name) from a_employee_mi where code = approve), " +
+            "       review_time, " +
+            "       review_notes, " +
+            "       effective_time, " +
+            "       state " +
+            "from emr_limit_unlock  where id = #{id} ")
+    EmrLimitUnlock selectUnlockById(int id);
+
+
+    @Update("update emr_limit_unlock " +
+            "set state       = #{param.state}, " +
+            "    approve     = #{param.approve}, " +
+            "    review_time = getdate(), " +
+            "    review_notes= #{param.reviewNotes} " +
+            "where id = #{param.id} ")
+    void updateUnlockByIdNew(@Param("param") EmrLimitUnlock param);
+
+    @Select("select id,  " +
+            "       pat_no,  " +
+            "       times,  " +
+            "       unlock_json,  " +
+            "       applicant,  " +
+            "       application_time,  " +
+            "       request_remarks,  " +
+            "       approve,  " +
+            "       review_time,  " +
+            "       review_notes,  " +
+            "       effective_time,  " +
+            "       state  " +
+            "from emr_limit_unlock  " +
+            "where pat_no = #{patNo}  " +
+            "  and times = #{times}  " +
+            "  and applicant = #{applicant}" +
+            "  and state = 1  " +
+            "  and effective_time > getdate()")
+    EmrLimitUnlock selectMyUnlockReqByPatNo(String patNo,
+                                            Integer times,
+                                            String applicant);
+
+
+}

+ 213 - 0
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/emr/EmrControlRuleSever.java

@@ -0,0 +1,213 @@
+package thyyxxk.webserver.service.zhuyuanyisheng.emr;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.dao.his.zhuyuanyisheng.emr.EmrControlDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrLimitUnlock;
+import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.*;
+import thyyxxk.webserver.utils.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+
+/**
+ * @author Administrator
+ */
+@Service
+@Slf4j
+public class EmrControlRuleSever {
+
+    private final EmrControlDao dao;
+
+    public EmrControlRuleSever(EmrControlDao dao) {
+        this.dao = dao;
+    }
+
+
+    public ResultVo<List<Map<String, Object>>> getAvailableObjects() {
+        return ResultVoUtil.success(dao.getAvailableObjects());
+    }
+
+    public List<EmrRule> getRuleList() {
+        List<EmrRule> list = dao.selectRules();
+        if (ListUtil.isBlank(list)) {
+            return new ArrayList<>();
+        }
+        list.forEach(item -> {
+            item.setMedicalRecordCode(dao.selectEmrCodeByRuleId(item.getId()));
+        });
+        return list;
+    }
+
+    public ResultVo<String> switchQualityControl(String id, Integer offOn) {
+        int num = dao.switchQualityControl(id, offOn);
+        if (num > 0) {
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
+        }
+        return ResultVoUtil.success();
+    }
+
+    public ResultVo<String> deleteRuleById(String id) {
+        dao.deleteRuleById(id);
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
+    }
+
+    /**
+     * 修改入院质控时间
+     *
+     * @param date 时间
+     * @return 提示
+     */
+    public ResultVo<String> modifyTheAdmissionQualityControlTime(String date) {
+        dao.setTheTime(date);
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
+    }
+
+    public ResultVo<String> getAdmissDate() {
+        return ResultVoUtil.success(dao.getAdmissDate());
+    }
+
+
+    /**
+     * 创建病历的限制
+     *
+     * @param code        病历编码
+     * @param patNo       住院号
+     * @param times       住院次数
+     * @param doctorLevel 医生等级
+     * @param id          病历id
+     * @return 返回提示
+     */
+    public ResultVo<EmrRuleVerify> createRestrictions(String code, String patNo, Integer times, Integer doctorLevel, String id) {
+        log.info("病历编码:{},住院号:{},住院次数:{}", code, patNo, times);
+        EmrRuleVerify ruleVerify = new EmrRuleVerify();
+        // 获取质控的list
+        List<EmrRule> ruleList = dao.selectRuleByEmrCode(code);
+        // 如果质控的list为空就可以创建
+        if (ListUtil.isBlank(ruleList)) {
+            ruleVerify.setFlag(false);
+            return ResultVoUtil.success(ruleVerify);
+        }
+        for (EmrRule item : ruleList) {
+            String sql = item.getSql().replace("${PATNO}", "'" + patNo + "'")
+                    .replace("${TIMES}", "'" + times + "'");
+            Map<String, Object> executeSql = dao.executeSql(sql);
+            if (executeSql == null) {
+                continue;
+            }
+            boolean whetherToTimeOut = false;
+            if (doctorLevel == 1) {
+                whetherToTimeOut = DateUtil.moreThanHours((Date) executeSql.get("date"), item.getPrescription());
+                ruleVerify.setFlag(whetherToTimeOut);
+            }
+            if (doctorLevel > 1) {
+                whetherToTimeOut = DateUtil.moreThanHours((Date) executeSql.get("date"), item.getSuperiorDoctorTime());
+            }
+            ruleVerify.setFlag(whetherToTimeOut);
+            ruleVerify.setMessage(item.getPromptStatement());
+            break;
+        }
+
+        log.info("ruleList:{}", JSON.toJSONString(ruleList));
+        return ResultVoUtil.success(ruleVerify);
+    }
+
+
+    @Transactional(rollbackFor = Exception.class)
+    public ResultVo<String> requestToUnlockMedicalRecords(EmrLimitUnlock param) {
+        param.setApplicant(TokenUtil.getInstance().getTokenUserId());
+        param.setApplicationTime(new Date());
+        log.info("数据:{}", JSON.toJSONString(param));
+
+        // 把原来地申请取消
+        int count = dao.updateUnlockOld(param);
+        String str = "申请成功,等待医务部审核。";
+        if (count > 0) {
+            str = "原申请已顶替,申请成功,等待医务部审核。";
+        }
+        int insert = dao.applicationUnlock(param);
+        if (insert == 0) {
+            throw new BizException(ExceptionEnum.ERROR_MESSAGE, "申请错误。");
+        }
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, str);
+    }
+
+
+    public ResultVo<IPage<EmrLimitUnlock>> getApplicationData(SelectUnlockParam param) {
+        IPage<EmrLimitUnlock> iPage = new Page<>(param.getCurrentPage(), param.getPageSize(), param.getTotal() == 0);
+        QueryWrapper<EmrLimitUnlock> qw = getEmrLimitUnlockQueryWrapper(param);
+        iPage.setTotal(param.getTotal());
+        return ResultVoUtil.success(dao.selectUnlock(iPage, qw));
+    }
+
+    @NotNull
+    private static QueryWrapper<EmrLimitUnlock> getEmrLimitUnlockQueryWrapper(SelectUnlockParam param) {
+        QueryWrapper<EmrLimitUnlock> qw = new QueryWrapper<>();
+        if (ListUtil.notBlank(param.getDateRange())) {
+            qw.ge("application_time", param.getDateRange().get(0));
+            qw.lt("application_time", param.getDateRange().get(1));
+        }
+        if (param.getFlag() > -1) {
+            qw.eq("state", param.getFlag());
+        }
+        return qw;
+    }
+
+    public void exportExcelUnlock(HttpServletResponse response, SelectUnlockParam param) {
+        IPage<EmrLimitUnlock> iPage = new Page<>(param.getCurrentPage(), -1, false);
+        QueryWrapper<EmrLimitUnlock> qw = getEmrLimitUnlockQueryWrapper(param);
+        iPage = dao.selectUnlock(iPage, qw);
+        if (ListUtil.isBlank(iPage.getRecords())) {
+            return;
+        }
+
+        String[] title = {"住院号", "住院次数", "申请人", "申请时间", "申请权限", "申请编辑时间", "申请备注", "状态", "审核人", "审核时间", "审核备注"};
+        String[][] content = new String[iPage.getRecords().size()][];
+        for (int i = 0; i < iPage.getRecords().size(); i++) {
+            content[i] = new String[title.length];
+            EmrLimitUnlock index = iPage.getRecords().get(i);
+            content[i][0] = index.getPatNo();
+            content[i][1] = String.valueOf(index.getTimes());
+            content[i][2] = index.getApplicantName();
+            content[i][3] = DateUtil.formatDatetime(index.getApplicationTime());
+            content[i][4] = index.getUnlockJson();
+            content[i][5] = DateUtil.formatDatetime(index.getEffectiveTime());
+            content[i][6] = index.getRequestRemarks();
+            content[i][7] = index.getStateName();
+            content[i][8] = index.getApproveName();
+            content[i][9] = DateUtil.formatDatetime(index.getReviewTime());
+            content[i][10] = index.getReviewNotes();
+        }
+        ExcelUtil.exportExcel(response, title, content);
+        log.info("数据:{}", JSON.toJSONString(iPage));
+    }
+
+    public ResultVo<String> reviewMedicalRecordsToUnlock(EmrLimitUnlock param) {
+        EmrLimitUnlock emrLimitUnlock = dao.selectUnlockById(param.getId());
+        if (emrLimitUnlock.getState().equals(3)) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "该数据已经被申请人删除了,无法审核。");
+        }
+        if (emrLimitUnlock.getState().equals(param.getState())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请勿重复操作。");
+        }
+        param.setApprove(TokenUtil.getInstance().getTokenUserId());
+        dao.updateUnlockByIdNew(param);
+        log.info("电子病历质控审核:{}", JSON.toJSONString(param));
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
+    }
+
+    public ResultVo<EmrLimitUnlock> getMyUnlockByPatNo(String patNo, Integer times) {
+        return ResultVoUtil.success(dao.selectMyUnlockReqByPatNo(patNo, times, TokenUtil.getInstance().getTokenUserId()));
+    }
+}