瀏覽代碼

检验检查迁移

lighter 7 月之前
父節點
當前提交
d1ad39ad61

+ 2 - 2
thyy-scheduled/src/main/java/org/thyy/scheduled/service/DpccService.java

@@ -131,7 +131,7 @@ public class DpccService {
                 .startDate(inquiry.getReqStartTime()).endDate(inquiry.getReqEndTime()).build();
         JSONObject json = JSONObject.from(request);
         ResultVo<List<JyIndexResponse>> resultVo =
-                restTemplate.postForObject(dpcc.getJyApi() + "/queryExamIndex", json, ResultVo.class);
+                restTemplate.postForObject(dpcc.getJyApi() + "/queryJyIndex", json, ResultVo.class);
         if (null == resultVo) {
             return new ArrayList<>();
         }
@@ -143,7 +143,7 @@ public class DpccService {
         json.put("reportId", reportId);
         json.put("responseMode", "Json");
         ResultVo<JyDetailResponse> resultVo =
-                restTemplate.postForObject(dpcc.getJyApi() + "/queryExamDetail", json, ResultVo.class);
+                restTemplate.postForObject(dpcc.getJyApi() + "/queryJyDetail", json, ResultVo.class);
         if (null == resultVo) {
             throw new BizException(ExceptionEnum.API_ERROR);
         }

+ 3 - 2
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/ThyyThirdpartApiApplication.java

@@ -1,14 +1,15 @@
 package org.thyy.thirdpartapi;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 @EnableScheduling
-@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
+@SpringBootApplication
 @ComponentScan("org.thyy.*")
+@MapperScan("org.thyy.thirdpartapi.inspection.dao")
 public class ThyyThirdpartApiApplication {
     public static void main(String[] args) {
         SpringApplication.run(ThyyThirdpartApiApplication.class, args);

+ 40 - 9
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/InspectionController.java

@@ -1,14 +1,18 @@
 package org.thyy.thirdpartapi.inspection;
 
-import com.alibaba.fastjson2.JSONObject;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.stereotype.Service;
+import cn.hutool.core.util.StrUtil;
 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.RestController;
+import org.thyy.thirdpartapi.inspection.request.ReportDetailInquiry;
+import org.thyy.thirdpartapi.inspection.request.ReportIndexInquiry;
+import org.thyy.thirdpartapi.inspection.response.bl.BlIndexResponse;
+import org.thyy.thirdpartapi.inspection.response.jc.JcIndexResponse;
 import org.thyy.thirdpartapi.inspection.response.jy.JyDetailResponse;
 import org.thyy.thirdpartapi.inspection.response.jy.JyIndexResponse;
+import org.thyy.thirdpartapi.inspection.response.xd.XdIndexResponse;
+import org.thyy.utils.exception.ExceptionEnum;
 import org.thyy.utils.result.R;
 import org.thyy.utils.result.ResultVo;
 
@@ -23,15 +27,42 @@ public class InspectionController {
         this.service = service;
     }
 
-    @PostMapping("/queryExamIndex")
-    public ResultVo<List<JyIndexResponse>> queryExamIndex(@RequestBody JSONObject request) {
-        List<JyIndexResponse> list = service.queryExamIndex(request);
+    @PostMapping("/queryJyIndex")
+    public ResultVo<List<JyIndexResponse>> queryJyIndex(@RequestBody ReportIndexInquiry request) {
+        List<JyIndexResponse> list = service.queryJyIndex(request);
         return R.ok(list);
     }
 
-    @PostMapping("/queryExamDetail")
-    public ResultVo<JyDetailResponse> queryExamDetail(@RequestBody JSONObject request) {
-        JyDetailResponse response = service.queryExamDetail(request);
+    @PostMapping("/queryJyDetail")
+    public ResultVo<JyDetailResponse> queryJyDetail(@RequestBody ReportIndexInquiry request) {
+        JyDetailResponse response = service.queryJyDetail(request);
         return R.ok(response);
     }
+
+    @PostMapping("/queryJcIndex")
+    public ResultVo<List<JcIndexResponse>> checkTestIndex(@RequestBody ReportIndexInquiry request) {
+        return R.ok(service.queryJcIndex(request));
+    }
+
+    @PostMapping("/queryJcDetail")
+    public ResultVo<JcIndexResponse> checkTestDetail(@RequestBody ReportDetailInquiry request) {
+        if (StrUtil.isBlank(request.getReportId())) {
+            return R.fail(ExceptionEnum.INVALID_PARAM, "报告ID不能为空!");
+        }
+        return R.ok(service.queryJcDetail(request));
+    }
+
+    @PostMapping("/queryBlIndex")
+    public ResultVo<List<BlIndexResponse>> checkPathologyIndex(@RequestBody ReportIndexInquiry request) {
+        request.setReqStartTime(request.getReqStartTime().replaceAll("-", ""));
+        request.setReqEndTime(request.getReqEndTime().replaceAll("-", ""));
+        return R.ok(service.queryBlIndex(request));
+    }
+
+    @PostMapping("/queryXdIndex")
+    public ResultVo<List<XdIndexResponse>> checkElectroIndex(@RequestBody ReportIndexInquiry request) {
+        request.setReqStartTime(request.getReqStartTime().replaceAll("-", ""));
+        request.setReqEndTime(request.getReqEndTime().replaceAll("-", ""));
+        return R.ok(service.queryXdIndex(request));
+    }
 }

+ 15 - 3
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/InspectionInterface.java

@@ -1,8 +1,12 @@
 package org.thyy.thirdpartapi.inspection;
 
-import com.alibaba.fastjson2.JSONObject;
+import org.thyy.thirdpartapi.inspection.request.ReportDetailInquiry;
+import org.thyy.thirdpartapi.inspection.request.ReportIndexInquiry;
+import org.thyy.thirdpartapi.inspection.response.bl.BlIndexResponse;
+import org.thyy.thirdpartapi.inspection.response.jc.JcIndexResponse;
 import org.thyy.thirdpartapi.inspection.response.jy.JyDetailResponse;
 import org.thyy.thirdpartapi.inspection.response.jy.JyIndexResponse;
+import org.thyy.thirdpartapi.inspection.response.xd.XdIndexResponse;
 
 import java.util.List;
 
@@ -11,7 +15,15 @@ import java.util.List;
  */
 public interface InspectionInterface {
 
-    List<JyIndexResponse> queryExamIndex(JSONObject request);
+    List<JyIndexResponse> queryJyIndex(ReportIndexInquiry request);
 
-    JyDetailResponse queryExamDetail(JSONObject request);
+    JyDetailResponse queryJyDetail(ReportIndexInquiry request);
+
+    List<JcIndexResponse> queryJcIndex(ReportIndexInquiry request);
+
+    JcIndexResponse queryJcDetail(ReportDetailInquiry request);
+
+    List<BlIndexResponse> queryBlIndex(ReportIndexInquiry request);
+
+    List<XdIndexResponse> queryXdIndex(ReportIndexInquiry request);
 }

+ 2 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/config/InspectionApi.java

@@ -11,5 +11,7 @@ import java.util.Map;
 @ConfigurationProperties(prefix = "thyy.inspection")
 public class InspectionApi {
     private String jy;
+    private String bl;
+    private String xd;
     private String service;
 }

+ 20 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/dao/InspectionDao.java

@@ -0,0 +1,20 @@
+package org.thyy.thirdpartapi.inspection.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.thyy.thirdpartapi.inspection.request.ReportIndexInquiry;
+import org.thyy.thirdpartapi.inspection.response.jc.JcIndexResponse;
+
+import java.util.List;
+
+@Mapper
+public interface InspectionDao {
+    @Select("select patient_uid,patient_name,examin_eparts,check_time from t_check_data " +
+            "where pat_no=#{patNo} and check_time>=#{reqStartTime} and check_time<=#{reqEndTime} ")
+    List<JcIndexResponse> selectJctIndex(ReportIndexInquiry inquiry);
+
+    @Select("select *, " +
+            "doctorName=(select top 1 rtrim(d.name) from a_employee_mi d where d.code_rs=doctor_code) " +
+            "from t_check_data where patient_uid=#{id}")
+    JcIndexResponse selectJcReport(String id);
+}

+ 96 - 26
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/inspectionImpl/ThyyInspectionImpl.java

@@ -2,6 +2,7 @@ package org.thyy.thirdpartapi.inspection.inspectionImpl;
 
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -10,7 +11,13 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 import org.thyy.thirdpartapi.inspection.InspectionInterface;
 import org.thyy.thirdpartapi.inspection.config.InspectionApi;
+import org.thyy.thirdpartapi.inspection.dao.InspectionDao;
+import org.thyy.thirdpartapi.inspection.request.ReportDetailInquiry;
+import org.thyy.thirdpartapi.inspection.request.ReportIndexInquiry;
+import org.thyy.thirdpartapi.inspection.response.bl.BlIndexResponse;
+import org.thyy.thirdpartapi.inspection.response.jc.JcIndexResponse;
 import org.thyy.thirdpartapi.inspection.response.jy.*;
+import org.thyy.thirdpartapi.inspection.response.xd.XdIndexResponse;
 import org.thyy.utils.exception.BizException;
 import org.thyy.utils.exception.ExceptionEnum;
 
@@ -21,29 +28,40 @@ import java.util.List;
 @Service
 @ConditionalOnProperty(prefix = "thyy.inspection", name = "service", havingValue = "shanghaihaotai", matchIfMissing = true)
 public class ThyyInspectionImpl implements InspectionInterface {
-    private String api;
-    private final RestTemplate restTemplate;
-    private final InspectionApi inspectionApiConfig;
+    private final RestTemplate template;
+    private final InspectionDao dao;
+    private final InspectionApi apiConfig;
 
     @Autowired
-    public ThyyInspectionImpl(RestTemplate restTemplate, InspectionApi inspectionApiConfig) {
-        this.restTemplate = restTemplate;
-        this.inspectionApiConfig = inspectionApiConfig;
-        init();
+    public ThyyInspectionImpl(RestTemplate template, InspectionDao dao, InspectionApi apiConfig) {
+        this.template = template;
+        this.dao = dao;
+        this.apiConfig = apiConfig;
     }
 
-    public void init() {
-        this.api = inspectionApiConfig.getJy();
-        log.info("检验检查模块初始化完成");
+    @Override
+    public List<JyIndexResponse> queryJyIndex(ReportIndexInquiry request) {
+        if (StrUtil.isBlank(apiConfig.getJy())) {
+            return new ArrayList<>();
+        }
+        JSONObject response = template.postForObject(apiConfig.getJy() + "/self", request, JSONObject.class);
+        JSONObject data = getJyJsonData(response);
+        String items = JSON.toJSONString(data.getJSONArray("items"));
+        return JSON.parseArray(items, JyIndexResponse.class);
     }
 
     @Override
-    public List<JyIndexResponse> queryExamIndex(JSONObject request) {
-        if (StrUtil.isBlank(api)) {
-            return new ArrayList<>();
+    public JyDetailResponse queryJyDetail(ReportIndexInquiry request) {
+        if (StrUtil.isBlank(apiConfig.getJy())) {
+            return null;
         }
+        JSONObject response = new RestTemplate().postForObject(
+                apiConfig.getJy() + "/detail", request, JSONObject.class);
+        JSONObject data = getJyJsonData(response);
+        return JSON.parseObject(JSON.toJSONString(data), JyDetailResponse.class);
+    }
 
-        JSONObject response = restTemplate.postForObject(api + "/self", request, JSONObject.class);
+    private JSONObject getJyJsonData(JSONObject response) {
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
         }
@@ -51,26 +69,78 @@ public class ThyyInspectionImpl implements InspectionInterface {
         if (null == code || !code) {
             throw new BizException(ExceptionEnum.API_ERROR, response.getString("message"));
         }
-        JSONObject data = response.getJSONObject("data");
-        String items = JSON.toJSONString(data.getJSONArray("items"));
-        return JSON.parseArray(items, JyIndexResponse.class);
+        return response.getJSONObject("data");
     }
 
     @Override
-    public JyDetailResponse queryExamDetail(JSONObject request) {
-        if (StrUtil.isBlank(api)) {
-            return null;
+    public List<JcIndexResponse> queryJcIndex(ReportIndexInquiry request) {
+        return dao.selectJctIndex(request);
+    }
+
+    @Override
+    public JcIndexResponse queryJcDetail(ReportDetailInquiry request) {
+        JcIndexResponse result = dao.selectJcReport(request.getReportId());
+        result.setExaminationSee(
+                result.getExaminationSee()
+                        .replaceAll("\r\n", "<br/>")
+                        .replaceAll("\n", "<br/>")
+        );
+        result.setExaminationreSult(
+                result.getExaminationreSult()
+                        .replaceAll("\r\n", "<br/>")
+                        .replaceAll("\n", "<br/>")
+        );
+        return result;
+    }
+
+    @Override
+    public List<BlIndexResponse> queryBlIndex(ReportIndexInquiry request) {
+        String url = apiConfig.getBl() +
+                "?beginTime=" + request.getReqStartTime() +
+                "&endTime=" + request.getReqEndTime() +
+                "&patientId=" + request.getSocialNo();
+
+        List<BlIndexResponse> blIndexList = new ArrayList<>();
+        JSONObject response = template.getForObject(url, JSONObject.class);
+        JSONArray rows = getIndexRows(response);
+        if (null != rows && !rows.isEmpty()) {
+            for (int i = 0; i < rows.size(); i++) {
+                JSONObject row = rows.getJSONObject(i);
+                BlIndexResponse blIndex = JSON.to(BlIndexResponse.class, row);
+                blIndexList.add(blIndex);
+            }
         }
-        JSONObject response = new RestTemplate().postForObject(
-                api + "/detail", request, JSONObject.class);
+        return blIndexList;
+    }
+
+    @Override
+    public List<XdIndexResponse> queryXdIndex(ReportIndexInquiry request) {
+        String url = apiConfig.getXd() +
+                "?id=" + request.getSocialNo() +
+                "&startTime=" + request.getReqStartTime() +
+                "&endTime=" + request.getReqEndTime();
+
+        List<XdIndexResponse> xdIndexList = new ArrayList<>();
+        JSONObject response = new RestTemplate().getForObject(url, JSONObject.class);
+        JSONArray rows = getIndexRows(response);
+        if (null != rows && !rows.isEmpty()) {
+            for (int i = 0; i < rows.size(); i++) {
+                JSONObject row = rows.getJSONObject(i);
+                XdIndexResponse xdIndex = JSON.to(XdIndexResponse.class, row);
+                xdIndexList.add(xdIndex);
+            }
+        }
+        return xdIndexList;
+    }
+
+    private JSONArray getIndexRows(JSONObject response) {
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
         }
-        Boolean code = response.getBoolean("code");
-        if (null == code || !code) {
+        int code = response.getIntValue("code");
+        if (code != 1) {
             throw new BizException(ExceptionEnum.API_ERROR, response.getString("message"));
         }
-        JSONObject data = response.getJSONObject("data");
-        return JSON.parseObject(JSON.toJSONString(data), JyDetailResponse.class);
+        return response.getJSONArray("data");
     }
 }

+ 12 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/request/ReportDetailInquiry.java

@@ -0,0 +1,12 @@
+package org.thyy.thirdpartapi.inspection.request;
+
+import lombok.Data;
+import org.thyy.thirdpartapi.inspection.config.ResponseMode;
+
+@Data
+public class ReportDetailInquiry {
+    private String reportId;
+    private String reportUrl;
+    private String patientId;
+    private ResponseMode responseMode = ResponseMode.Json;
+}

+ 1 - 1
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/request/jy/ReportIndexInquiry.java → thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/request/ReportIndexInquiry.java

@@ -1,4 +1,4 @@
-package org.thyy.thirdpartapi.inspection.request.jy;
+package org.thyy.thirdpartapi.inspection.request;
 
 import lombok.Data;
 import org.thyy.thirdpartapi.inspection.config.Category;

+ 0 - 10
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/request/jy/ReportDetailInquiry.java

@@ -1,10 +0,0 @@
-package org.thyy.thirdpartapi.inspection.request.jy;
-
-import lombok.Data;
-
-@Data
-public class ReportDetailInquiry {
-    private String reportId;
-    private String reportUrl;
-    private String patientId;
-}

+ 40 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/response/bl/BlIndexResponse.java

@@ -0,0 +1,40 @@
+package org.thyy.thirdpartapi.inspection.response.bl;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import lombok.Data;
+
+@Data
+public class BlIndexResponse {
+
+    @JSONField(name = "申请单号")
+    private String reportId;
+
+    @JSONField(name = "住院号")
+    private String inpatientNo;
+
+    @JSONField(name = "检查项目")
+    private String examItem;
+
+    @JSONField(name = "姓名")
+    private String name;
+
+    @JSONField(name = "门诊号")
+    private String patientId;
+
+    @JSONField(name = "报告日期")
+    private String applyDate;
+
+    @JSONField(name = "报告图片地址")
+    private String reportUrl;
+
+    @JSONField(name = "检查结论")
+    private String conclusion;
+
+    public String getExamPurpose() {
+        return examItem;
+    }
+
+    public String getTrscDate() {
+        return applyDate;
+    }
+}

+ 31 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/response/jc/JcIndexResponse.java

@@ -0,0 +1,31 @@
+package org.thyy.thirdpartapi.inspection.response.jc;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class JcIndexResponse {
+    private String patientUid;
+    private String patNo;
+    private Integer times;
+    private String patientName;
+    private String examinEparts;
+    private String examinationSee;
+    private String examinationreSult;
+    private String doctorCode;
+    private String doctorName;
+    private String checkDoctorCode;
+    private String checkDoctorName;
+    private String reportUrl;
+    private Date checkTime;
+    private Date reportTime;
+
+    public String getExamPurpose() {
+        return examinEparts;
+    }
+
+    public Date getTrscDate() {
+        return checkTime;
+    }
+}

+ 34 - 0
thyy-thirdpart-api/src/main/java/org/thyy/thirdpartapi/inspection/response/xd/XdIndexResponse.java

@@ -0,0 +1,34 @@
+package org.thyy.thirdpartapi.inspection.response.xd;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import lombok.Data;
+
+@Data
+public class XdIndexResponse {
+    @JSONField(name = "Name")
+    private String name;
+
+    @JSONField(name = "reqNo")
+    private String reqNo;
+
+    @JSONField(name = "AppliDate")
+    private String applyDate;
+
+    @JSONField(name = "DiagnosticMessage")
+    private String diagnostic;
+
+    @JSONField(name = "filePath")
+    private String filePath;
+
+    public String getReportUrl() {
+        return filePath;
+    }
+
+    public String getExamPurpose() {
+        return diagnostic;
+    }
+
+    public String getTrscDate() {
+        return applyDate;
+    }
+}

+ 54 - 3
thyy-thirdpart-api/src/main/resources/application.yml

@@ -1,11 +1,60 @@
-spring:
-  application:
-    name: thyy-thirdpart-api
 server:
   port: 21701
   servlet:
     context-path: /thyy/thirdpart/api
 
+spring:
+  application:
+    name: thyy-thirdpart-api
+  datasource:
+    url: "jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb"
+    username: "sa"
+    password:
+    driver-class-name: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
+    druid:
+      #type: com.alibaba.druid.pool.DruidDataSource
+      #初始化时建立物理连接的个数。初始化发生在显示调用init方法,或者第一次getConnection时
+      initial-size: 20
+      #最大连接池数量
+      max-active: 50
+      #最小连接池数量
+      min-idle: 10
+      #获取连接时最大等待时间,单位毫秒
+      max-wait: 60000
+      #使用非公平锁。
+      use-unfair-lock: true
+      #用来检测连接是否有效的sql,要求是一个查询语句。
+      validation-query: SELECT 1
+      #建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
+      test-while-idle: true
+      #申请连接时执行validationQuery检测连接是否有效,
+      test-on-borrow: true
+      #归还连接时执行validationQuery检测连接是否有效,
+      test-on-return: false
+      #Destroy线程会检测连接的间隔时间,testWhileIdle的判断依据,详细看testWhileIdle属性的说明
+      time-between-eviction-runs-millis: 60000
+      #配置一个连接在池中最小生存的时间,单位是毫秒
+      min-evictable-idle-time-millis: 300000
+      #监控统计用的filter:stat  日志用的filter:log4j    防御sql注入的filter:wall
+      filters: stat
+      #是否缓存preparedStatement,也就是PSCache,在mysql5.5以下的版本中没有PSCache功能,建议关闭掉
+      pool-prepared-statements: false
+      #要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。
+      max-pool-prepared-statement-per-connection-size: 200
+      #对于长时间不使用的连接强制关闭
+      remove-abandoned: true
+      #数据库链接超过180秒开始关闭空闲连接 秒为单位
+      remove-abandoned-timeout: 180
+      #将当前关闭动作记录到日志  此配置项会影响性能,只在排查的时候打开,系统运行时最好关闭。
+      log-abandoned: true
+  jackson:
+    time-zone: Asia/Shanghai
+    date-format: yyyy-MM-dd HH:mm:ss
+  mvc:
+    format:
+      date: yyyy-MM-dd
+      date-time: yyyy-MM-dd HH:mm:ss
+
 thyy:
   tts:
     service: xfyun
@@ -16,4 +65,6 @@ thyy:
     api-secret: OWZjZGE4NjI3MDdkYzg4ZjllY2VjNGQ0
   inspection:
     jy: http://172.16.32.178/apis/third/report/query
+    bl: http://172.16.32.160:9205/thyy/api/public/bl_report
+    xd: http://172.16.32.167:9206/thyy/api/public/ecgReport
     service: shanghaihaotai