|
@ -2,6 +2,7 @@ package com.yihu.jw.hospital.module.rehabilitation.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.dict.dao.BaseFrequencyDictDao;
|
|
|
import com.yihu.jw.dict.dao.FrequencyDao;
|
|
@ -128,40 +129,51 @@ public class SynchronizePatientService {
|
|
|
saveModifyList(modifyList);
|
|
|
return "下转数据错误,身份证号不存在";
|
|
|
}
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "居民信息不存在";
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "居民信息不存在";
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
}
|
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
}else {
|
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
}
|
|
|
|
|
|
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){
|
|
|
//专病配置
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
if(planTemplateDO==null){
|
|
|
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健康失败";
|
|
|
//判断签约的才推送i健康
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
if(isSign==null){
|
|
|
return "请求i健康失败";
|
|
|
}
|
|
|
if(isSign.getJSONObject("obj")!=null){
|
|
|
//推送i健康数据
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
saveModifyList(modifyList);
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
return "请求i健康失败";
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
return "推送i健康成功";
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
rehabilitationPatientInfoDao.save(re);
|
|
|
return "推送i健康成功";
|
|
|
}
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
@ -333,6 +345,19 @@ public class SynchronizePatientService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取三院专病配置
|
|
|
public RehabilitationPlanTemplateDO findPlanTemplate(String dept,String diagnosis){
|
|
|
String sql = "SELECT t.*,d.is_family isFamily,d.id diseaseId,d.name diseaseName,d.family_relation familyRelation " +
|
|
|
"FROM base_disease_hospital d,wlyy_rehabilitation_plan_template t " +
|
|
|
"WHERE d.rehabilitation_template_id=t.id and d.`status`='1' and d.rehabilitation_down_type='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 null;
|
|
|
}
|
|
|
return diseaseList.get(0);
|
|
|
}
|
|
|
|
|
|
//基卫补推送出院小结后,重新下转
|
|
|
public StringBuilder reSynchronizePation(String type,String hospital,String createTime) throws Exception{
|
|
|
StringBuilder results = new StringBuilder("居民下转\n");
|
|
@ -371,43 +396,55 @@ public class SynchronizePatientService {
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
continue;
|
|
|
}
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
}
|
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
}else {
|
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
}
|
|
|
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){
|
|
|
//三院专病配置
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
if(planTemplateDO==null){
|
|
|
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){
|
|
|
//判断签约的才推送i健康
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
if(isSign==null){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
//推送i健康数据
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
saveModifyList(modifyList);
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
@ -658,43 +695,55 @@ public class SynchronizePatientService {
|
|
|
results.append("下转数据错误,身份证号不存在\n");
|
|
|
continue;
|
|
|
}
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
if(StringUtils.isBlank(re.getPatient())){
|
|
|
List<BasePatientDO> patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//获取患者信息
|
|
|
if (patientList.size() == 0) {
|
|
|
//未找到居民,从健康档案添加居民
|
|
|
patient = patientService.addPaitentByIdcard(re.getIdcard(),re.getName(),re.getSsc(),re.getMobile(),re.getSex());
|
|
|
if (patient == null) {
|
|
|
infoUpdate(tmpList,5,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("居民信息不存在\n");
|
|
|
continue;
|
|
|
} else {
|
|
|
patientList = patientDao.getPatientByIdcardOrSsc(re.getIdcard());//重新获取该患者信息
|
|
|
patient = patientList.get(0);
|
|
|
}
|
|
|
}
|
|
|
infoUpdate4(tmpList,patient.getId(),modifyList);
|
|
|
}else {
|
|
|
patient = patientDao.findByIdAndDel(re.getPatient(),"1");
|
|
|
}
|
|
|
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){
|
|
|
//三院专病配置
|
|
|
RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis);
|
|
|
if(planTemplateDO==null){
|
|
|
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){
|
|
|
//判断签约的才推送i健康
|
|
|
JSONObject isSign = businessService.isSign(re.getIdcard());
|
|
|
if(isSign==null){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
re.setIjkId(ijkId);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
if(isSign.getJSONObject("obj")!=null) {
|
|
|
//推送i健康数据
|
|
|
infoUpdate2(tmpList,planTemplateDO.getFamilyRelation(),modifyList);
|
|
|
saveModifyList(modifyList);
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = businessService.pushPatientInfos(re);
|
|
|
if(jsonObject==null||jsonObject.getInteger("status")==-1){
|
|
|
results.append("推送i健康失败\n");
|
|
|
continue;
|
|
|
}
|
|
|
Long ijkId = jsonObject.getLong("data");
|
|
|
infoUpdate3(tmpList,3,ijkId,modifyList,null);
|
|
|
saveModifyList(modifyList);
|
|
|
results.append("推送i健康成功\n");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
String diseaseId = planTemplateDO.getDiseaseId();
|
|
|
String diseaseName = planTemplateDO.getDiseaseName();
|
|
@ -989,4 +1038,32 @@ public class SynchronizePatientService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void infoUpdate2(List<RehabilitationPatientInfoDO> lists,String problemCode,List<RehabilitationPatientInfoDO> modifyList){
|
|
|
for (RehabilitationPatientInfoDO re:lists){
|
|
|
re.setProblemCode(problemCode);
|
|
|
modifyList.remove(re);
|
|
|
modifyList.add(re);
|
|
|
}
|
|
|
}
|
|
|
public void infoUpdate3(List<RehabilitationPatientInfoDO> lists,Integer status,Long ijkId,List<RehabilitationPatientInfoDO> modifyList,BaseDoctorDO doctorDO){
|
|
|
for (RehabilitationPatientInfoDO re:lists){
|
|
|
re.setStatus(status);
|
|
|
re.setIjkId(ijkId);
|
|
|
modifyList.remove(re);
|
|
|
if(status==1&&doctorDO!=null){
|
|
|
re.setDoctor(doctorDO.getId());
|
|
|
re.setDoctorName(doctorDO.getName());
|
|
|
re.setReceiveTime(new Date());
|
|
|
}
|
|
|
modifyList.add(re);
|
|
|
}
|
|
|
}
|
|
|
public void infoUpdate4(List<RehabilitationPatientInfoDO> lists,String patient,List<RehabilitationPatientInfoDO> modifyList){
|
|
|
for (RehabilitationPatientInfoDO re:lists){
|
|
|
re.setPatient(patient);
|
|
|
modifyList.remove(re);
|
|
|
modifyList.add(re);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|