瀏覽代碼

义乌妇保补录接口上传

wangsy 5 月之前
父節點
當前提交
5f1cee0564

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

@@ -193,6 +193,8 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/qc/data/sendDateInfo").permitAll()
                 .antMatchers("/qc/data/sendDateInfoOne").permitAll()
                 .antMatchers("/qc/data/updateBaby").permitAll()
+                .antMatchers("/qc/data/sendDataDeal").permitAll()
+                .antMatchers("/qc/data/sendDataDealOne").permitAll()
                 .antMatchers("/qc/data_str/sendAdmissionNote").permitAll()
                 .antMatchers("/qc/data_str/sendBloodResult").permitAll()
                 .antMatchers("/qc/data_str/sendBloodTransfusion").permitAll()

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

@@ -254,6 +254,8 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/qc/data/sendDateInfo", request)
                 || matchers("/qc/data/sendDateInfoOne", request)
                 || matchers("/qc/data/updateBaby", request)
+                || matchers("/qc/data/sendDataDeal", request)
+                || matchers("/qc/data/sendDataDealOne", request)
                 || matchers("/qc/data_str/sendAdmissionNote", request)
                 || matchers("/qc/data_str/sendBloodResult", request)
                 || matchers("/qc/data_str/sendBloodTransfusion", request)

+ 212 - 0
src/main/java/com/diagbot/facade/data/SendDataDealFacade.java

