|
@ -6,43 +6,30 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
|
|
|
import com.yihu.jw.dict.dao.FrequencyDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.door.SignFamily;
|
|
|
import com.yihu.jw.entity.door.SignPatientLabelInfo;
|
|
|
import com.yihu.jw.entity.hospital.DmHospitalDO;
|
|
|
import com.yihu.jw.entity.hospital.appointment.WlyySpecialDiseaseDO;
|
|
|
import com.yihu.jw.entity.hospital.doctor.Frequency;
|
|
|
import com.yihu.jw.entity.rehabilitation.PatientDischargeDO;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientDischargeDao;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.PatientDiseaseServer;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.PatientMedicalRecordsDO;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPatientInfoDO;
|
|
|
import com.yihu.jw.entity.util.TransforSqlUtl;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.*;
|
|
|
import com.yihu.jw.hospital.HospitalDao;
|
|
|
import com.yihu.jw.hospital.appointment.dao.SpecialDiseaseDao;
|
|
|
import com.yihu.jw.hospital.async.AsynService;
|
|
|
import com.yihu.jw.hospital.message.service.SystemMessageService;
|
|
|
import com.yihu.jw.hospital.module.followup.service.FollowUpService;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.dao.PatientDischargeDao;
|
|
|
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.module.specialist.dao.PatientDiseaseServerDao;
|
|
|
import com.yihu.jw.hospital.team.dao.SignPatientLabelInfoDao;
|
|
|
import com.yihu.jw.hospital.team.dao.WlyyAdminTeamDao;
|
|
|
import com.yihu.jw.hospital.team.dao.WlyySignFamilyDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.service.BasePatientService;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
|
|
|
import com.yihu.jw.wlyy.service.WlyyBusinessService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -50,8 +37,10 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import com.yihu.jw.util.html.HtmlUtil;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Base64;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* Created by liub on 2020/9/29.
|
|
@ -65,8 +54,7 @@ public class SynchronizePatientService {
|
|
|
// @Value("${specialist.url}")
|
|
|
private String specialistUrl;
|
|
|
// @Value("${demo.flag}")
|
|
|
private Boolean demoFlag;
|
|
|
private Map<String,List> hospitalSyncDisease = new HashMap<>();//医院自动下转疾病配置
|
|
|
private Boolean demoFlag=true;
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
@Autowired
|
|
@ -86,15 +74,11 @@ public class SynchronizePatientService {
|
|
|
@Autowired
|
|
|
private HospitalDao hospitalDao;
|
|
|
@Autowired
|
|
|
private WlyyAdminTeamDao wlyyAdminTeamDao;
|
|
|
@Autowired
|
|
|
private FollowUpService followUpService;
|
|
|
@Autowired
|
|
|
private BaseFrequencyDictDao baseFrequencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
private FrequencyDao frequencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
private AsynService asynService;
|
|
|
@Autowired
|
|
@ -103,8 +87,6 @@ public class SynchronizePatientService {
|
|
|
@Autowired
|
|
|
private PatientDischargeDao patientDischargeDao;
|
|
|
@Autowired
|
|
|
private WlyySignFamilyDao signFamilyDao;
|
|
|
@Autowired
|
|
|
private BasePatientService patientService;
|
|
|
@Autowired
|
|
|
private RehabilitationInfoService rehabilitationInfoService;
|
|
@ -120,12 +102,16 @@ public class SynchronizePatientService {
|
|
|
|
|
|
@Autowired
|
|
|
private ZsRehabilitationInfoService zsRehabilitationInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private PatientRehabilitationPlanDao patientRehabilitationPlanDao;
|
|
|
@Autowired
|
|
|
private RehabilitationDetailDao rehabilitationDetailDao;
|
|
|
@Autowired
|
|
|
private WlyyBusinessService businessService;
|
|
|
|
|
|
|
|
|
//手动重新下转
|
|
|
public String synchronizePationSingle(Long id) throws Exception{
|
|
|
setHospitalSyncDisease();
|
|
|
RehabilitationPatientInfoDO re = rehabilitationPatientInfoDao.findById(id).orElse(null);
|
|
|
if(re==null){
|
|
|
return "数据不存在";
|
|
@ -133,56 +119,9 @@ public class SynchronizePatientService {
|
|
|
if(re.getStatus()==1){
|
|
|
return "已下转成功,不允许操作";
|
|
|
}
|
|
|
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(), DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
boolean bl = false;//是否是厦心下转病人
|
|
|
if("12350200568420163H".equals(re.getHospitalCode())){
|
|
|
bl = true;
|
|
|
}
|
|
|
//去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
if(re.getHospitalName().equals("厦门大学附属心血管病医院")&&StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "下转数据错误,未指明下转专病类型";
|
|
|
}
|
|
|
String hospitalCode =getHospitalCode(re.getHospitalCode());
|
|
|
if(hospitalCode==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "未查询到该医院: "+re.getHospitalName()+",无法进行下转";
|
|
|
}
|
|
|
DmHospitalDO hos = hospitalDao.findByCode(hospitalCode);
|
|
|
if(hos==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "未查询到该医院: "+re.getHospitalName()+",无法进行下转";
|
|
|
}
|
|
|
JSONObject diseaseObj = getHosSyncDiseaseInfo(hos.getCode(),StringUtils.isBlank(re.getProblemCode())?"":re.getProblemCode());//获取医院自动下转对应的疾病信息
|
|
|
if(diseaseObj==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "该《"+hos.getName()+"》医院暂未支持下转";
|
|
|
}
|
|
|
Integer teamCount = wlyyAdminTeamDao.findAcceptTeamCount(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
if (teamCount == 0) {//未找到该机构团队
|
|
|
return "未找到该医院接收团队:" + re.getHospitalName() + ",疾病类型:"+diseaseObj.getString("diseaseName");
|
|
|
}
|
|
|
Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
|
|
|
//如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
|
|
|
String hospitalDoctor = re.getHospitalDoctor(); // 曾昭萍/350*******64
|
|
|
if (StringUtils.isNoneBlank(hospitalDoctor)){
|
|
|
String[] tmp = hospitalDoctor.split("/");
|
|
|
if (tmp.length==2){//存在唯一标识身份证
|
|
|
String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
|
|
|
" where doc.del=1 and doc.idcard='"+tmp[1]+"'";
|
|
|
List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
|
|
|
if (doctors.size()>0){
|
|
|
doctor = doctors.get(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
BasePatientDO patient = null;
|
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
@ -192,31 +131,60 @@ public class SynchronizePatientService {
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
if (patientService.addPaitentByIdcard(re.getIdcard()) == null) {
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "居民信息不存在";
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
}
|
|
|
}
|
|
|
patient = patientList.get(0);
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
}
|
|
|
String dept = re.getDept();
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
//或者三院专病配置
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName 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='1' 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 "未找到满足条件的专病配置";
|
|
|
}
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = diseaseList.get(0);
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
//推送i健康数据
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject.getInteger("status")!=-1){
|
|
|
return "推送i健康失败";
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
rehabilitationPatientInfoDao.save(re);
|
|
|
return "推送i健康成功";
|
|
|
}
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
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);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历信息";
|
|
|
}
|
|
|
//同步住院病历信息
|
|
|
// 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);
|
|
|
// saveModifyList(modifyList);
|
|
|
// return "同步患者病历:" + re.getIdcard() + "----无住院病历信息";
|
|
|
// }
|
|
|
}
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
JSONArray temlist = rejson.getJSONArray("data");
|
|
@ -225,40 +193,23 @@ public class SynchronizePatientService {
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历信息";
|
|
|
}
|
|
|
int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//添加下转居名
|
|
|
PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
patientDischargeDO.setType(2);//下转列表type==2
|
|
|
patientDischargeDO.setPatient(patient.getId());
|
|
|
patientDischargeDO.setName(patient.getName());
|
|
|
patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
patientDischargeDO.setSsc(patient.getSsc());
|
|
|
patientDischargeDO.setAddress(patient.getAddress());
|
|
|
patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
patientDischargeDO.setCreateTime(new Date());
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily != null) {//只有有签约信息 才能进行下转
|
|
|
patientDischargeDO.setSignStatus(1);
|
|
|
patientDischargeDO.setHospital(signFamily.getHospital());
|
|
|
patientDischargeDO.setHospitalName(signFamily.getHospitalName());
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//无签约
|
|
|
patientDischargeDO.setSignStatus(0);
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "居民未家签";
|
|
|
}
|
|
|
}
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily == null) {
|
|
|
return "居民未家签";
|
|
|
}
|
|
|
// int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
// if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
// infoUpdate(tmpList,6,modifyList,null);
|
|
|
// } else {//添加下转居名
|
|
|
// PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
// patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
// patientDischargeDO.setType(2);//下转列表type==2
|
|
|
// patientDischargeDO.setPatient(patient.getId());
|
|
|
// patientDischargeDO.setName(patient.getName());
|
|
|
// patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
// patientDischargeDO.setSsc(patient.getSsc());
|
|
|
// patientDischargeDO.setAddress(patient.getAddress());
|
|
|
// patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
// patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
// patientDischargeDO.setCreateTime(new Date());
|
|
|
// }
|
|
|
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
|
|
@ -266,7 +217,7 @@ public class SynchronizePatientService {
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
pmr.setHospital(hos.getCode());
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
}
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
@ -278,189 +229,77 @@ public class SynchronizePatientService {
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
String html = getEmrContentByRID(tem.getString("patient"),tem.getString("id"),tem.getString("orgCode"));
|
|
|
if (StringUtils.isNoneBlank(html)){
|
|
|
List<String> tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.in\" (.*?)</TD>");
|
|
|
String diagnosisIn =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisIn)){
|
|
|
try {
|
|
|
diagnosisIn =diagnosisIn.substring(diagnosisIn.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisIn="";
|
|
|
}
|
|
|
}
|
|
|
tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.out\" (.*?)</TD>");
|
|
|
String diagnosisOut =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisOut)){
|
|
|
try {
|
|
|
diagnosisOut =diagnosisOut.substring(diagnosisOut.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisOut="";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
}
|
|
|
}else {
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息";
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息";
|
|
|
}
|
|
|
}
|
|
|
if (tem.getString("dataFrom").equals("3"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
com.alibaba.fastjson.JSONObject zsResultData = zsRehabilitationInfoService.zsHospitalRecordDetail(tem.getString("patient"),tem.getString("id"));
|
|
|
if (zsResultData!=null){
|
|
|
if(zsResultData.containsKey("入院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("入院诊断"))){
|
|
|
pmr.setDischargeDiagnosisName(zsResultData.getString("入院诊断"));
|
|
|
}else {
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无入院诊断信息";
|
|
|
}
|
|
|
if (zsResultData.containsKey("出院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("出院诊断"))){
|
|
|
pmr.setAdmittingDiagnosisName(zsResultData.getString("出院诊断"));
|
|
|
}else {
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无出院诊断信息";
|
|
|
}
|
|
|
}else {
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息";
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息";
|
|
|
}
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
// }
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
// }
|
|
|
}
|
|
|
pmr.setDiseaseCode(diseaseObj.getString("disease"));//疾病code
|
|
|
pmr.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
String jsonData = JSON.toJSONString(pmr);
|
|
|
|
|
|
//创建居民住院病历
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctor.getId(), patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
|
|
|
BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "创建病历失败";
|
|
|
} else {//
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
JSONObject json = new JSONObject();//创建康复计划json
|
|
|
json.put("patient", patient.getId());//患者code
|
|
|
json.put("name", patient.getName());//患者名称
|
|
|
json.put("title", patient.getName() + "的康复计划");//title
|
|
|
json.put("healthStatusCode", "2");//健康状态
|
|
|
//目前默认为冠心病
|
|
|
json.put("disease", diseaseObj.getString("disease"));//疾病
|
|
|
json.put("diseaseName", diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
json.put("planType", 1);//
|
|
|
json.put("payment", 2);//
|
|
|
json.put("totalExpense", "");//
|
|
|
json.put("adviceContent", "出院继续观察");//
|
|
|
json.put("medicalRecordsCode", patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
json.put("teamCode", teamId);//
|
|
|
json.put("createUser", doctor.getId());
|
|
|
json.put("createUserName", doctor.getName());
|
|
|
json.put("patientInfoCode",re.getCode());//自动下转的code
|
|
|
json.put("thirdOrgCode",re.getHospitalCode());//自动下转的医院code
|
|
|
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
planDO.setPatient(patient.getId());
|
|
|
planDO.setName(patient.getName());
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
planDO.setPlanType(1);
|
|
|
planDO.setPayment(2);
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
planDO.setCreateTime(new Date());
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
planDO.setDisease(diseaseId);
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
// planDO.setTotalExpense();
|
|
|
StringBuilder results = new StringBuilder();
|
|
|
createRehabilitationPlanJson(json,signFamily,familyDoctor,results,doctor,re,bl);
|
|
|
|
|
|
//创建康复计划
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
String url = specialistUrl + "/svr-specialist/createPatientRehabilitationPlan";
|
|
|
params.add(new BasicNameValuePair("rehabilitationPlan", json.toString()));
|
|
|
result = httpClientUtil.post(url, params, "UTF-8");
|
|
|
rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
if (rejson == null) {
|
|
|
return "创建康复计划请求失败";
|
|
|
}
|
|
|
if (rejson.getInteger("status") != 200) {//创建康复计划不成功,无法下转
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
if (planDO == null) {//创建康复计划不成功,无法下转
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "创建康复计划请求失败:" + rejson.getInteger("status");
|
|
|
return "创建康复计划失败";
|
|
|
} else {//创建康复计划成功
|
|
|
JSONArray detailModelList = rejson.getJSONArray("detailModelList");
|
|
|
String planId = detailModelList.getJSONObject(0).getString("planId");
|
|
|
if(bl){
|
|
|
//厦心
|
|
|
asynService.createFollowJob(detailModelList,planId,signFamily);
|
|
|
}
|
|
|
String sql = "SELECT count(1) FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 \n" +
|
|
|
"and r.patient = '" + patient.getId() + "' \n" +
|
|
|
"and r.team_code = '" + teamId + "' limit 1 " ;
|
|
|
Integer relationCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String updateTime = df.format(date);
|
|
|
String planId = planDO.getId();
|
|
|
String relationId = " ";
|
|
|
if (relationCount == 0) {//与专科医生进行签约
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
} else {//修改签约信息
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
sql = "SELECT r.id FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 " +
|
|
|
"and r.patient = '" + patient.getId() + "' " +
|
|
|
"and r.team_code = '" + teamId + "'" ;
|
|
|
relationId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
sql = " delete FROM wlyy_specialist.`wlyy_specialist_patient_relation` where id='"+relationId+"' ";
|
|
|
runSqlNow(sql);
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
}
|
|
|
////创建患者疾病类型 wlyy_patient_disease_server
|
|
|
//获取id
|
|
|
PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
// PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
|
|
|
PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
|
|
|
patientDiseaseServerUp.setSpecialistRelationCode(relationId);
|
|
|
patientDiseaseServerUp.setPatient(patient.getId());
|
|
|
patientDiseaseServerUp.setPatientName(patient.getName());
|
|
|
patientDiseaseServerUp.setDisease(diseaseObj.getString("disease"));//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
patientDiseaseServerUp.setDisease(diseaseId);//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
|
|
|
patientDiseaseServerUp.setDel("1");
|
|
|
patientDiseaseServerUp.setUpdateTime(new Date());
|
|
|
patientDiseaseServerUp.setCreateTime(new Date());
|
|
|
|
|
|
if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
} else {
|
|
|
patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
}
|
|
|
// if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// } else {
|
|
|
// patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// }
|
|
|
//居民专科标签。
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
if (healthList.size() > 0) {
|
|
@ -476,14 +315,12 @@ public class SynchronizePatientService {
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
infoUpdate(tmpList,1,modifyList,signFamily);
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName"));
|
|
|
infoUpdate(tmpList,1,modifyList,planDoctor);
|
|
|
// logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName"));
|
|
|
//给服务医生群组发送下转消息
|
|
|
if (StringUtils.isNoneBlank(planId)){
|
|
|
asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
}
|
|
|
|
|
|
messageService.addSpecialistDynamicMessages(patient,doctor,familyDoctor,"下转成功",diseaseObj.getString("disease"),"1",null);
|
|
|
}
|
|
|
saveModifyList(modifyList);
|
|
|
}
|
|
@ -498,7 +335,6 @@ public class SynchronizePatientService {
|
|
|
|
|
|
//基卫补推送出院小结后,重新下转
|
|
|
public StringBuilder reSynchronizePation(String type,String hospital,String createTime) throws Exception{
|
|
|
setHospitalSyncDisease();
|
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
|
List<RehabilitationPatientInfoDO> rehabilitationPatientInfoDOs;
|
|
|
Date nowDate = DateUtil.strToDate(createTime);
|
|
@ -517,13 +353,9 @@ public class SynchronizePatientService {
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
for (RehabilitationPatientInfoDO re : rehabilitationPatientInfoDOs) {
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
boolean bl = false;//是否是厦心下转病人
|
|
|
if("12350200568420163H".equals(re.getHospitalCode())){
|
|
|
bl = true;
|
|
|
}
|
|
|
Date diagnoseTime = re.getDiagnoseTime();
|
|
|
//诊断时间为空或超过一个月 也不做下转
|
|
|
if (diagnoseTime==null&&!re.getHospitalCode().equals("12350200568420163H")){
|
|
|
if (diagnoseTime==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
@ -531,91 +363,74 @@ public class SynchronizePatientService {
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
//去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
if(re.getHospitalName().equals("厦门大学附属心血管病医院")&&StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
boolean isPatientExist = false;//判断医生康复下转列表中是否存在该患者,存在:不推送至未下转消息,不存在:推送下转消息。
|
|
|
String hospitalCode =getHospitalCode(re.getHospitalCode());
|
|
|
if(hospitalCode==null){
|
|
|
results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
DmHospitalDO hos = hospitalDao.findByCode(hospitalCode);
|
|
|
if(hos==null){
|
|
|
results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject diseaseObj = getHosSyncDiseaseInfo(hos.getCode(),StringUtils.isBlank(re.getProblemCode())?"":re.getProblemCode());//获取医院自动下转对应的疾病信息
|
|
|
if(diseaseObj==null){
|
|
|
results.append(re.getIdcard() + "--该《"+hos.getName()+"》医院暂未支持下转,医院code:" + hos.getCode() +"\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--该《"+hos.getName()+"》医院暂未支持下转,医院code:" + hos.getCode());
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
Integer teamCount = wlyyAdminTeamDao.findAcceptTeamCount(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
if (teamCount == 0) {//未找到该机构团队
|
|
|
results.append(re.getIdcard() + "--未找到该医院接收团队:" + re.getHospitalName() + ",疾病类型:"+diseaseObj.getString("diseaseName")+"\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--未找到该医院接收团队:" + re.getHospitalName() + ",疾病类型:"+diseaseObj.getString("diseaseName"));
|
|
|
continue;
|
|
|
}
|
|
|
Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
// AdminTeam adminTeam = wlyyAdminTeamDao.findAdminTeamById(teamId);//接收该病种团队
|
|
|
String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
|
|
|
//如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
|
|
|
String hospitalDoctor = re.getHospitalDoctor(); // 曾昭萍/350*******64
|
|
|
if (StringUtils.isNoneBlank(hospitalDoctor)){
|
|
|
String[] tmp = hospitalDoctor.split("/");
|
|
|
if (tmp.length==2){//存在唯一标识身份证
|
|
|
String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
|
|
|
" where doc.del=1 and doc.idcard='"+tmp[1]+"'";
|
|
|
List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
|
|
|
if (doctors.size()>0){
|
|
|
doctor = doctors.get(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
BasePatientDO patient = null;
|
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
continue;
|
|
|
}
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
if (patientService.addPaitentByIdcard(re.getIdcard()) == null) {
|
|
|
results.append("从健康档案添加居民:" + re.getIdcard() + "--同步患者请求失败\n");
|
|
|
logger.info("康复计划自动下转————" + "从健康档案添加居民:" + re.getIdcard() + "--同步患者请求失败");
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
patient = patientList.get(0);
|
|
|
String dept = re.getDept();
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
//或者三院专病配置
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName 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='1' 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){
|
|
|
results.append("未找到满足条件的专病配置\n");
|
|
|
continue;
|
|
|
}
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = diseaseList.get(0);
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
//推送i健康数据
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject.getInteger("status")!=-1){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
}
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
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;
|
|
|
}
|
|
|
// 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");
|
|
@ -628,61 +443,31 @@ public class SynchronizePatientService {
|
|
|
// }
|
|
|
continue;
|
|
|
}
|
|
|
int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
isPatientExist = true;//不推送下转消息
|
|
|
results.append(re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//添加下转居名
|
|
|
PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
patientDischargeDO.setType(2);//下转列表type==2
|
|
|
patientDischargeDO.setPatient(patient.getId());
|
|
|
patientDischargeDO.setName(patient.getName());
|
|
|
patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
patientDischargeDO.setSsc(patient.getSsc());
|
|
|
patientDischargeDO.setAddress(patient.getAddress());
|
|
|
patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
patientDischargeDO.setCreateTime(new Date());
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily != null) {//只有有签约信息 才能进行下转
|
|
|
patientDischargeDO.setSignStatus(1);
|
|
|
patientDischargeDO.setHospital(signFamily.getHospital());
|
|
|
patientDischargeDO.setHospitalName(signFamily.getHospitalName());
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
results.append(re.getIdcard() + "--添加至医生:"+doctor.getName()+" 的未下转列表,已家签\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--添加至医生:"+doctor.getName()+" 的未下转列表,已家签");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//无签约
|
|
|
patientDischargeDO.setSignStatus(0);
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
results.append(re.getIdcard() + "--添加至"+doctor.getName()+" 的未下转列表,待家签\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--添加至"+doctor.getName()+" 的未下转列表,待家签");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//厦心不推送消息
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
// }
|
|
|
//无家签 不再进行创建康复操作
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
// int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
// if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
// isPatientExist = true;//不推送下转消息
|
|
|
// results.append(re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态\n");
|
|
|
// logger.info("康复计划自动下转————" + re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态");
|
|
|
// infoUpdate(tmpList,6,modifyList,null);
|
|
|
// } else {//添加下转居名
|
|
|
// PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
// patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
// patientDischargeDO.setType(2);//下转列表type==2
|
|
|
// patientDischargeDO.setPatient(patient.getId());
|
|
|
// patientDischargeDO.setName(patient.getName());
|
|
|
// patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
// patientDischargeDO.setSsc(patient.getSsc());
|
|
|
// patientDischargeDO.setAddress(patient.getAddress());
|
|
|
// patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
// patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
// patientDischargeDO.setCreateTime(new Date());
|
|
|
// }
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//仅厦心进行自动下转至已下转 //厦心不推送消息
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
// continue;
|
|
|
// }
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily == null) {
|
|
|
results.append(re.getIdcard() + "--无签约信息,不做下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--无签约信息,不做下转");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
/**
|
|
|
* {
|
|
@ -701,7 +486,7 @@ public class SynchronizePatientService {
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
pmr.setHospital(hos.getCode());
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
}
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
@ -713,92 +498,22 @@ public class SynchronizePatientService {
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
String html = getEmrContentByRID(tem.getString("patient"),tem.getString("id"),tem.getString("orgCode"));
|
|
|
if (StringUtils.isNoneBlank(html)){
|
|
|
List<String> tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.in\" (.*?)</TD>");
|
|
|
String diagnosisIn =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisIn)){
|
|
|
try {
|
|
|
diagnosisIn =diagnosisIn.substring(diagnosisIn.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisIn="";
|
|
|
}
|
|
|
}
|
|
|
tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.out\" (.*?)</TD>");
|
|
|
String diagnosisOut =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisOut)){
|
|
|
try {
|
|
|
diagnosisOut =diagnosisOut.substring(diagnosisOut.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisOut="";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
}
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
if (tem.getString("dataFrom").equals("3"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
com.alibaba.fastjson.JSONObject zsResultData = zsRehabilitationInfoService.zsHospitalRecordDetail(tem.getString("patient"),tem.getString("id"));
|
|
|
if (zsResultData!=null){
|
|
|
if(zsResultData.containsKey("入院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("入院诊断"))){
|
|
|
pmr.setDischargeDiagnosisName(zsResultData.getString("入院诊断"));
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无入院诊断信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无入院诊断信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
if (zsResultData.containsKey("出院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("出院诊断"))){
|
|
|
pmr.setAdmittingDiagnosisName(zsResultData.getString("出院诊断"));
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无出院诊断信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无出院诊断信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" +"同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
// }
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
// }
|
|
|
}
|
|
|
pmr.setDiseaseCode(diseaseObj.getString("disease"));//疾病code
|
|
|
pmr.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
String jsonData = JSON.toJSONString(pmr);
|
|
|
|
|
|
//创建居民住院病历
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctor.getId(), patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
|
|
|
BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
|
|
|
logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
|
|
@ -808,116 +523,62 @@ public class SynchronizePatientService {
|
|
|
// }
|
|
|
continue;
|
|
|
} else {//
|
|
|
// com.alibaba.fastjson.JSONObject record = rejson.getJSONObject("data");
|
|
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
JSONObject json = new JSONObject();//创建康复计划json
|
|
|
json.put("patient", patient.getId());//患者code
|
|
|
json.put("name", patient.getName());//患者名称
|
|
|
json.put("title", patient.getName() + "的康复计划");//title
|
|
|
json.put("healthStatusCode", "2");//健康状态
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
planDO.setPatient(patient.getId());
|
|
|
planDO.setName(patient.getName());
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
planDO.setPlanType(1);
|
|
|
planDO.setPayment(2);
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
planDO.setCreateTime(new Date());
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
planDO.setDisease(diseaseId);
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
// planDO.setTotalExpense();
|
|
|
//目前默认为冠心病
|
|
|
json.put("disease", diseaseObj.getString("disease"));//疾病
|
|
|
json.put("diseaseName", diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
json.put("planType", 1);//
|
|
|
json.put("payment", 2);//
|
|
|
json.put("totalExpense", "");//
|
|
|
json.put("adviceContent", "出院继续观察");//
|
|
|
json.put("medicalRecordsCode", patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
json.put("teamCode", teamId);//
|
|
|
json.put("createUser", doctor.getId());
|
|
|
json.put("createUserName", doctor.getName());
|
|
|
json.put("patientInfoCode",re.getCode());//自动下转的code
|
|
|
json.put("thirdOrgCode",re.getHospitalCode());//自动下转的医院code
|
|
|
|
|
|
createRehabilitationPlanJson(json,signFamily,familyDoctor,results,doctor,re,bl);
|
|
|
|
|
|
//创建康复计划
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
String url = specialistUrl + "/svr-specialist/createPatientRehabilitationPlan";
|
|
|
params.add(new BasicNameValuePair("rehabilitationPlan", json.toString()));
|
|
|
result = httpClientUtil.post(url, params, "UTF-8");
|
|
|
rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
if (rejson == null) {
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败response==null\n");
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败response==null");
|
|
|
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;
|
|
|
}
|
|
|
if (rejson.getInteger("status") != 200) {//创建康复计划不成功,无法下转
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败Status:" + rejson.getInteger("status") + "\n");
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败Status:" + rejson.getInteger("status"));
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
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 {//创建康复计划成功
|
|
|
JSONArray detailModelList = rejson.getJSONArray("detailModelList");
|
|
|
String planId = detailModelList.getJSONObject(0).getString("planId");
|
|
|
if(bl){
|
|
|
//厦心
|
|
|
asynService.createFollowJob(detailModelList,planId,signFamily);
|
|
|
}
|
|
|
String sql = "SELECT count(1) FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 \n" +
|
|
|
"and r.patient = '" + patient.getId() + "' \n" +
|
|
|
"and r.team_code = '" + teamId + "' limit 1 " ;
|
|
|
// "and r.doctor= '" + doctor.getId() + "'";
|
|
|
Integer relationCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
String planId = planDO.getId();
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String updateTime = df.format(date);
|
|
|
String relationId = " ";
|
|
|
if (relationCount == 0) {//与专科医生进行签约
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
} else {//修改签约信息
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
sql = "SELECT r.id FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 " +
|
|
|
"and r.patient = '" + patient.getId() + "' " +
|
|
|
"and r.team_code = '" + teamId + "'" ;
|
|
|
relationId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
sql = " delete FROM wlyy_specialist.`wlyy_specialist_patient_relation` where id='"+relationId+"' ";
|
|
|
runSqlNow(sql);
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
}
|
|
|
////创建患者疾病类型 wlyy_patient_disease_server
|
|
|
//获取id
|
|
|
PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
// PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
|
|
|
PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
|
|
|
patientDiseaseServerUp.setSpecialistRelationCode(relationId);
|
|
|
patientDiseaseServerUp.setPatient(patient.getId());
|
|
|
patientDiseaseServerUp.setPatientName(patient.getName());
|
|
|
patientDiseaseServerUp.setDisease(diseaseObj.getString("disease"));//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
patientDiseaseServerUp.setDisease(diseaseId);//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
|
|
|
patientDiseaseServerUp.setDel("1");
|
|
|
patientDiseaseServerUp.setUpdateTime(new Date());
|
|
|
patientDiseaseServerUp.setCreateTime(new Date());
|
|
|
|
|
|
if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
} else {
|
|
|
patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
}
|
|
|
// if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// } else {
|
|
|
// patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// }
|
|
|
//居民专科标签。
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
if (healthList.size() > 0) {
|
|
@ -933,15 +594,14 @@ public class SynchronizePatientService {
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
infoUpdate(tmpList,1,modifyList,signFamily);
|
|
|
infoUpdate(tmpList,1,modifyList,null);
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),1);
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName")+"\n");
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName"));
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功\n");
|
|
|
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);
|
|
|
// if (StringUtils.isNoneBlank(planId)){
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -956,7 +616,6 @@ public class SynchronizePatientService {
|
|
|
|
|
|
//康复管理自动下转
|
|
|
public StringBuilder synchronizePation(String type) throws Exception {
|
|
|
setHospitalSyncDisease();
|
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
|
JSONArray successSync = new JSONArray();//存储下转信息
|
|
|
List<RehabilitationPatientInfoDO> rehabilitationPatientInfoDOs;
|
|
@ -976,13 +635,9 @@ public class SynchronizePatientService {
|
|
|
List<RehabilitationPatientInfoDO> modifyList = new ArrayList<>();
|
|
|
for (RehabilitationPatientInfoDO re : rehabilitationPatientInfoDOs) {
|
|
|
List<RehabilitationPatientInfoDO> tmpList = getPatientInfoList(re.getIdcard(),DateUtil.dateToStrShort(re.getCreateTime()));
|
|
|
boolean bl = false;//是否是厦心下转病人
|
|
|
if("12350200568420163H".equals(re.getHospitalCode())){
|
|
|
bl = true;
|
|
|
}
|
|
|
Date diagnoseTime = re.getDiagnoseTime();
|
|
|
//诊断时间为空或超过一个月 也不做下转
|
|
|
if (diagnoseTime==null&&!re.getHospitalCode().equals("12350200568420163H")){
|
|
|
if (diagnoseTime==null){
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
@ -991,90 +646,78 @@ public class SynchronizePatientService {
|
|
|
continue;
|
|
|
}
|
|
|
//去除智业获取的厦心患者,智业获取到的一定有problemCode
|
|
|
if(re.getHospitalName().equals("厦门大学附属心血管病医院")&&StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
if(StringUtils.isNoneBlank(re.getProblemCode())){
|
|
|
infoUpdate(tmpList,2,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
boolean isPatientExist = false;//判断医生康复下转列表中是否存在该患者,存在:不推送至未下转消息,不存在:推送下转消息。
|
|
|
String hospitalCode =getHospitalCode(re.getHospitalCode());
|
|
|
if(hospitalCode==null){
|
|
|
results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
DmHospitalDO hos = hospitalDao.findByCode(hospitalCode);
|
|
|
if(hos==null){
|
|
|
results.append(re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "---未查询到该医院----- "+re.getHospitalName()+",无法进行下转");
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject diseaseObj = getHosSyncDiseaseInfo(hos.getCode(),StringUtils.isBlank(re.getProblemCode())?"":re.getProblemCode());//获取医院自动下转对应的疾病信息
|
|
|
if(diseaseObj==null){
|
|
|
results.append(re.getIdcard() + "--该《"+hos.getName()+"》医院暂未支持下转,医院code:" + hos.getCode() +"\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--该《"+hos.getName()+"》医院暂未支持下转,医院code:" + hos.getCode());
|
|
|
infoUpdate(tmpList,4,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
Integer teamCount = wlyyAdminTeamDao.findAcceptTeamCount(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
if (teamCount == 0) {//未找到该机构团队
|
|
|
results.append(re.getIdcard() + "--未找到该医院接收团队:" + re.getHospitalName() + ",疾病类型:"+diseaseObj.getString("diseaseName")+"\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--未找到该医院接收团队:" + re.getHospitalName() + ",疾病类型:"+diseaseObj.getString("diseaseName"));
|
|
|
continue;
|
|
|
}
|
|
|
Long teamId = wlyyAdminTeamDao.findTeamID(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
// AdminTeam adminTeam = wlyyAdminTeamDao.findAdminTeamById(teamId);//接收该病种团队
|
|
|
String leaderCode = wlyyAdminTeamDao.findTeamLeader(diseaseObj.getString("disease"), 0, hos.getCode());
|
|
|
BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
|
|
|
//如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
|
|
|
String hospitalDoctor = re.getHospitalDoctor(); // 曾昭萍/350*******64
|
|
|
if (StringUtils.isNoneBlank(hospitalDoctor)){
|
|
|
String[] tmp = hospitalDoctor.split("/");
|
|
|
if (tmp.length==2){//存在唯一标识身份证
|
|
|
String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
|
|
|
" where doc.del=1 and doc.idcard='"+tmp[1]+"'";
|
|
|
List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
|
|
|
if (doctors.size()>0){
|
|
|
doctor = doctors.get(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
BasePatientDO patient = null;
|
|
|
if(StringUtils.isBlank(re.getIdcard())){
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
continue;
|
|
|
}
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
if (patientService.addPaitentByIdcard(re.getIdcard()) == null) {
|
|
|
results.append("从健康档案添加居民:" + re.getIdcard() + "--同步患者请求失败\n");
|
|
|
logger.info("康复计划自动下转————" + "从健康档案添加居民:" + re.getIdcard() + "--同步患者请求失败");
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
String dept = re.getDept();
|
|
|
String diagnosis = re.getDiagnosis();
|
|
|
//或者三院专病配置
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName 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='1' 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){
|
|
|
results.append("未找到满足条件的专病配置\n");
|
|
|
continue;
|
|
|
}
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = diseaseList.get(0);
|
|
|
if(planTemplateDO.getIsFamily()==1){
|
|
|
//推送i健康数据
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject.getInteger("status")!=-1){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
}
|
|
|
patient = patientList.get(0);
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
|
String planTemplateId = planTemplateDO.getId();
|
|
|
String planDoctorId = planTemplateDO.getPlanDoctor();//计划负责人
|
|
|
BaseDoctorDO planDoctor = doctorDao.findByIdAndDel(planDoctorId);
|
|
|
|
|
|
//同步病历 //如果同步病历失败,不做下转
|
|
|
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;
|
|
|
}
|
|
|
// 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");
|
|
@ -1087,61 +730,31 @@ public class SynchronizePatientService {
|
|
|
// }
|
|
|
continue;
|
|
|
}
|
|
|
int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
isPatientExist = true;//不推送下转消息
|
|
|
results.append(re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//添加下转居名
|
|
|
PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
patientDischargeDO.setType(2);//下转列表type==2
|
|
|
patientDischargeDO.setPatient(patient.getId());
|
|
|
patientDischargeDO.setName(patient.getName());
|
|
|
patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
patientDischargeDO.setSsc(patient.getSsc());
|
|
|
patientDischargeDO.setAddress(patient.getAddress());
|
|
|
patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
patientDischargeDO.setCreateTime(new Date());
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily != null) {//只有有签约信息 才能进行下转
|
|
|
patientDischargeDO.setSignStatus(1);
|
|
|
patientDischargeDO.setHospital(signFamily.getHospital());
|
|
|
patientDischargeDO.setHospitalName(signFamily.getHospitalName());
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
results.append(re.getIdcard() + "--添加至医生:"+doctor.getName()+" 的未下转列表,已家签\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--添加至医生:"+doctor.getName()+" 的未下转列表,已家签");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
} else {//无签约
|
|
|
patientDischargeDO.setSignStatus(0);
|
|
|
patientDischargeDao.save(patientDischargeDO);
|
|
|
results.append(re.getIdcard() + "--添加至"+doctor.getName()+" 的未下转列表,待家签\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--添加至"+doctor.getName()+" 的未下转列表,待家签");
|
|
|
infoUpdate(tmpList,6,modifyList,null);
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//厦心不推送消息
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
// }
|
|
|
//无家签 不再进行创建康复操作
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
// int count = patientDischargeDao.isPatientExist(patient.getIdcard(), doctor.getId());//判断康复计划表是否已存该居名
|
|
|
// if (count > 0) {//该患者已存在该团队中 修改分配状态
|
|
|
// isPatientExist = true;//不推送下转消息
|
|
|
// results.append(re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态\n");
|
|
|
// logger.info("康复计划自动下转————" + re.getIdcard() + "--患者已存于医生:"+doctor.getName()+"康复下转列表中,修改分配状态");
|
|
|
// infoUpdate(tmpList,6,modifyList,null);
|
|
|
// } else {//添加下转居名
|
|
|
// PatientDischargeDO patientDischargeDO = new PatientDischargeDO();
|
|
|
// patientDischargeDO.setCode(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
// patientDischargeDO.setType(2);//下转列表type==2
|
|
|
// patientDischargeDO.setPatient(patient.getId());
|
|
|
// patientDischargeDO.setName(patient.getName());
|
|
|
// patientDischargeDO.setIdcard(patient.getIdcard());
|
|
|
// patientDischargeDO.setSsc(patient.getSsc());
|
|
|
// patientDischargeDO.setAddress(patient.getAddress());
|
|
|
// patientDischargeDO.setCreateUser(doctor.getId());
|
|
|
// patientDischargeDO.setCreateUserName(doctor.getName());
|
|
|
// patientDischargeDO.setCreateTime(new Date());
|
|
|
// }
|
|
|
// if (!needCreateRehabilitationPlan(hos.getCode())) {//仅厦心进行自动下转至已下转 //厦心不推送消息
|
|
|
// if(!isPatientExist){//患者不存在与医生原有的康复列表中,添加推送消息
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),0);
|
|
|
// }
|
|
|
// continue;
|
|
|
// }
|
|
|
SignFamily signFamily = signFamilyDao.getExpensesSignByIdcard(patient.getIdcard());
|
|
|
if (signFamily == null) {
|
|
|
results.append(re.getIdcard() + "--无签约信息,不做下转\n");
|
|
|
logger.info("康复计划自动下转————" + re.getIdcard() + "--无签约信息,不做下转");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
/**
|
|
|
* {
|
|
@ -1160,7 +773,7 @@ public class SynchronizePatientService {
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
pmr.setHospital(hos.getCode());
|
|
|
// pmr.setHospital(hos.getCode());
|
|
|
}
|
|
|
pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
pmr.setDischargeDiagnosisName(re.getDiagnosisName());
|
|
@ -1172,92 +785,22 @@ public class SynchronizePatientService {
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
String html = getEmrContentByRID(tem.getString("patient"),tem.getString("id"),tem.getString("orgCode"));
|
|
|
if (StringUtils.isNoneBlank(html)){
|
|
|
List<String> tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.in\" (.*?)</TD>");
|
|
|
String diagnosisIn =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisIn)){
|
|
|
try {
|
|
|
diagnosisIn =diagnosisIn.substring(diagnosisIn.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisIn="";
|
|
|
}
|
|
|
}
|
|
|
tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.out\" (.*?)</TD>");
|
|
|
String diagnosisOut =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNotBlank(diagnosisOut)){
|
|
|
try {
|
|
|
diagnosisOut =diagnosisOut.substring(diagnosisOut.indexOf('>')+1);
|
|
|
}catch (Exception e){
|
|
|
diagnosisOut="";
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
}
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
if (tem.getString("dataFrom").equals("3"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
com.alibaba.fastjson.JSONObject zsResultData = zsRehabilitationInfoService.zsHospitalRecordDetail(tem.getString("patient"),tem.getString("id"));
|
|
|
if (zsResultData!=null){
|
|
|
if(zsResultData.containsKey("入院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("入院诊断"))){
|
|
|
pmr.setDischargeDiagnosisName(zsResultData.getString("入院诊断"));
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无入院诊断信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无入院诊断信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
if (zsResultData.containsKey("出院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("出院诊断"))){
|
|
|
pmr.setAdmittingDiagnosisName(zsResultData.getString("出院诊断"));
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无出院诊断信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无出院诊断信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}else {
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" +"同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
results.append("同步患者病历:" + re.getIdcard() + "----无住院病历详情信息\n");
|
|
|
logger.info("康复计划自动下转————" + "同步患者病历:" + re.getIdcard() + "----无住院病历详情信息");
|
|
|
infoUpdate(tmpList,3,modifyList,null);
|
|
|
continue;
|
|
|
}
|
|
|
// if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
// pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
// }
|
|
|
// if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
// pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
// }
|
|
|
}
|
|
|
pmr.setDiseaseCode(diseaseObj.getString("disease"));//疾病code
|
|
|
pmr.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
pmr.setDiseaseCode(diseaseId);//疾病code
|
|
|
pmr.setDiseaseName(diseaseName);//疾病名称
|
|
|
String jsonData = JSON.toJSONString(pmr);
|
|
|
|
|
|
//创建居民住院病历
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctor.getId(), patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(planDoctorId, patient.getId(), patient.getName(), patientMedicalRecordsDO, null);
|
|
|
|
|
|
BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
|
|
|
if (patientMedicalRecordsDO1 == null) {
|
|
|
results.append("创建病历请求:" + re.getIdcard() + "----创建病历失败\n");
|
|
|
logger.info("康复计划自动下转————" + "创建病历请求:" + re.getIdcard() + "----创建病历失败");
|
|
@ -1267,116 +810,59 @@ public class SynchronizePatientService {
|
|
|
// }
|
|
|
continue;
|
|
|
} else {//
|
|
|
// com.alibaba.fastjson.JSONObject record = rejson.getJSONObject("data");
|
|
|
|
|
|
// ↓创建康复计划。创建完成即为已下转
|
|
|
JSONObject json = new JSONObject();//创建康复计划json
|
|
|
json.put("patient", patient.getId());//患者code
|
|
|
json.put("name", patient.getName());//患者名称
|
|
|
json.put("title", patient.getName() + "的康复计划");//title
|
|
|
json.put("healthStatusCode", "2");//健康状态
|
|
|
PatientRehabilitationPlanDO planDO = new PatientRehabilitationPlanDO();
|
|
|
planDO.setStatus(3);//待分配 执行医生和科室
|
|
|
planDO.setPatient(patient.getId());
|
|
|
planDO.setName(patient.getName());
|
|
|
planDO.setTitle(patient.getName()+"的康复计划");
|
|
|
planDO.setHealthStatusCode("2");
|
|
|
planDO.setPlanType(1);
|
|
|
planDO.setPayment(2);
|
|
|
planDO.setAdviceContent("出院继续观察");
|
|
|
planDO.setMedicalRecordsCode(patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
planDO.setPlanDoctor(planDoctorId);
|
|
|
planDO.setPlanDoctorName(planDoctor.getName());
|
|
|
planDO.setPatientInfoCode(re.getCode());
|
|
|
planDO.setCreateTime(new Date());
|
|
|
planDO.setUpdateTime(new Date());
|
|
|
planDO.setDisease(diseaseId);
|
|
|
planDO.setDiseaseName(diseaseName);
|
|
|
// planDO.setTotalExpense();
|
|
|
//目前默认为冠心病
|
|
|
json.put("disease", diseaseObj.getString("disease"));//疾病
|
|
|
json.put("diseaseName", diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
json.put("planType", 1);//
|
|
|
json.put("payment", 2);//
|
|
|
json.put("totalExpense", "");//
|
|
|
json.put("adviceContent", "出院继续观察");//
|
|
|
json.put("medicalRecordsCode", patientMedicalRecordsDO1.getCode());//居民住院病历code
|
|
|
json.put("teamCode", teamId);//
|
|
|
json.put("createUser", doctor.getId());
|
|
|
json.put("createUserName", doctor.getName());
|
|
|
json.put("patientInfoCode",re.getCode());//自动下转的code
|
|
|
json.put("thirdOrgCode",re.getHospitalCode());//自动下转的医院code
|
|
|
|
|
|
createRehabilitationPlanJson(json,signFamily,familyDoctor,results,doctor,re,bl);
|
|
|
|
|
|
//创建康复计划
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
String url = specialistUrl + "/svr-specialist/createPatientRehabilitationPlan";
|
|
|
params.add(new BasicNameValuePair("rehabilitationPlan", json.toString()));
|
|
|
result = httpClientUtil.post(url, params, "UTF-8");
|
|
|
rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
if (rejson == null) {
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败response==null\n");
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败response==null");
|
|
|
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;
|
|
|
}
|
|
|
if (rejson.getInteger("status") != 200) {//创建康复计划不成功,无法下转
|
|
|
results.append("创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败Status:" + rejson.getInteger("status") + "\n");
|
|
|
logger.info("康复计划自动下转————" + "创建康复计划请求:" + re.getIdcard() + "----创建康复计划请求失败Status:" + rejson.getInteger("status"));
|
|
|
planDO = createRehabilitationPlanJson(planDO,planTemplateId,results,re);
|
|
|
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 {//创建康复计划成功
|
|
|
JSONArray detailModelList = rejson.getJSONArray("detailModelList");
|
|
|
String planId = detailModelList.getJSONObject(0).getString("planId");
|
|
|
if(bl){
|
|
|
//厦心
|
|
|
asynService.createFollowJob(detailModelList,planId,signFamily);
|
|
|
}
|
|
|
String sql = "SELECT count(1) FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 \n" +
|
|
|
"and r.patient = '" + patient.getId() + "' \n" +
|
|
|
"and r.team_code = '" + teamId + "' limit 1 " ;
|
|
|
// "and r.doctor= '" + doctor.getId() + "'";
|
|
|
Integer relationCount = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
Date date = new Date();
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String updateTime = df.format(date);
|
|
|
String relationId = " ";
|
|
|
if (relationCount == 0) {//与专科医生进行签约
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
} else {//修改签约信息
|
|
|
String doctorNameEnc = TransforSqlUtl.encryptContent(doctor.getName());
|
|
|
String pName = TransforSqlUtl.encryptContent(patient.getName());
|
|
|
sql = "SELECT r.id FROM wlyy_specialist.`wlyy_specialist_patient_relation` r \n" +
|
|
|
"where r.sign_status = 1 and r.status >= 0 " +
|
|
|
"and r.patient = '" + patient.getId() + "' " +
|
|
|
"and r.team_code = '" + teamId + "'" ;
|
|
|
relationId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
sql = " delete FROM wlyy_specialist.`wlyy_specialist_patient_relation` where id='"+relationId+"' ";
|
|
|
runSqlNow(sql);
|
|
|
relationId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
sql = "INSERT INTO wlyy_specialist.wlyy_specialist_patient_relation (id,doctor,doctor_name,patient,patient_name,team_code,sign_status,status, " +
|
|
|
"sign_year,sign_date,create_time,create_user,create_user_name,update_time,disease_code) " +
|
|
|
"VALUES('" + relationId + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + patient.getId() + "','" + pName + "'," + teamId + ",'1','1', " +
|
|
|
"'" + DateUtil.getSignYear() + "','" + updateTime + "','" + updateTime + "','" + doctor.getId() + "','" + doctorNameEnc + "','" + updateTime + "','"+diseaseObj.getString("disease")+"')";
|
|
|
runSqlNow(sql);
|
|
|
}
|
|
|
String planId = planDO.getId();
|
|
|
////创建患者疾病类型 wlyy_patient_disease_server
|
|
|
String relationId = "";
|
|
|
//获取id
|
|
|
PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
// PatientDiseaseServer patientDiseaseServer = patientDiseaseServerDao.findBySpecialistRelationCodeAndDiseaseAndCode(relationId,diseaseObj.getString("disease"), "1");
|
|
|
|
|
|
PatientDiseaseServer patientDiseaseServerUp = new PatientDiseaseServer();
|
|
|
patientDiseaseServerUp.setSpecialistRelationCode(relationId);
|
|
|
patientDiseaseServerUp.setPatient(patient.getId());
|
|
|
patientDiseaseServerUp.setPatientName(patient.getName());
|
|
|
patientDiseaseServerUp.setDisease(diseaseObj.getString("disease"));//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
patientDiseaseServerUp.setDisease(diseaseId);//疾病
|
|
|
patientDiseaseServerUp.setDiseaseName(diseaseName);//疾病名称
|
|
|
patientDiseaseServerUp.setDel("1");
|
|
|
patientDiseaseServerUp.setUpdateTime(new Date());
|
|
|
patientDiseaseServerUp.setCreateTime(new Date());
|
|
|
|
|
|
if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
} else {
|
|
|
patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
}
|
|
|
// if (patientDiseaseServer == null) {//创建疾病类型
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// } else {
|
|
|
// patientDiseaseServerDao.updateBySpecialistRelationCodeAndDel(relationId);
|
|
|
// patientDiseaseServerDao.save(patientDiseaseServerUp);
|
|
|
// }
|
|
|
//居民专科标签。
|
|
|
List<SignPatientLabelInfo> healthList = signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(patient.getId(), "8", 1);
|
|
|
if (healthList.size() > 0) {
|
|
@ -1392,23 +878,17 @@ public class SynchronizePatientService {
|
|
|
signPatientLabelInfo.setStatus(1);
|
|
|
signPatientLabelInfo.setCzrq(new Date());
|
|
|
signPatientLabelInfoDao.save(signPatientLabelInfo);
|
|
|
infoUpdate(tmpList,1,modifyList,signFamily);
|
|
|
// successSync = addSyncPatientInfo(successSync, doctor.getId(), doctor.getName(), teamId, adminTeam.getName(), hos.getCode(), hos.getName(), patient.getId(),1);
|
|
|
results.append("下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName")+"\n");
|
|
|
logger.info("康复计划自动下转————" +"下转结束:" + re.getIdcard() + "----下转成功,已转至医生:"+doctor.getName()+"《"+hos.getName()+"》的已下转列表,下转疾病:"+diseaseObj.getString("diseaseName"));
|
|
|
infoUpdate(tmpList,1,modifyList,planDoctor);
|
|
|
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);
|
|
|
// if (StringUtils.isNoneBlank(planId)){
|
|
|
// asynService.sendMsg(planId,signFamily,patient,doctor,patientMedicalRecordsDO1,re);
|
|
|
// }
|
|
|
// messageService.addSpecialistDynamicMessages(patient,doctor,familyDoctor,"下转成功",diseaseObj.getString("disease"),"1",null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// for (int i = 0; i < successSync.size(); i++) {
|
|
|
// JSONObject syncObject = (JSONObject) successSync.get(i);
|
|
|
// sendMessageToDoctor(syncObject);//APP端发送消息通知
|
|
|
// sendMessageToDoctorTemplates(syncObject);//i健康助手发送消息通知
|
|
|
// }
|
|
|
rehabilitationPatientInfoDao.saveAll(modifyList);
|
|
|
return results;
|
|
|
}
|
|
@ -1416,466 +896,53 @@ public class SynchronizePatientService {
|
|
|
/**
|
|
|
* 创建康复计划json
|
|
|
*/
|
|
|
public JSONArray createRehabilitationPlanJson(JSONObject json, SignFamily signFamily, BaseDoctorDO familyDoctor, StringBuilder results
|
|
|
, BaseDoctorDO doctor, RehabilitationPatientInfoDO re, Boolean bl) throws Exception{
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
//获取系统默认的康复模板
|
|
|
String sql = "select id from wlyy_specialist.wlyy_rehabilitation_plan_template where title='系统模板'";
|
|
|
String templateId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
sql = "select hospital_service_item_id as code, execute_times as executeTimes,frequency_code as frequencyCode,time_type as timeType,\n" +
|
|
|
"remark,expense\n" +
|
|
|
"from wlyy_specialist.wlyy_rehabilitation_template_detail where template_id = '" + templateId + "'";
|
|
|
List<Map<String, Object>> templateDetail = jdbcTemplate.queryForList(sql);
|
|
|
public PatientRehabilitationPlanDO createRehabilitationPlanJson(PatientRehabilitationPlanDO planDO, String planTemplateId,StringBuilder results
|
|
|
, RehabilitationPatientInfoDO re) 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");
|
|
|
} else {
|
|
|
org.json.JSONArray detailArray = new org.json.JSONArray();
|
|
|
for (Map<String, Object> templateMap : templateDetail) {
|
|
|
JSONObject detail = new JSONObject();//创建康复计划detail
|
|
|
if (templateMap.get("code").toString().equals("1")) {//电话关怀,下转隔天,执行医生未家庭医生
|
|
|
detail.put("hospitalServiceItemId", templateMap.get("code").toString());//机构服务id
|
|
|
detail.put("type", 1);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", signFamily.getDoctor());//医生编码
|
|
|
detail.put("doctorName", signFamily.getDoctorName());//
|
|
|
Date date = DateUtil.getPreDays(new Date(), 1);
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String executeTimes = df.format(date) + " 10:00:00";
|
|
|
//BaseDoctorDO familyDoctor = doctorDao.findByCode(signFamily.getDoctor());
|
|
|
detail.put("executeTime", executeTimes);
|
|
|
detail.put("frequencyCode", "qd_10");// 1次/天:10:00
|
|
|
detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
|
|
|
detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
|
|
|
detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
|
|
|
//先注释-20231013
|
|
|
// detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
|
|
|
// detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
|
|
|
detailArray.put(detail);
|
|
|
}else if(bl&&("6".equals(templateMap.get("code").toString())||"7".equals(templateMap.get("code").toString()))){
|
|
|
//判断厦心出转病人,创建复诊计划
|
|
|
if("7".equals(templateMap.get("code").toString())){
|
|
|
//自动创建后1周(7天)、1个月(30天)、3个月(90天)、6个月(180天)及1年(365天)复诊计划(仅针对厦心出院下转的居民),
|
|
|
//执行人为家庭医生,类型为线下复诊
|
|
|
// org.json.JSONArray detailArray = new org.json.JSONArray();
|
|
|
int[] dayArray = new int[]{7,30,90,180,365};
|
|
|
List<String> timeList = DateUtil.getDaysByNow(dayArray);
|
|
|
|
|
|
for (String t : timeList) {
|
|
|
detail = new JSONObject();//创建康复计划detail
|
|
|
detail.put("hospitalServiceItemId","7");//机构服务id,写死康复复诊
|
|
|
detail.put("type", 1);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", signFamily.getDoctor());//医生编码
|
|
|
detail.put("doctorName", signFamily.getDoctorName());//
|
|
|
detail.put("executeTime",t+" 10:00:00");
|
|
|
detail.put("frequencyCode", "qd_10");// 1次/天:10:00
|
|
|
detail.put("timeType", 0);//
|
|
|
detail.put("remark", "");//
|
|
|
detail.put("expense", 0);//
|
|
|
//先注释-20231013
|
|
|
// detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
|
|
|
// detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
|
|
|
detail.put("reservationType",2);//复诊类型:1线上,2线下,3远程
|
|
|
detailArray.put(detail);
|
|
|
}
|
|
|
}else{
|
|
|
int[] dayArray2 = new int[]{58,118,148,207,238,268,298,328};
|
|
|
List<String> dayList = DateUtil.getDaysByNow(dayArray2);
|
|
|
for (String d : dayList) {
|
|
|
//创建一条康复随访
|
|
|
detail = new JSONObject();//创建康复计划detail
|
|
|
detail.put("hospitalServiceItemId","6");//机构服务id,写死康复随访(社区)
|
|
|
detail.put("type", 1);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", signFamily.getDoctor());//医生编码
|
|
|
detail.put("doctorName", signFamily.getDoctorName());//
|
|
|
detail.put("executeTime",d+" 10:00:00");
|
|
|
detail.put("followupDetailType",1);//默认0,1是冠心病社区表单
|
|
|
detail.put("frequencyCode", "qd_10");// 1次/天:10:00
|
|
|
detail.put("timeType", 0);//
|
|
|
detail.put("remark", "");//
|
|
|
detail.put("expense", 0);//
|
|
|
//先注释-20231013
|
|
|
// detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
|
|
|
// detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
|
|
|
detail.put("reservationType",2);//复诊类型:1线上,2线下,3远程
|
|
|
detailArray.put(detail);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
detail.put("hospitalServiceItemId", templateMap.get("code").toString());//机构服务id
|
|
|
detail.put("type", 2);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", doctor.getId());//医生编码
|
|
|
detail.put("doctorName", doctor.getName());//
|
|
|
if (templateMap.get("executeTimes") != null && templateMap.get("frequencyCode") != null) {
|
|
|
String executeTimes = templateMap.get("executeTimes").toString();
|
|
|
String frequencyCode = templateMap.get("frequencyCode").toString();
|
|
|
if (StringUtils.isNotBlank(executeTimes) && StringUtils.isNoneBlank(frequencyCode)) {
|
|
|
Frequency frequency = frequencyDao.findByCode(frequencyCode);
|
|
|
List<String> list = new ArrayList<>();
|
|
|
String[] executeTime = executeTimes.split(",");
|
|
|
for (int i = 0; i < executeTime.length; i++) {
|
|
|
List<String> times = rehabilitationPlanService.getFrequencyDate(frequency.getCode(), executeTime[i], frequency.getUnit(), frequency.getTime(), Long.parseLong(templateMap.get("timeType").toString()));
|
|
|
for (int j = 0; j < times.size(); j++) {
|
|
|
if (list != null && list.size() != 0) {
|
|
|
if (!list.contains(times.get(j))) {
|
|
|
list.add(times.get(j));
|
|
|
}
|
|
|
} else {
|
|
|
list.add(times.get(j));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
if (list != null && list.size() != 0) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
buffer.append(list.get(i) + ",");
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(buffer)) {
|
|
|
buffer.deleteCharAt(buffer.length() - 1);
|
|
|
}
|
|
|
}
|
|
|
detail.put("executeTime", buffer);
|
|
|
}
|
|
|
}
|
|
|
detail.put("frequencyCode", templateMap.get("frequencyCode") == null ? "" : templateMap.get("frequencyCode").toString());//
|
|
|
detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
|
|
|
detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
|
|
|
detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
|
|
|
//先注释20231013
|
|
|
// detail.put("hospital", doctor.getHospital());
|
|
|
// detail.put("hospitalName", doctor.getHospitalName());
|
|
|
detailArray.put(detail);
|
|
|
}
|
|
|
}
|
|
|
json.put("detail", detailArray);
|
|
|
}
|
|
|
|
|
|
return jsonArray;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 厦心康复下转数据修复
|
|
|
* 1 生成普通康复计划服务项
|
|
|
* 2 康复随访自动创建社区随访表单
|
|
|
*/
|
|
|
public void fixData(){
|
|
|
String sql = "SELECT DISTINCT p.id,p.patient,pi.hospital_doctor from \n" +
|
|
|
"wlyy_specialist.wlyy_patient_rehabilitation_plan p LEFT JOIN wlyy.wlyy_patient pa on p.patient=pa.code and pa.`status`=1\n" +
|
|
|
"LEFT JOIN wlyy.wlyy_rehabilitation_patient_info pi on pi.idcard = pa.idcard and pi.create_time>'2022-07-01' and pi.`status`=1,\n" +
|
|
|
"wlyy.wlyy_doctor d\n" +
|
|
|
"WHERE p.create_user = d.code and d.hospital = '97fbc7707643471b8458-6def1ff92496' and p.patient!='b72ea6741bb64251912016c0937a7baa'\n" +
|
|
|
"and p.create_time>'2022-08-06' and p.create_time<'2022-08-09 14:55:00'\n" +
|
|
|
" ORDER BY p.create_time desc";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map : list){
|
|
|
String planId = map.get("id")+"";
|
|
|
String patient = map.get("patient")+"";
|
|
|
String hospital_doctor = map.get("hospital_doctor")+"";
|
|
|
fixOneData(planId,patient,hospital_doctor);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void fixOneData(String planId,String patient,String hospitalDoctor){
|
|
|
try {
|
|
|
JSONObject json = new JSONObject();//创建康复计划json
|
|
|
json.put("id", planId);
|
|
|
|
|
|
SignFamily signFamily = signFamilyDao.findByPatient(patient);
|
|
|
BaseDoctorDO familyDoctor = doctorDao.findById(signFamily.getDoctor()).orElse(null);
|
|
|
Long teamId = wlyyAdminTeamDao.findTeamID("3", 0, "97fbc7707643471b8458-6def1ff92496");
|
|
|
String leaderCode = wlyyAdminTeamDao.findTeamLeader("3", 0, "97fbc7707643471b8458-6def1ff92496");
|
|
|
BaseDoctorDO doctor = doctorDao.findById(leaderCode).orElse(null);
|
|
|
//如果存在转诊医生 且该医生存在于接受团队中,下转至该医生列表下
|
|
|
if (StringUtils.isNoneBlank(hospitalDoctor)){
|
|
|
String[] tmp = hospitalDoctor.split("/");
|
|
|
if (tmp.length==2){//存在唯一标识身份证
|
|
|
String sql =" select doc.* from wlyy_doctor doc INNER JOIN wlyy_admin_team_member tm ON doc.`code` = tm.doctor_code and team_id='"+teamId+"' and available=1 \n" +
|
|
|
" where doc.del=1 and doc.idcard='"+tmp[1]+"'";
|
|
|
List<BaseDoctorDO> doctors = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseDoctorDO.class));
|
|
|
if (doctors.size()>0){
|
|
|
doctor = doctors.get(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
json.put("createUser", doctor.getId());
|
|
|
json.put("createUserName", doctor.getName());
|
|
|
fixCreateRehabilitationPlanJson(json,signFamily,familyDoctor,doctor);
|
|
|
|
|
|
//创建康复计划
|
|
|
List<NameValuePair> params = new ArrayList<>();
|
|
|
String url = specialistUrl + "/svr-specialist/createRehabilitationDetail";
|
|
|
params.add(new BasicNameValuePair("rehabilitationPlan", json.toString()));
|
|
|
String result = httpClientUtil.post(url, params, "UTF-8");
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
if (rejson.getInteger("status") == 200) {
|
|
|
logger.info("修复成功:"+signFamily.getIdcard());
|
|
|
//创建冠心病社区随访表单
|
|
|
String sql = "SELECT id,DATE_FORMAT(execute_time,'%Y-%m-%d %H:%i:%s') execute_time from wlyy_specialist.wlyy_rehabilitation_plan_detail \n" +
|
|
|
"WHERE plan_id = '"+planId+"' and hospital_service_item_id ='6' and relation_code is null";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:list){
|
|
|
String detailId = map.get("id")+"";
|
|
|
String executeTime = map.get("execute_time")+"";
|
|
|
|
|
|
//创建康复随访
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("date",executeTime);
|
|
|
data.put("type","2");
|
|
|
data.put("doctor",signFamily.getDoctor());
|
|
|
data.put("followupClass","21");
|
|
|
data.put("type1","1");
|
|
|
data.put("id",detailId);
|
|
|
|
|
|
JSONObject dataJson = new JSONObject();
|
|
|
dataJson.put("rehabilitationDetailId",detailId);
|
|
|
dataJson.put("patientCode",signFamily.getPatient());
|
|
|
dataJson.put("patientName",signFamily.getName());
|
|
|
dataJson.put("doctorCode",signFamily.getDoctor());
|
|
|
dataJson.put("doctorName",signFamily.getDoctorName());
|
|
|
dataJson.put("relationRecordType",5);
|
|
|
dataJson.put("relationRecordCode","");
|
|
|
dataJson.put("status",0);
|
|
|
try {
|
|
|
followUpService.addFollowupPlanNew(signFamily.getDoctor(),signFamily.getPatient(),data,dataJson.toString());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
logger.info("修复失败:"+planId);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 创建康复计划json
|
|
|
*/
|
|
|
public void fixCreateRehabilitationPlanJson(JSONObject json, SignFamily signFamily, BaseDoctorDO familyDoctor
|
|
|
, BaseDoctorDO doctor) throws Exception{
|
|
|
//获取系统默认的康复模板
|
|
|
String sql = "select id from wlyy_specialist.wlyy_rehabilitation_plan_template where title='系统模板'";
|
|
|
String templateId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
sql = "select hospital_service_item_id as code, execute_times as executeTimes,frequency_code as frequencyCode,time_type as timeType,\n" +
|
|
|
"remark,expense\n" +
|
|
|
"from wlyy_specialist.wlyy_rehabilitation_template_detail where template_id = '" + templateId + "'";
|
|
|
List<Map<String, Object>> templateDetail = jdbcTemplate.queryForList(sql);
|
|
|
if (templateDetail.size() == 0) {
|
|
|
logger.info("系统默认的康复模板请求:" + signFamily.getIdcard() + "----系统默认的康复模板为空,请手动进行下转\n");
|
|
|
} else {
|
|
|
org.json.JSONArray detailArray = new org.json.JSONArray();
|
|
|
for (Map<String, Object> templateMap : templateDetail) {
|
|
|
JSONObject detail = new JSONObject();//创建康复计划detail
|
|
|
if (templateMap.get("code").toString().equals("1")) {//电话关怀,下转隔天,执行医生未家庭医生
|
|
|
detail.put("hospitalServiceItemId", templateMap.get("code").toString());//机构服务id
|
|
|
detail.put("type", 1);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", signFamily.getDoctor());//医生编码
|
|
|
detail.put("doctorName", signFamily.getDoctorName());//
|
|
|
Date date = DateUtil.getPreDays(new Date(), 1);
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String executeTimes = df.format(date) + " 10:00:00";
|
|
|
//BaseDoctorDO familyDoctor = doctorDao.findByCode(signFamily.getDoctor());
|
|
|
detail.put("executeTime", executeTimes);
|
|
|
detail.put("frequencyCode", "qd_10");// 1次/天:10:00
|
|
|
detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
|
|
|
detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
|
|
|
detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
|
|
|
//先注释20231013
|
|
|
// detail.put("hospital", familyDoctor.getHospital());//执行医生hospital
|
|
|
// detail.put("hospitalName", familyDoctor.getHospitalName());//执行医生hospital_name
|
|
|
detailArray.put(detail);
|
|
|
}else if("6".equals(templateMap.get("code").toString())||"7".equals(templateMap.get("code").toString())){
|
|
|
|
|
|
} else {
|
|
|
detail.put("hospitalServiceItemId", templateMap.get("code").toString());//机构服务id
|
|
|
detail.put("type", 2);//执行者类型(1家医团队,2专科团队)
|
|
|
detail.put("doctor", doctor.getId());//医生编码
|
|
|
detail.put("doctorName", doctor.getName());//
|
|
|
if (templateMap.get("executeTimes") != null && templateMap.get("frequencyCode") != null) {
|
|
|
String executeTimes = templateMap.get("executeTimes").toString();
|
|
|
String frequencyCode = templateMap.get("frequencyCode").toString();
|
|
|
if (StringUtils.isNotBlank(executeTimes) && StringUtils.isNoneBlank(frequencyCode)) {
|
|
|
Frequency frequency = frequencyDao.findByCode(frequencyCode);
|
|
|
List<String> list = new ArrayList<>();
|
|
|
String[] executeTime = executeTimes.split(",");
|
|
|
for (int i = 0; i < executeTime.length; i++) {
|
|
|
List<String> times = rehabilitationPlanService.getFrequencyDate(frequency.getCode(), executeTime[i], frequency.getUnit(), frequency.getTime(), Long.parseLong(templateMap.get("timeType").toString()));
|
|
|
for (int j = 0; j < times.size(); j++) {
|
|
|
if (list != null && list.size() != 0) {
|
|
|
if (!list.contains(times.get(j))) {
|
|
|
list.add(times.get(j));
|
|
|
}
|
|
|
} else {
|
|
|
list.add(times.get(j));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
StringBuffer buffer = new StringBuffer();
|
|
|
if (list != null && list.size() != 0) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
buffer.append(list.get(i) + ",");
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(buffer)) {
|
|
|
buffer.deleteCharAt(buffer.length() - 1);
|
|
|
}
|
|
|
}
|
|
|
detail.put("executeTime", buffer);
|
|
|
}
|
|
|
}
|
|
|
detail.put("frequencyCode", templateMap.get("frequencyCode") == null ? "" : templateMap.get("frequencyCode").toString());//
|
|
|
detail.put("timeType", templateMap.get("timeType") == null ? 0 : Integer.parseInt(templateMap.get("timeType").toString()));//
|
|
|
detail.put("remark", templateMap.get("remark") == null ? "" : templateMap.get("remark").toString());//
|
|
|
detail.put("expense", templateMap.get("expense") == null ? 0 : Integer.parseInt(templateMap.get("expense").toString()));//
|
|
|
// detail.put("hospital", doctor.getHospital());
|
|
|
// detail.put("hospitalName", doctor.getHospitalName());
|
|
|
detailArray.put(detail);
|
|
|
}
|
|
|
}
|
|
|
json.put("detail", detailArray);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 医院接收自动下转疾病配置
|
|
|
*/
|
|
|
public void setHospitalSyncDisease(){
|
|
|
//厦门大学附属心血管病医院
|
|
|
List<String> temp = new ArrayList<>();
|
|
|
temp.add("1003");//冠心病
|
|
|
this.hospitalSyncDisease.put("97fbc7707643471b8458-6def1ff92496",temp);
|
|
|
//厦门大学附属第一医院
|
|
|
temp = new ArrayList<>();
|
|
|
temp.add("1001");//肺癌
|
|
|
temp.add("1004");//慢性前列腺
|
|
|
temp.add("1009");//脑卒中
|
|
|
this.hospitalSyncDisease.put("0a0b4ec0-5b04-11e6-8344-fa163e8aee56",temp);
|
|
|
//厦门市海沧医院
|
|
|
temp = new ArrayList<>();
|
|
|
temp.add("1006");//慢性阻塞性肺病
|
|
|
this.hospitalSyncDisease.put("0a11148d-5b04-11e6-8344-fa163e8aee56",temp);
|
|
|
//厦门市妇幼保健院
|
|
|
temp = new ArrayList<>();
|
|
|
temp.add("1008");//慢性妇科炎症
|
|
|
this. hospitalSyncDisease.put("8d94ce907e4d4356b68f6c5d4d0d6bc9",temp);
|
|
|
//厦门大学附属中山医院
|
|
|
temp = new ArrayList<>();
|
|
|
temp.add("1001");//肺癌
|
|
|
temp.add("1002");//慢性胃肠病
|
|
|
temp.add("1003");//冠心病
|
|
|
temp.add("1004");//慢性前列腺
|
|
|
temp.add("1005");//慢性乳腺
|
|
|
temp.add("1006");//慢性阻塞性肺病
|
|
|
temp.add("1007");//慢性肝病
|
|
|
temp.add("1008");//慢性妇科炎症
|
|
|
temp.add("1009");//脑卒中
|
|
|
temp.add("1010");//慢性肾病
|
|
|
this.hospitalSyncDisease.put("922b8fa9-5aff-11e6-8344-fa163e8aee56",temp);
|
|
|
//厦门市中医院
|
|
|
temp = new ArrayList<>();
|
|
|
temp.add("1007");//慢性肝病
|
|
|
this.hospitalSyncDisease.put("922b91b8-5aff-11e6-8344-fa163e8aee56",temp);
|
|
|
}
|
|
|
/**
|
|
|
* 厦门大学附属第一医院:肺癌、慢性前列腺、脑卒中
|
|
|
* 厦门市海沧医院:慢性阻塞性肺病
|
|
|
* 厦门市妇幼保健院:慢性妇科炎症
|
|
|
* 厦门大学附属中山医院:十大专病
|
|
|
* 厦门市中医院:慢性肝病
|
|
|
* 厦门大学附属心血管病医院:冠心病
|
|
|
* 获取医院自动下转对应的疾病类型
|
|
|
* 肺癌 1001
|
|
|
* 慢性胃肠病 1002
|
|
|
* 冠心病 1003
|
|
|
* 慢性前列腺疾病 1004
|
|
|
* 慢性乳腺疾病 1005
|
|
|
* 慢性阻塞性肺病 1006
|
|
|
* 脂肪肝 1007
|
|
|
* 慢性妇科炎症 1008
|
|
|
* 脑卒中 1009
|
|
|
* 慢性肾病 1010
|
|
|
* @param hospitalCode
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getHosSyncDiseaseInfo(String hospitalCode, String problemCode){
|
|
|
JSONObject diseaseObj = new JSONObject();
|
|
|
if (hospitalCode.equals("97fbc7707643471b8458-6def1ff92496")&&StringUtils.isBlank(problemCode)) {//厦心
|
|
|
problemCode ="1003";
|
|
|
}
|
|
|
if(!hospitalCode.equals("97fbc7707643471b8458-6def1ff92496")&&StringUtils.isBlank(problemCode)){
|
|
|
return null;
|
|
|
}
|
|
|
List diseaseList = hospitalSyncDisease.get(hospitalCode);
|
|
|
if (diseaseList!=null&&diseaseList.contains(problemCode)){
|
|
|
String diseaseCode=getDiseaseCodeByProblemCode(problemCode);
|
|
|
/*if (true){
|
|
|
String diseaseCode=getDiseaseCodeByProblemCode(problemCode);
|
|
|
SpecialDisease specialDisease = specialDiseaseDao.findByCode("3");*/
|
|
|
WlyySpecialDiseaseDO specialDisease = specialDiseaseDao.findByCode(diseaseCode);
|
|
|
if(specialDisease==null){
|
|
|
return null;
|
|
|
}
|
|
|
diseaseObj.put("diseaseName",specialDisease.getName());
|
|
|
diseaseObj.put("disease",specialDisease.getCode());
|
|
|
}
|
|
|
else {
|
|
|
diseaseObj=null;
|
|
|
}
|
|
|
|
|
|
return diseaseObj;
|
|
|
}
|
|
|
|
|
|
public String getHospitalCode(String hospitalCode){
|
|
|
switch (hospitalCode){
|
|
|
case "57": {
|
|
|
return "0a0b4ec0-5b04-11e6-8344-fa163e8aee56";
|
|
|
}
|
|
|
case "12350200568420163H": {
|
|
|
return "97fbc7707643471b8458-6def1ff92496";
|
|
|
}
|
|
|
case "53": {
|
|
|
return "922b8fa9-5aff-11e6-8344-fa163e8aee56";
|
|
|
}
|
|
|
case "55": {
|
|
|
return "922b954d-5aff-11e6-8344-fa163e8aee56";
|
|
|
}
|
|
|
case "54": {
|
|
|
return "922b91b8-5aff-11e6-8344-fa163e8aee56";
|
|
|
}
|
|
|
case "2": {
|
|
|
return "8d94ce907e4d4356b68f6c5d4d0d6bc9";
|
|
|
}
|
|
|
case "125": {
|
|
|
return "0a11148d-5b04-11e6-8344-fa163e8aee56";
|
|
|
}
|
|
|
default: {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
planDO = patientRehabilitationPlanDao.save(planDO);
|
|
|
List<RehabilitationDetailDO> detailDOList = new ArrayList<>();
|
|
|
for(RehabilitationTemplateDetailDO detailDO : templateDetail) {
|
|
|
// String server_item_id = detailDO.getServerTimeType();
|
|
|
// String plan_start_time_type = detailDO.getPlanStartTimeType();//计划开始时间类型
|
|
|
// String server_count = detailDO.getServerCount();//服务次数
|
|
|
String frequency_code = detailDO.getFrequencyCode();//频次
|
|
|
// LocalDateTime localDateTime = LocalDateTime.now();
|
|
|
// int addNum = Integer.parseInt(plan_start_time_type);
|
|
|
// localDateTime = localDateTime.plusDays(addNum);
|
|
|
// List<String> timeList = CronUtils.getExecutionTimeByNum(frequency_code,Integer.parseInt(server_count),localDateTime);
|
|
|
// for (String time :timeList){
|
|
|
// ServiceItemPlanDO planDO = new ServiceItemPlanDO();
|
|
|
// planDO.setPlanTime(time);
|
|
|
// planDO.setPatient(patient);
|
|
|
// planDO.setName(name);
|
|
|
// planDO.setStatus("0");
|
|
|
// planDO.setServicePackId(packageId);
|
|
|
// planDO.setServiceItemId(server_item_id);
|
|
|
// planDO.setItemConfigId(id);
|
|
|
// planDO.setRelationType(code);
|
|
|
// planDO.setSignId(signId);
|
|
|
// planDOList.add(planDO);
|
|
|
// }
|
|
|
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);
|
|
|
detailDOList.add(detail);
|
|
|
}
|
|
|
rehabilitationDetailDao.saveAll(detailDOList);
|
|
|
planDO.setDetailDOList(detailDOList);
|
|
|
return planDO;
|
|
|
}
|
|
|
|
|
|
public String getDiseaseCodeByProblemCode(String problemCode){
|
|
|
if(problemCode.equals("1001")) return "11"; //肺癌
|
|
|
else if(problemCode.equals("1002")) {
|
|
|
return "14"; // "慢性胃肠病";
|
|
|
} else if(problemCode.equals("1003")) {
|
|
|
return "3"; // "冠心病";
|
|
|
} else if(problemCode.equals("1004")) {
|
|
|
return "10"; // "慢性前列腺";
|
|
|
} else if(problemCode.equals("1005")) {
|
|
|
return "13"; // "慢性乳腺疾病";
|
|
|
} else if(problemCode.equals("1006")) {
|
|
|
return "15"; // "慢性阻塞性肺病";
|
|
|
} else if(problemCode.equals("1007")) {
|
|
|
return "16"; // "慢性肝病";
|
|
|
} else if(problemCode.equals("1008")) {
|
|
|
return "17"; // "慢性妇科炎症";
|
|
|
} else if(problemCode.equals("1009")) {
|
|
|
return "9"; // "脑卒中";
|
|
|
} else if(problemCode.equals("1010")) {
|
|
|
return "12"; // "慢性肾病";
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Transactional(propagation= Propagation.NOT_SUPPORTED)
|
|
|
public void runSqlNow(String sql){
|
|
@ -1909,15 +976,13 @@ public class SynchronizePatientService {
|
|
|
}
|
|
|
|
|
|
//更新患者下转状态
|
|
|
public void infoUpdate(List<RehabilitationPatientInfoDO> lists,Integer status,List<RehabilitationPatientInfoDO> modifyList,SignFamily signFamily){
|
|
|
public void infoUpdate(List<RehabilitationPatientInfoDO> lists,Integer status,List<RehabilitationPatientInfoDO> modifyList,BaseDoctorDO doctorDO){
|
|
|
for (RehabilitationPatientInfoDO re:lists){
|
|
|
re.setStatus(status);
|
|
|
modifyList.remove(re);
|
|
|
if(status==1&&signFamily!=null){
|
|
|
re.setDoctor(signFamily.getDoctor());
|
|
|
re.setDoctorName(signFamily.getDoctorName());
|
|
|
re.setOrgCode(signFamily.getHospital());
|
|
|
re.setOrgName(signFamily.getHospitalName());
|
|
|
if(status==1&&doctorDO!=null){
|
|
|
re.setDoctor(doctorDO.getId());
|
|
|
re.setDoctorName(doctorDO.getName());
|
|
|
re.setReceiveTime(new Date());
|
|
|
}
|
|
|
modifyList.add(re);
|