|
@@ -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());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|