@@ -0,0 +1,212 @@
+package com.diagbot.facade.data;
+
+
+import com.alibaba.fastjson.JSON;
+import com.diagbot.entity.*;
+import com.diagbot.facade.BasDoctorInfoFacade;
+import com.diagbot.facade.BehospitalInfoFacade;
+import com.diagbot.util.StringUtil;
+import com.diagbot.util.TZDBConn;
+import com.diagbot.vo.AnalyzeRunVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.*;
+
+@Component
+public class SendDataDealFacade {
+
+    @Autowired
+    private ADoctorAdviceFacade aDoctorAdviceFacade;
+    @Autowired
+    private AHomePageFacade aHomePageFacade;
+    @Autowired
+    private AHomeOperationInfoFacade aHomeOperationInfoFacade;
+    @Autowired
+    private AHomeDiagnoseInfoFacade aHomeDiagnoseInfoFacade;
+    @Autowired
+    private ABehospitalInfoFacade aBehospitalInfoFacade;
+    @Autowired
+    private AMedicalRecordContentFacade aMedicalRecordContentFacade;
+    @Autowired
+    private AMedicalRecordFacade aMedicalRecordFacade;
+    @Autowired
+    private AMedAbnormalInfoFacade aMedAbnormalInfoFacade;
+    @Autowired
+    BehospitalInfoFacade behospitalInfoFacade;
+    @Autowired
+    private BasDoctorInfoFacade basDoctorInfoFacade;
+
+    private TZDBConn tzDBConn = new TZDBConn();
+
+
+    public void sendDataDeal(String startDate, String stopDate,String doctorID,String type) {
+
+        List<BehospitalInfo> behospitalInfoList = sendDataDealABehospitalInfo(startDate, stopDate,doctorID,type);
+//        根据的到的病人登记数据来获取病人的其他信息
+        if (behospitalInfoList.size() > 0) {
+            behospitalInfoList.forEach(s -> {
+                sendDataDealADoctorAdvice(s.getBehospitalCode());
+                sendDataDealAMedicalRecord(s.getBehospitalCode(),"");
+            });
+        } else {
+            System.out.println("没有该时间点的病人登记信息");
+        }
+
+    }
+
+    public void sendDateDealOne(String code, String doctorID, String recID) {
+        sendInfo(code, doctorID);
+        sendDataDealADoctorAdvice(code);
+        sendDataDealAMedicalRecord(code, recID);
+        try {
+            AnalyzeRunVO analyzeRunVO = new AnalyzeRunVO();
+            analyzeRunVO.setHospitalId(Long.valueOf("5"));
+            analyzeRunVO.setBehospitalCode(code);
+            behospitalInfoFacade.analyzeApi(analyzeRunVO);
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("补传自动评分失败", code, "", "", e.getMessage());
+
+        }
+    }
+
+    /**
+     * 获取病人住院登记历史数据
+     */
+    public List<BehospitalInfo> sendInfo(String code, String doctorID) {
+        List<BehospitalInfo> behospitalInfos = new ArrayList<>();
+        try {
+//            String sql = "select * from   AI_V_SENDPATIENTINFO where behospitalCode = '"+code+"'";
+            String sql = "SELECT * FROM AI_V_SENDPATIENTINFO t WHERE t.BEHOSPITALCODE='" + code + "'";
+            behospitalInfos = tzDBConn.getBehospitalInfo(sql);
+
+            if (StringUtil.isNotBlank(doctorID) && doctorID.equals("1")) {
+                //拉取时更新各医生姓名
+                for (BehospitalInfo info : behospitalInfos) {
+                    BasDoctorInfo doctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getDoctorId())
+                            .one();
+                    BasDoctorInfo directorDoctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getDirectorDoctorId())
+                            .one();
+                    BasDoctorInfo behDoctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getBehDoctorId())
+                            .one();
+                    if (doctorName != null) {
+                        info.setDoctorName(doctorName.getName());
+                    }
+                    if (directorDoctorName != null) {
+                        info.setDirectorDoctorName(directorDoctorName.getName());
+                    }
+                    if (behDoctorName != null) {
+                        info.setBehDoctorName(behDoctorName.getName());
+                    }
+                }
+            }
+
+            aBehospitalInfoFacade.execute(behospitalInfos);
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("获取病人住院登记历史数据", code, JSON.toJSONString(behospitalInfos), "", e.getMessage());
+        }
+        return behospitalInfos;
+    }
+
+
+    /**
+     * 获取病人住院登记历史数据
+     */
+    public List<BehospitalInfo> sendDataDealABehospitalInfo(String startDate, String stopDate,String doctorID, String type) {
+        List<BehospitalInfo> behospitalInfos = new ArrayList<>();
+        try {
+            String sql = "";
+            if(StringUtil.isNotBlank(type) && type.equals("2")){
+                sql = "select * from AI_V_SENDPATIENTINFO t where to_char(t.leavehospitaldate,'yyyymmdd')>= '" + startDate + " ' " +
+                        " and to_char(t.leavehospitaldate,'yyyymmdd')<= '" + stopDate + " '";
+            }else {
+                sql = "select * from AI_V_SENDPATIENTINFO t where to_char(t.behospitalDate,'yyyymmdd')>= '" + startDate + " ' " +
+                        " and to_char(t.behospitalDate,'yyyymmdd')<= '" + stopDate + " '";
+            }
+            behospitalInfos = tzDBConn.getBehospitalInfo(sql);
+
+            if (StringUtil.isNotBlank(doctorID) && doctorID.equals("1")) {
+                //拉取时更新各医生姓名
+                for (BehospitalInfo info : behospitalInfos) {
+                    BasDoctorInfo doctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getDoctorId())
+                            .one();
+                    BasDoctorInfo directorDoctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getDirectorDoctorId())
+                            .one();
+                    BasDoctorInfo behDoctorName = basDoctorInfoFacade.lambdaQuery()
+                            .eq(BasDoctorInfo::getDoctorId, info.getBehDoctorId())
+                            .one();
+                    if (doctorName != null) {
+                        info.setDoctorName(doctorName.getName());
+                    }
+                    if (directorDoctorName != null) {
+                        info.setDirectorDoctorName(directorDoctorName.getName());
+                    }
+                    if (behDoctorName != null) {
+                        info.setBehDoctorName(behDoctorName.getName());
+                    }
+                }
+            }
+
+            aBehospitalInfoFacade.execute(behospitalInfos);
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("获取病人住院登记历史数据", startDate + "--" + stopDate, JSON.toJSONString(behospitalInfos), "", e.getMessage());
+        }
+        return behospitalInfos;
+    }
+
+    /**
+     * 获取医嘱历史数据
+     */
+    public void sendDataDealADoctorAdvice(String behospitalCode) {
+        try {
+            String sql = "select * from  AI_V_SENDDOCTORADVICE  where behospitalCode= '" + behospitalCode + "'";
+            List<DoctorAdvice> doctorAdviceList = tzDBConn.getDoctorAdvice(sql);
+            aDoctorAdviceFacade.execute(doctorAdviceList);
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("获取医嘱历史数据", behospitalCode, "", "", e.getMessage());
+        }
+
+    }
+
+    /**
+     * 获取文书历史数据
+     */
+    public void sendDataDealAMedicalRecord(String behospitalCode, String recID) {
+        try {
+            //只更新单条文书
+            if (StringUtil.isNotBlank(recID)) {
+                sendDataDealAMedicalRecordContent(recID);
+            } else {
+                //            String sql = "select * from  v_jkcdss_bl_bingli   where behospitalCode= '"+behospitalCode+" '";
+                String sql = "SELECT * FROM AI_V_SENDMRRECORDING WHERE BEHOSPITALCODE = '" + behospitalCode + "'";
+                List<MedicalRecord> medicalRecords = tzDBConn.getMedicalRecord(sql);
+                aMedicalRecordFacade.execute(medicalRecords);
+                medicalRecords.forEach(medicalRecord -> {
+                    String recId = medicalRecord.getRecId();
+                    sendDataDealAMedicalRecordContent(recId);
+                });
+            }
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("获取文书历史数据", behospitalCode, "", "", e.getMessage());
+        }
+    }
+
+    /**
+     * 获取文书详情历史数据
+     */
+    public void sendDataDealAMedicalRecordContent(String recId) {
+        try {
+            String sql = "select * from AI_V_SENDMRRECORDINGGD where RECID= '" + recId + "'";
+            List<MedicalRecordContent> medicalRecordContents = tzDBConn.getMedicalRecordContent(sql);
+            aMedicalRecordContentFacade.execute(medicalRecordContents);
+        } catch (Exception e) {
+            aMedAbnormalInfoFacade.saveAbnormalInfo("获取文书详情历史数据", recId, "", "", e.getMessage());
+        }
+    }
+
+}

