Browse Source

添加查询病理报告的功能

lighter 1 year ago
parent
commit
08b468463f

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>12.1.1</version>
+    <version>12.1.2</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 10 - 1
src/main/java/thyyxxk/wxservice_server/controller/InspectionsController.java

@@ -8,6 +8,8 @@ import thyyxxk.wxservice_server.entity.inspections.request.QueryReportDetail;
 import thyyxxk.wxservice_server.entity.inspections.response.TestReport;
 import thyyxxk.wxservice_server.factory.examreport.model.ExamDetailResponse;
 import thyyxxk.wxservice_server.factory.examreport.model.ExamIndexResponse;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyIndex;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyRequest;
 import thyyxxk.wxservice_server.service.InspectionsService;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
@@ -42,7 +44,14 @@ public class InspectionsController {
     }
 
     @PostMapping("/checkTestDetail")
-    public ResultVo<TestReport> checkTestDetail(@RequestBody QueryReportDetail param) throws Exception {
+    public ResultVo<TestReport> checkTestDetail(@RequestBody QueryReportDetail param) {
         return ResultVoUtil.success(service.checkTestDetail(param));
     }
+
+    @PostMapping("/checkPathologyIndex")
+    public ResultVo<List<PathologyIndex>> checkPathologyIndex(@RequestBody PathologyRequest request) {
+        request.setReqStartTime(request.getReqStartTime().replaceAll("-", ""));
+        request.setReqEndTime(request.getReqEndTime().replaceAll("-", ""));
+        return ResultVoUtil.success(service.checkPathologyIndex(request));
+    }
 }

+ 7 - 4
src/main/java/thyyxxk/wxservice_server/dao/InpatientDao.java

@@ -33,8 +33,13 @@ public interface InpatientDao {
             "d.code=a.small_dept")
     InpatientInfo getInpatientInfo(@Param("inpatientNo") String inpatientNo);
 
-    @Select("select rtrim(inpatient_no) from a_patient_mi where social_no=" +
-            "(select social_no from mz_patient_mi where patient_id=#{patientId})")
+    @Select("select rtrim(inpatient_no) from a_patient_mi where mz_no=#{patientId}")
+    List<String> selectInpatientNoByPatientId(@Param("patientId") String patientId);
+
+    @Select("select rtrim(a.inpatient_no) from a_patient_mi a,mz_patient_mi b " +
+            "where upper(a.social_no)=upper(b.social_no) and b.patient_id=#{patientId} " +
+            "and a.inpatient_no not like 'S%' and a.inpatient_no not like 'JT%' " +
+            "and a.inpatient_no not like '%$%'")
     List<String> selectInpatientNoBySocialNo(@Param("patientId") String patientId);
 
     @Select("select social_no from a_patient_mi where inpatient_no=#{inpatientNo}")
@@ -44,8 +49,6 @@ public interface InpatientDao {
             "social_no=#{socialNo} order by lv_date desc ")
     String selectPatientIdBySocialNo(@Param("socialNo") String socialNo);
 
