|
@ -2,6 +2,7 @@ package com.yihu.hos.rest.services.crawler;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.yihu.hos.core.datatype.CollectionUtil;
|
|
import com.yihu.hos.core.datatype.CollectionUtil;
|
|
import com.yihu.hos.core.datatype.DateUtil;
|
|
import com.yihu.hos.core.datatype.DateUtil;
|
|
import com.yihu.hos.core.datatype.StringUtil;
|
|
import com.yihu.hos.core.datatype.StringUtil;
|
|
@ -13,6 +14,8 @@ import com.yihu.hos.rest.models.crawler.adapter.AdapterDataSet;
|
|
import com.yihu.hos.rest.models.crawler.adapter.StdDataSet;
|
|
import com.yihu.hos.rest.models.crawler.adapter.StdDataSet;
|
|
import com.yihu.hos.rest.models.crawler.config.SysConfig;
|
|
import com.yihu.hos.rest.models.crawler.config.SysConfig;
|
|
import com.yihu.hos.rest.models.crawler.patient.Patient;
|
|
import com.yihu.hos.rest.models.crawler.patient.Patient;
|
|
|
|
import com.yihu.hos.rest.models.crawler.qc.QcDaily;
|
|
|
|
import com.yihu.hos.rest.models.crawler.qc.QcPatientIndex;
|
|
import com.yihu.hos.rest.models.rs.RsJobConfig;
|
|
import com.yihu.hos.rest.models.rs.RsJobConfig;
|
|
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
|
|
import com.yihu.hos.rest.models.standard.adapter.AdapterDatasetModel;
|
|
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
|
|
import com.yihu.hos.rest.models.standard.adapter.AdapterDictEntryModel;
|
|
@ -31,9 +34,9 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
@Service("CrawlerManager")
|
|
|
|
|
|
@Service("qCCrawlerManager")
|
|
public class CrawlerManager {
|
|
public class CrawlerManager {
|
|
public static final String BEAN_ID = "CrawlerManager";
|
|
|
|
|
|
public static final String BEAN_ID = "qCCrawlerManager";
|
|
private static String unstructured = "unstructured";
|
|
private static String unstructured = "unstructured";
|
|
private static Logger logger = LoggerFactory.getLogger(CrawlerManager.class);
|
|
private static Logger logger = LoggerFactory.getLogger(CrawlerManager.class);
|
|
@Resource
|
|
@Resource
|
|
@ -50,6 +53,8 @@ public class CrawlerManager {
|
|
private StdMetadataService StdMetadataService;
|
|
private StdMetadataService StdMetadataService;
|
|
@Resource(name = AdapterSchemeService.BEAN_ID)
|
|
@Resource(name = AdapterSchemeService.BEAN_ID)
|
|
private AdapterSchemeService adapterSchemeService;
|
|
private AdapterSchemeService adapterSchemeService;
|
|
|
|
@Resource
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
private static DataCollectDispatcher dispatch = DataCollectDispatcher.getInstance();
|
|
private static DataCollectDispatcher dispatch = DataCollectDispatcher.getInstance();
|
|
private static SysConfig sysConfig = SysConfig.getInstance();
|
|
private static SysConfig sysConfig = SysConfig.getInstance();
|
|
@ -70,11 +75,88 @@ public class CrawlerManager {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public Result dataCrawlerByJobId(String jobId) throws Exception {
|
|
|
|
|
|
/**
|
|
|
|
* 病人事件列表
|
|
|
|
*
|
|
|
|
* @param jobId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public List<Patient> PatientListByJobId(String jobId) throws Exception {
|
|
|
|
RsJobConfig rsJobConfig = datacollect.getJobById(jobId);
|
|
|
|
logger.info("质控服务-病人列表获取jobId:" + jobId);
|
|
|
|
Date begin = rsJobConfig.getRepeatStartTime();
|
|
|
|
Date end = rsJobConfig.getRepeatEndTime();
|
|
|
|
|
|
|
|
if (end == null) {
|
|
|
|
int totalOffset = rsJobConfig.getDelayTime();
|
|
|
|
Calendar instance = Calendar.getInstance();
|
|
|
|
instance.setTime(new Date(DateUtil.getSysDateTime().getTime()));
|
|
|
|
instance.add(Calendar.SECOND, -totalOffset); //调整截止时间,当前时间-偏移量
|
|
|
|
end = instance.getTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
|
|
System.out.println("质控服务-错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
end = DateUtil.fromatDateToTimestamp(end);
|
|
|
|
|
|
|
|
if (!rsJobConfig.getJobType().equals("0")) {
|
|
|
|
//调整截止时间,当前时间-偏移量
|
|
|
|
end = DateUtil.addDate(-rsJobConfig.getDelayTime(), DateUtil.getSysDateTime());
|
|
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
|
|
System.out.println("质控服务-错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DateUtil.getDifferenceOfDays(begin, end) > 1) {
|
|
|
|
end = DateUtil.addDate(1, begin);
|
|
|
|
end = DateUtil.fromatDateToTimestamp(end);
|
|
|
|
}
|
|
|
|
|
|
|
|
DataGridResult dataGridResult = datacollect.getJobDatasetByJobId(jobId);
|
|
|
|
this.datasetList = dataGridResult.getDetailModelList();
|
|
|
|
this.schemeVersion = rsJobConfig.getSchemeVersion();
|
|
|
|
List<Patient> patientList = getPatientList(begin, end);
|
|
|
|
return patientList;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Patient> getPatientList(Date beginDate, Date endDate) {
|
|
|
|
Map<String, Object> condition = new HashMap<>();
|
|
|
|
condition.put("beginDate", beginDate);
|
|
|
|
condition.put("endDate", endDate);
|
|
|
|
Integer count = 0;
|
|
|
|
Integer totalCount = 0;
|
|
|
|
String message;
|
|
|
|
/**
|
|
|
|
* 适配基本数据准备
|
|
|
|
*/
|
|
|
|
if (!getDataForPrepare()) {
|
|
|
|
message = "适配数据尚未准备";
|
|
|
|
logger.error(message);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
|
|
|
|
|
|
|
|
return patientList;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 上传档案/质控上传
|
|
|
|
* @param jobId
|
|
|
|
* @param checkType
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Result dataCrawlerByJobId(String jobId,String checkType) throws Exception {
|
|
RsJobConfig rsJobConfig = datacollect.getJobById(jobId);
|
|
RsJobConfig rsJobConfig = datacollect.getJobById(jobId);
|
|
|
|
|
|
String random = UUID.randomUUID().toString();
|
|
String random = UUID.randomUUID().toString();
|
|
logger.info("档案采集上传开始,流水号:" + random + ",jobId:" + jobId);
|
|
|
|
|
|
logger.info("质控数据采集上传开始,流水号:" + random + ",jobId:"+jobId);
|
|
Date begin = rsJobConfig.getRepeatStartTime();
|
|
Date begin = rsJobConfig.getRepeatStartTime();
|
|
Date end = rsJobConfig.getRepeatEndTime();
|
|
Date end = rsJobConfig.getRepeatEndTime();
|
|
|
|
|
|
@ -82,12 +164,12 @@ public class CrawlerManager {
|
|
int totalOffset = rsJobConfig.getDelayTime();
|
|
int totalOffset = rsJobConfig.getDelayTime();
|
|
Calendar instance = Calendar.getInstance();
|
|
Calendar instance = Calendar.getInstance();
|
|
instance.setTime(new Date(DateUtil.getSysDateTime().getTime()));
|
|
instance.setTime(new Date(DateUtil.getSysDateTime().getTime()));
|
|
instance.add(Calendar.SECOND, -totalOffset); //调整截止时间,当前时间-偏移量
|
|
|
|
|
|
instance.add(Calendar.SECOND, - totalOffset); //调整截止时间,当前时间-偏移量
|
|
end = instance.getTime();
|
|
end = instance.getTime();
|
|
}
|
|
}
|
|
|
|
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
return Result.error("错误:采集上传结束时间小于开始时间!jobId: "+jobId +",start:"+begin.toString()+" end: "+end.toString()); //结束时间小于开始时间时,不获取
|
|
|
|
|
|
return Result.error("错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
|
|
}
|
|
}
|
|
|
|
|
|
end = DateUtil.fromatDateToTimestamp(end);
|
|
end = DateUtil.fromatDateToTimestamp(end);
|
|
@ -96,7 +178,7 @@ public class CrawlerManager {
|
|
//调整截止时间,当前时间-偏移量
|
|
//调整截止时间,当前时间-偏移量
|
|
end = DateUtil.addDate(-rsJobConfig.getDelayTime(), DateUtil.getSysDateTime());
|
|
end = DateUtil.addDate(-rsJobConfig.getDelayTime(), DateUtil.getSysDateTime());
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
if ((end.getTime() - begin.getTime()) <= 0) {
|
|
return Result.error("调整截止时间偏移量错误:采集上传结束时间小于开始时间!jobId: " + jobId + ",start:" + begin.toString() + " end: " + end.toString()); //结束时间小于开始时间时,不获取
|
|
|
|
|
|
return Result.success("错误:采集结束时间小于开始时间!"); //结束时间小于开始时间时,不获取
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -108,17 +190,17 @@ public class CrawlerManager {
|
|
DataGridResult dataGridResult = datacollect.getJobDatasetByJobId(jobId);
|
|
DataGridResult dataGridResult = datacollect.getJobDatasetByJobId(jobId);
|
|
this.datasetList = dataGridResult.getDetailModelList();
|
|
this.datasetList = dataGridResult.getDetailModelList();
|
|
this.schemeVersion = rsJobConfig.getSchemeVersion();
|
|
this.schemeVersion = rsJobConfig.getSchemeVersion();
|
|
Result result = dataCrawler(begin, end);
|
|
|
|
|
|
Result result = dataCrawler(begin, end,checkType);
|
|
if (!rsJobConfig.getJobType().equals("0")) {
|
|
if (!rsJobConfig.getJobType().equals("0")) {
|
|
rsJobConfig.setRepeatStartTime(end);
|
|
rsJobConfig.setRepeatStartTime(end);
|
|
// rsJobConfig.setRepeatEndTime(DateUtil.formatYMDToYMDHMS(DateUtil.getSysDateTime().toString()));
|
|
// rsJobConfig.setRepeatEndTime(DateUtil.formatYMDToYMDHMS(DateUtil.getSysDateTime().toString()));
|
|
}
|
|
}
|
|
datacollect.updateJob(rsJobConfig);
|
|
datacollect.updateJob(rsJobConfig);
|
|
logger.info("档案采集上传结束,上传结果:" + result.isSuccessFlg() + "流水号:" + random + ",jobId:" + jobId + ",message:" + result.getMessage());
|
|
|
|
|
|
logger.info("质控采集上传结束,流水号:" + random + ",jobId:" + jobId + ",message:" + result.getMessage());
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
public Result dataCrawler(Date beginDate, Date endDate) {
|
|
|
|
|
|
public Result dataCrawler(Date beginDate, Date endDate,String checkType) {
|
|
Map<String, Object> condition = new HashMap<>();
|
|
Map<String, Object> condition = new HashMap<>();
|
|
condition.put("beginDate", beginDate);
|
|
condition.put("beginDate", beginDate);
|
|
condition.put("endDate", endDate);
|
|
condition.put("endDate", endDate);
|
|
@ -137,38 +219,45 @@ public class CrawlerManager {
|
|
List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
|
|
List<Patient> patientList = dispatch.getPatientList(condition, adapterDataSetMap);
|
|
if (!CollectionUtil.isEmpty(patientList)) {
|
|
if (!CollectionUtil.isEmpty(patientList)) {
|
|
totalCount = patientList.size();
|
|
totalCount = patientList.size();
|
|
|
|
QcDaily qcDaily = genQcDaily(patientList);
|
|
|
|
QcPatientIndex qcPatientIndex =null;
|
|
for (Patient patient : patientList) {
|
|
for (Patient patient : patientList) {
|
|
Boolean result = collectProcess(patient);
|
|
|
|
if (result) {
|
|
|
|
count++;
|
|
|
|
|
|
Boolean result = collectProcess(patient,checkType);
|
|
|
|
qcPatientIndex = new QcPatientIndex(patient.getPatientId(),patient.getEventNo(),patient.getReferenceTime());
|
|
|
|
qcDaily.addTotal(qcPatientIndex,patient.getDataSet());
|
|
|
|
if (result) {
|
|
|
|
count++;
|
|
|
|
qcDaily.addReal(qcPatientIndex,patient.getDataSet());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qcDaily!=null){
|
|
|
|
qcDaily.setOrg_code(patientList.get(0).getOrgCode());
|
|
|
|
qcDaily.setInner_version(this.schemeVersion);
|
|
|
|
qcDaily.setCreate_date(DateUtil.getCurrentString(DateUtil.DATE_WORLD_FORMAT));
|
|
|
|
qcDaily.setTotal_outpatient_num(qcDaily.getTotal_outpatient().size());
|
|
|
|
qcDaily.setTotal_hospital_num(qcDaily.getTotal_hospital().size());
|
|
|
|
qcDaily.setReal_outpatient_num(qcDaily.getReal_outpatient().size());
|
|
|
|
qcDaily.setReal_hospital_num(qcDaily.getReal_hospital().size());
|
|
|
|
boolean b = dispatch.uploadQcDaily(objectMapper.convertValue(qcDaily, JsonNode.class),patientList.get(0));
|
|
|
|
if (!b){
|
|
|
|
logger.debug("质控服务-日报包上传失败!!!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
message = "本次采集上传病人共" + totalCount + "条,成功采集上传信息" + count + "条";
|
|
|
|
|
|
message = "本次上传病人共" + totalCount + "条,成功上传信息"+ count + "条";
|
|
return Result.success(message);
|
|
return Result.success(message);
|
|
}
|
|
}
|
|
|
|
|
|
//单个病人采集上传
|
|
|
|
public Boolean collectProcess(Patient patient) {
|
|
|
|
|
|
//单个病人质控数据采集上传
|
|
|
|
public Boolean collectProcess(Patient patient, String collectType) {
|
|
if (!getDataForPrepare()) {
|
|
if (!getDataForPrepare()) {
|
|
logger.error("适配数据尚未准备");
|
|
logger.error("适配数据尚未准备");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
patient.setReUploadFlg(StringUtil.toString(false));
|
|
patient.setReUploadFlg(StringUtil.toString(false));
|
|
logger.trace("采集->注册->打包上传,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
|
|
logger.trace("采集->质控分析->打包上传,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
try {
|
|
try {
|
|
//getToken
|
|
|
|
// if (!dispatch.getToken()) {
|
|
|
|
// logger.error("token获取失败");
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//getRemoteVersion
|
|
|
|
// if (!dispatch.getRemoteVersion(patient.getOrgCode())) {
|
|
|
|
// logger.error("远程版本获取失败");
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
|
|
if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
|
|
Map.Entry<String, AdapterDataSet> next = adapterDataSetMap.entrySet().iterator().next();
|
|
Map.Entry<String, AdapterDataSet> next = adapterDataSetMap.entrySet().iterator().next();
|
|
@ -182,28 +271,26 @@ public class CrawlerManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
|
|
|
|
logger.error("版本获取失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
|
|
Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
|
|
Map<String, JsonNode> dataMap = new HashMap<>();
|
|
Map<String, JsonNode> dataMap = new HashMap<>();
|
|
|
|
int realCount = 0;
|
|
|
|
List<String> realList = new ArrayList<>();
|
|
|
|
ObjectNode qcDataSet = dispatch.genQcDataSet(patient);//获取质控数据结构
|
|
|
|
qcDataSet.put("total_num",adapterDataSetMap.size());
|
|
for (String key : adapterDataSetMap.keySet()) {
|
|
for (String key : adapterDataSetMap.keySet()) {
|
|
/**
|
|
/**
|
|
* 获取数据
|
|
* 获取数据
|
|
*/
|
|
*/
|
|
AdapterDataSet adapterDataSet = adapterDataSetMap.get(key);
|
|
AdapterDataSet adapterDataSet = adapterDataSetMap.get(key);
|
|
String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
|
|
String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
|
|
JsonNode jsonObject = null;
|
|
|
|
if (!StringUtil.isEmpty(stdVersion)){
|
|
|
|
jsonObject = dispatch.fecthData(patient, adapterDataSet,stdVersion);
|
|
|
|
}
|
|
|
|
|
|
JsonNode jsonObject = dispatch.fecthData(patient, adapterDataSet,stdVersion);
|
|
if (StringUtil.isEmpty(jsonObject)) {
|
|
if (StringUtil.isEmpty(jsonObject)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
dataSetMap.put(adapterDataSet.getAdapterDataSetT().getStdDatasetCode(), adapterDataSet);
|
|
dataSetMap.put(adapterDataSet.getAdapterDataSetT().getStdDatasetCode(), adapterDataSet);
|
|
dataMap.put(key, jsonObject);
|
|
dataMap.put(key, jsonObject);
|
|
|
|
realCount++;
|
|
|
|
realList.add(key);
|
|
/**
|
|
/**
|
|
* 注册病人
|
|
* 注册病人
|
|
*/
|
|
*/
|
|
@ -216,106 +303,42 @@ public class CrawlerManager {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
logger.info("上传档案流程-获取病人信息成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
qcDataSet.put("real_num",realCount);
|
|
|
|
qcDataSet.set("total", objectMapper.convertValue(adapterDataSetMap.keySet().toArray(), JsonNode.class));
|
|
|
|
qcDataSet.set("real", objectMapper.convertValue(realList, JsonNode.class));
|
|
|
|
boolean b = dispatch.toQcDataSetFile(qcDataSet, patient);//生成数据集质控文件
|
|
|
|
logger.info("采集病人数据成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
//上传档案
|
|
//上传档案
|
|
logger.info("上传病人档案");
|
|
|
|
|
|
logger.info("上传病人档案及质控数据");
|
|
try {
|
|
try {
|
|
if (!CollectionUtil.isEmpty(dataMap.keySet())) {
|
|
if (!CollectionUtil.isEmpty(dataMap.keySet())) {
|
|
if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
|
|
|
|
logger.error("上传档案失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
logger.error("档案上传失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
logger.error("采集病人失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo(), e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//TOADD 单个病人采集上传(包含blob)
|
|
|
|
public Boolean collectProcess2(Patient patient) {
|
|
|
|
if (!getDataForPrepare()) {
|
|
|
|
logger.error("适配数据尚未准备");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
patient.setReUploadFlg(StringUtil.toString(false));
|
|
|
|
logger.trace("采集->注册->打包上传,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
try {
|
|
|
|
//getToken
|
|
|
|
if (!dispatch.getToken()) {
|
|
|
|
logger.error("token获取失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//getRemoteVersion
|
|
|
|
// if (!dispatch.getRemoteVersion(patient.getOrgCode())) {
|
|
|
|
// logger.error("远程版本获取失败");
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (StringUtil.isEmpty(sysConfig.getVersionMap().get(patient.getOrgCode()))) {
|
|
|
|
logger.error("版本获取失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, AdapterDataSet> dataSetMap = new HashMap<>();
|
|
|
|
Map<String, JsonNode> dataMap = new HashMap<>();
|
|
|
|
|
|
if (StringUtil.isEmpty(collectType)) {
|
|
|
|
//采集档案
|
|
|
|
if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
|
|
|
|
logger.error("上传档案失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//TODO 规则检验
|
|
|
|
if (!dispatch.uploadQcData(dataMap, patient, dataSetMap, stdDataSetMap,collectType)) {
|
|
|
|
logger.error("上传质控包失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
if (adapterDataSetMap.containsKey(unstructured)) {
|
|
|
|
//TODO 非结构化档处理
|
|
|
|
} else {
|
|
|
|
//TODO 结构化档案处理
|
|
|
|
}
|
|
|
|
for (String key : adapterDataSetMap.keySet()) {
|
|
|
|
/**
|
|
|
|
* 获取数据
|
|
|
|
*/
|
|
|
|
AdapterDataSet adapterDataSet = adapterDataSetMap.get(key);
|
|
|
|
String stdVersion = adapterDatasetService.getStdVersionByAdapterDataSet(this.schemeVersion);
|
|
|
|
JsonNode jsonObject = null;
|
|
|
|
if (!StringUtil.isEmpty(stdVersion)){
|
|
|
|
jsonObject = dispatch.fecthData(patient, adapterDataSet,stdVersion);
|
|
|
|
}
|
|
|
|
if (StringUtil.isEmpty(jsonObject)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dataSetMap.put(adapterDataSet.getAdapterDataSetT().getStdDatasetCode(), adapterDataSet);
|
|
|
|
dataMap.put(key, jsonObject);
|
|
|
|
/**
|
|
|
|
* 注册病人
|
|
|
|
*/
|
|
|
|
if (SysConfig.getInstance().getRegisterDataSet().equals(adapterDataSet.getAdapterDataSetT().getStdDatasetCode())) {
|
|
|
|
if (!StringUtil.isEmpty(jsonObject.get("data")) && !StringUtil.isEmpty(jsonObject.get("data").get(0))) {
|
|
|
|
if (!StringUtil.isEmpty(jsonObject.get("data").get(0).get(SysConfig.getInstance().getRegisterIdCardNo()))) {
|
|
|
|
logger.info("注册病人");
|
|
|
|
dispatch.register(patient, jsonObject.toString());
|
|
|
|
|
|
if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
|
|
|
|
logger.error("上传档案失败");
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
logger.info("上传-采集病人信息成功,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
//上传档案
|
|
|
|
logger.info("上传病人档案");
|
|
|
|
try {
|
|
|
|
if (!CollectionUtil.isEmpty(dataMap.keySet())) {
|
|
|
|
if (!dispatch.upload(dataMap, patient, dataSetMap, stdDataSetMap)) {
|
|
|
|
logger.error("上传档案失败");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.error("档案上传失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
|
|
|
|
logger.error("质控数据上传失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
logger.error("采集病人失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo(), e);
|
|
|
|
|
|
logger.error("采集质控数据失败,patient_id:" + patient.getPatientId() + ", event_no:" + patient.getEventNo(), e);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
@ -364,6 +387,7 @@ public class CrawlerManager {
|
|
* 推模式接口调用,默认只使用最新版本的适配
|
|
* 推模式接口调用,默认只使用最新版本的适配
|
|
*/
|
|
*/
|
|
AdapterSchemeVersionModel adapterSchemeVersionModel = adapterSchemeVersionService.getEhrAdapterVersionLasted();
|
|
AdapterSchemeVersionModel adapterSchemeVersionModel = adapterSchemeVersionService.getEhrAdapterVersionLasted();
|
|
|
|
|
|
if (adapterSchemeVersionModel == null) {
|
|
if (adapterSchemeVersionModel == null) {
|
|
logger.error("获取最新ehr适配版本错误");
|
|
logger.error("获取最新ehr适配版本错误");
|
|
return false;
|
|
return false;
|
|
@ -418,7 +442,6 @@ public class CrawlerManager {
|
|
stdFlg = true;
|
|
stdFlg = true;
|
|
return true;
|
|
return true;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -447,4 +470,18 @@ public class CrawlerManager {
|
|
public void setDatasetList(List<DictItem> datasetList) {
|
|
public void setDatasetList(List<DictItem> datasetList) {
|
|
this.datasetList = datasetList;
|
|
this.datasetList = datasetList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public QcDaily genQcDaily(List<Patient> patients){
|
|
|
|
QcDaily qcDaily = new QcDaily();
|
|
|
|
if (patients!=null && patients.isEmpty()){
|
|
|
|
qcDaily.setOrg_code(patients.get(0).getOrgCode());
|
|
|
|
qcDaily.setInner_version(SysConfig.getInstance().getVersionMap().get(patients.get(0).getOrgCode()));
|
|
|
|
qcDaily.setCreate_date(DateUtil.getUtcDate(new Date()));
|
|
|
|
|
|
|
|
}
|
|
|
|
return qcDaily;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|