소스 검색

检查报告存储

lighter 1 주 전
부모
커밋
a1bbb4bd4c

+ 53 - 0
src/main/java/thyyxxk/webserver/controller/examinations/YjReqController.java

@@ -0,0 +1,53 @@
+package thyyxxk.webserver.controller.examinations;
+
+import org.springframework.beans.factory.annotation.Autowired;
+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 thyyxxk.webserver.dao.his.examinations.InspectionsDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+import thyyxxk.webserver.service.hutoolcache.UserCache;
+import thyyxxk.webserver.service.yj_req.MzYjReqService;
+import thyyxxk.webserver.service.yj_req.YjReqInterface;
+import thyyxxk.webserver.service.yj_req.ZyYjReqService;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/yjReq")
+public class YjReqController {
+    private final MzYjReqService mzYjReqService;
+    private final ZyYjReqService zyYjReqService;
+    private final InspectionsDao dao;
+    private final UserCache userCache;
+
+    @Autowired
+    public YjReqController(MzYjReqService mzYjReqService, ZyYjReqService zyYjReqService, InspectionsDao dao, UserCache userCache) {
+        this.mzYjReqService = mzYjReqService;
+        this.zyYjReqService = zyYjReqService;
+        this.dao = dao;
+        this.userCache = userCache;
+    }
+
+    @PostMapping("/queryYjReqIndex")
+    public ResultVo<List<YjReqIndex>> queryYjReqIndex(@RequestBody IndexInquiry inquiry) {
+        if (inquiry.getPatNo().contains("-")) {
+            return ResultVoUtil.success(mzYjReqService.queryYjReqIndex(inquiry));
+        }
+        return ResultVoUtil.success(zyYjReqService.queryYjReqIndex(inquiry));
+    }
+
+    @PostMapping("/uploadYjPdf")
+    public ResultVo<String> uploadYjPdf(YjReqIndex index) {
+        index.setUid(index.getPatNo() + "_" + index.getReqNo());
+        index.setStaffDept(userCache.getUserInfoByToken().getDeptCode());
+        if (null == index.getReqDoctor()) {
+            index.setReqDoctor("");
+        }
+        return ResultVoUtil.success(YjReqInterface.uploadPdf(index, dao));
+    }
+}

+ 12 - 13
src/main/java/thyyxxk/webserver/dao/his/examinations/InspectionsDao.java

@@ -1,13 +1,11 @@
 package thyyxxk.webserver.dao.his.examinations;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.examinations.bookablemanage.ExamItem;
 import thyyxxk.webserver.entity.examinations.inspections.request.ReportIndexInquiry;
 import thyyxxk.webserver.entity.examinations.inspections.response.TestReport;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
 
 import java.util.List;
 
@@ -39,18 +37,19 @@ public interface InspectionsDao {
     @Update("update ${tableName} set wx_bookable_flag=#{wxBookableFlag},book_tip=#{bookTip} where code=#{code}")
     void updateWxBookableFlag(ExamItem item);
 
-    @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<TestReport> selectTestReportIndex(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}")
-    TestReport selectTestReport(String id);
-
     @Select("select rtrim(social_no) from a_patient_mi where inpatient_no=#{patNo}")
     String selectInpatientSocialNo(String patNo);
 
     @Select("select rtrim(social_no) from mz_patient_mi where patient_id=#{patNo}")
     String selectOutpatientSocialNo(String patNo);
+
+    @Delete("delete from t_check_data where patient_uid=#{uid}")
+    void deleteOldReport(String uid);
+
+    @Insert("insert into t_check_data (patient_uid,patient_name,pat_no,times,examin_eparts,room_code, " +
+            "examination_see,examinationre_sult,doctor_code,check_doctor_code,check_time,report_time, " +
+            "patient_from,report_url,top_req_no) " +
+            "values (#{uid},#{patName},#{patNo},#{times},#{groupName},#{staffDept},'','',#{reqDoctor},'', " +
+            "'','',#{patientFrom},#{reportUrl},#{reqNo})")
+    void insertNewCheckData(YjReqIndex index);
 }

+ 16 - 0
src/main/java/thyyxxk/webserver/dao/his/examinations/MzYjReqDao.java

@@ -0,0 +1,16 @@
+package thyyxxk.webserver.dao.his.examinations;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+
+import java.util.List;
+
+@Mapper
+public interface MzYjReqDao {
+    @Select("select patientType='OUTPATIENT',patientFrom=2,req_no,patient_id as patNo,times,req_doctor, " +
+            "p_name as patName,group_name,req_date,req_comment from mz_yj_req " +
+            "where patient_id=#{patNo} and req_date>=#{start} and req_date<=#{end} ")
+    List<YjReqIndex> getYjReqIndex(IndexInquiry inquiry);
+}

