|
@@ -5,17 +5,25 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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.exception.BizException;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.constants.Capacity;
|
|
|
import thyyxxk.webserver.dao.his.zhuyuanyisheng.EmrControlDao;
|
|
|
import thyyxxk.webserver.entity.ResultVo;
|
|
|
+import thyyxxk.webserver.entity.adverseevent.ReportIndex;
|
|
|
+import thyyxxk.webserver.entity.zhuyuanyisheng.emr.EmrLimitUnlock;
|
|
|
import thyyxxk.webserver.entity.zhuyuanyisheng.emrcontrolrule.*;
|
|
|
import thyyxxk.webserver.service.PublicServer;
|
|
|
import thyyxxk.webserver.service.wxapi.SendWxInfoService;
|
|
|
import thyyxxk.webserver.utils.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
@@ -251,39 +259,25 @@ public class EmrControlRuleSever {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 创建限制
|
|
|
+ * 创建病历的限制
|
|
|
*
|
|
|
- * @param code 病历编码
|
|
|
- * @param patNo 住院号
|
|
|
- * @param times 住院次数
|
|
|
- * @return 返回 boolean
|
|
|
+ * @param code 病历编码
|
|
|
+ * @param patNo 住院号
|
|
|
+ * @param times 住院次数
|
|
|
+ * @param doctorLevel 医生等级
|
|
|
+ * @param id 病历id
|
|
|
+ * @return 返回提示
|
|
|
*/
|
|
|
- @DS("his")
|
|
|
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);
|
|
|
}
|
|
|
-
|
|
|
- String unlockSql;
|
|
|
- if (StringUtil.notBlank(id)) {
|
|
|
- unlockSql = "emr_id = '" + id + "'";
|
|
|
- } else {
|
|
|
- unlockSql = "code = '" + code + "'";
|
|
|
- }
|
|
|
-
|
|
|
- EmrRuleUnlock emrRuleUnlock = dao.selectRemoveRestrictions(patNo, times, unlockSql, TokenUtil.getTokenUserId());
|
|
|
-
|
|
|
- if (emrRuleUnlock != null) {
|
|
|
- ruleVerify.setFlag(false);
|
|
|
- ruleVerify.setMessage(DateUtil.formatDatetime(emrRuleUnlock.getDate(), DateUtil.DATE) + "后,无法编辑。");
|
|
|
- return ResultVoUtil.success(ruleVerify);
|
|
|
- }
|
|
|
-
|
|
|
for (EmrRule item : ruleList) {
|
|
|
String sql = item.getSql().replace("#{PATNO}", "'" + patNo + "'")
|
|
|
.replace("#{TIMES}", "'" + times + "'");
|
|
@@ -349,4 +343,91 @@ public class EmrControlRuleSever {
|
|
|
return ResultVoUtil.success();
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public ResultVo<String> requestToUnlockMedicalRecords(EmrLimitUnlock param) {
|
|
|
+ param.setApplicant(TokenUtil.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);
|
|
|
+ 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.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.getTokenUserId()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|