|
@ -8,18 +8,15 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
|
import com.yihu.jw.entity.base.servicePackage.ServiceItemPlanDO;
|
|
|
import com.yihu.jw.entity.followup.Followup;
|
|
|
import com.yihu.jw.entity.followup.FollowupContent;
|
|
|
import com.yihu.jw.entity.followup.FollowupSign;
|
|
|
import com.yihu.jw.entity.followup.*;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.family.WlyyPatientFamilyMemberDO;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPatientInfoDO;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.hospital.family.dao.WlyyPatientFamilyMemberDao;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.hospital.module.followup.dao.FollowUpDao;
|
|
|
import com.yihu.jw.hospital.module.followup.dao.FollowupContentDao;
|
|
|
import com.yihu.jw.hospital.module.followup.dao.FollowupSignDao;
|
|
|
import com.yihu.jw.hospital.module.followup.dao.*;
|
|
|
import com.yihu.jw.hospital.module.rehabilitation.service.RehabilitationManageService;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
|
|
@ -27,6 +24,7 @@ import com.yihu.jw.rehabilitation.ServiceItemPlanDao;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.encrypt.MD5;
|
|
|
import com.yihu.jw.util.entity.ServiceException;
|
|
|
import com.yihu.jw.util.idcard.IdCardUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -36,6 +34,7 @@ import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
@ -78,6 +77,12 @@ public class FollowUpService {
|
|
|
@Autowired
|
|
|
private FollowupContentDao followupContentDao;
|
|
|
@Autowired
|
|
|
private FollowupOncologyDao followupOncologyDao;
|
|
|
@Autowired
|
|
|
private FollowupOrthopedicsDao followupOrthopedicsDao;
|
|
|
@Autowired
|
|
|
private FollowupHandFootDao followupHandFootDao;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
@Autowired
|
|
|
private SystemMessageDao messageDao;
|
|
@ -282,6 +287,7 @@ public class FollowUpService {
|
|
|
|
|
|
re.put("id", String.valueOf(followup.getId()));
|
|
|
re.put("followupNo", followup.getFollowupNo());
|
|
|
re.put("followupFormType", followup.getFollowupFormType());
|
|
|
re.put("followupDate", DateUtil.dateToStrLong(followup.getFollowupDate()));
|
|
|
re.put("followupNextDate", DateUtil.dateToStrLong(followup.getFollowupNextDate()));
|
|
|
|
|
@ -786,7 +792,7 @@ public class FollowUpService {
|
|
|
}
|
|
|
|
|
|
//添加康复计划随访
|
|
|
public Followup addRehabilatationFollowup(ServiceItemPlanDO itemPlanDO,String nextTime) {
|
|
|
public Followup addRehabilatationFollowup(ServiceItemPlanDO itemPlanDO,String nextTime,String followupFormType,Long lastFollowupId) {
|
|
|
try {
|
|
|
Followup followup = new Followup();
|
|
|
followup.setFollowupType("2");
|
|
@ -799,6 +805,8 @@ public class FollowUpService {
|
|
|
followup.setDoctorCode(itemPlanDO.getDoctor());
|
|
|
followup.setDoctorName(itemPlanDO.getDoctorName());
|
|
|
followup.setPatientCode(itemPlanDO.getPatient());
|
|
|
followup.setFollowupFormType(followupFormType);
|
|
|
followup.setLastFollowupId(lastFollowupId);
|
|
|
BasePatientDO patient = patientDao.findById(itemPlanDO.getPatient()).orElse(null);
|
|
|
followup.setPatientName(patient.getName());
|
|
|
followup.setIdcard(patient.getIdcard());
|
|
@ -1047,14 +1055,6 @@ public class FollowUpService {
|
|
|
|
|
|
//关联康复计划完成
|
|
|
rehabilitationManageService.completePlanFollowup(followup.getId());
|
|
|
|
|
|
//随访完成,增加随访状态完成的标记
|
|
|
// Prescription prescription = prescriptionDao.findByCode(followup.getPrescriptionCode());
|
|
|
// if (prescription != null) {
|
|
|
// prescription.setViewSuifang(1);
|
|
|
// prescriptionDao.save(prescription);
|
|
|
// }
|
|
|
|
|
|
} else {
|
|
|
throw new RuntimeException("查找不到该随访计划!");
|
|
|
}
|
|
@ -1106,58 +1106,242 @@ public class FollowUpService {
|
|
|
/**
|
|
|
* 获取面访项目数据
|
|
|
*/
|
|
|
public Map<String, String> getFollowupProjectData(String id, String followupProject) throws Exception {
|
|
|
Map<String, String> re = new HashMap<>();
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
|
|
|
for (FollowupContent item : dataList) {
|
|
|
re.put(item.getFollowupKey(), item.getFollowupValue());
|
|
|
public Object getFollowupProjectData(String id, String followupProject) throws Exception {
|
|
|
Long followupId = Long.valueOf(id);
|
|
|
if("1".equals(followupProject)){
|
|
|
Map<String, String> re = new HashMap<>();
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(followupId, followupProject);
|
|
|
for (FollowupContent item : dataList) {
|
|
|
re.put(item.getFollowupKey(), item.getFollowupValue());
|
|
|
}
|
|
|
return re;
|
|
|
}
|
|
|
if("2".equals(followupProject)){
|
|
|
//骨科患者术后随访
|
|
|
FollowupOrthopedics old = followupOrthopedicsDao.findByFollowupId(followupId);
|
|
|
if(old==null){
|
|
|
old = new FollowupOrthopedics();
|
|
|
Followup followup = followupDao.findById(followupId).get();
|
|
|
if(followup.getLastFollowupId()!=null){
|
|
|
FollowupOrthopedics last = followupOrthopedicsDao.findByFollowupId(followup.getLastFollowupId());
|
|
|
if(last!=null){
|
|
|
BeanUtils.copyProperties(last,old);
|
|
|
old.setId(null);
|
|
|
old.setCreateTime(null);
|
|
|
old.setFollowupId(followupId);
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(old.getPatient())){
|
|
|
//填写初始默认值
|
|
|
old.setPatient(followup.getPatientCode());
|
|
|
BasePatientDO patientDO = patientDao.findById(followup.getPatientCode()).get();
|
|
|
old.setName(patientDO.getName());
|
|
|
old.setSex(patientDO.getSex()+"");
|
|
|
old.setAge(com.yihu.jw.util.common.IdCardUtil.getAgeByBirthdayOrIdcard(patientDO.getIdcard(), patientDO.getBirthday()));
|
|
|
old.setMobile(patientDO.getMobile());
|
|
|
//查找对应的下转记录
|
|
|
RehabilitationPatientInfoDO infoDO = findRehabilitationPatientInfo(followupId,followup.getPatientCode());
|
|
|
old.setVisitNo(infoDO.getVisitNo());
|
|
|
}
|
|
|
old.setNextFollowupTime(DateUtil.dateToStrLong(followup.getFollowupNextDate()));
|
|
|
return old;
|
|
|
}else {
|
|
|
//已填写,直接返回填写结果
|
|
|
return old;
|
|
|
}
|
|
|
}
|
|
|
return re;
|
|
|
if("3".equals(followupProject)){
|
|
|
//肿瘤科患者随访
|
|
|
FollowupOncology old = followupOncologyDao.findByFollowupId(followupId);
|
|
|
if(old==null){
|
|
|
old = new FollowupOncology();
|
|
|
Followup followup = followupDao.findById(followupId).get();
|
|
|
if(followup.getLastFollowupId()!=null){
|
|
|
FollowupOncology last = followupOncologyDao.findByFollowupId(followup.getLastFollowupId());
|
|
|
if(last!=null){
|
|
|
BeanUtils.copyProperties(last,old);
|
|
|
old.setId(null);
|
|
|
old.setCreateTime(null);
|
|
|
old.setFollowupId(followupId);
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(old.getPatient())){
|
|
|
//填写初始默认值
|
|
|
old.setPatient(followup.getPatientCode());
|
|
|
BasePatientDO patientDO = patientDao.findById(followup.getPatientCode()).get();
|
|
|
old.setName(patientDO.getName());
|
|
|
old.setSex(patientDO.getSex()+"");
|
|
|
old.setAge(com.yihu.jw.util.common.IdCardUtil.getAgeByBirthdayOrIdcard(patientDO.getIdcard(), patientDO.getBirthday()));
|
|
|
old.setMobile(patientDO.getMobile());
|
|
|
//查找对应的下转记录
|
|
|
RehabilitationPatientInfoDO infoDO = findRehabilitationPatientInfo(followupId,followup.getPatientCode());
|
|
|
old.setVisitNo(infoDO.getVisitNo());
|
|
|
}
|
|
|
old.setNextFollowupTime(DateUtil.dateToStrLong(followup.getFollowupNextDate()));
|
|
|
return old;
|
|
|
}else {
|
|
|
//已填写,直接返回填写结果
|
|
|
return old;
|
|
|
}
|
|
|
}
|
|
|
if("4".equals(followupProject)){
|
|
|
//手足外科患者随访
|
|
|
FollowupHandFoot old = followupHandFootDao.findByFollowupId(followupId);
|
|
|
if(old==null){
|
|
|
old = new FollowupHandFoot();
|
|
|
Followup followup = followupDao.findById(followupId).get();
|
|
|
if(followup.getLastFollowupId()!=null){
|
|
|
FollowupHandFoot last = followupHandFootDao.findByFollowupId(followup.getLastFollowupId());
|
|
|
if(last!=null){
|
|
|
BeanUtils.copyProperties(last,old);
|
|
|
old.setId(null);
|
|
|
old.setCreateTime(null);
|
|
|
old.setFollowupId(followupId);
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(old.getPatient())){
|
|
|
//填写初始默认值
|
|
|
old.setPatient(followup.getPatientCode());
|
|
|
BasePatientDO patientDO = patientDao.findById(followup.getPatientCode()).get();
|
|
|
old.setName(patientDO.getName());
|
|
|
old.setSex(patientDO.getSex()+"");
|
|
|
old.setAge(com.yihu.jw.util.common.IdCardUtil.getAgeByBirthdayOrIdcard(patientDO.getIdcard(), patientDO.getBirthday()));
|
|
|
old.setMobile(patientDO.getMobile());
|
|
|
//查找对应的下转记录
|
|
|
RehabilitationPatientInfoDO infoDO = findRehabilitationPatientInfo(followupId,followup.getPatientCode());
|
|
|
old.setVisitNo(infoDO.getVisitNo());
|
|
|
}
|
|
|
old.setNextFollowupTime(DateUtil.dateToStrLong(followup.getFollowupNextDate()));
|
|
|
return old;
|
|
|
}else {
|
|
|
//已填写,直接返回填写结果
|
|
|
return old;
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public RehabilitationPatientInfoDO findRehabilitationPatientInfo(Long followupId,String patient){
|
|
|
String sql = "SELECT i.* from wlyy_rehabilitation_patient_info i,wlyy_patient_rehabilitation_plan p, " +
|
|
|
" base_service_item_plan ip " +
|
|
|
" WHERE ip.patient='"+patient+"' and ip.relation_type='6' and ip.relation_code='"+followupId+"' " +
|
|
|
" and ip.plan_id=p.id and p.patient_info_code=i.code";
|
|
|
List<RehabilitationPatientInfoDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RehabilitationPatientInfoDO.class));
|
|
|
if(list.size()>0){
|
|
|
return list.get(0);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存面访项目数据
|
|
|
*/
|
|
|
@Transactional
|
|
|
public void saveFollowupProjectData(String id, String followupProject, String followupProjectData) throws Exception {
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(Long.valueOf(id), followupProject);
|
|
|
|
|
|
//删除原有记录
|
|
|
followupContentDao.deleteAll(dataList);
|
|
|
|
|
|
Map<String, String> data = objectMapper.readValue(followupProjectData, Map.class);
|
|
|
|
|
|
if (data != null && data.keySet().size() > 0) {
|
|
|
List<FollowupContent> newList = new ArrayList<>();
|
|
|
for (String key : data.keySet()) {
|
|
|
FollowupContent item = new FollowupContent();
|
|
|
item.setFollowupId(Long.valueOf(id));
|
|
|
item.setFollowupProject(followupProject);
|
|
|
item.setFollowupKey(key);
|
|
|
item.setFollowupValue(data.get(key));
|
|
|
item.setCreateTime(new Date());
|
|
|
newList.add(item);
|
|
|
public void saveFollowupProjectData(String id, String followupProject, String followupProjectData,String doctorId) throws Exception {
|
|
|
Long followupId = Long.valueOf(id);
|
|
|
if("1".equals(followupProject)){
|
|
|
//通用
|
|
|
List<FollowupContent> dataList = followupContentDao.findByFollowupIdAndFollowupProject(followupId, followupProject);
|
|
|
//删除原有记录
|
|
|
followupContentDao.deleteAll(dataList);
|
|
|
Map<String, String> data = objectMapper.readValue(followupProjectData, Map.class);
|
|
|
if (data != null && data.keySet().size() > 0) {
|
|
|
List<FollowupContent> newList = new ArrayList<>();
|
|
|
for (String key : data.keySet()) {
|
|
|
FollowupContent item = new FollowupContent();
|
|
|
item.setFollowupId(Long.valueOf(id));
|
|
|
item.setFollowupProject(followupProject);
|
|
|
item.setFollowupKey(key);
|
|
|
item.setFollowupValue(data.get(key));
|
|
|
item.setCreateTime(new Date());
|
|
|
newList.add(item);
|
|
|
}
|
|
|
followupContentDao.saveAll(newList);
|
|
|
}
|
|
|
}
|
|
|
String nextFollowupTime = null;
|
|
|
String nextFollowupWay = null;
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctorId).orElse(null);
|
|
|
if("2".equals(followupProject)){
|
|
|
//骨科患者术后随访
|
|
|
FollowupOrthopedics followupOrthopedics = JSON.parseObject(followupProjectData,FollowupOrthopedics.class);
|
|
|
if(StringUtils.isBlank(followupOrthopedics.getPatient())){
|
|
|
throw new ServiceException("参数错误");
|
|
|
}
|
|
|
if(followupOrthopedics.getFollowupId()==null){
|
|
|
followupOrthopedics.setFollowupId(followupId);
|
|
|
}
|
|
|
FollowupOrthopedics old = followupOrthopedicsDao.findByFollowupId(followupId);
|
|
|
if(old!=null){
|
|
|
throw new ServiceException("已保存,请勿重复保存");
|
|
|
}
|
|
|
nextFollowupTime = followupOrthopedics.getNextFollowupTime();
|
|
|
nextFollowupWay = followupOrthopedics.getNextFollowupWay();
|
|
|
followupOrthopedics.setCreateTime(new Date());
|
|
|
if(doctorDO!=null){
|
|
|
followupOrthopedics.setDoctor(doctorId);
|
|
|
followupOrthopedics.setDoctorName(doctorDO.getName());
|
|
|
}
|
|
|
followupOrthopedicsDao.save(followupOrthopedics);
|
|
|
}
|
|
|
if("3".equals(followupProject)){
|
|
|
//肿瘤科患者随访
|
|
|
FollowupOncology followupOncology = JSON.parseObject(followupProjectData,FollowupOncology.class);
|
|
|
if(StringUtils.isBlank(followupOncology.getPatient())){
|
|
|
throw new ServiceException("参数错误");
|
|
|
}
|
|
|
if(followupOncology.getFollowupId()==null){
|
|
|
followupOncology.setFollowupId(followupId);
|
|
|
}
|
|
|
FollowupOncology old = followupOncologyDao.findByFollowupId(followupId);
|
|
|
if(old!=null){
|
|
|
throw new ServiceException("已保存,请勿重复保存");
|
|
|
}
|
|
|
nextFollowupTime = followupOncology.getNextFollowupTime();
|
|
|
nextFollowupWay = followupOncology.getNextFollowupWay();
|
|
|
followupOncology.setCreateTime(new Date());
|
|
|
if(doctorDO!=null){
|
|
|
followupOncology.setDoctor(doctorId);
|
|
|
followupOncology.setDoctorName(doctorDO.getName());
|
|
|
}
|
|
|
followupOncologyDao.save(followupOncology);
|
|
|
}
|
|
|
if("4".equals(followupProject)){
|
|
|
//手足外科患者随访
|
|
|
FollowupHandFoot followupHandFoot = JSON.parseObject(followupProjectData,FollowupHandFoot.class);
|
|
|
if(StringUtils.isBlank(followupHandFoot.getPatient())){
|
|
|
throw new ServiceException("参数错误");
|
|
|
}
|
|
|
if(followupHandFoot.getFollowupId()==null){
|
|
|
followupHandFoot.setFollowupId(followupId);
|
|
|
}
|
|
|
FollowupHandFoot old = followupHandFootDao.findByFollowupId(followupId);
|
|
|
if(old!=null){
|
|
|
throw new ServiceException("已保存,请勿重复保存");
|
|
|
}
|
|
|
nextFollowupTime = followupHandFoot.getNextFollowupTime();
|
|
|
nextFollowupWay = followupHandFoot.getNextFollowupWay();
|
|
|
followupHandFoot.setCreateTime(new Date());
|
|
|
if(doctorDO!=null){
|
|
|
followupHandFoot.setDoctor(doctorId);
|
|
|
followupHandFoot.setDoctorName(doctorDO.getName());
|
|
|
}
|
|
|
followupHandFootDao.save(followupHandFoot);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(nextFollowupTime)||StringUtils.isNotBlank(nextFollowupWay)){
|
|
|
//设置下次随访
|
|
|
Followup f = followupDao.findByLastFollowupId(followupId);
|
|
|
if(f!=null){
|
|
|
if(StringUtils.isNotBlank(nextFollowupTime)){
|
|
|
f.setFollowupDate(DateUtil.strToDate(nextFollowupTime));
|
|
|
f.setFollowupPlanDate(DateUtil.strToDate(nextFollowupTime));
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(nextFollowupWay)){
|
|
|
f.setFollowupType(nextFollowupWay);
|
|
|
}
|
|
|
followupDao.save(f);
|
|
|
}
|
|
|
followupContentDao.saveAll(newList);
|
|
|
|
|
|
}
|
|
|
|
|
|
// Followup followup = followupDao.findById(Long.valueOf(id)).orElse(null);
|
|
|
|
|
|
//如果该随访是已完成的,则添加随访信息上传映射,上传到基卫
|
|
|
// if ("1".equals(followup.getStatus())) {
|
|
|
// FollowupMapping followupMapping = followUpMappingDao.findByFollowupId(Integer.parseInt(id));
|
|
|
// if (followupMapping == null) {
|
|
|
// followupMapping = new FollowupMapping();
|
|
|
// followupMapping.setCode(UUID.randomUUID().toString());
|
|
|
// followupMapping.setFollowupId(Integer.parseInt(id));
|
|
|
// followupMapping.setUpdateTime(DateUtil.getNowTimestamp());
|
|
|
// followupMapping.setCreateTime(DateUtil.getNowTimestamp());
|
|
|
// }
|
|
|
// followupMapping.setNeedUpload(1);
|
|
|
// followUpMappingDao.save(followupMapping);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
|