Browse Source

病历批量测试接口

gaodm 4 years ago
parent
commit
d10bc62355

+ 2 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -156,6 +156,8 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/sys/file/deleteRemoteFile").permitAll()
                 .antMatchers("/sys/mrqc/caseWritingPrompt").permitAll()
                 .antMatchers("/demo/testcaseInfo/testcaseProcess").permitAll()
+                .antMatchers("/demo/mrtestInfo/importExcel").permitAll()
+                .antMatchers("/demo/mrtestInfo/mrTestProcess").permitAll()
                 .antMatchers("/**").authenticated();
         //                .antMatchers("/**").permitAll();
     }

+ 2 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -198,6 +198,8 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/sys/file/deleteRemoteFile", request)
                 || matchers("/sys/mrqc/caseWritingPrompt", request)
                 || matchers("/demo/testcaseInfo/testcaseProcess", request)
+                || matchers("/demo/mrtestInfo/importExcel", request)
+                || matchers("/demo/mrtestInfo/mrTestProcess", request)
                 || matchers("/", request)) {
             return true;
         }

+ 305 - 0
src/main/java/com/diagbot/entity/MrtestInfo.java

@@ -0,0 +1,305 @@
+package com.diagbot.entity;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 病历测试表
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-10-26
+ */
+@TableName("demo_mrtest_info")
+public class MrtestInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 医院id
+     */
+    @Excel(name = "医院id", isImportField = "true")
+    private Long hospitalId;
+
+    /**
+     * 接口类型 1:开单提醒,2:推理接口
+     */
+    private Integer type;
+
+    /**
+     * 病历号
+     */
+    @Excel(name = "病历号", isImportField = "true")
+    private String mrCode;
+
+    /**
+     * 字段来源
+     */
+    @Excel(name = "字段来源", isImportField = "true")
+    private String textSource;
+
+    /**
+     * 原始文本
+     */
+    @Excel(name = "原始文本", isImportField = "true")
+    private String text;
+
+    /**
+     * 原始词
+     */
+    @Excel(name = "原始词", isImportField = "true")
+    private String word;
+
+    /**
+     * 替换后文本
+     */
+    @Excel(name = "替换后文本", isImportField = "true")
+    private String replaceText;
+
+    /**
+     * 替换词
+     */
+    @Excel(name = "替换词", isImportField = "true")
+    private String replaceWord;
+
+    /**
+     * 开单项类型
+     */
+    @Excel(name = "开单项类型", isImportField = "true")
+    private String billType;
+
+    /**
+     * 开单项
+     */
+    @Excel(name = "开单项", isImportField = "true")
+    private String billName;
+
+    /**
+     * 结果
+     */
+    private String result;
+
+    /**
+     * 是否通过 0:未通过,1:未通过
+     */
+    private Integer pass;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+
+    public Long getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Long hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getMrCode() {
+        return mrCode;
+    }
+
+    public void setMrCode(String mrCode) {
+        this.mrCode = mrCode;
+    }
+
+    public String getTextSource() {
+        return textSource;
+    }
+
+    public void setTextSource(String textSource) {
+        this.textSource = textSource;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+
+    public String getWord() {
+        return word;
+    }
+
+    public void setWord(String word) {
+        this.word = word;
+    }
+
+    public String getReplaceText() {
+        return replaceText;
+    }
+
+    public void setReplaceText(String replaceText) {
+        this.replaceText = replaceText;
+    }
+
+    public String getReplaceWord() {
+        return replaceWord;
+    }
+
+    public void setReplaceWord(String replaceWord) {
+        this.replaceWord = replaceWord;
+    }
+
+    public String getBillType() {
+        return billType;
+    }
+
+    public void setBillType(String billType) {
+        this.billType = billType;
+    }
+
+    public String getBillName() {
+        return billName;
+    }
+
+    public void setBillName(String billName) {
+        this.billName = billName;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public Integer getPass() {
+        return pass;
+    }
+
+    public void setPass(Integer pass) {
+        this.pass = pass;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "MrtestInfo{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", hospitalId=" + hospitalId +
+                ", type=" + type +
+                ", mrCode=" + mrCode +
+                ", textSource=" + textSource +
+                ", text=" + text +
+                ", word=" + word +
+                ", replaceText=" + replaceText +
+                ", replaceWord=" + replaceWord +
+                ", billType=" + billType +
+                ", billName=" + billName +
+                ", result=" + result +
+                ", pass=" + pass +
+                ", remark=" + remark +
+                "}";
+    }
+}

+ 132 - 0
src/main/java/com/diagbot/facade/MrtestInfoFacade.java

@@ -0,0 +1,132 @@
+package com.diagbot.facade;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.diagbot.biz.push.entity.Item;
+import com.diagbot.biz.push.entity.Pacs;
+import com.diagbot.client.CdssCoreClient;
+import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.MrtestInfo;
+import com.diagbot.enums.IsDeleteEnum;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.MrtestInfoServiceImpl;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ExcelUtils;
+import com.diagbot.util.GsonUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.IndicationPushVO;
+import com.diagbot.vo.MrtestInfoVO;
+import com.diagbot.vo.SearchData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/10/26 12:11
+ */
+@Component
+public class MrtestInfoFacade extends MrtestInfoServiceImpl {
+    @Autowired
+    @Qualifier("mrtestInfoServiceImpl")
+    private MrtestInfoServiceImpl mrtestInfoService;
+    @Autowired
+    private CdssCoreClient cdssCoreClient;
+    @Autowired
+    private AssembleFacade assembleFacade;
+
+    public void importExcel(MultipartFile file) {
+        List<MrtestInfo> mrtestInfoList = ExcelUtils.importExcel(file, 0, 1, MrtestInfo.class);
+        if (ListUtil.isNotEmpty(mrtestInfoList)) {
+            mrtestInfoService.saveBatch(mrtestInfoList);
+        } else {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
+        }
+    }
+
+    public Boolean mrTestProcess(MrtestInfoVO mrtestInfoVO) {
+        List<MrtestInfo> mrtestInfoList
+                = mrtestInfoService.list(
+                new QueryWrapper<MrtestInfo>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq((null != mrtestInfoVO && null != mrtestInfoVO.getHospitalId()),
+                                "hospital_id", mrtestInfoVO.getHospitalId())
+        );
+
+        if (ListUtil.isEmpty(mrtestInfoList)) {
+            throw new CommonException(CommonErrorCode.NOT_EXISTS);
+        } else {
+            Date now = DateUtil.now();
+            for (MrtestInfo mrtestInfo : mrtestInfoList) {
+                //只处理目前存在的类型
+                if (mrtestInfo.getType().equals(1)) {
+                    if (mrtestInfo.getTextSource().equals("现病史")) {
+                        if (StringUtil.isNotBlank(mrtestInfo.getReplaceText())) {
+                            if (StringUtil.isNotBlank(mrtestInfo.getBillName())) {
+                                IndicationPushVO indicationPushVO = new IndicationPushVO();
+                                indicationPushVO.setHospitalId(mrtestInfo.getHospitalId());
+                                indicationPushVO.setSex(1);
+                                indicationPushVO.setAge("20");
+                                indicationPushVO.setRuleType("2");
+                                if ("医保手术和操作名称".equals(mrtestInfo.getBillType())) {
+                                    List<Item> operationOrder = new ArrayList<>();
+                                    Item item = new Item();
+                                    item.setName(mrtestInfo.getBillName());
+                                    operationOrder.add(item);
+                                    indicationPushVO.setOperationOrder(operationOrder);
+                                } else if ("辅助检查名称".equals(mrtestInfo.getBillType())
+                                        || "辅助检查子项目名称".equals(mrtestInfo.getBillType())) {
+                                    List<Pacs> pacsOrder = new ArrayList<>();
+                                    Pacs pacs = new Pacs();
+                                    pacs.setName(mrtestInfo.getBillName());
+                                    pacsOrder.add(pacs);
+                                    indicationPushVO.setPacsOrder(pacsOrder);
+                                } else {
+                                    mrtestInfo.setGmtModified(now);
+                                    mrtestInfo.setResult("");
+                                    mrtestInfo.setPass(0);
+                                    mrtestInfo.setRemark("处理对象外数据");
+                                    continue;
+                                }
+
+                                SearchData searchData = new SearchData();
+                                BeanUtil.copyProperties(indicationPushVO, searchData);
+                                //入参映射
+                                searchData = assembleFacade.assembleData(searchData);
+                                BeanUtil.copyProperties(searchData, indicationPushVO);
+                                RespDTO<IndicationDTO> resp = cdssCoreClient.indication(indicationPushVO);
+                                if (null != resp && null != resp.data) {
+                                    mrtestInfo.setGmtModified(now);
+                                    mrtestInfo.setResult(GsonUtil.toJson(resp.data.getBillMsgList()));
+                                    mrtestInfo.setPass(0);
+                                    mrtestInfo.setRemark("提醒接口有返回结果");
+                                } else {
+                                    mrtestInfo.setGmtModified(now);
+                                    mrtestInfo.setResult("");
+                                    mrtestInfo.setPass(0);
+                                    mrtestInfo.setRemark("提醒接口无返回结果");
+                                }
+                            }
+                        }
+                    }
+                } else {
+                    mrtestInfo.setGmtModified(now);
+                    mrtestInfo.setResult("");
+                    mrtestInfo.setPass(0);
+                    mrtestInfo.setRemark("处理对象外数据");
+                }
+            }
+            mrtestInfoService.updateBatchById(mrtestInfoList);
+        }
+        return true;
+    }
+}

+ 16 - 0
src/main/java/com/diagbot/mapper/MrtestInfoMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.MrtestInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 病历测试表 Mapper 接口
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-10-26
+ */
+public interface MrtestInfoMapper extends BaseMapper<MrtestInfo> {
+
+}

+ 16 - 0
src/main/java/com/diagbot/service/MrtestInfoService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.MrtestInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 病历测试表 服务类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-10-26
+ */
+public interface MrtestInfoService extends IService<MrtestInfo> {
+
+}

+ 20 - 0
src/main/java/com/diagbot/service/impl/MrtestInfoServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.MrtestInfo;
+import com.diagbot.mapper.MrtestInfoMapper;
+import com.diagbot.service.MrtestInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 病历测试表 服务实现类
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-10-26
+ */
+@Service
+public class MrtestInfoServiceImpl extends ServiceImpl<MrtestInfoMapper, MrtestInfo> implements MrtestInfoService {
+
+}

+ 15 - 0
src/main/java/com/diagbot/vo/MrtestInfoVO.java

@@ -0,0 +1,15 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/10/26 12:26
+ */
+@Getter
+@Setter
+public class MrtestInfoVO {
+    private Long hospitalId;
+}

+ 57 - 0
src/main/java/com/diagbot/web/MrtestInfoController.java

@@ -0,0 +1,57 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.MrtestInfoFacade;
+import com.diagbot.vo.MrtestInfoVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ * 病历测试表 前端控制器
+ * </p>
+ *
+ * @author gaodm
+ * @since 2020-10-26
+ */
+@RestController
+@RequestMapping("/demo/mrtestInfo")
+@Api(value = "病历测试API", tags = { "病历测试API" })
+@SuppressWarnings("unchecked")
+public class MrtestInfoController {
+    @Autowired
+    private MrtestInfoFacade mrtestInfoFacade;
+
+    /**
+     * 数据导入
+     *
+     * @param file
+     * @return
+     */
+    @ApiOperation(value = "数据导入[by:gaodm]",
+            notes = "")
+    @PostMapping("/importExcel")
+    @SysLogger("importExcel")
+    @Transactional
+    public void importExcel(@RequestParam("file") MultipartFile file) {
+        mrtestInfoFacade.importExcel(file);
+    }
+
+    @ApiOperation(value = "执行病历测试[by:gaodm]",
+            notes = "hospitalId:医院id(可不填);")
+    @PostMapping("/mrTestProcess")
+    @SysLogger("mrTestProcess")
+    @Transactional
+    public RespDTO<Boolean> mrTestProcess(@RequestBody MrtestInfoVO mrtestInfoVO) {
+        return RespDTO.onSuc(mrtestInfoFacade.mrTestProcess(mrtestInfoVO));
+    }
+}

+ 28 - 0
src/main/resources/mapper/MrtestInfoMapper.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.MrtestInfoMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.MrtestInfo">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="type" property="type" />
+        <result column="mr_code" property="mrCode" />
+        <result column="text_source" property="textSource" />
+        <result column="text" property="text" />
+        <result column="word" property="word" />
+        <result column="replace_text" property="replaceText" />
+        <result column="replace_word" property="replaceWord" />
+        <result column="bill_type" property="billType" />
+        <result column="bill_name" property="billName" />
+        <result column="result" property="result" />
+        <result column="pass" property="pass" />
+        <result column="remark" property="remark" />
+    </resultMap>
+
+</mapper>

+ 1 - 1
src/test/java/com/diagbot/CodeGeneration.java

@@ -56,7 +56,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
         strategy.setTablePrefix(new String[] { "demo_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "demo_testcase_info"}); // 需要生成的表
+        strategy.setInclude(new String[] { "demo_mrtest_info"}); // 需要生成的表
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);