2 Commits 446e723bc0 ... f057c29e45

Autor SHA1 Mensagem Data
  LAPTOP-KB9HII50\70708 f057c29e45 代码修改 2 semanas atrás
  LAPTOP-KB9HII50\70708 bc979ec82f 代码修改 2 semanas atrás

+ 12 - 1
common/common-entity/src/db/2025.sql

@ -47,7 +47,7 @@ ALTER table wlyy_patient_medical_records_rehabilitation add COLUMN `con_no` varc
ALTER table wlyy_patient_medical_records_rehabilitation add COLUMN `event_type` varchar(1) DEFAULT NULL COMMENT '病历类型';
ALTER TABLE `wlyy_rehabilitation_template_detail`
ADD COLUMN `followup_form_type` varchar(100) DEFAULT NULL COMMENT '随访表单类型';
ADD COLUMN `followup_form_type` varchar(10) DEFAULT NULL COMMENT '随访表单类型';
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('followup_form_type1', NULL, 'followup_form_type', '1', '全院通用', NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访表单类型');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('followup_form_type2', NULL, 'followup_form_type', '2', '骨科患者术后随访', NULL, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '随访表单类型');
@ -58,6 +58,12 @@ INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict
-- ysj 2025-07-30
ALTER TABLE `wlyy_followup`
    ADD COLUMN `followup_form_type` varchar(10) DEFAULT NULL COMMENT '随访表单类型';
ALTER TABLE `wlyy_followup`
    ADD COLUMN `last_followup_id` int(11) DEFAULT NULL COMMENT '上次随访id';
update wlyy_followup set followup_form_type = '1' where followup_form_type is null;
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('wound_healing_status', NULL, 'wound_healing_status', NULL, NULL, NULL, NULL, '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '伤口愈合情况');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('wound_healing_status0', NULL, 'wound_healing_status', '1', '干燥无渗液', NULL, '0', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '伤口愈合情况');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('wound_healing_status1', NULL, 'wound_healing_status', '2', '少量渗液', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '伤口愈合情况');
@ -179,3 +185,8 @@ INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`,
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('lifestyle1', NULL, 'lifestyle', '1', '戒烟', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '生活方式');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('lifestyle2', NULL, 'lifestyle', '2', '限酒', NULL, '2', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '生活方式');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('lifestyle3', NULL, 'lifestyle', '3', '适量运动', NULL, '3', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '生活方式');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('adl', NULL, 'adl', NULL, NULL, NULL, NULL, '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '日常生活能力');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('adl1', NULL, 'adl', '1', '独立进食/穿衣', NULL, '1', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '日常生活能力');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('adl2', NULL, 'adl', '2', '需部分辅助', NULL, '2', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '日常生活能力');
INSERT INTO `wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('adl3', NULL, 'adl', '3', '完全依赖他人', NULL, '3', '350211A1002', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '日常生活能力');

+ 19 - 5
common/common-entity/src/main/java/com/yihu/jw/entity/followup/Followup.java

@ -102,16 +102,13 @@ public class Followup extends LongIdentityEntity {
	private Integer bdStatus;//bd_status
	private Integer pgStatus;//pg_status
	private String visitCount;//访视次序 (中度到重度慢阻肺)
	private String followupFormType;//随访表单类型 字典followup_form_type 1通用(空值按通用的逻辑处理)
	private Long lastFollowupId;//上次随访id
	private String planId;
	private String planDetailId;
	private String planItemId;
	@Column(name = "doctor_read_status")
	public Integer getDoctorReadStatus() {
		return doctorReadStatus;
@ -516,4 +513,21 @@ public class Followup extends LongIdentityEntity {
	public void setPlanItemId(String planItemId) {
		this.planItemId = planItemId;
	}
	public String getFollowupFormType() {
		return followupFormType;
	}
	public void setFollowupFormType(String followupFormType) {
		this.followupFormType = followupFormType;
	}
	public Long getLastFollowupId() {
		return lastFollowupId;
	}
	public void setLastFollowupId(Long lastFollowupId) {
		this.lastFollowupId = lastFollowupId;
	}
}

+ 81 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/followup/FollowupHandFoot.java

@ -44,6 +44,15 @@ public class FollowupHandFoot extends IdEntityWithCreateTime {
    private String diabetesWoundHealing; // 糖尿病伤口愈合
    private String diabetesFootFeel; // 糖尿病足感觉
    private String diabetesBloodSugar; // 糖尿病血糖
    private String diabetesBloodSugarB;//糖尿病-血糖监测-餐前
    private String diabetesBloodSugarA;//糖尿病-血糖监测-餐后
    private String planTraining;//是否按计划进行康复训练 1是 0否
    private String planTrainingReason;//是否按计划进行康复训练-原因内容
    private String adl;//日常生活能力 字典adl
    private String specialNeeds;//特殊需求
    private String nextFollowupTime; // 下次随访时间
    private String nextFollowupWay; // 下次随访方式
    private String nextFocus; // 下次关注重点
    @Column(name = "patient")
    public String getPatient() {
@ -296,7 +305,79 @@ public class FollowupHandFoot extends IdEntityWithCreateTime {
    public void setDiabetesBloodSugar(String diabetesBloodSugar) {
        this.diabetesBloodSugar = diabetesBloodSugar;
    }
    @Column(name = "diabetes_blood_sugar_b")
    public String getDiabetesBloodSugarB() {
        return diabetesBloodSugarB;
    }
    public void setDiabetesBloodSugarB(String diabetesBloodSugarB) {
        this.diabetesBloodSugarB = diabetesBloodSugarB;
    }
    @Column(name = "diabetes_blood_sugar_a")
    public String getDiabetesBloodSugarA() {
        return diabetesBloodSugarA;
    }
    public void setDiabetesBloodSugarA(String diabetesBloodSugarA) {
        this.diabetesBloodSugarA = diabetesBloodSugarA;
    }
    @Column(name = "plan_training")
    public String getPlanTraining() {
        return planTraining;
    }
    public void setPlanTraining(String planTraining) {
        this.planTraining = planTraining;
    }
    @Column(name = "plan_training_reason")
    public String getPlanTrainingReason() {
        return planTrainingReason;
    }
    public void setPlanTrainingReason(String planTrainingReason) {
        this.planTrainingReason = planTrainingReason;
    }
    @Column(name = "adl")
    public String getAdl() {
        return adl;
    }
    public void setAdl(String adl) {
        this.adl = adl;
    }
    @Column(name = "special_needs")
    public String getSpecialNeeds() {
        return specialNeeds;
    }
    public void setSpecialNeeds(String specialNeeds) {
        this.specialNeeds = specialNeeds;
    }
    @Column(name = "next_followup_time")
    public String getNextFollowupTime() {
        return nextFollowupTime;
    }
    public void setNextFollowupTime(String nextFollowupTime) {
        this.nextFollowupTime = nextFollowupTime;
    }
    @Column(name = "next_followup_way")
    public String getNextFollowupWay() {
        return nextFollowupWay;
    }
    public void setNextFollowupWay(String nextFollowupWay) {
        this.nextFollowupWay = nextFollowupWay;
    }
    @Column(name = "next_focus")
    public String getNextFocus() {
        return nextFocus;
    }
    public void setNextFocus(String nextFocus) {
        this.nextFocus = nextFocus;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java

@ -82,6 +82,7 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    private String value1;
    private String value2;
    private String value3;
    private String followupFormType; // 随访表单类型,字典 followup_form_type
    @Column(name = "reservation_type")
    public Integer getReservationType() {
@ -418,4 +419,12 @@ public class RehabilitationDetailDO extends UuidIdentityEntity implements Serial
    public void setValue3(String value3) {
        this.value3 = value3;
    }
    @Transient
    public String getFollowupFormType() {
        return followupFormType;
    }
    public void setFollowupFormType(String followupFormType) {
        this.followupFormType = followupFormType;
    }
}

+ 6 - 4
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/controller/DoctorFollowUpController.java

@ -416,8 +416,7 @@ public class DoctorFollowUpController extends BaseController {
                                         @ApiParam(name = "followupProject", value = "随访项目")
                                         @RequestParam(value = "followupProject", required = false) String followupProject) {
        try {
            Map<String, String> maps = followUpService.getFollowupProjectData(id, followupProject);
            return write(200, "获取随访项目数据成功!", "data", maps);
            return write(200, "获取随访项目数据成功!", "data", followUpService.getFollowupProjectData(id, followupProject));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "获取随访项目数据失败!");
@ -433,9 +432,12 @@ public class DoctorFollowUpController extends BaseController {
                                          @ApiParam(name = "followupProjectData", value = "随访项目数据", defaultValue = "{\"BLOOD_SUGAR\":\"33.3\",\"BLOOD_SUGAR_TYPE\":\"1\",\"WEIGHT\":\"76\",\"WEIGHT_EXP\":\"60\",\"BMI\":\"11\"}")
                                          @RequestParam(value = "followupProjectData", required = true) String followupProjectData) {
        try {
            followUpService.saveFollowupProjectData(id, followupProject, followupProjectData);
            String doctorId = getUID();
            followUpService.saveFollowupProjectData(id, followupProject, followupProjectData,doctorId);
            return write(200, "保存随访项目数据成功!");
        } catch (Exception e) {
        } catch (ServiceException se){
            return error(-1,se.getMessage());
        }catch (Exception e) {
            return invalidUserException(e, -1, "保存随访项目数据失败!" + e.getMessage());
        }
    }

+ 2 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/dao/FollowUpDao.java

@ -20,6 +20,8 @@ import java.util.Set;
public interface FollowUpDao extends PagingAndSortingRepository<Followup, Long>, JpaSpecificationExecutor<Followup> {
    Followup findByLastFollowupId(Long lastFollowupId);
    @Query("select a.followupDate from Followup a where a.doctorCode = ?1 and a.patientCode = ?2 and a.followupClass = '9'" )
    List<Date> findFollowupDateList(String doctor, String patientCode) throws Exception;

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/dao/FollowupHandFootDao.java

@ -9,5 +9,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface FollowupHandFootDao extends PagingAndSortingRepository<FollowupHandFoot, Long>
        , JpaSpecificationExecutor<FollowupHandFoot> {
    FollowupHandFoot findByFollowupId(Long followupId);
}

+ 1 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/dao/FollowupOncologyDao.java

@ -9,4 +9,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface FollowupOncologyDao extends PagingAndSortingRepository<FollowupOncology, Long>
        , JpaSpecificationExecutor<FollowupOncology> {
    FollowupOncology findByFollowupId(Long followupId);
}

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/dao/FollowupOrthopedicsDao.java

@ -10,5 +10,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface FollowupOrthopedicsDao extends PagingAndSortingRepository<FollowupOrthopedics, Long>
        , JpaSpecificationExecutor<FollowupOrthopedics> {
    FollowupOrthopedics findByFollowupId(Long followupId);
}

+ 241 - 57
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/followup/service/FollowUpService.java

@ -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);
//        }
    }

+ 3 - 2
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/RehabilitationManageService.java

@ -298,7 +298,7 @@ public class RehabilitationManageService {
        }else {
            timeList = CronUtils.getExecutionTimeByNum(frequency_code, Integer.parseInt(server_count), localDateTime);
        }
        Long lastFollowupId = null;
        for (int i = 0; i <timeList.size(); i++){
            String time = timeList.get(i);
            ServiceItemPlanDO itemPlanDO = new ServiceItemPlanDO();
@ -316,8 +316,9 @@ public class RehabilitationManageService {
                if(i < timeList.size()-1){
                    nextTime = timeList.get(i+1);
                }
                Followup followup = followUpService.addRehabilatationFollowup(itemPlanDO,nextTime);
                Followup followup = followUpService.addRehabilatationFollowup(itemPlanDO,nextTime,detailDO.getFollowupFormType(),lastFollowupId);
                if (followup != null) {
                    lastFollowupId = followup.getId();
                    itemPlanDO.setRelationCode(followup.getId() + "");
                }
            }

+ 28 - 40
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/rehabilitation/service/SynchronizePatientService.java

@ -131,10 +131,16 @@ public class SynchronizePatientService  {
            rehabilitationPatientInfoDao.save(infoDO);
            return "就诊卡信息不存在";
        }
        if(patient.getSex()==null||patient.getSex()==3){
            JSONObject cardJson = cardList.getJSONObject(0);
            String xb = cardJson.getString("XB");//性别
            int sex = "女".equals(xb)?2:1;
            patient.setSex(sex);
            patientDao.save(patient);
        }
        infoDO.setSex(patient.getSex());
        infoDO.setPatient(patient.getId());
        infoDO.setIdcard(patient.getIdcard());
        infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
        infoDO.setAddress(patient.getAddress());
        String ssc = null;
        String mobile = null;
@ -252,7 +258,7 @@ public class SynchronizePatientService  {
            String ATTENDINGPHYSICIAN = jaCy.getString("ATTENDINGPHYSICIAN");//黎喜梅 主治医师
            String DISCHARGEDISEASE = jaCy.getString("DISCHARGEDISEASE");//出院诊断
            String ADMISSIONDAY = jaCy.getString("ADMISSIONDAY");//5, 住院天数
//                String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
            String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
//                String ID = jaCy.getString("ID");//42661889-5-6000861496-2-9-0-20",
//                String LAST_MODIFY_DATE_TIME = jaCy.getString("LAST_MODIFY_DATE_TIME");//2025-05-13 21:16:12",
//                String BEDNO = jaCy.getString("BEDNO");//A12-46",
@ -281,7 +287,10 @@ public class SynchronizePatientService  {
            pmr.setDischargeDiagnosisName(DISCHARGEDISEASE);
            pmr.setAdvice(DISCHARGEORDER);
            infoDO.setVisitNo(ADMISSIONNO);
            if(!BIRTH.equals(DateUtil.dateToStrLong(patient.getBirthday()))){
                patient.setBirthday(DateUtil.strToDate(BIRTH));
                patientDao.save(patient);
            }
            deptName = DEPTNAME;
            dept = findDeptByName(DEPTNAME);
            doctorNameZy = RESIDENTPHYSICIAN;
@ -289,6 +298,7 @@ public class SynchronizePatientService  {
            pmr.setDeptName(deptName);
            zyTime = DISCHARGETIME;
        }
        infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
        infoDO.setDept(dept);
        infoDO.setDeptName(deptName);
@ -541,11 +551,18 @@ public class SynchronizePatientService  {
                results.append("就诊卡信息不存在\n");
                continue;
            }
            if(patient.getSex()==null||patient.getSex()==3){
                JSONObject cardJson = cardList.getJSONObject(0);
                String xb = cardJson.getString("XB");//性别
                int sex = "女".equals(xb)?2:1;
                patient.setSex(sex);
                patientDao.save(patient);
            }
            infoDO.setSex(patient.getSex());
//            infoDO.setMobile(patient.getMobile());
            infoDO.setPatient(patient.getId());
            infoDO.setIdcard(patient.getIdcard());
            infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
            String ssc = null;
            String mobile = null;
            infoDO.setAddress(patient.getAddress());
@ -654,7 +671,7 @@ public class SynchronizePatientService  {
                String ATTENDINGPHYSICIAN = jaCy.getString("ATTENDINGPHYSICIAN");//黎喜梅 主治医师
                String DISCHARGEDISEASE = jaCy.getString("DISCHARGEDISEASE");//出院诊断
                String ADMISSIONDAY = jaCy.getString("ADMISSIONDAY");//5, 住院天数
//                String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
                String BIRTH = jaCy.getString("BIRTH");//1968-12-02 00:00:00", 出生日期
//                String ID = jaCy.getString("ID");//42661889-5-6000861496-2-9-0-20",
//                String LAST_MODIFY_DATE_TIME = jaCy.getString("LAST_MODIFY_DATE_TIME");//2025-05-13 21:16:12",
//                String BEDNO = jaCy.getString("BEDNO");//A12-46",
@ -682,7 +699,10 @@ public class SynchronizePatientService  {
                pmr.setAdmittingDiagnosisName(ADMISSIONDISEASE);
                pmr.setDischargeDiagnosisName(DISCHARGEDISEASE);
                pmr.setAdvice(DISCHARGEORDER);
                if(!BIRTH.equals(DateUtil.dateToStrLong(patient.getBirthday()))){
                    patient.setBirthday(DateUtil.strToDate(BIRTH));
                    patientDao.save(patient);
                }
                deptName = DEPTNAME;
                dept = findDeptByName(DEPTNAME);
                doctorNameZy = RESIDENTPHYSICIAN;
@ -692,7 +712,7 @@ public class SynchronizePatientService  {
            }
            infoDO.setDeptName(deptName);
            infoDO.setDept(dept);
            infoDO.setAge(IdCardUtil.getAgeByBirthdayOrIdcard(patient.getIdcard(), patient.getBirthday()));
            //三院专病配置
            RehabilitationPlanTemplateDO planTemplateDO = findPlanTemplate(dept,diagnosis,eventType);
            if(planTemplateDO==null){
@ -880,39 +900,6 @@ public class SynchronizePatientService  {
        return null;
    }
    /**
     * 创建康复计划json
     */
    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");
            return null;
        }
        planDO = patientRehabilitationPlanDao.save(planDO);
        List<RehabilitationDetailDO> detailDOList = new ArrayList<>();
        for(RehabilitationTemplateDetailDO detailDO : templateDetail) {
            String frequency_code = detailDO.getFrequencyCode();//频次
            RehabilitationDetailDO detail = new RehabilitationDetailDO();
            detail.setHospitalServiceItemId(detailDO.getHospitalServiceItemId());
            detail.setCreateTime(new Date());
            detail.setStatus(0);
            detail.setType(1);
            detail.setUpdateTime(new Date());
            detail.setPlanId(planDO.getId());
            detail.setFrequencyCode(frequency_code);
            detailDOList.add(detail);
        }
        rehabilitationDetailDao.saveAll(detailDOList);
        rehabilitationManageService.addPlanLog(planDO.getId(),planDO.getPlanDoctor(),planDO.getPlanDoctorName());
        planDO.setDetailDOList(detailDOList);
        return planDO;
    }
    /**
     * 创建康复计划json
     */
@ -947,6 +934,7 @@ public class SynchronizePatientService  {
                detail.setDoctor(doctorId);
                detail.setDoctorName(doctorName);
            }
            detail.setFollowupFormType(detailDO.getFollowupFormType());
            detailDOList.add(detail);
        }
        rehabilitationDetailDao.saveAll(detailDOList);