+ 25 - 0
src/main/java/com/diagbot/web/DataController.java

@@ -63,6 +63,9 @@ public class DataController {
     @Autowired
     private ADataFacade aDataFacade;
 
+    @Autowired
+    private SendDataDealFacade sendDataDealFacade;
+
     @ApiOperation(value = "数据引擎-获取医院所有在职医生的基本信息")
     @PostMapping("/sendDoctorInfos")
     @SysLogger("sendDoctorInfos")
@@ -274,4 +277,26 @@ public class DataController {
     public RespDTO updateBaby(@RequestBody String startDate, String endDate){
         return aBehospitalInfoFacade.updateBaby(startDate,endDate);
     }
+
+    @ApiOperation(value = "数据引擎-历史数据批量拉取<义乌妇保院>",
+            notes = "startDate: 开始时间(yyyymmdd)<br>" +
+                    "stopDate: 结束时间(yyyymmdd) <br>" +
+                    "doctorID: 是否更新入院登记信息中的医生名称【1:更新 2:否】 <br>"+
+                    "type: [1:按照入院时间拉取 2:按照出院时间拉取] <br>")
+    @PostMapping("/sendDataDeal")
+    @SysLogger("sendDataDeal")
+    public void sendDataDeal(String startDate,String stopDate,String doctorID,String type){
+        sendDataDealFacade.sendDataDeal(startDate,stopDate,doctorID,type);
+    }
+
+
+    @ApiOperation(value = "数据引擎-单个病人历史数据拉取<义乌妇保院>",
+            notes = "code: 住院号<br>" +
+                    "doctorID: 是否更新入院登记信息中的医生名称【1:更新 2:否】 <br>" +
+                    "recID:只输入recID只更新单条文书 <br>")
+    @PostMapping("/sendDataDealOne")
+    @SysLogger("sendDataDealOne")
+    public void sendDataDealOne(String code,String doctorID,String recID){
+        sendDataDealFacade.sendDateDealOne(code, doctorID,recID);
+    }
 }