|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.jw.hospital.module.rehabilitation.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
@ -7,13 +8,17 @@ import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.door.SignPatientLabelInfo;
|
|
|
import com.yihu.jw.entity.patient.BasePatientDischargeRecord;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.*;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientRehabilitationPlanDao;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationDetailDao;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.RehabilitationPatientInfoDao;
|
|
|
import com.yihu.jw.hospital.prescription.service.DsyyPrescriptionService;
|
|
|
import com.yihu.jw.hospital.team.dao.SignPatientLabelInfoDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDischargeRecordDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -27,10 +32,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Base64;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by liub on 2020/9/29.
|
|
@ -69,6 +71,10 @@ public class SynchronizePatientService {
|
|
|
private WlyyBusinessService businessService;
|
|
|
@Autowired
|
|
|
private RehabilitationManageService rehabilitationManageService;
|
|
|
@Autowired
|
|
|
private BasePatientDischargeRecordDao basePatientDischargeRecordDao;
|
|
|
@Autowired
|
|
|
private DsyyPrescriptionService dsyyPrescriptionService;
|
|
|
|
|
|
|
|
|
//手动重新下转
|
|
@ -268,9 +274,22 @@ public class SynchronizePatientService {
|
|
|
//获取三院专病配置
|
|
|
public RehabilitationPlanTemplateDO findPlanTemplate(String dept,String diagnosis){
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName,d.family_relation familyRelation " +
|
|
|
"FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
|
"WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='0' and d.rehabilitation_type='1'" +
|
|
|
"and d.dept like '%"+dept+"%' and d.diagnosis like '%"+diagnosis+"%' LIMIT 1";
|
|
|
" FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
|
" WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='0' and d.rehabilitation_type='1'" +
|
|
|
" and d.dept like '%"+dept+"%' and d.diagnosis like '%"+diagnosis+"%' LIMIT 1";
|
|
|
List<RehabilitationPlanTemplateDO> diseaseList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationPlanTemplateDO.class));
|
|
|
if(diseaseList.size()==0){
|
|
|
return null;
|
|
|
}
|
|
|
return diseaseList.get(0);
|
|
|
}
|
|
|
|
|
|
//获取三院专病配置
|
|
|
public RehabilitationPlanTemplateDO findPlanTemplate(String dept,String diagnosis,String turnDownRange){
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName,d.family_relation familyRelation " +
|
|
|
",d.distribution_type distributionType,d.distribution_to distributionTo FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
|
" WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='0' and d.rehabilitation_type='1'" +
|
|
|
" and d.turn_down_range in('"+turnDownRange+"','3') and d.dept like '%"+dept+"%' and d.diagnosis like '%"+diagnosis+"%' LIMIT 1";
|
|
|
List<RehabilitationPlanTemplateDO> diseaseList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationPlanTemplateDO.class));
|
|
|
if(diseaseList.size()==0){
|
|
|
return null;
|
|
@ -529,71 +548,151 @@ public class SynchronizePatientService {
|
|
|
//康复管理自动下转
|
|
|
public StringBuilder synchronizePation(String type) throws Exception {
|
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
|
JSONArray successSync = new JSONArray();//存储下转信息
|
|
|
List<RehabilitationPatientInfoDO> rehabilitationPatientInfoDOs;
|
|
|
Date nowDate = new Date();
|
|
|
Date preTime = DateUtil.getPreDays(nowDate,-30);
|
|
|
String preTimeStr = DateUtil.dateToStrShort(DateUtil.getPreDays(nowDate,-30));
|
|
|
String sql = "";
|
|
|
if (StringUtils.isBlank(type)){//为空
|
|
|
results.append("未分配居民下转type:"+type+"\n");
|
|
|
rehabilitationPatientInfoDOs = rehabilitationPatientInfoDao.findUnDispation(preTime);
|
|
|
}
|
|
|
else{
|
|
|
Integer typeInt = Integer.parseInt(type);
|
|
|
sql = " select * from base_patient_discharge_record where status is null and create_time>'"+preTimeStr+"' order by create_time limit 30";
|
|
|
}else{
|
|
|
results.append("指定状态居民下转type:"+type+"\n");
|
|
|
rehabilitationPatientInfoDOs = rehabilitationPatientInfoDao.findUnDispationByStatus(typeInt,preTime);
|
|
|
sql = " select * from base_patient_discharge_record where status='"+type+"' and create_time>'"+preTimeStr+"' order by create_time limit 30";
|
|
|
}
|
|
|
logger.info("康复计划自动下转————需要下转的居民人数" + rehabilitationPatientInfoDOs.size());
|
|
|
results.append("需要下转的居民人数" + rehabilitationPatientInfoDOs.size() + "\n");
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
for (RehabilitationPatientInfoDO re : rehabilitationPatientInfoDOs) {
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
Date diagnoseTime = re.getDiagnoseTime();
|
|
|
//诊断时间为空或超过一个月 也不做下转
|
|
|
if (diagnoseTime==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
List<BasePatientDischargeRecord> patientDischargeRecords = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BasePatientDischargeRecord.class));
|
|
|
logger.info("康复计划自动下转————需要下转的居民人数" + patientDischargeRecords.size());
|
|
|
results.append("需要下转的居民人数" + patientDischargeRecords.size() + "\n");
|
|
|
List<BasePatientDischargeRecord> modifyList = new ArrayList<>();
|
|
|
for (BasePatientDischargeRecord re : patientDischargeRecords) {
|
|
|
String idcard = re.getIdcard();
|
|
|
if(StringUtils.isBlank(idcard)){
|
|
|
re.setStatus("2");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
continue;
|
|
|
}
|
|
|
if (DateUtil.getDays(nowDate,diagnoseTime)>30){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
String content = re.getContent();
|
|
|
JSONObject json = null;
|
|
|
try {
|
|
|
json = JSON.parseObject(content);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
//去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
if(StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
if(json==null){
|
|
|
re.setStatus("2");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// List<BasePatientDischargeRecord> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
// Date diagnoseTime = re.getDiagnoseTime();
|
|
|
// //诊断时间为空或超过一个月 也不做下转
|
|
|
// if (diagnoseTime==null){
|
|
|
// dischargeUpdate(tmpList,"4",modifyList);
|
|
|
// continue;
|
|
|
// }
|
|
|
// if (DateUtil.getDays(nowDate,diagnoseTime)>30){
|
|
|
// dischargeUpdate(tmpList,"4",modifyList);
|
|
|
// continue;
|
|
|
// }
|
|
|
// //去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
// if(StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
// dischargeUpdate(tmpList,"2",modifyList);
|
|
|
// continue;
|
|
|
// }
|
|
|
//"idcard":"510722201908261751","patientName":"龚嘉乐","cardNo":"510722201908261751" "conNo":"9","visitNo":"1727810009"}
|
|
|
String name = json.getString("patientName");
|
|
|
String cardNo = json.getString("cardNo");
|
|
|
String conNo = json.getString("conNo");//就诊次数
|
|
|
String visitNo = json.getString("visitNo");//就诊号
|
|
|
BasePatientDO patient = null;
|
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
continue;
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcard(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从his视图添加居民
|
|
|
patient = dsyyPrescriptionService.addPaitentByIdcard(re.getIdcard(),name);
|
|
|
if (patient == null) {
|
|
|
re.setStatus("3");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
JSONArray jaMzbl = new JSONArray();
|
|
|
JSONArray jaCy = new JSONArray();
|
|
|
String eventType = "";//1门诊 2住院
|
|
|
try {
|
|
|
//门诊病历
|
|
|
String mzbl = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWMZBL-014","",conNo,1,1);
|
|
|
if(StringUtils.isNotBlank(mzbl)){
|
|
|
jaMzbl = JSONArray.parseArray(mzbl);
|
|
|
}
|
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
}else {
|
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
//出院小结
|
|
|
String cyxj = dsyyPrescriptionService.selectReportInfo("JHIDS-USD-HLWCYXJ-013","",conNo,1,1);
|
|
|
if(StringUtils.isNotBlank(cyxj)){
|
|
|
jaCy = JSONArray.parseArray(cyxj);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
String dept = re.getDept();
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
if(StringUtils.isBlank(eventType)){
|
|
|
re.setStatus("4");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
continue;
|
|
|
}
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
String result = "";
|
|
|
if (demoFlag) {//测试线获取病历模板
|
|
|
result = patientRecordService.getJosnFileResullt("event2");
|
|
|
} else {
|
|
|
// try {
|
|
|
// JSONObject jsonEvent = new JSONObject();
|
|
|
// List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient.getId(), "2", "1", "1", "2010-10-10 00:00:00", hos.getCode());
|
|
|
// jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
// result = jsonEvent.toString();
|
|
|
// }catch (Exception e){
|
|
|
// infoUpdate(tmpList,3,modifyList,null);
|
|
|
// results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
// logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
// continue;
|
|
|
// }
|
|
|
}
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
|
if (0 == temlist.size()) {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
|
|
//创建下转记录表
|
|
|
RehabilitationPatientInfoDO infoDO = new RehabilitationPatientInfoDO();
|
|
|
infoDO.setPatient(patient.getId());
|
|
|
infoDO.setStatus(0);
|
|
|
infoDO.setIdcard(patient.getIdcard());
|
|
|
infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
|
|
|
infoDO.setSsc(patient.getSsc());
|
|
|
infoDO.setAddress(patient.getAddress());
|
|
|
infoDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
infoDO.setCreateTime(new Date());
|
|
|
infoDO.setName(patient.getName());
|
|
|
infoDO.setSex(patient.getSex());
|
|
|
infoDO.setMobile(patient.getMobile());
|
|
|
infoDO.setFromSource(2);
|
|
|
infoDO.setSignStatus(0);
|
|
|
infoDO.setDischargeRecordId(re.getId());
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
|
|
|
String dept = "科室";
|
|
|
// String dept = re.getDept();
|
|
|
// String diagnosis = re.getDiagnosis();
|
|
|
String diagnosis = "诊断";
|
|
|
//三院专病配置
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis,eventType);
|
|
|
if(planTemplateDO==null){
|
|
|
re.setStatus("5");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("未找到满足条件的专病配置\n");
|
|
|
continue;
|
|
|
}
|
|
@ -601,21 +700,27 @@ public class SynchronizePatientService {
|
|
|
//判断签约的才推送i健康
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
if(isSign==null){
|
|
|
re.setStatus("6");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
infoDO.setSignStatus(1);
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
//推送i健康数据
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
saveModifyList(modifyList);
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(infoDO);
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
re.setStatus("6");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
infoDO.setIjkId(ijkId);
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
re.setStatus("7");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
}
|
|
@ -623,45 +728,26 @@ public class SynchronizePatientService {
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
String planDoctorType = planTemplateDO.getPlanDoctorType();//计划负责人 1手动获取,2自动获取
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//类型=1康复计划负责人,类型2 1主管医生 2主治医生
|
|
|
String distributionType = planTemplateDO.getDistributionType();//分配方式 1手动分配 2自动分配(分配康复计划项的执行医生)
|
|
|
String distributionTo = planTemplateDO.getDistributionTo();//分配对象 1主管医生 2主治医生
|
|
|
BaseDoctorDO planDoctor = null;
|
|
|
BaseDoctorDO zgDoctor = null;//主管医生
|
|
|
BaseDoctorDO zzDoctor = null;//主治医生
|
|
|
if("1".equals(planDoctorType)){
|
|
|
planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
}else {
|
|
|
if("1".equals(planDoctorId)){
|
|
|
//1主管医生
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
String result = "";
|
|
|
if (demoFlag) {//测试线获取病历模板
|
|
|
result = patientRecordService.getJosnFileResullt("event" + "2");
|
|
|
} else {
|
|
|
// try {
|
|
|
// JSONObject jsonEvent = new JSONObject();
|
|
|
// List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient.getId(), "2", "1", "1", "2010-10-10 00:00:00", hos.getCode());
|
|
|
// jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
// result = jsonEvent.toString();
|
|
|
// }catch (Exception e){
|
|
|
// infoUpdate(tmpList,3,modifyList,null);
|
|
|
// results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
// logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
// continue;
|
|
|
// }
|
|
|
}
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
|
if (0 == temlist.size()) {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
continue;
|
|
|
}else {
|
|
|
//2主治医生
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//仅厦心进行自动下转至已下转 //厦心不推送消息
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
// continue;
|
|
|
// }
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
|
|
/**
|
|
|
* {
|
|
|
"orgName": "厦门大学附属心血管病医院",
|
|
@ -681,11 +767,11 @@ public class SynchronizePatientService {
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
}
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
|
pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
// pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
// pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
|
// pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
pmr.setJwpatient(tem.getString("patient"));
|
|
|
pmr.setAdmittingDiagnosisName(re.getDiagnosisName());
|
|
|
// pmr.setAdmittingDiagnosisName(re.getDiagnosisName());
|
|
|
pmr.setEvent(tem.getString("id"));
|
|
|
pmr.setDataFrom(tem.getString("dataFrom"));
|
|
|
pmr.setAdvice("出院继续观察");
|
|
@ -708,10 +794,6 @@ public class SynchronizePatientService {
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
|
|
|
logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
continue;
|
|
|
} else {//
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
@ -727,22 +809,17 @@ public class SynchronizePatientService {
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
planDO.setPatientInfoCode(infoDO.getCode());
|
|
|
planDO.setCreateTime(new Date());
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
planDO.setDisease(diseaseId);
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
// planDO.setTotalExpense();
|
|
|
//目前默认为冠心病
|
|
|
//创建康复计划
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,infoDO);
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败\n");
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败");
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
continue;
|
|
|
} else {//创建康复计划成功
|
|
|
String planId = planDO.getId();
|
|
@ -763,18 +840,16 @@ public class SynchronizePatientService {
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
infoUpdate(tmpList,1,modifyList,planDoctor);
|
|
|
|
|
|
infoDO.setStatus(1);
|
|
|
rehabilitationPatientInfoDao.save(infoDO);
|
|
|
re.setStatus("1");
|
|
|
basePatientDischargeRecordDao.equals(re);
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功");
|
|
|
//给服务医生群组发送下转消息
|
|
|
// if (StringUtils.isNoneBlank(planId)){
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
// }
|
|
|
// messageService.addSpecialistDynamicMessages(patient,doctor,familyDoctor,"下转成功",diseaseObj.getString("disease"),"1",null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
rehabilitationPatientInfoDao.saveAll(modifyList);
|
|
|
return results;
|
|
|
}
|
|
|
|
|
@ -811,6 +886,53 @@ public class SynchronizePatientService {
|
|
|
return planDO;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建康复计划json
|
|
|
*/
|
|
|
public PatientRehabilitationPlanDO createRehabilitationPlanJson(PatientRehabilitationPlanDO planDO, String planTemplateId,StringBuilder results
|
|
|
, RehabilitationPatientInfoDO re,String distributionType,String distributionTo,BaseDoctorDO zgDoctor,BaseDoctorDO zzDoctor) throws Exception{
|
|
|
String sql = "select * from wlyy_rehabilitation_template_detail where template_id = '" + planTemplateId + "'";
|
|
|
List<RehabilitationTemplateDetailDO> templateDetail = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationTemplateDetailDO.class));
|
|
|
if (templateDetail.size() == 0) {
|
|
|
results.append("系统默认的康复模板请求:" + re.getIdcard() + "----系统默认的康复模板为空,请手动进行下转\n");
|
|
|
return null;
|
|
|
}
|
|
|
planDO = patientRehabilitationPlanDao.save(planDO);
|
|
|
List<RehabilitationDetailDO> detailDOList = new ArrayList<>();
|
|
|
for(RehabilitationTemplateDetailDO detailDO : templateDetail) {
|
|
|
String frequency_code = detailDO.getFrequencyCode();//频次
|
|
|
RehabilitationDetailDO detail = new RehabilitationDetailDO();
|
|
|
detail.setHospitalServiceItemId(detailDO.getHospitalServiceItemId());
|
|
|
detail.setCreateTime(new Date());
|
|
|
detail.setStatus(0);
|
|
|
detail.setType(1);
|
|
|
detail.setUpdateTime(new Date());
|
|
|
detail.setPlanId(planDO.getId());
|
|
|
detail.setFrequencyCode(frequency_code);
|
|
|
if("2".equals(distributionType)){
|
|
|
if("1".equals(distributionTo)){
|
|
|
//1主管医生
|
|
|
// detail.setDept();
|
|
|
// detail.setDeptName();
|
|
|
detail.setDoctor(zgDoctor.getId());
|
|
|
detail.setDoctorName(zgDoctor.getName());
|
|
|
}else {
|
|
|
//2主治医生
|
|
|
// detail.setDept();
|
|
|
// detail.setDeptName();
|
|
|
detail.setDoctor(zzDoctor.getId());
|
|
|
detail.setDoctorName(zzDoctor.getName());
|
|
|
}
|
|
|
}
|
|
|
detailDOList.add(detail);
|
|
|
}
|
|
|
rehabilitationDetailDao.saveAll(detailDOList);
|
|
|
|
|
|
rehabilitationManageService.addPlanLog(planDO.getId(),planDO.getPlanDoctor(),planDO.getPlanDoctorName());
|
|
|
|
|
|
planDO.setDetailDOList(detailDOList);
|
|
|
return planDO;
|
|
|
}
|
|
|
|
|
|
@Transactional(propagation= Propagation.NOT_SUPPORTED)
|
|
|
public void runSqlNow(String sql){
|
|
@ -857,6 +979,15 @@ public class SynchronizePatientService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//更新患者下转状态
|
|
|
public void dischargeUpdate(List<BasePatientDischargeRecord> lists,String status,List<BasePatientDischargeRecord> modifyList){
|
|
|
for (BasePatientDischargeRecord re:lists){
|
|
|
re.setStatus(status);
|
|
|
modifyList.remove(re);
|
|
|
modifyList.add(re);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void infoUpdate2(List<RehabilitationPatientInfoDO> lists,String problemCode,List<RehabilitationPatientInfoDO> modifyList){
|
|
|
for (RehabilitationPatientInfoDO re:lists){
|
|
|
re.setProblemCode(problemCode);
|