-    @Select("select rtrim(inpatient_no) from a_patient_mi where mz_no=#{patientId}")
-    List<String> selectInpatientNoByPatientId(@Param("patientId") String patientId);
 
     @Update("execute zy_receive_drug #{inpatientNo} , #{admissTimes} , 1 , '0'")
     void receiveMedicineFees(@Param("inpatientNo") String inpatientNo,

+ 3 - 9
src/main/java/thyyxxk/wxservice_server/dao/InspectionsDao.java

@@ -16,15 +16,6 @@ public interface InspectionsDao {
     @Select("select rtrim(max(tj_no)) from mz_patient_mi with(nolock) where patient_id=#{patientId}")
     String selectTjNo(@Param("patientId") String patientId);
 
-    /**
-     * 通过门诊号获取住院号
-     * */
-    @Select("select rtrim(a.inpatient_no) from a_patient_mi a,mz_patient_mi b " +
-            "where upper(a.social_no)=upper(b.social_no) and b.patient_id=#{patientId} " +
-            "and a.inpatient_no not like 'S%' and a.inpatient_no not like 'JT%' " +
-            "and a.inpatient_no not like '%$%'")
-    List<String> selectInpatientNo(@Param("patientId") String patientId);
-
     @Select("select distinct rtrim(patient_id) from mz_patient_mi with(nolock) where social_no=#{socialNo}")
     List<String> selectMzNos(@Param("socialNo") String socialNo);
 
@@ -37,6 +28,9 @@ public interface InspectionsDao {
     @Select("select count(1) from t_wechat_patient_bind where patient_id=#{patId} and openid=#{openid} and del_flag=0")
     int selectPatIdAndOpenidMatchCount(@Param("patId") String patId, @Param("openid") String openid);
 
+    @Select("select max(social_no) from t_wechat_patient_bind where patient_id=#{patNo}")
+    String getPatSocialNo(@Param("patNo") String patNo);
+
     @Select("select patient_uid,patient_name,examin_eparts,check_time from t_check_data " +
             "where pat_no=#{patientId} and check_time>=#{start} and check_time<=#{end} ")
     List<TestReport> selectTestReportIndex(CheckExamParam param);

+ 41 - 0
src/main/java/thyyxxk/wxservice_server/factory/pathology/PathologyService.java

@@ -0,0 +1,41 @@
+package thyyxxk.wxservice_server.factory.pathology;
+
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyIndex;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyRequest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Slf4j
+public class PathologyService {
+    private static final String URL = "http://172.16.32.160:9205/thyy/api/public/bl_report?beginTime={}&endTime={}&patientId={}";
+
+    public List<PathologyIndex> queryOutpatientPathologyIndex(PathologyRequest request) {
+        String url = StrUtil.format(URL, request.getReqStartTime(),
+                request.getReqEndTime(), request.getSocialNo());
+
+        List<PathologyIndex> pathologyIndexList = new ArrayList<>();
+        JSONObject response = new RestTemplate().getForObject(url, JSONObject.class);
+        log.info("查询病理报告:\n链接:{}\n结果:{}", url, response);
+        if (null != response) {
+            int code = response.getIntValue("code");
+            if (code == 1) {
+                JSONArray rows = response.getJSONArray("data");
+                if (null != rows && !rows.isEmpty()) {
+                    for (int i = 0; i < rows.size(); i++) {
+                        JSONObject row = rows.getJSONObject(i);
+                        PathologyIndex pathologyIndex = JSONObject.toJavaObject(row, PathologyIndex.class);
+                        pathologyIndexList.add(pathologyIndex);
+                    }
+                }
+            }
+        }
+        return pathologyIndexList;
+    }
+
+}

+ 43 - 0
src/main/java/thyyxxk/wxservice_server/factory/pathology/model/PathologyIndex.java

@@ -0,0 +1,43 @@
+package thyyxxk.wxservice_server.factory.pathology.model;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import thyyxxk.wxservice_server.utils.StringUtil;
+
+@Data
+public class PathologyIndex {
+
+    @JSONField(name = "申请单号")
+    private Integer 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;
+
+    private String nginxUrl;
+
+    public String getNginxUrl() {
+        if (StringUtil.isBlank(reportUrl)) {
+            return null;
+        }
+        return reportUrl.replace("http://172.16.32.192:801",
+                "https://staticweb.hnthyy.cn/pathologyReport");
+    }
+}

+ 11 - 0
src/main/java/thyyxxk/wxservice_server/factory/pathology/model/PathologyRequest.java

@@ -0,0 +1,11 @@
+package thyyxxk.wxservice_server.factory.pathology.model;
+
+import lombok.Data;
+
+@Data
+public class PathologyRequest {
+    private String socialNo;
+    private String patientId;
+    private String reqStartTime;
+    private String reqEndTime;
+}

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/service/InpatientService.java

@@ -87,7 +87,7 @@ public class InpatientService {
         return ResultVoUtil.success(map);
     }
 
-    private List<String> getInpatientNoByPatientId(String patientId) {
+    public List<String> getInpatientNoByPatientId(String patientId) {
         List<String> inpatientNos = dao.selectInpatientNoByPatientId(patientId);
         if (inpatientNos.isEmpty()) {
             inpatientNos = dao.selectInpatientNoBySocialNo(patientId);

+ 17 - 3
src/main/java/thyyxxk/wxservice_server/service/InspectionsService.java

@@ -14,6 +14,9 @@ import thyyxxk.wxservice_server.factory.examreport.ExamReportService;
 import thyyxxk.wxservice_server.factory.examreport.model.ExamDetailResponse;
 import thyyxxk.wxservice_server.factory.examreport.model.ExamIndexRequest;
 import thyyxxk.wxservice_server.factory.examreport.model.ExamIndexResponse;
+import thyyxxk.wxservice_server.factory.pathology.PathologyService;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyIndex;
+import thyyxxk.wxservice_server.factory.pathology.model.PathologyRequest;
 import thyyxxk.wxservice_server.factory.thmz.ThmzService;
 import thyyxxk.wxservice_server.utils.*;
 
@@ -28,12 +31,14 @@ public class InspectionsService {
     private final InspectionsDao dao;
     private final ElectronicHealthCardService healthCardService;
     private final ThmzService thmzService;
+    private final InpatientService inpatientService;
 
     @Autowired
-    public InspectionsService(InspectionsDao dao, ElectronicHealthCardService healthCardService, ThmzService thmzService) {
+    public InspectionsService(InspectionsDao dao, ElectronicHealthCardService healthCardService, ThmzService thmzService, InpatientService inpatientService) {
         this.dao = dao;
         this.healthCardService = healthCardService;
         this.thmzService = thmzService;
+        this.inpatientService = inpatientService;
     }
 
     public List<ExamIndexResponse> getExamIndex(CheckExamParam param) {
@@ -62,7 +67,7 @@ public class InspectionsService {
                     .patientNumType("Pis").patientNum(tjNo)
                     .startDate(param.getStart()).endDate(param.getEnd()).build());
         }
-        final List<String> inpatientNos = dao.selectInpatientNo(param.getPatientId());
+        List<String> inpatientNos = inpatientService.getInpatientNoByPatientId(param.getPatientId());
         for (String inpatientNo : inpatientNos) {
             requestList.add(new ExamIndexRequest.Builder()
                     .patientNumType("InPatient").patientNum(inpatientNo)
@@ -95,7 +100,7 @@ public class InspectionsService {
         return dao.selectTestReportIndex(param);
     }
 
-    public TestReport checkTestDetail(QueryReportDetail param) throws Exception {
+    public TestReport checkTestDetail(QueryReportDetail param) {
         if (StringUtil.isBlank(param.getPatientUid())) {
             throw new BizException(ExceptionEnum.NULL_POINTER, "报告ID不能为空!");
         }
@@ -117,4 +122,13 @@ public class InspectionsService {
         );
         return result;
     }
+
+    public List<PathologyIndex> checkPathologyIndex(PathologyRequest request) {
+        PathologyService pathologyService = new PathologyService();
+        request.setSocialNo(dao.getPatSocialNo(request.getPatientId()));
+        List<PathologyIndex> list = pathologyService.queryOutpatientPathologyIndex(request);
+        list.sort(Comparator.comparing(PathologyIndex::getApplyDate).reversed());
+        return list;
+    }
+
 }