+ 17 - 0
src/main/java/thyyxxk/webserver/dao/his/examinations/ZyYjReqDao.java

@@ -0,0 +1,17 @@
+package thyyxxk.webserver.dao.his.examinations;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+
+import java.util.List;
+
+@Mapper
+public interface ZyYjReqDao {
+
+    @Select("select patientType='INPATIENT',patientFrom=1,req_no,inpatient_no as patNo,admiss_times as times, " +
+            "p_name as patName,req_doctor,group_name,req_date,req_comment from ysh_yj_req " +
+            "where inpatient_no=#{patNo} and req_date>=#{start} and req_date<=#{end} ")
+    List<YjReqIndex> getYjReqIndex(IndexInquiry inquiry);
+}

+ 10 - 0
src/main/java/thyyxxk/webserver/entity/yiji/IndexInquiry.java

@@ -0,0 +1,10 @@
+package thyyxxk.webserver.entity.yiji;
+
+import lombok.Data;
+
+@Data
+public class IndexInquiry {
+    private String patNo;
+    private String start;
+    private String end;
+}

+ 25 - 0
src/main/java/thyyxxk/webserver/entity/yiji/YjReqIndex.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.entity.yiji;
+
+import lombok.Data;
+import org.springframework.web.multipart.MultipartFile;
+import thyyxxk.webserver.api.medicallaboratory.model.PatientType;
+
+import java.util.Date;
+
+@Data
+public class YjReqIndex {
+    private PatientType patientType;
+    private Integer patientFrom;
+    private String uid;
+    private String reqNo;
+    private String patNo;
+    private Integer times;
+    private String patName;
+    private String groupName;
+    private Date reqDate;
+    private String reqComment;
+    private String staffDept;
+    private String reqDoctor;
+    private String reportUrl;
+    private MultipartFile file;
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/entity/zhuyuanyisheng/jianyanjiancha/CheckTheCallbacks.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
-import thyyxxk.webserver.config.exception.ExceptionEnum;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotEmpty;

+ 25 - 0
src/main/java/thyyxxk/webserver/service/yj_req/MzYjReqService.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.service.yj_req;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.examinations.MzYjReqDao;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+
+import java.util.List;
+
+@Service
+public class MzYjReqService implements YjReqInterface {
+    private final MzYjReqDao dao;
+
+    @Autowired
+    public MzYjReqService(MzYjReqDao dao) {
+        this.dao = dao;
+    }
+
+    @Override
+    public List<YjReqIndex> queryYjReqIndex(IndexInquiry inquiry) {
+        return dao.getYjReqIndex(inquiry);
+    }
+
+}

+ 38 - 0
src/main/java/thyyxxk/webserver/service/yj_req/YjReqInterface.java

@@ -0,0 +1,38 @@
+package thyyxxk.webserver.service.yj_req;
+
+import lombok.Data;
+import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.config.exception.BizException;
+import thyyxxk.webserver.dao.his.examinations.InspectionsDao;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+
+import java.util.List;
+
+public interface YjReqInterface {
+
+    List<YjReqIndex> queryYjReqIndex(IndexInquiry inquiry);
+
+    static String uploadPdf(YjReqIndex yjReq, InspectionsDao dao) {
+        RestTemplate restTemplate = new RestTemplate();
+        JcbgSaveReq saveReq = new JcbgSaveReq();
+        saveReq.setUid(yjReq.getUid());
+        try {
+            saveReq.setFile(yjReq.getFile().getBytes());
+        } catch (Exception e) {
+            throw new BizException(e.getMessage());
+        }
+        String url = "https://staticweb.hnthyy.cn/wxserver/api/saveJcbg/save";
+        String result = restTemplate.postForObject(url, saveReq, String.class);
+        yjReq.setReportUrl(result);
+        dao.deleteOldReport(yjReq.getUid());
+        dao.insertNewCheckData(yjReq);
+        return result;
+    }
+
+    @Data
+    class JcbgSaveReq {
+        private String uid;
+        private byte[] file;
+    }
+}

+ 25 - 0
src/main/java/thyyxxk/webserver/service/yj_req/ZyYjReqService.java

@@ -0,0 +1,25 @@
+package thyyxxk.webserver.service.yj_req;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.examinations.ZyYjReqDao;
+import thyyxxk.webserver.entity.yiji.IndexInquiry;
+import thyyxxk.webserver.entity.yiji.YjReqIndex;
+
+import java.util.List;
+
+@Service
+public class ZyYjReqService implements YjReqInterface{
+    private final ZyYjReqDao dao;
+
+    @Autowired
+    public ZyYjReqService(ZyYjReqDao dao) {
+        this.dao = dao;
+    }
+
+    @Override
+    public List<YjReqIndex> queryYjReqIndex(IndexInquiry inquiry) {
+        return dao.getYjReqIndex(inquiry);
+    }
+
+}