Bladeren bron

代码修改

LAPTOP-KB9HII50\70708 2 weken geleden
bovenliggende
commit
f057c29e45

+ 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);